diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/FenceGateBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/FenceGateBlock.java.patch | 323 |
1 files changed, 323 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/FenceGateBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/FenceGateBlock.java.patch new file mode 100644 index 0000000000..2690ba35f6 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/FenceGateBlock.java.patch @@ -0,0 +1,323 @@ +--- a/net/minecraft/world/level/block/FenceGateBlock.java ++++ b/net/minecraft/world/level/block/FenceGateBlock.java +@@ -2,14 +2,14 @@ + + import com.mojang.serialization.MapCodec; + import com.mojang.serialization.codecs.RecordCodecBuilder; +-import com.mojang.serialization.codecs.RecordCodecBuilder.Instance; + import java.util.function.BiConsumer; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; + import net.minecraft.sounds.SoundSource; + import net.minecraft.tags.BlockTags; +-import net.minecraft.world.InteractionHand; ++import net.minecraft.world.EnumHand; + import net.minecraft.world.InteractionResult; ++import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.item.context.BlockPlaceContext; +@@ -18,207 +18,185 @@ + import net.minecraft.world.level.Level; + import net.minecraft.world.level.LevelAccessor; + 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.WoodType; + import net.minecraft.world.level.gameevent.GameEvent; +-import net.minecraft.world.level.pathfinder.PathComputationType; ++import net.minecraft.world.level.pathfinder.PathMode; + import net.minecraft.world.phys.BlockHitResult; + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.Shapes; + import net.minecraft.world.phys.shapes.VoxelShape; + + public class FenceGateBlock extends HorizontalDirectionalBlock { +- public static final MapCodec<FenceGateBlock> CODEC = RecordCodecBuilder.mapCodec( +- instance -> instance.group(WoodType.CODEC.fieldOf("wood_type").forGetter(fenceGateBlock -> fenceGateBlock.type), propertiesCodec()) +- .apply(instance, FenceGateBlock::new) +- ); ++ ++ public static final MapCodec<FenceGateBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> { ++ return instance.group(WoodType.CODEC.fieldOf("wood_type").forGetter((blockfencegate) -> { ++ return blockfencegate.type; ++ }), propertiesCodec()).apply(instance, FenceGateBlock::new); ++ }); + public static final BooleanProperty OPEN = BlockStateProperties.OPEN; + public static final BooleanProperty POWERED = BlockStateProperties.POWERED; + public static final BooleanProperty IN_WALL = BlockStateProperties.IN_WALL; +- protected static final VoxelShape Z_SHAPE = Block.box(0.0, 0.0, 6.0, 16.0, 16.0, 10.0); +- protected static final VoxelShape X_SHAPE = Block.box(6.0, 0.0, 0.0, 10.0, 16.0, 16.0); +- protected static final VoxelShape Z_SHAPE_LOW = Block.box(0.0, 0.0, 6.0, 16.0, 13.0, 10.0); +- protected static final VoxelShape X_SHAPE_LOW = Block.box(6.0, 0.0, 0.0, 10.0, 13.0, 16.0); +- protected static final VoxelShape Z_COLLISION_SHAPE = Block.box(0.0, 0.0, 6.0, 16.0, 24.0, 10.0); +- protected static final VoxelShape X_COLLISION_SHAPE = Block.box(6.0, 0.0, 0.0, 10.0, 24.0, 16.0); +- protected static final VoxelShape Z_SUPPORT_SHAPE = Block.box(0.0, 5.0, 6.0, 16.0, 24.0, 10.0); +- protected static final VoxelShape X_SUPPORT_SHAPE = Block.box(6.0, 5.0, 0.0, 10.0, 24.0, 16.0); +- protected static final VoxelShape Z_OCCLUSION_SHAPE = Shapes.or(Block.box(0.0, 5.0, 7.0, 2.0, 16.0, 9.0), Block.box(14.0, 5.0, 7.0, 16.0, 16.0, 9.0)); +- protected static final VoxelShape X_OCCLUSION_SHAPE = Shapes.or(Block.box(7.0, 5.0, 0.0, 9.0, 16.0, 2.0), Block.box(7.0, 5.0, 14.0, 9.0, 16.0, 16.0)); +- protected static final VoxelShape Z_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(0.0, 2.0, 7.0, 2.0, 13.0, 9.0), Block.box(14.0, 2.0, 7.0, 16.0, 13.0, 9.0)); +- protected static final VoxelShape X_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(7.0, 2.0, 0.0, 9.0, 13.0, 2.0), Block.box(7.0, 2.0, 14.0, 9.0, 13.0, 16.0)); ++ protected static final VoxelShape Z_SHAPE = Block.box(0.0D, 0.0D, 6.0D, 16.0D, 16.0D, 10.0D); ++ protected static final VoxelShape X_SHAPE = Block.box(6.0D, 0.0D, 0.0D, 10.0D, 16.0D, 16.0D); ++ protected static final VoxelShape Z_SHAPE_LOW = Block.box(0.0D, 0.0D, 6.0D, 16.0D, 13.0D, 10.0D); ++ protected static final VoxelShape X_SHAPE_LOW = Block.box(6.0D, 0.0D, 0.0D, 10.0D, 13.0D, 16.0D); ++ protected static final VoxelShape Z_COLLISION_SHAPE = Block.box(0.0D, 0.0D, 6.0D, 16.0D, 24.0D, 10.0D); ++ protected static final VoxelShape X_COLLISION_SHAPE = Block.box(6.0D, 0.0D, 0.0D, 10.0D, 24.0D, 16.0D); ++ protected static final VoxelShape Z_SUPPORT_SHAPE = Block.box(0.0D, 5.0D, 6.0D, 16.0D, 24.0D, 10.0D); ++ protected static final VoxelShape X_SUPPORT_SHAPE = Block.box(6.0D, 5.0D, 0.0D, 10.0D, 24.0D, 16.0D); ++ protected static final VoxelShape Z_OCCLUSION_SHAPE = Shapes.or(Block.box(0.0D, 5.0D, 7.0D, 2.0D, 16.0D, 9.0D), Block.box(14.0D, 5.0D, 7.0D, 16.0D, 16.0D, 9.0D)); ++ protected static final VoxelShape X_OCCLUSION_SHAPE = Shapes.or(Block.box(7.0D, 5.0D, 0.0D, 9.0D, 16.0D, 2.0D), Block.box(7.0D, 5.0D, 14.0D, 9.0D, 16.0D, 16.0D)); ++ protected static final VoxelShape Z_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(0.0D, 2.0D, 7.0D, 2.0D, 13.0D, 9.0D), Block.box(14.0D, 2.0D, 7.0D, 16.0D, 13.0D, 9.0D)); ++ protected static final VoxelShape X_OCCLUSION_SHAPE_LOW = Shapes.or(Block.box(7.0D, 2.0D, 0.0D, 9.0D, 13.0D, 2.0D), Block.box(7.0D, 2.0D, 14.0D, 9.0D, 13.0D, 16.0D)); + private final WoodType type; + + @Override + public MapCodec<FenceGateBlock> codec() { +- return CODEC; ++ return FenceGateBlock.CODEC; + } + +- public FenceGateBlock(WoodType woodType, BlockBehaviour.Properties properties) { +- super(properties.sound(woodType.soundType())); +- this.type = woodType; +- this.registerDefaultState( +- this.stateDefinition +- .any() +- .setValue(OPEN, Boolean.valueOf(false)) +- .setValue(POWERED, Boolean.valueOf(false)) +- .setValue(IN_WALL, Boolean.valueOf(false)) +- ); ++ public FenceGateBlock(WoodType blockpropertywood, BlockBehaviour.Properties blockbase_info) { ++ super(blockbase_info.sound(blockpropertywood.soundType())); ++ this.type = blockpropertywood; ++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(FenceGateBlock.OPEN, false)).setValue(FenceGateBlock.POWERED, false)).setValue(FenceGateBlock.IN_WALL, false)); + } + + @Override +- public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { +- if (state.getValue(IN_WALL)) { +- return state.getValue(FACING).getAxis() == Direction.Axis.X ? X_SHAPE_LOW : Z_SHAPE_LOW; +- } else { +- return state.getValue(FACING).getAxis() == Direction.Axis.X ? X_SHAPE : Z_SHAPE; +- } ++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ return (Boolean) state.getValue(FenceGateBlock.IN_WALL) ? (((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == Direction.Axis.X ? FenceGateBlock.X_SHAPE_LOW : FenceGateBlock.Z_SHAPE_LOW) : (((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == Direction.Axis.X ? FenceGateBlock.X_SHAPE : FenceGateBlock.Z_SHAPE); + } + + @Override +- public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { +- Direction.Axis axis = facing.getAxis(); +- if (state.getValue(FACING).getClockWise().getAxis() != axis) { ++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { ++ Direction.Axis enumdirection_enumaxis = facing.getAxis(); ++ ++ if (((Direction) state.getValue(FenceGateBlock.FACING)).getClockWise().getAxis() != enumdirection_enumaxis) { + return super.updateShape(state, facing, facingState, level, currentPos, facingPos); + } else { + boolean flag = this.isWall(facingState) || this.isWall(level.getBlockState(currentPos.relative(facing.getOpposite()))); +- return state.setValue(IN_WALL, Boolean.valueOf(flag)); ++ ++ return (IBlockData) state.setValue(FenceGateBlock.IN_WALL, flag); + } + } + + @Override +- public VoxelShape getBlockSupportShape(BlockState state, BlockGetter level, BlockPos pos) { +- if (state.getValue(OPEN)) { +- return Shapes.empty(); +- } else { +- return state.getValue(FACING).getAxis() == Direction.Axis.Z ? Z_SUPPORT_SHAPE : X_SUPPORT_SHAPE; +- } ++ public VoxelShape getBlockSupportShape(IBlockData state, BlockGetter level, BlockPos pos) { ++ return (Boolean) state.getValue(FenceGateBlock.OPEN) ? Shapes.empty() : (((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == Direction.Axis.Z ? FenceGateBlock.Z_SUPPORT_SHAPE : FenceGateBlock.X_SUPPORT_SHAPE); + } + + @Override +- public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { +- if (state.getValue(OPEN)) { +- return Shapes.empty(); +- } else { +- return state.getValue(FACING).getAxis() == Direction.Axis.Z ? Z_COLLISION_SHAPE : X_COLLISION_SHAPE; +- } ++ public VoxelShape getCollisionShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ return (Boolean) state.getValue(FenceGateBlock.OPEN) ? Shapes.empty() : (((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == Direction.Axis.Z ? FenceGateBlock.Z_COLLISION_SHAPE : FenceGateBlock.X_COLLISION_SHAPE); + } + + @Override +- public VoxelShape getOcclusionShape(BlockState state, BlockGetter level, BlockPos pos) { +- if (state.getValue(IN_WALL)) { +- return state.getValue(FACING).getAxis() == Direction.Axis.X ? X_OCCLUSION_SHAPE_LOW : Z_OCCLUSION_SHAPE_LOW; +- } else { +- return state.getValue(FACING).getAxis() == Direction.Axis.X ? X_OCCLUSION_SHAPE : Z_OCCLUSION_SHAPE; +- } ++ public VoxelShape getOcclusionShape(IBlockData state, BlockGetter level, BlockPos pos) { ++ return (Boolean) state.getValue(FenceGateBlock.IN_WALL) ? (((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == Direction.Axis.X ? FenceGateBlock.X_OCCLUSION_SHAPE_LOW : FenceGateBlock.Z_OCCLUSION_SHAPE_LOW) : (((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == Direction.Axis.X ? FenceGateBlock.X_OCCLUSION_SHAPE : FenceGateBlock.Z_OCCLUSION_SHAPE); + } + + @Override +- public boolean isPathfindable(BlockState state, BlockGetter level, BlockPos pos, PathComputationType type) { ++ public boolean isPathfindable(IBlockData state, BlockGetter level, BlockPos pos, PathMode type) { + switch (type) { + case LAND: +- return state.getValue(OPEN); ++ return (Boolean) state.getValue(FenceGateBlock.OPEN); + case WATER: + return false; + case AIR: +- return state.getValue(OPEN); ++ return (Boolean) state.getValue(FenceGateBlock.OPEN); + default: + return false; + } + } + + @Override +- public BlockState getStateForPlacement(BlockPlaceContext context) { +- Level level = context.getLevel(); +- BlockPos clickedPos = context.getClickedPos(); +- boolean hasNeighborSignal = level.hasNeighborSignal(clickedPos); +- Direction horizontalDirection = context.getHorizontalDirection(); +- Direction.Axis axis = horizontalDirection.getAxis(); +- boolean flag = axis == Direction.Axis.Z && (this.isWall(level.getBlockState(clickedPos.west())) || this.isWall(level.getBlockState(clickedPos.east()))) +- || axis == Direction.Axis.X && (this.isWall(level.getBlockState(clickedPos.north())) || this.isWall(level.getBlockState(clickedPos.south()))); +- return this.defaultBlockState() +- .setValue(FACING, horizontalDirection) +- .setValue(OPEN, Boolean.valueOf(hasNeighborSignal)) +- .setValue(POWERED, Boolean.valueOf(hasNeighborSignal)) +- .setValue(IN_WALL, Boolean.valueOf(flag)); ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ Level world = context.getLevel(); ++ BlockPos blockposition = context.getClickedPos(); ++ boolean flag = world.hasNeighborSignal(blockposition); ++ Direction enumdirection = context.getHorizontalDirection(); ++ Direction.Axis enumdirection_enumaxis = enumdirection.getAxis(); ++ boolean flag1 = enumdirection_enumaxis == Direction.Axis.Z && (this.isWall(world.getBlockState(blockposition.west())) || this.isWall(world.getBlockState(blockposition.east()))) || enumdirection_enumaxis == Direction.Axis.X && (this.isWall(world.getBlockState(blockposition.north())) || this.isWall(world.getBlockState(blockposition.south()))); ++ ++ return (IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.defaultBlockState().setValue(FenceGateBlock.FACING, enumdirection)).setValue(FenceGateBlock.OPEN, flag)).setValue(FenceGateBlock.POWERED, flag)).setValue(FenceGateBlock.IN_WALL, flag1); + } + +- private boolean isWall(BlockState state) { ++ private boolean isWall(IBlockData state) { + return state.is(BlockTags.WALLS); + } + + @Override +- public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { +- if (state.getValue(OPEN)) { +- state = state.setValue(OPEN, Boolean.valueOf(false)); ++ public InteractionResult use(IBlockData state, Level level, BlockPos pos, Player player, EnumHand hand, BlockHitResult hit) { ++ if ((Boolean) state.getValue(FenceGateBlock.OPEN)) { ++ state = (IBlockData) state.setValue(FenceGateBlock.OPEN, false); + level.setBlock(pos, state, 10); + } else { +- Direction direction = player.getDirection(); +- if (state.getValue(FACING) == direction.getOpposite()) { +- state = state.setValue(FACING, direction); ++ Direction enumdirection = player.getDirection(); ++ ++ if (state.getValue(FenceGateBlock.FACING) == enumdirection.getOpposite()) { ++ state = (IBlockData) state.setValue(FenceGateBlock.FACING, enumdirection); + } + +- state = state.setValue(OPEN, Boolean.valueOf(true)); ++ state = (IBlockData) state.setValue(FenceGateBlock.OPEN, true); + level.setBlock(pos, state, 10); + } + +- boolean flag = state.getValue(OPEN); +- level.playSound( +- player, pos, flag ? this.type.fenceGateOpen() : this.type.fenceGateClose(), SoundSource.BLOCKS, 1.0F, level.getRandom().nextFloat() * 0.1F + 0.9F +- ); +- level.gameEvent(player, flag ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, pos); ++ boolean flag = (Boolean) state.getValue(FenceGateBlock.OPEN); ++ ++ level.playSound(player, pos, flag ? this.type.fenceGateOpen() : this.type.fenceGateClose(), SoundSource.BLOCKS, 1.0F, level.getRandom().nextFloat() * 0.1F + 0.9F); ++ level.gameEvent((Entity) player, flag ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, pos); + return InteractionResult.sidedSuccess(level.isClientSide); + } + + @Override +- public void onExplosionHit(BlockState blockState, Level level, BlockPos blockPos, Explosion explosion, BiConsumer<ItemStack, BlockPos> biConsumer) { +- if (explosion.getBlockInteraction() == Explosion.BlockInteraction.TRIGGER_BLOCK && !level.isClientSide() && !blockState.getValue(POWERED)) { +- boolean flag = blockState.getValue(OPEN); +- level.setBlockAndUpdate(blockPos, blockState.setValue(OPEN, Boolean.valueOf(!flag))); +- level.playSound( +- null, +- blockPos, +- flag ? this.type.fenceGateClose() : this.type.fenceGateOpen(), +- SoundSource.BLOCKS, +- 1.0F, +- level.getRandom().nextFloat() * 0.1F + 0.9F +- ); +- level.gameEvent(flag ? GameEvent.BLOCK_CLOSE : GameEvent.BLOCK_OPEN, blockPos, GameEvent.Context.of(blockState)); ++ public void onExplosionHit(IBlockData iblockdata, Level world, BlockPos blockposition, Explosion explosion, BiConsumer<ItemStack, BlockPos> biconsumer) { ++ if (explosion.getBlockInteraction() == Explosion.Effect.TRIGGER_BLOCK && !world.isClientSide() && !(Boolean) iblockdata.getValue(FenceGateBlock.POWERED)) { ++ boolean flag = (Boolean) iblockdata.getValue(FenceGateBlock.OPEN); ++ ++ world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(FenceGateBlock.OPEN, !flag)); ++ world.playSound((Player) null, blockposition, flag ? this.type.fenceGateClose() : this.type.fenceGateOpen(), SoundSource.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.1F + 0.9F); ++ world.gameEvent(flag ? GameEvent.BLOCK_CLOSE : GameEvent.BLOCK_OPEN, blockposition, GameEvent.Context.of(iblockdata)); + } + +- super.onExplosionHit(blockState, level, blockPos, explosion, biConsumer); ++ super.onExplosionHit(iblockdata, world, blockposition, explosion, biconsumer); + } + + @Override +- public void neighborChanged(BlockState state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) { ++ public void neighborChanged(IBlockData state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) { + if (!level.isClientSide) { +- boolean hasNeighborSignal = level.hasNeighborSignal(pos); +- if (state.getValue(POWERED) != hasNeighborSignal) { +- level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(hasNeighborSignal)).setValue(OPEN, Boolean.valueOf(hasNeighborSignal)), 2); +- if (state.getValue(OPEN) != hasNeighborSignal) { +- level.playSound( +- null, +- pos, +- hasNeighborSignal ? this.type.fenceGateOpen() : this.type.fenceGateClose(), +- SoundSource.BLOCKS, +- 1.0F, +- level.getRandom().nextFloat() * 0.1F + 0.9F +- ); +- level.gameEvent(null, hasNeighborSignal ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, pos); ++ boolean flag1 = level.hasNeighborSignal(pos); ++ // CraftBukkit start ++ boolean oldPowered = state.getValue(FenceGateBlock.POWERED); ++ if (oldPowered != flag1) { ++ int newPower = flag1 ? 15 : 0; ++ int oldPower = oldPowered ? 15 : 0; ++ org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); ++ org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(bukkitBlock, oldPower, newPower); ++ level.getCraftServer().getPluginManager().callEvent(eventRedstone); ++ flag1 = eventRedstone.getNewCurrent() > 0; ++ } ++ // CraftBukkit end ++ ++ if ((Boolean) state.getValue(FenceGateBlock.POWERED) != flag1) { ++ level.setBlock(pos, (IBlockData) ((IBlockData) state.setValue(FenceGateBlock.POWERED, flag1)).setValue(FenceGateBlock.OPEN, flag1), 2); ++ if ((Boolean) state.getValue(FenceGateBlock.OPEN) != flag1) { ++ level.playSound((Player) null, pos, flag1 ? this.type.fenceGateOpen() : this.type.fenceGateClose(), SoundSource.BLOCKS, 1.0F, level.getRandom().nextFloat() * 0.1F + 0.9F); ++ level.gameEvent((Entity) null, flag1 ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, pos); + } + } ++ + } + } + + @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { +- builder.add(FACING, OPEN, POWERED, IN_WALL); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(FenceGateBlock.FACING, FenceGateBlock.OPEN, FenceGateBlock.POWERED, FenceGateBlock.IN_WALL); + } + +- public static boolean connectsToDirection(BlockState state, Direction direction) { +- return state.getValue(FACING).getAxis() == direction.getClockWise().getAxis(); ++ public static boolean connectsToDirection(IBlockData state, Direction direction) { ++ return ((Direction) state.getValue(FenceGateBlock.FACING)).getAxis() == direction.getClockWise().getAxis(); + } + } |