diff --git a/gradle.properties b/gradle.properties index 472e9b2..1b5bcb5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=20w18a - yarn_mappings=20w18a+build.1 + minecraft_version=20w19a + yarn_mappings=20w19a+build.4 loader_version=0.8.2+build.194 # Mod Properties - mod_version = 1.0.0 + mod_version = 1.0.1 maven_group = me.TheElm archives_base_name = nether-piglin-mod # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.7.1+build.331-1.16 + fabric_version=0.10.5+build.331-1.16 diff --git a/src/main/java/me/TheElm/NetherMod/interfaces/EmotionalPiglins.java b/src/main/java/me/TheElm/NetherMod/interfaces/EmotionalPiglins.java index 050e432..34bbec6 100644 --- a/src/main/java/me/TheElm/NetherMod/interfaces/EmotionalPiglins.java +++ b/src/main/java/me/TheElm/NetherMod/interfaces/EmotionalPiglins.java @@ -25,12 +25,30 @@ package me.TheElm.NetherMod.interfaces; +import net.minecraft.item.ItemStack; import net.minecraft.particle.ParticleEffect; public interface EmotionalPiglins { - void produceParticles(ParticleEffect parameters); + /** + * Produce Particles at the Piglin + * @param particle The particle type to spawn at the Piglin + */ + void produceParticles(ParticleEffect particle); - void incrementGold(); + /** + * Called when giving an itemstack to a piglin + * @param stack An ItemStack that was traded to the Piglin + */ + void incrementGold(ItemStack stack); + + /** + * Called when giving stacks of items to a piglin + * @param stacks Multiple ItemStacks that were traded to the Piglin + */ + default void incrementGold(Iterable stacks) { + for (ItemStack stack : stacks) + this.incrementGold(stack); + } } diff --git a/src/main/java/me/TheElm/NetherMod/mixins/PiglinEmotions.java b/src/main/java/me/TheElm/NetherMod/mixins/PiglinEmotions.java index b06c8ce..3d58765 100644 --- a/src/main/java/me/TheElm/NetherMod/mixins/PiglinEmotions.java +++ b/src/main/java/me/TheElm/NetherMod/mixins/PiglinEmotions.java @@ -115,8 +115,8 @@ public void produceParticles(ParticleEffect particle) { } @Override - public void incrementGold() { - this.addGoldToInventory(new ItemStack(Items.GOLD_INGOT, 1), true); + public void incrementGold(ItemStack stack) { + this.addGoldToInventory(stack.copy(), true); this.craftingCheck(); } diff --git a/src/main/java/me/TheElm/NetherMod/mixins/PiglinSigns.java b/src/main/java/me/TheElm/NetherMod/mixins/PiglinSigns.java index d5677aa..5f459f6 100644 --- a/src/main/java/me/TheElm/NetherMod/mixins/PiglinSigns.java +++ b/src/main/java/me/TheElm/NetherMod/mixins/PiglinSigns.java @@ -31,12 +31,15 @@ import net.minecraft.entity.mob.PiglinEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.particle.ParticleTypes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.util.List; + @Mixin(PiglinBrain.class) public class PiglinSigns { @@ -57,12 +60,12 @@ private static void onAngerAt(PiglinEntity piglin, LivingEntity target, Callback /** * A Mixin for when the piglin completes a trade * @param piglin The piglin that completed a trade - * @param stack The itemstack that the piglin picked up + * @param droppedStacks The list of itemstacks that the piglin gave from the trade * @param callback The Mixin callback */ @Inject(at = @At("HEAD"), method = "doBarter") - private static void onBarter(PiglinEntity piglin, ItemStack stack, CallbackInfo callback) { - ((EmotionalPiglins)piglin).incrementGold(); + private static void onBarter(PiglinEntity piglin, List droppedStacks, CallbackInfo callback) { + // Increment the item that the piglin picked up + ((EmotionalPiglins)piglin).incrementGold(new ItemStack(Items.GOLD_INGOT, 1)); } - }