use of de.siphalor.nbtcrafting.util.IAnvilContainer in project nbt-crafting by Siphalor.
the class MixinAnvilContainerResultSlot method onItemTaken.
@Inject(method = "onTakeItem(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/item/ItemStack;)" + "Lnet/minecraft/item/ItemStack;", at = @At("RETURN"))
public void onItemTaken(PlayerEntity player, ItemStack stack, CallbackInfoReturnable<ItemStack> cir) {
AnvilRecipe recipe = ((IAnvilContainer) container).nbtcrafting$getRecipe();
if (recipe != null && originalBaseStack != null) {
stack.onCraft(player.world, player, stack.getCount());
if (!recipe.getBase().isEmpty()) {
originalBaseStack.decrement(1);
container.setStackInSlot(0, originalBaseStack);
}
}
if (player instanceof ServerPlayerEntity) {
if (!NbtCrafting.hasClientMod((ServerPlayerEntity) player)) {
((ServerPlayerEntity) player).networkHandler.sendPacket(new ContainerSlotUpdateS2CPacket(-1, 0, stack));
}
}
}
Aggregations