fix: item duplication bug

Avoid ejecting the grid if mechanical crafter is moving. Should fix #3741
This commit is contained in:
Xavier Stouder 2022-09-13 23:33:32 +02:00
parent aeee9f8793
commit 737578a90e

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.crafter;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.AllTileEntities; import com.simibubi.create.AllTileEntities;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock; import com.simibubi.create.content.contraptions.base.HorizontalKineticBlock;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.components.crafter.ConnectedInputHandler.ConnectedInput; import com.simibubi.create.content.contraptions.components.crafter.ConnectedInputHandler.ConnectedInput;
@ -95,11 +96,14 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock
} }
} }
Create.LOGGER.info("onRemove:" + (isMoving ? "moving" : "not moving"));
if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) { if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) {
MechanicalCrafterTileEntity crafter = CrafterHelper.getCrafter(worldIn, pos); MechanicalCrafterTileEntity crafter = CrafterHelper.getCrafter(worldIn, pos);
if (crafter != null) { if (crafter != null) {
if (crafter.covered) if (crafter.covered)
Block.popResource(worldIn, pos, AllItems.CRAFTER_SLOT_COVER.asStack()); Block.popResource(worldIn, pos, AllItems.CRAFTER_SLOT_COVER.asStack());
if (!isMoving)
crafter.ejectWholeGrid(); crafter.ejectWholeGrid();
} }