From 2a9795f4118a415264276c615895ece50c461030 Mon Sep 17 00:00:00 2001 From: Snownee <1850986885@qq.com> Date: Sat, 16 May 2020 01:44:58 +0800 Subject: [PATCH 1/3] Fix contraption blocks do not drop while replacing by bedrock --- .../components/contraptions/Contraption.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java index d06f73f8a..a509f2ba8 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java @@ -565,11 +565,15 @@ public abstract class Contraption { state = state.with(SawBlock.RUNNING, false); BlockState blockState = world.getBlockState(targetPos); - if (blockState.getBlockHardness(world, targetPos) == -1) - continue; - if (state.getCollisionShape(world, targetPos).isEmpty() - && !blockState.getCollisionShape(world, targetPos).isEmpty()) + if (blockState.getBlockHardness(world, targetPos) == -1 + || (state.getCollisionShape(world, targetPos).isEmpty() + && !blockState.getCollisionShape(world, targetPos).isEmpty())) { + if (targetPos.getY() == 0) + targetPos = targetPos.up(); + world.playEvent(2001, targetPos, Block.getStateId(state)); + Block.spawnDrops(state, world, targetPos, null); continue; + } world.destroyBlock(targetPos, true); world.setBlockState(targetPos, state, 3 | BlockFlags.IS_MOVING); From 1578a2ac68377eb6fff7412a4ffeddd8495ba7e6 Mon Sep 17 00:00:00 2001 From: Snownee <1850986885@qq.com> Date: Sat, 16 May 2020 01:49:32 +0800 Subject: [PATCH 2/3] Improve glue behavior. Glue can no longer place on torch or so on --- .../components/contraptions/glue/SuperGlueEntity.java | 7 +++++-- .../components/contraptions/glue/SuperGlueRenderer.java | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/glue/SuperGlueEntity.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/glue/SuperGlueEntity.java index c4b58507d..5eca4e99b 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/glue/SuperGlueEntity.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/glue/SuperGlueEntity.java @@ -13,6 +13,7 @@ import com.simibubi.create.modules.schematics.ISpecialEntityItemRequirement; import com.simibubi.create.modules.schematics.ItemRequirement; import com.simibubi.create.modules.schematics.ItemRequirement.ItemUseType; +import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; import net.minecraft.client.world.ClientWorld; @@ -164,11 +165,13 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat } public static boolean isValidFace(World world, BlockPos pos, Direction direction) { + BlockState state = world.getBlockState(pos); + if (BlockMovementTraits.isBlockAttachedTowards(state, direction)) + return true; if (!BlockMovementTraits.movementNecessary(world, pos)) return false; - if (BlockMovementTraits.notSupportive(world.getBlockState(pos), direction)) { + if (BlockMovementTraits.notSupportive(state, direction)) return false; - } return true; } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/glue/SuperGlueRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/glue/SuperGlueRenderer.java index 5765ebcc6..11717232f 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/glue/SuperGlueRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/glue/SuperGlueRenderer.java @@ -83,7 +83,7 @@ public class SuperGlueRenderer extends EntityRenderer { return false; BlockPos pos = entity.hangingPosition; BlockPos pos2 = pos.offset(entity.getFacingDirection().getOpposite()); - return !SuperGlueEntity.isValidFace(entity.world, pos2, entity.getFacingDirection()) || !SuperGlueEntity.isValidFace(entity.world, pos, entity.getFacingDirection().getOpposite()); + return SuperGlueEntity.isValidFace(entity.world, pos2, entity.getFacingDirection()) != SuperGlueEntity.isValidFace(entity.world, pos, entity.getFacingDirection().getOpposite()); } private void initQuads() { From 6ed79de6c700365c8c2006f38a29364ffcd896f2 Mon Sep 17 00:00:00 2001 From: Snownee <1850986885@qq.com> Date: Sat, 16 May 2020 01:55:52 +0800 Subject: [PATCH 3/3] Fix potential item duplicating (Block like bell) --- .../components/contraptions/Contraption.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java index a509f2ba8..6602497c4 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -519,16 +520,20 @@ public abstract class Contraption { glueToRemove.forEach(SuperGlueEntity::remove); for (boolean brittles : Iterate.trueAndFalse) { - for (BlockInfo block : blocks.values()) { + for (Iterator iterator = blocks.values().iterator(); iterator.hasNext();) { + BlockInfo block = iterator.next(); if (brittles != BlockMovementTraits.isBrittle(block.state)) continue; BlockPos add = block.pos.add(anchor).add(offset); if (customRemoval.test(add, block.state)) continue; + Block blockIn = world.getBlockState(add).getBlock(); + if (block.state.getBlock() != blockIn) + iterator.remove(); world.getWorld().removeTileEntity(add); int flags = 67; - if (world.getBlockState(add).getBlock() instanceof DoorBlock) + if (blockIn instanceof DoorBlock) flags = flags | 32 | 16; world.setBlockState(add, Blocks.AIR.getDefaultState(), flags); }