aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/level/block/PoweredRailBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/PoweredRailBlock.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/level/block/PoweredRailBlock.java.patch381
1 files changed, 381 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/PoweredRailBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/PoweredRailBlock.java.patch
new file mode 100644
index 0000000000..e8e8b74e39
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/PoweredRailBlock.java.patch
@@ -0,0 +1,381 @@
+--- a/net/minecraft/world/level/block/PoweredRailBlock.java
++++ b/net/minecraft/world/level/block/PoweredRailBlock.java
+@@ -4,215 +4,211 @@
+ import net.minecraft.core.BlockPos;
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.level.block.state.BlockBehaviour;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.state.IBlockData;
+ import net.minecraft.world.level.block.state.StateDefinition;
+ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
+ import net.minecraft.world.level.block.state.properties.BooleanProperty;
+ import net.minecraft.world.level.block.state.properties.EnumProperty;
+ import net.minecraft.world.level.block.state.properties.Property;
+ import net.minecraft.world.level.block.state.properties.RailShape;
++import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
+ public class PoweredRailBlock extends BaseRailBlock {
++
+ public static final MapCodec<PoweredRailBlock> CODEC = simpleCodec(PoweredRailBlock::new);
+ public static final EnumProperty<RailShape> SHAPE = BlockStateProperties.RAIL_SHAPE_STRAIGHT;
+ public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
+
+ @Override
+ public MapCodec<PoweredRailBlock> codec() {
+- return CODEC;
++ return PoweredRailBlock.CODEC;
+ }
+
+ protected PoweredRailBlock(BlockBehaviour.Properties properties) {
+ super(true, properties);
+- this.registerDefaultState(
+- this.stateDefinition
+- .any()
+- .setValue(SHAPE, RailShape.NORTH_SOUTH)
+- .setValue(POWERED, Boolean.valueOf(false))
+- .setValue(WATERLOGGED, Boolean.valueOf(false))
+- );
++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_SOUTH)).setValue(PoweredRailBlock.POWERED, false)).setValue(PoweredRailBlock.WATERLOGGED, false));
+ }
+
+- protected boolean findPoweredRailSignal(Level level, BlockPos pos, BlockState state, boolean searchForward, int recursionCount) {
++ protected boolean findPoweredRailSignal(Level level, BlockPos pos, IBlockData state, boolean searchForward, int recursionCount) {
+ if (recursionCount >= 8) {
+ return false;
+ } else {
+- int x = pos.getX();
+- int y = pos.getY();
+- int z = pos.getZ();
+- boolean flag = true;
+- RailShape railShape = state.getValue(SHAPE);
+- switch (railShape) {
++ int j = pos.getX();
++ int k = pos.getY();
++ int l = pos.getZ();
++ boolean flag1 = true;
++ RailShape blockpropertytrackposition = (RailShape) state.getValue(PoweredRailBlock.SHAPE);
++
++ switch (blockpropertytrackposition) {
+ case NORTH_SOUTH:
+ if (searchForward) {
+- z++;
++ ++l;
+ } else {
+- z--;
++ --l;
+ }
+ break;
+ case EAST_WEST:
+ if (searchForward) {
+- x--;
++ --j;
+ } else {
+- x++;
++ ++j;
+ }
+ break;
+ case ASCENDING_EAST:
+ if (searchForward) {
+- x--;
++ --j;
+ } else {
+- x++;
+- y++;
+- flag = false;
++ ++j;
++ ++k;
++ flag1 = false;
+ }
+
+- railShape = RailShape.EAST_WEST;
++ blockpropertytrackposition = RailShape.EAST_WEST;
+ break;
+ case ASCENDING_WEST:
+ if (searchForward) {
+- x--;
+- y++;
+- flag = false;
++ --j;
++ ++k;
++ flag1 = false;
+ } else {
+- x++;
++ ++j;
+ }
+
+- railShape = RailShape.EAST_WEST;
++ blockpropertytrackposition = RailShape.EAST_WEST;
+ break;
+ case ASCENDING_NORTH:
+ if (searchForward) {
+- z++;
++ ++l;
+ } else {
+- z--;
+- y++;
+- flag = false;
++ --l;
++ ++k;
++ flag1 = false;
+ }
+
+- railShape = RailShape.NORTH_SOUTH;
++ blockpropertytrackposition = RailShape.NORTH_SOUTH;
+ break;
+ case ASCENDING_SOUTH:
+ if (searchForward) {
+- z++;
+- y++;
+- flag = false;
++ ++l;
++ ++k;
++ flag1 = false;
+ } else {
+- z--;
++ --l;
+ }
+
+- railShape = RailShape.NORTH_SOUTH;
++ blockpropertytrackposition = RailShape.NORTH_SOUTH;
+ }
+
+- return this.isSameRailWithPower(level, new BlockPos(x, y, z), searchForward, recursionCount, railShape)
+- || flag && this.isSameRailWithPower(level, new BlockPos(x, y - 1, z), searchForward, recursionCount, railShape);
++ return this.isSameRailWithPower(level, new BlockPos(j, k, l), searchForward, recursionCount, blockpropertytrackposition) ? true : flag1 && this.isSameRailWithPower(level, new BlockPos(j, k - 1, l), searchForward, recursionCount, blockpropertytrackposition);
+ }
+ }
+
+ protected boolean isSameRailWithPower(Level level, BlockPos state, boolean searchForward, int recursionCount, RailShape shape) {
+- BlockState blockState = level.getBlockState(state);
+- if (!blockState.is(this)) {
++ IBlockData iblockdata = level.getBlockState(state);
++
++ if (!iblockdata.is((Block) this)) {
+ return false;
+ } else {
+- RailShape railShape = blockState.getValue(SHAPE);
+- return (
+- shape != RailShape.EAST_WEST
+- || railShape != RailShape.NORTH_SOUTH && railShape != RailShape.ASCENDING_NORTH && railShape != RailShape.ASCENDING_SOUTH
+- )
+- && (
+- shape != RailShape.NORTH_SOUTH
+- || railShape != RailShape.EAST_WEST && railShape != RailShape.ASCENDING_EAST && railShape != RailShape.ASCENDING_WEST
+- )
+- && blockState.getValue(POWERED)
+- && (level.hasNeighborSignal(state) || this.findPoweredRailSignal(level, state, blockState, searchForward, recursionCount + 1));
++ RailShape blockpropertytrackposition1 = (RailShape) iblockdata.getValue(PoweredRailBlock.SHAPE);
++
++ return shape == RailShape.EAST_WEST && (blockpropertytrackposition1 == RailShape.NORTH_SOUTH || blockpropertytrackposition1 == RailShape.ASCENDING_NORTH || blockpropertytrackposition1 == RailShape.ASCENDING_SOUTH) ? false : (shape == RailShape.NORTH_SOUTH && (blockpropertytrackposition1 == RailShape.EAST_WEST || blockpropertytrackposition1 == RailShape.ASCENDING_EAST || blockpropertytrackposition1 == RailShape.ASCENDING_WEST) ? false : ((Boolean) iblockdata.getValue(PoweredRailBlock.POWERED) ? (level.hasNeighborSignal(state) ? true : this.findPoweredRailSignal(level, state, iblockdata, searchForward, recursionCount + 1)) : false));
+ }
+ }
+
+ @Override
+- protected void updateState(BlockState state, Level level, BlockPos pos, Block block) {
+- boolean flag = state.getValue(POWERED);
+- boolean flag1 = level.hasNeighborSignal(pos)
+- || this.findPoweredRailSignal(level, pos, state, true, 0)
+- || this.findPoweredRailSignal(level, pos, state, false, 0);
++ protected void updateState(IBlockData state, Level level, BlockPos pos, Block block) {
++ boolean flag = (Boolean) state.getValue(PoweredRailBlock.POWERED);
++ boolean flag1 = level.hasNeighborSignal(pos) || this.findPoweredRailSignal(level, pos, state, true, 0) || this.findPoweredRailSignal(level, pos, state, false, 0);
++
+ if (flag1 != flag) {
+- level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(flag1)), 3);
++ // CraftBukkit start
++ int power = flag ? 15 : 0;
++ int newPower = CraftEventFactory.callRedstoneChange(level, pos, power, 15 - power).getNewCurrent();
++ if (newPower == power) {
++ return;
++ }
++ // CraftBukkit end
++ level.setBlock(pos, (IBlockData) state.setValue(PoweredRailBlock.POWERED, flag1), 3);
+ level.updateNeighborsAt(pos.below(), this);
+- if (state.getValue(SHAPE).isAscending()) {
++ if (((RailShape) state.getValue(PoweredRailBlock.SHAPE)).isAscending()) {
+ level.updateNeighborsAt(pos.above(), this);
+ }
+ }
++
+ }
+
+ @Override
+ public Property<RailShape> getShapeProperty() {
+- return SHAPE;
++ return PoweredRailBlock.SHAPE;
+ }
+
+ @Override
+- public BlockState rotate(BlockState state, Rotation rot) {
++ public IBlockData rotate(IBlockData state, Rotation rot) {
+ switch (rot) {
+ case CLOCKWISE_180:
+- switch ((RailShape)state.getValue(SHAPE)) {
++ switch ((RailShape) state.getValue(PoweredRailBlock.SHAPE)) {
+ case ASCENDING_EAST:
+- return state.setValue(SHAPE, RailShape.ASCENDING_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_WEST);
+ case ASCENDING_WEST:
+- return state.setValue(SHAPE, RailShape.ASCENDING_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_EAST);
+ case ASCENDING_NORTH:
+- return state.setValue(SHAPE, RailShape.ASCENDING_SOUTH);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_SOUTH);
+ case ASCENDING_SOUTH:
+- return state.setValue(SHAPE, RailShape.ASCENDING_NORTH);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_NORTH);
+ case SOUTH_EAST:
+- return state.setValue(SHAPE, RailShape.NORTH_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_WEST);
+ case SOUTH_WEST:
+- return state.setValue(SHAPE, RailShape.NORTH_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_EAST);
+ case NORTH_WEST:
+- return state.setValue(SHAPE, RailShape.SOUTH_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_EAST);
+ case NORTH_EAST:
+- return state.setValue(SHAPE, RailShape.SOUTH_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_WEST);
+ }
+ case COUNTERCLOCKWISE_90:
+- switch ((RailShape)state.getValue(SHAPE)) {
++ switch ((RailShape) state.getValue(PoweredRailBlock.SHAPE)) {
+ case NORTH_SOUTH:
+- return state.setValue(SHAPE, RailShape.EAST_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.EAST_WEST);
+ case EAST_WEST:
+- return state.setValue(SHAPE, RailShape.NORTH_SOUTH);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_SOUTH);
+ case ASCENDING_EAST:
+- return state.setValue(SHAPE, RailShape.ASCENDING_NORTH);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_NORTH);
+ case ASCENDING_WEST:
+- return state.setValue(SHAPE, RailShape.ASCENDING_SOUTH);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_SOUTH);
+ case ASCENDING_NORTH:
+- return state.setValue(SHAPE, RailShape.ASCENDING_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_WEST);
+ case ASCENDING_SOUTH:
+- return state.setValue(SHAPE, RailShape.ASCENDING_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_EAST);
+ case SOUTH_EAST:
+- return state.setValue(SHAPE, RailShape.NORTH_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_EAST);
+ case SOUTH_WEST:
+- return state.setValue(SHAPE, RailShape.SOUTH_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_EAST);
+ case NORTH_WEST:
+- return state.setValue(SHAPE, RailShape.SOUTH_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_WEST);
+ case NORTH_EAST:
+- return state.setValue(SHAPE, RailShape.NORTH_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_WEST);
+ }
+ case CLOCKWISE_90:
+- switch ((RailShape)state.getValue(SHAPE)) {
++ switch ((RailShape) state.getValue(PoweredRailBlock.SHAPE)) {
+ case NORTH_SOUTH:
+- return state.setValue(SHAPE, RailShape.EAST_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.EAST_WEST);
+ case EAST_WEST:
+- return state.setValue(SHAPE, RailShape.NORTH_SOUTH);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_SOUTH);
+ case ASCENDING_EAST:
+- return state.setValue(SHAPE, RailShape.ASCENDING_SOUTH);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_SOUTH);
+ case ASCENDING_WEST:
+- return state.setValue(SHAPE, RailShape.ASCENDING_NORTH);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_NORTH);
+ case ASCENDING_NORTH:
+- return state.setValue(SHAPE, RailShape.ASCENDING_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_EAST);
+ case ASCENDING_SOUTH:
+- return state.setValue(SHAPE, RailShape.ASCENDING_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_WEST);
+ case SOUTH_EAST:
+- return state.setValue(SHAPE, RailShape.SOUTH_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_WEST);
+ case SOUTH_WEST:
+- return state.setValue(SHAPE, RailShape.NORTH_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_WEST);
+ case NORTH_WEST:
+- return state.setValue(SHAPE, RailShape.NORTH_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_EAST);
+ case NORTH_EAST:
+- return state.setValue(SHAPE, RailShape.SOUTH_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_EAST);
+ }
+ default:
+ return state;
+@@ -220,44 +216,45 @@
+ }
+
+ @Override
+- public BlockState mirror(BlockState state, Mirror mirror) {
+- RailShape railShape = state.getValue(SHAPE);
++ public IBlockData mirror(IBlockData state, Mirror mirror) {
++ RailShape blockpropertytrackposition = (RailShape) state.getValue(PoweredRailBlock.SHAPE);
++
+ switch (mirror) {
+ case LEFT_RIGHT:
+- switch (railShape) {
++ switch (blockpropertytrackposition) {
+ case ASCENDING_NORTH:
+- return state.setValue(SHAPE, RailShape.ASCENDING_SOUTH);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_SOUTH);
+ case ASCENDING_SOUTH:
+- return state.setValue(SHAPE, RailShape.ASCENDING_NORTH);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_NORTH);
+ case SOUTH_EAST:
+- return state.setValue(SHAPE, RailShape.NORTH_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_EAST);
+ case SOUTH_WEST:
+- return state.setValue(SHAPE, RailShape.NORTH_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_WEST);
+ case NORTH_WEST:
+- return state.setValue(SHAPE, RailShape.SOUTH_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_WEST);
+ case NORTH_EAST:
+- return state.setValue(SHAPE, RailShape.SOUTH_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_EAST);
+ default:
+ return super.mirror(state, mirror);
+ }
+ case FRONT_BACK:
+- switch (railShape) {
++ switch (blockpropertytrackposition) {
+ case ASCENDING_EAST:
+- return state.setValue(SHAPE, RailShape.ASCENDING_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_WEST);
+ case ASCENDING_WEST:
+- return state.setValue(SHAPE, RailShape.ASCENDING_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.ASCENDING_EAST);
+ case ASCENDING_NORTH:
+ case ASCENDING_SOUTH:
+ default:
+ break;
+ case SOUTH_EAST:
+- return state.setValue(SHAPE, RailShape.SOUTH_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_WEST);
+ case SOUTH_WEST:
+- return state.setValue(SHAPE, RailShape.SOUTH_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.SOUTH_EAST);
+ case NORTH_WEST:
+- return state.setValue(SHAPE, RailShape.NORTH_EAST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_EAST);
+ case NORTH_EAST:
+- return state.setValue(SHAPE, RailShape.NORTH_WEST);
++ return (IBlockData) state.setValue(PoweredRailBlock.SHAPE, RailShape.NORTH_WEST);
+ }
+ }
+
+@@ -265,7 +262,7 @@
+ }
+
+ @Override
+- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
+- builder.add(SHAPE, POWERED, WATERLOGGED);
++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) {
++ builder.add(PoweredRailBlock.SHAPE, PoweredRailBlock.POWERED, PoweredRailBlock.WATERLOGGED);
+ }
+ }