diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/LeverBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/LeverBlock.java.patch | 256 |
1 files changed, 256 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/LeverBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/LeverBlock.java.patch new file mode 100644 index 0000000000..edb624f642 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/LeverBlock.java.patch @@ -0,0 +1,256 @@ +--- a/net/minecraft/world/level/block/LeverBlock.java ++++ b/net/minecraft/world/level/block/LeverBlock.java +@@ -4,12 +4,13 @@ + import java.util.function.BiConsumer; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; +-import net.minecraft.core.particles.DustParticleOptions; ++import net.minecraft.core.particles.ParticleParamRedstone; + import net.minecraft.sounds.SoundEvents; + import net.minecraft.sounds.SoundSource; + import net.minecraft.util.RandomSource; +-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.level.BlockGetter; +@@ -17,7 +18,7 @@ + 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.AttachFace; + import net.minecraft.world.level.block.state.properties.BlockStateProperties; +@@ -26,123 +27,142 @@ + import net.minecraft.world.phys.BlockHitResult; + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; ++import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit + + public class LeverBlock extends FaceAttachedHorizontalDirectionalBlock { ++ + public static final MapCodec<LeverBlock> CODEC = simpleCodec(LeverBlock::new); + public static final BooleanProperty POWERED = BlockStateProperties.POWERED; + protected static final int DEPTH = 6; + protected static final int WIDTH = 6; + protected static final int HEIGHT = 8; +- protected static final VoxelShape NORTH_AABB = Block.box(5.0, 4.0, 10.0, 11.0, 12.0, 16.0); +- protected static final VoxelShape SOUTH_AABB = Block.box(5.0, 4.0, 0.0, 11.0, 12.0, 6.0); +- protected static final VoxelShape WEST_AABB = Block.box(10.0, 4.0, 5.0, 16.0, 12.0, 11.0); +- protected static final VoxelShape EAST_AABB = Block.box(0.0, 4.0, 5.0, 6.0, 12.0, 11.0); +- protected static final VoxelShape UP_AABB_Z = Block.box(5.0, 0.0, 4.0, 11.0, 6.0, 12.0); +- protected static final VoxelShape UP_AABB_X = Block.box(4.0, 0.0, 5.0, 12.0, 6.0, 11.0); +- protected static final VoxelShape DOWN_AABB_Z = Block.box(5.0, 10.0, 4.0, 11.0, 16.0, 12.0); +- protected static final VoxelShape DOWN_AABB_X = Block.box(4.0, 10.0, 5.0, 12.0, 16.0, 11.0); ++ protected static final VoxelShape NORTH_AABB = Block.box(5.0D, 4.0D, 10.0D, 11.0D, 12.0D, 16.0D); ++ protected static final VoxelShape SOUTH_AABB = Block.box(5.0D, 4.0D, 0.0D, 11.0D, 12.0D, 6.0D); ++ protected static final VoxelShape WEST_AABB = Block.box(10.0D, 4.0D, 5.0D, 16.0D, 12.0D, 11.0D); ++ protected static final VoxelShape EAST_AABB = Block.box(0.0D, 4.0D, 5.0D, 6.0D, 12.0D, 11.0D); ++ protected static final VoxelShape UP_AABB_Z = Block.box(5.0D, 0.0D, 4.0D, 11.0D, 6.0D, 12.0D); ++ protected static final VoxelShape UP_AABB_X = Block.box(4.0D, 0.0D, 5.0D, 12.0D, 6.0D, 11.0D); ++ protected static final VoxelShape DOWN_AABB_Z = Block.box(5.0D, 10.0D, 4.0D, 11.0D, 16.0D, 12.0D); ++ protected static final VoxelShape DOWN_AABB_X = Block.box(4.0D, 10.0D, 5.0D, 12.0D, 16.0D, 11.0D); + + @Override + public MapCodec<LeverBlock> codec() { +- return CODEC; ++ return LeverBlock.CODEC; + } + + protected LeverBlock(BlockBehaviour.Properties properties) { + super(properties); +- this.registerDefaultState( +- this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(POWERED, Boolean.valueOf(false)).setValue(FACE, AttachFace.WALL) +- ); ++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(LeverBlock.FACING, Direction.NORTH)).setValue(LeverBlock.POWERED, false)).setValue(LeverBlock.FACE, AttachFace.WALL)); + } + + @Override +- public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { +- switch ((AttachFace)state.getValue(FACE)) { ++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ switch ((AttachFace) state.getValue(LeverBlock.FACE)) { + case FLOOR: +- switch (state.getValue(FACING).getAxis()) { ++ switch (((Direction) state.getValue(LeverBlock.FACING)).getAxis()) { + case X: +- return UP_AABB_X; ++ return LeverBlock.UP_AABB_X; + case Z: + default: +- return UP_AABB_Z; ++ return LeverBlock.UP_AABB_Z; + } + case WALL: +- switch ((Direction)state.getValue(FACING)) { ++ switch ((Direction) state.getValue(LeverBlock.FACING)) { + case EAST: +- return EAST_AABB; ++ return LeverBlock.EAST_AABB; + case WEST: +- return WEST_AABB; ++ return LeverBlock.WEST_AABB; + case SOUTH: +- return SOUTH_AABB; ++ return LeverBlock.SOUTH_AABB; + case NORTH: + default: +- return NORTH_AABB; ++ return LeverBlock.NORTH_AABB; + } + case CEILING: + default: +- switch (state.getValue(FACING).getAxis()) { ++ switch (((Direction) state.getValue(LeverBlock.FACING)).getAxis()) { + case X: +- return DOWN_AABB_X; ++ return LeverBlock.DOWN_AABB_X; + case Z: + default: +- return DOWN_AABB_Z; ++ return LeverBlock.DOWN_AABB_Z; + } + } + } + + @Override +- public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { ++ public InteractionResult use(IBlockData state, Level level, BlockPos pos, Player player, EnumHand hand, BlockHitResult hit) { ++ IBlockData iblockdata1; ++ + if (level.isClientSide) { +- BlockState blockState = state.cycle(POWERED); +- if (blockState.getValue(POWERED)) { +- makeParticle(blockState, level, pos, 1.0F); ++ iblockdata1 = (IBlockData) state.cycle(LeverBlock.POWERED); ++ if ((Boolean) iblockdata1.getValue(LeverBlock.POWERED)) { ++ makeParticle(iblockdata1, level, pos, 1.0F); + } + + return InteractionResult.SUCCESS; + } else { +- BlockState blockState = this.pull(state, level, pos); +- float f = blockState.getValue(POWERED) ? 0.6F : 0.5F; +- level.playSound(null, pos, SoundEvents.LEVER_CLICK, SoundSource.BLOCKS, 0.3F, f); +- level.gameEvent(player, blockState.getValue(POWERED) ? GameEvent.BLOCK_ACTIVATE : GameEvent.BLOCK_DEACTIVATE, pos); ++ // CraftBukkit start - Interact Lever ++ boolean powered = state.getValue(LeverBlock.POWERED); // Old powered state ++ org.bukkit.block.Block block = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ int old = (powered) ? 15 : 0; ++ int current = (!powered) ? 15 : 0; ++ ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current); ++ level.getCraftServer().getPluginManager().callEvent(eventRedstone); ++ ++ if ((eventRedstone.getNewCurrent() > 0) != (!powered)) { ++ return InteractionResult.SUCCESS; ++ } ++ // CraftBukkit end ++ ++ iblockdata1 = this.pull(state, level, pos); ++ float f = (Boolean) iblockdata1.getValue(LeverBlock.POWERED) ? 0.6F : 0.5F; ++ ++ level.playSound((Player) null, pos, SoundEvents.LEVER_CLICK, SoundSource.BLOCKS, 0.3F, f); ++ level.gameEvent((Entity) player, (Boolean) iblockdata1.getValue(LeverBlock.POWERED) ? GameEvent.BLOCK_ACTIVATE : GameEvent.BLOCK_DEACTIVATE, pos); + return InteractionResult.CONSUME; + } + } + + @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()) { +- this.pull(blockState, level, blockPos); ++ public void onExplosionHit(IBlockData iblockdata, Level world, BlockPos blockposition, Explosion explosion, BiConsumer<ItemStack, BlockPos> biconsumer) { ++ if (explosion.getBlockInteraction() == Explosion.Effect.TRIGGER_BLOCK && !world.isClientSide()) { ++ this.pull(iblockdata, world, blockposition); + } + +- super.onExplosionHit(blockState, level, blockPos, explosion, biConsumer); ++ super.onExplosionHit(iblockdata, world, blockposition, explosion, biconsumer); + } + +- public BlockState pull(BlockState state, Level level, BlockPos pos) { +- state = state.cycle(POWERED); ++ public IBlockData pull(IBlockData state, Level level, BlockPos pos) { ++ state = (IBlockData) state.cycle(LeverBlock.POWERED); + level.setBlock(pos, state, 3); + this.updateNeighbours(state, level, pos); + return state; + } + +- private static void makeParticle(BlockState state, LevelAccessor level, BlockPos pos, float alpha) { +- Direction opposite = state.getValue(FACING).getOpposite(); +- Direction opposite1 = getConnectedDirection(state).getOpposite(); +- double d = (double)pos.getX() + 0.5 + 0.1 * (double)opposite.getStepX() + 0.2 * (double)opposite1.getStepX(); +- double d1 = (double)pos.getY() + 0.5 + 0.1 * (double)opposite.getStepY() + 0.2 * (double)opposite1.getStepY(); +- double d2 = (double)pos.getZ() + 0.5 + 0.1 * (double)opposite.getStepZ() + 0.2 * (double)opposite1.getStepZ(); +- level.addParticle(new DustParticleOptions(DustParticleOptions.REDSTONE_PARTICLE_COLOR, alpha), d, d1, d2, 0.0, 0.0, 0.0); ++ private static void makeParticle(IBlockData state, LevelAccessor level, BlockPos pos, float alpha) { ++ Direction enumdirection = ((Direction) state.getValue(LeverBlock.FACING)).getOpposite(); ++ Direction enumdirection1 = getConnectedDirection(state).getOpposite(); ++ double d0 = (double) pos.getX() + 0.5D + 0.1D * (double) enumdirection.getStepX() + 0.2D * (double) enumdirection1.getStepX(); ++ double d1 = (double) pos.getY() + 0.5D + 0.1D * (double) enumdirection.getStepY() + 0.2D * (double) enumdirection1.getStepY(); ++ double d2 = (double) pos.getZ() + 0.5D + 0.1D * (double) enumdirection.getStepZ() + 0.2D * (double) enumdirection1.getStepZ(); ++ ++ level.addParticle(new ParticleParamRedstone(ParticleParamRedstone.REDSTONE_PARTICLE_COLOR, alpha), d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + + @Override +- public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { +- if (state.getValue(POWERED) && random.nextFloat() < 0.25F) { ++ public void animateTick(IBlockData state, Level level, BlockPos pos, RandomSource random) { ++ if ((Boolean) state.getValue(LeverBlock.POWERED) && random.nextFloat() < 0.25F) { + makeParticle(state, level, pos, 0.5F); + } ++ + } + + @Override +- public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) { ++ public void onRemove(IBlockData state, Level level, BlockPos pos, IBlockData newState, boolean isMoving) { + if (!isMoving && !state.is(newState.getBlock())) { +- if (state.getValue(POWERED)) { ++ if ((Boolean) state.getValue(LeverBlock.POWERED)) { + this.updateNeighbours(state, level, pos); + } + +@@ -151,27 +171,27 @@ + } + + @Override +- public int getSignal(BlockState blockState, BlockGetter blockAccess, BlockPos pos, Direction side) { +- return blockState.getValue(POWERED) ? 15 : 0; ++ public int getSignal(IBlockData blockState, BlockGetter blockAccess, BlockPos pos, Direction side) { ++ return (Boolean) blockState.getValue(LeverBlock.POWERED) ? 15 : 0; + } + + @Override +- public int getDirectSignal(BlockState blockState, BlockGetter blockAccess, BlockPos pos, Direction side) { +- return blockState.getValue(POWERED) && getConnectedDirection(blockState) == side ? 15 : 0; ++ public int getDirectSignal(IBlockData blockState, BlockGetter blockAccess, BlockPos pos, Direction side) { ++ return (Boolean) blockState.getValue(LeverBlock.POWERED) && getConnectedDirection(blockState) == side ? 15 : 0; + } + + @Override +- public boolean isSignalSource(BlockState state) { ++ public boolean isSignalSource(IBlockData state) { + return true; + } + +- private void updateNeighbours(BlockState state, Level level, BlockPos pos) { ++ private void updateNeighbours(IBlockData state, Level level, BlockPos pos) { + level.updateNeighborsAt(pos, this); + level.updateNeighborsAt(pos.relative(getConnectedDirection(state).getOpposite()), this); + } + + @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { +- builder.add(FACE, FACING, POWERED); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(LeverBlock.FACE, LeverBlock.FACING, LeverBlock.POWERED); + } + } |