From 0a869190b267bc0a56f6a9088a51199484813067 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Sat, 9 May 2020 14:27:09 +0200 Subject: [PATCH] Deployer dupes - Fixed blazing sword taking damage in the nether - Fixed blazing sword not igniting entities - More safety checks - Fixed stack overflow when overpowering a RSC from both inputs - Fixed outrageous duplication glitch in deployer item handler - Fixed crafters not able to return multiple buckets - Super glue can now be used to make chassis sticky --- .../java/com/simibubi/create/AllItems.java | 3 ++- .../foundation/gui/ScreenElementRenderer.java | 15 ++++++----- .../contraptions/BlockMovementTraits.java | 5 ++++ .../chassis/AbstractChassisBlock.java | 3 ++- .../crafter/MechanicalCrafterTileEntity.java | 8 +++--- .../deployer/DeployerItemHandler.java | 5 ++-- .../advanced/SpeedControllerTileEntity.java | 19 ++++++++++++-- .../contraptions/relays/belt/BeltBlock.java | 10 ++++--- .../relays/belt/BeltTileEntity.java | 5 +++- .../curiosities/tools/BlazingSwordItem.java | 26 +++++++++++++++++++ .../curiosities/tools/BlazingToolItem.java | 2 +- .../modules/logistics/InWorldProcessing.java | 3 +++ 12 files changed, 84 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/simibubi/create/modules/curiosities/tools/BlazingSwordItem.java diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index 8c6f1c348..2604f2829 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -26,6 +26,7 @@ import com.simibubi.create.modules.curiosities.ShadowSteelItem; import com.simibubi.create.modules.curiosities.deforester.DeforesterItem; import com.simibubi.create.modules.curiosities.symmetry.SymmetryWandItem; import com.simibubi.create.modules.curiosities.tools.AllToolTiers; +import com.simibubi.create.modules.curiosities.tools.BlazingSwordItem; import com.simibubi.create.modules.curiosities.tools.BlazingToolItem; import com.simibubi.create.modules.curiosities.tools.RoseQuartzToolItem; import com.simibubi.create.modules.curiosities.tools.SandPaperItem; @@ -119,7 +120,7 @@ public enum AllItems { BLAZING_PICKAXE(p -> new BlazingToolItem(1, -2.8F, p, PICKAXE)), BLAZING_SHOVEL(p -> new BlazingToolItem(1.5F, -3.0F, p, SHOVEL)), BLAZING_AXE(p -> new BlazingToolItem(5.0F, -3.0F, p, AXE)), - BLAZING_SWORD(p -> new SwordItem(AllToolTiers.BLAZING, 3, -2.4F, p)), + BLAZING_SWORD(p -> new BlazingSwordItem(AllToolTiers.BLAZING, 3, -2.4F, p)), ROSE_QUARTZ_PICKAXE(p -> new RoseQuartzToolItem(1, -2.8F, p, PICKAXE)), ROSE_QUARTZ_SHOVEL(p -> new RoseQuartzToolItem(1.5F, -3.0F, p, SHOVEL)), diff --git a/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java b/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java index d6c11bc94..f71fbff42 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/gui/ScreenElementRenderer.java @@ -85,12 +85,15 @@ public class ScreenElementRenderer { blockRenderer.renderBlockBrightness(blockToRender, 1); } else { GlStateManager.rotated(90, 0, 1, 0); - if (color == -1) { - blockRenderer.getBlockModelRenderer().renderModelBrightnessColor(modelToRender, 1, 1, 1, 1); - } else { - Vec3d rgb = ColorHelper.getRGB(color); - blockRenderer.getBlockModelRenderer().renderModelBrightnessColor(modelToRender, 1, (float) rgb.x, - (float) rgb.y, (float) rgb.z); + if (modelToRender != null) { + if (color == -1) { + blockRenderer.getBlockModelRenderer().renderModelBrightnessColor(modelToRender, 1, 1, 1, 1); + } else { + Vec3d rgb = ColorHelper.getRGB(color); + blockRenderer + .getBlockModelRenderer() + .renderModelBrightnessColor(modelToRender, 1, (float) rgb.x, (float) rgb.y, (float) rgb.z); + } } } GlStateManager.popMatrix(); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/BlockMovementTraits.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/BlockMovementTraits.java index af70da30a..3063b4f00 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/BlockMovementTraits.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/BlockMovementTraits.java @@ -29,6 +29,7 @@ import net.minecraft.block.AbstractRailBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.block.CarpetBlock; import net.minecraft.block.DoorBlock; import net.minecraft.block.FenceGateBlock; import net.minecraft.block.FlowerPotBlock; @@ -142,6 +143,8 @@ public class BlockMovementTraits { return true; if (block instanceof EngineBlock) return true; + if (block instanceof CarpetBlock) + return true; return false; } @@ -168,6 +171,8 @@ public class BlockMovementTraits { return direction == Direction.DOWN; if (block instanceof RedstoneWireBlock) return direction == Direction.DOWN; + if (block instanceof CarpetBlock) + return direction == Direction.DOWN; if (block instanceof RedstoneWallTorchBlock) return state.get(RedstoneWallTorchBlock.FACING) == direction.getOpposite(); if (block instanceof TorchBlock) diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/chassis/AbstractChassisBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/chassis/AbstractChassisBlock.java index a4f269a9b..64bebbe05 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/chassis/AbstractChassisBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/chassis/AbstractChassisBlock.java @@ -1,5 +1,6 @@ package com.simibubi.create.modules.contraptions.components.contraptions.chassis; +import com.simibubi.create.AllItems; import com.simibubi.create.AllSoundEvents; import com.simibubi.create.modules.contraptions.IWrenchable; @@ -45,7 +46,7 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements return false; ItemStack heldItem = player.getHeldItem(handIn); - boolean isSlimeBall = heldItem.getItem().isIn(Tags.Items.SLIMEBALLS); + boolean isSlimeBall = heldItem.getItem().isIn(Tags.Items.SLIMEBALLS) || AllItems.SUPER_GLUE.typeOf(heldItem); BooleanProperty affectedSide = getGlueableSide(state, hit.getFace()); if (affectedSide == null) diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterTileEntity.java index f9be57d87..02f0b6902 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterTileEntity.java @@ -217,10 +217,12 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { }); groupedItems = new GroupedItems(result); - containers.forEach(stack -> { - GroupedItems container = new GroupedItems(stack); + for (int i = 0; i < containers.size(); i++) { + ItemStack stack = containers.get(i); + GroupedItems container = new GroupedItems(); + container.grid.put(Pair.of(i, 0), stack); container.mergeOnto(groupedItems, Pointing.LEFT); - }); + } phase = Phase.CRAFTING; countDown = 2000; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerItemHandler.java b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerItemHandler.java index b598ff183..cd507742b 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerItemHandler.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerItemHandler.java @@ -58,7 +58,8 @@ public class DeployerItemHandler implements IItemHandlerModifiable { return stack; int space = held.getMaxStackSize() - held.getCount(); - ItemStack split = stack.copy().split(space); + ItemStack remainder = stack.copy(); + ItemStack split = remainder.split(space); if (space == 0) return stack; @@ -68,7 +69,7 @@ public class DeployerItemHandler implements IItemHandlerModifiable { set(held); } - return split; + return remainder; } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/SpeedControllerTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/SpeedControllerTileEntity.java index d90c58efe..fbccb83d3 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/SpeedControllerTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/advanced/SpeedControllerTileEntity.java @@ -59,10 +59,25 @@ public class SpeedControllerTileEntity extends KineticTileEntity { boolean targetingController) { if (!(speedControllerIn instanceof SpeedControllerTileEntity)) return 0; - SpeedControllerTileEntity speedController = (SpeedControllerTileEntity) speedControllerIn; + float speed = speedControllerIn.getTheoreticalSpeed(); + float wheelSpeed = cogWheel.getTheoreticalSpeed(); + float desiredOutputSpeed = getDesiredOutputSpeed(cogWheel, speedControllerIn, targetingController); + + float compareSpeed = targetingController ? speed : wheelSpeed; + if (desiredOutputSpeed >= 0 && compareSpeed >= 0) + return Math.max(desiredOutputSpeed, compareSpeed); + if (desiredOutputSpeed < 0 && compareSpeed < 0) + return Math.min(desiredOutputSpeed, compareSpeed); + + return desiredOutputSpeed; + } + + public static float getDesiredOutputSpeed(KineticTileEntity cogWheel, KineticTileEntity speedControllerIn, + boolean targetingController) { + SpeedControllerTileEntity speedController = (SpeedControllerTileEntity) speedControllerIn; float targetSpeed = speedController.targetSpeed.getValue(); - float speed = speedControllerIn.getSpeed(); + float speed = speedControllerIn.getTheoreticalSpeed(); float wheelSpeed = cogWheel.getTheoreticalSpeed(); if (targetSpeed == 0) diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java index 8f274e8f9..7bf57c436 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java @@ -57,6 +57,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; import net.minecraft.world.World; @@ -365,6 +366,9 @@ public class BeltBlock extends HorizontalKineticBlock @Override public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + if (state.getBlock() != this) + return VoxelShapes.empty(); + VoxelShape shape = getShape(state, worldIn, pos, context); try { if (context.getEntity() == null) @@ -629,7 +633,7 @@ public class BeltBlock extends HorizontalKineticBlock @Override public BlockState rotate(BlockState state, Rotation rot) { BlockState rotate = super.rotate(state, rot); - + if (state.get(SLOPE) != Slope.VERTICAL) return rotate; if (state.get(HORIZONTAL_FACING).getAxisDirection() != rotate.get(HORIZONTAL_FACING).getAxisDirection()) { @@ -638,8 +642,8 @@ public class BeltBlock extends HorizontalKineticBlock if (state.get(PART) == Part.END) return rotate.with(PART, Part.START); } - + return rotate; } - + } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java index 6cc9fda13..6aa355884 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltTileEntity.java @@ -133,7 +133,10 @@ public class BeltTileEntity extends KineticTileEntity { TileEntity te = world.getTileEntity(controller); if (te == null || !(te instanceof BeltTileEntity)) return; - IItemHandler handler = ((BeltTileEntity) te).getInventory().createHandlerForSegment(index); + BeltInventory inventory = ((BeltTileEntity) te).getInventory(); + if (inventory == null) + return; + IItemHandler handler = inventory.createHandlerForSegment(index); itemHandler = LazyOptional.of(() -> handler); } diff --git a/src/main/java/com/simibubi/create/modules/curiosities/tools/BlazingSwordItem.java b/src/main/java/com/simibubi/create/modules/curiosities/tools/BlazingSwordItem.java new file mode 100644 index 000000000..36ec39727 --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/curiosities/tools/BlazingSwordItem.java @@ -0,0 +1,26 @@ +package com.simibubi.create.modules.curiosities.tools; + +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.IItemTier; +import net.minecraft.item.ItemStack; +import net.minecraft.item.SwordItem; + +public class BlazingSwordItem extends SwordItem { + + public BlazingSwordItem(IItemTier tier, int attackDamageIn, float attackSpeedIn, Properties builder) { + super(tier, attackDamageIn, attackSpeedIn, builder); + } + + @Override + public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker) { + target.setFire(2); + return BlazingToolItem.shouldTakeDamage(attacker.world, stack) ? super.hitEntity(stack, target, attacker) + : true; + } + + @Override + public int getBurnTime(ItemStack itemStack) { + return itemStack.getMaxDamage() - itemStack.getDamage() + 1; + } + +} diff --git a/src/main/java/com/simibubi/create/modules/curiosities/tools/BlazingToolItem.java b/src/main/java/com/simibubi/create/modules/curiosities/tools/BlazingToolItem.java index 7c24a302f..b97990f33 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/tools/BlazingToolItem.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/tools/BlazingToolItem.java @@ -54,7 +54,7 @@ public class BlazingToolItem extends AbstractToolItem { return shouldTakeDamage(attacker.world, stack) ? super.hitEntity(stack, target, attacker) : true; } - protected boolean shouldTakeDamage(World world, ItemStack stack) { + static boolean shouldTakeDamage(World world, ItemStack stack) { return world.getDimension().getType() != DimensionType.THE_NETHER; } diff --git a/src/main/java/com/simibubi/create/modules/logistics/InWorldProcessing.java b/src/main/java/com/simibubi/create/modules/logistics/InWorldProcessing.java index 6dd533f39..3fc370dca 100644 --- a/src/main/java/com/simibubi/create/modules/logistics/InWorldProcessing.java +++ b/src/main/java/com/simibubi/create/modules/logistics/InWorldProcessing.java @@ -152,6 +152,9 @@ public class InWorldProcessing { return null; List stacks = process(transported.stack, type, belt.getWorld()); + if (stacks == null) + return null; + List transportedStacks = new ArrayList<>(); for (ItemStack additional : stacks) { TransportedItemStack newTransported = transported.getSimilar();