From 27c69250d192d786913f5d2219c6b60934bae543 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Mon, 22 Nov 2021 11:38:52 +0100 Subject: [PATCH] Portable Spillage Interface - Fixed Chutes spilling items when inserting into disconnected storage interfaces - Blaze Burners can now be picked up using the Wrench - Additional safety checks from random crash reports --- .../actors/PortableItemInterfaceTileEntity.java | 8 ++++++-- .../components/actors/SawMovementBehaviour.java | 2 +- .../components/press/MechanicalPressTileEntity.java | 4 ++-- .../contraptions/processing/burner/BlazeBurnerBlock.java | 3 ++- .../processing/burner/LitBlazeBurnerBlock.java | 3 ++- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableItemInterfaceTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableItemInterfaceTileEntity.java index 227c42dee..4ce72e843 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableItemInterfaceTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableItemInterfaceTileEntity.java @@ -17,7 +17,7 @@ public class PortableItemInterfaceTileEntity extends PortableStorageInterfaceTil public PortableItemInterfaceTileEntity(TileEntityType tileEntityTypeIn) { super(tileEntityTypeIn); - capability = LazyOptional.empty(); + capability = createEmptyHandler(); } @Override @@ -31,10 +31,14 @@ public class PortableItemInterfaceTileEntity extends PortableStorageInterfaceTil @Override protected void stopTransferring() { LazyOptional oldCap = capability; - capability = LazyOptional.of(() -> new InterfaceItemHandler(new ItemStackHandler(0))); + capability = createEmptyHandler(); oldCap.invalidate(); super.stopTransferring(); } + + private LazyOptional createEmptyHandler() { + return LazyOptional.of(() -> new InterfaceItemHandler(new ItemStackHandler(0))); + } @Override protected void invalidateCapability() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java index d86291925..7e4647403 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/SawMovementBehaviour.java @@ -78,7 +78,7 @@ public class SawMovementBehaviour extends BlockBreakingMovementBehaviour { World world = context.world; Vector3d dropPos = VecHelper.getCenterOf(pos); - float distance = (float) dropPos.distanceTo(context.position); + float distance = context.position == null ? 1 : (float) dropPos.distanceTo(context.position); ItemEntity entity = new ItemEntity(world, dropPos.x, dropPos.y, dropPos.z, remainder); entity.setDeltaMovement(context.relativeMotion.scale(distance / 20f)); world.addFreshEntity(entity); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java index f94473c89..e30e64e82 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntity.java @@ -228,9 +228,9 @@ public class MechanicalPressTileEntity extends BasinOperatingTileEntity { pressedItems.clear(); applyBasinRecipe(); Optional basin = getBasin(); - SmartInventory inputs = basin.get() - .getInputInventory(); if (basin.isPresent()) { + SmartInventory inputs = basin.get() + .getInputInventory(); for (int slot = 0; slot < inputs.getSlots(); slot++) { ItemStack stackInSlot = inputs.getItem(slot); if (stackInSlot.isEmpty()) diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlock.java index 077da0232..68dabcddb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlock.java @@ -10,6 +10,7 @@ import com.simibubi.create.AllItems; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.processing.BasinTileEntity; +import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.utility.Lang; @@ -55,7 +56,7 @@ import net.minecraftforge.common.util.FakePlayer; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault -public class BlazeBurnerBlock extends Block implements ITE { +public class BlazeBurnerBlock extends Block implements ITE, IWrenchable { public static final EnumProperty HEAT_LEVEL = EnumProperty.create("blaze", HeatLevel.class); diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/LitBlazeBurnerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/LitBlazeBurnerBlock.java index f81829625..60c546178 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/LitBlazeBurnerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/LitBlazeBurnerBlock.java @@ -4,6 +4,7 @@ import java.util.Random; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; +import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.block.Block; @@ -31,7 +32,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ToolType; -public class LitBlazeBurnerBlock extends Block { +public class LitBlazeBurnerBlock extends Block implements IWrenchable { public static final EnumProperty FLAME_TYPE = EnumProperty.create("flame_type", FlameType.class);