amethyst shards are halved not reduced

This commit is contained in:
yrsegal@gmail.com 2022-04-08 17:52:03 -04:00
parent d17b5c21ac
commit 352ed65dc4
2 changed files with 9 additions and 9 deletions

View file

@ -18,6 +18,6 @@
} }
} }
], ],
"delta": -2, "delta": 0.5,
"type": "hexcasting:amethyst_shard_reducer" "type": "hexcasting:amethyst_shard_reducer"
} }

View file

@ -14,11 +14,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
public class AmethystShardReducerModifier extends LootModifier { public class AmethystShardReducerModifier extends LootModifier {
private final int delta; private final double modifier;
public AmethystShardReducerModifier(int delta, LootItemCondition[] conditions) { public AmethystShardReducerModifier(double modifier, LootItemCondition[] conditions) {
super(conditions); super(conditions);
this.delta = delta; this.modifier = modifier;
} }
@NotNull @NotNull
@ -26,7 +26,7 @@ public class AmethystShardReducerModifier extends LootModifier {
protected List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) { protected List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) {
for (var stack : generatedLoot) { for (var stack : generatedLoot) {
if (stack.is(Items.AMETHYST_SHARD)) { if (stack.is(Items.AMETHYST_SHARD)) {
stack.grow(this.delta); stack.shrink((int) (stack.getCount() * modifier));
} }
} }
return generatedLoot; return generatedLoot;
@ -36,14 +36,14 @@ public class AmethystShardReducerModifier extends LootModifier {
@Override @Override
public AmethystShardReducerModifier read(ResourceLocation location, JsonObject json, public AmethystShardReducerModifier read(ResourceLocation location, JsonObject json,
LootItemCondition[] conditions) { LootItemCondition[] conditions) {
var delta = GsonHelper.getAsInt(json, "delta"); var modifier = GsonHelper.getAsDouble(json, "modifier");
return new AmethystShardReducerModifier(delta, conditions); return new AmethystShardReducerModifier(modifier, conditions);
} }
@Override @Override
public JsonObject write(AmethystShardReducerModifier instance) { public JsonObject write(AmethystShardReducerModifier instance) {
var obj = this.makeConditions(instance.conditions); var obj = this.makeConditions(instance.conditions);
obj.addProperty("delta", instance.delta); obj.addProperty("modifier", instance.modifier);
return obj; return obj;
} }
} }