Skip to content

Commit

Permalink
Updated to version 1.0.1
Browse files Browse the repository at this point in the history
Added support for 20w19a
---
Added additional Javadocs
Added some options for possible future implementations of bartering using gold blocks or nuggets
  • Loading branch information
GStefanowich committed May 7, 2020
1 parent f3ab2c0 commit 41a1e71
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 20 additions & 2 deletions src/main/java/me/TheElm/NetherMod/interfaces/EmotionalPiglins.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemStack> stacks) {
for (ItemStack stack : stacks)
this.incrementGold(stack);
}

}
4 changes: 2 additions & 2 deletions src/main/java/me/TheElm/NetherMod/mixins/PiglinEmotions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
11 changes: 7 additions & 4 deletions src/main/java/me/TheElm/NetherMod/mixins/PiglinSigns.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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<ItemStack> droppedStacks, CallbackInfo callback) {
// Increment the item that the piglin picked up
((EmotionalPiglins)piglin).incrementGold(new ItemStack(Items.GOLD_INGOT, 1));
}

}

0 comments on commit 41a1e71

Please sign in to comment.