From 4e370dffe749265b0cb361e57221f370efe70fd9 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 3 Feb 2019 21:39:52 +0100 Subject: [PATCH] fixed the auto crafter ignoring container items --- .../blocks/tiles/TileEntityAutoCrafter.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAutoCrafter.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAutoCrafter.java index fde2daf0..7bcbe113 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAutoCrafter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAutoCrafter.java @@ -15,6 +15,7 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.EntitySelectors; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; @@ -85,7 +86,9 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickable { resultItem.motionX = resultItem.motionY = resultItem.motionZ = 0; this.world.spawnEntity(resultItem); - for (EntityItem item : items) { + NonNullList remainingItems = recipe.getRemainingItems(this.crafting); + for (int i = 0; i < items.length; i++) { + EntityItem item = items[i]; if (item == null) continue; ItemStack stack = item.getItem(); @@ -96,6 +99,13 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickable { item.setItem(stack); } + ItemStack remain = remainingItems.get(i); + if (!remain.isEmpty()) { + EntityItem remItem = new EntityItem(this.world, item.posX, item.posY, item.posZ, remain.copy()); + remItem.motionX = remItem.motionY = remItem.motionZ = 0; + this.world.spawnEntity(remItem); + } + PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19)); }