Fix bell duplicating

This commit is contained in:
Snownee 2020-05-14 21:42:52 +08:00
parent 1fe647b16e
commit 8d4e6895bc
2 changed files with 28 additions and 3 deletions

View File

@ -26,6 +26,7 @@ import com.simibubi.create.modules.logistics.block.transposer.TransposerBlock;
import net.minecraft.block.AbstractPressurePlateBlock;
import net.minecraft.block.AbstractRailBlock;
import net.minecraft.block.BellBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -33,6 +34,7 @@ import net.minecraft.block.CarpetBlock;
import net.minecraft.block.DoorBlock;
import net.minecraft.block.FenceGateBlock;
import net.minecraft.block.FlowerPotBlock;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.HorizontalFaceBlock;
import net.minecraft.block.LadderBlock;
import net.minecraft.block.RedstoneDiodeBlock;
@ -42,6 +44,7 @@ import net.minecraft.block.TorchBlock;
import net.minecraft.block.WallTorchBlock;
import net.minecraft.block.material.PushReaction;
import net.minecraft.state.properties.AttachFace;
import net.minecraft.state.properties.BellAttachment;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
@ -145,6 +148,8 @@ public class BlockMovementTraits {
return true;
if (block instanceof CarpetBlock)
return true;
if (block instanceof BellBlock)
return true;
return false;
}
@ -198,6 +203,16 @@ public class BlockMovementTraits {
return direction == state.get(NozzleBlock.FACING).getOpposite();
if (block instanceof EngineBlock)
return direction == state.get(EngineBlock.HORIZONTAL_FACING).getOpposite();
if (block instanceof BellBlock) {
BellAttachment attachment = state.get(BlockStateProperties.BELL_ATTACHMENT);
if (attachment == BellAttachment.FLOOR) {
return direction == Direction.DOWN;
}
if (attachment == BellAttachment.CEILING) {
return direction == Direction.UP;
}
return direction == state.get(HorizontalBlock.HORIZONTAL_FACING);
}
return false;
}

View File

@ -12,6 +12,7 @@ import com.simibubi.create.modules.contraptions.components.contraptions.chassis.
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock;
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Slope;
import net.minecraft.block.BellBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalFaceBlock;
@ -19,6 +20,8 @@ import net.minecraft.block.SlabBlock;
import net.minecraft.block.StairsBlock;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.properties.AttachFace;
import net.minecraft.state.properties.BellAttachment;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.Half;
import net.minecraft.state.properties.SlabType;
import net.minecraft.util.Direction;
@ -78,11 +81,18 @@ public class StructureTransform {
* horizontal axes
*/
public BlockState apply(BlockState state) {
if (rotationAxis == Axis.Y)
return state.rotate(rotation);
Block block = state.getBlock();
if (rotationAxis == Axis.Y) {
if (block instanceof BellBlock) {
if (state.get(BlockStateProperties.BELL_ATTACHMENT) == BellAttachment.DOUBLE_WALL) {
state = state.with(BlockStateProperties.BELL_ATTACHMENT, BellAttachment.SINGLE_WALL);
}
return state.with(HorizontalFaceBlock.HORIZONTAL_FACING, rotation.rotate(state.get(HorizontalFaceBlock.HORIZONTAL_FACING)));
}
return state.rotate(rotation);
}
if (block instanceof AbstractChassisBlock)
return rotateChassis(state);