diff options
author | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
---|---|---|
committer | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
commit | bee74680e607c2e29b038329f62181238911cd83 (patch) | |
tree | 708fd1a4a0227d9071243adf2a42d5e9e96cde4a /patch-remap/mache-spigotflower/net/minecraft/world/level/block/LightningRodBlock.java.patch | |
parent | 0a44692ef6ff6e255d48eb3ba1bb114166eafda9 (diff) | |
download | Paper-softspoon.tar.gz Paper-softspoon.zip |
add remapped patches as a testsoftspoon
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/LightningRodBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/LightningRodBlock.java.patch | 220 |
1 files changed, 220 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/LightningRodBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/LightningRodBlock.java.patch new file mode 100644 index 0000000000..dae930f7d5 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/LightningRodBlock.java.patch @@ -0,0 +1,220 @@ +--- a/net/minecraft/world/level/block/LightningRodBlock.java ++++ b/net/minecraft/world/level/block/LightningRodBlock.java +@@ -22,7 +22,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.BlockStateProperties; + import net.minecraft.world.level.block.state.properties.BooleanProperty; +@@ -32,6 +32,10 @@ + import net.minecraft.world.level.material.Fluids; + import net.minecraft.world.phys.BlockHitResult; + import net.minecraft.world.phys.Vec3; ++// CraftBukkit start ++import org.bukkit.craftbukkit.block.CraftBlock; ++import org.bukkit.event.block.BlockRedstoneEvent; ++// CraftBukkit end + + public class LightningRodBlock extends RodBlock implements SimpleWaterloggedBlock { + +@@ -43,134 +47,133 @@ + private static final int SPARK_CYCLE = 200; + + @Override +- @Override + public MapCodec<LightningRodBlock> codec() { + return LightningRodBlock.CODEC; + } + +- public LightningRodBlock(BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties); +- this.registerDefaultState((BlockState) ((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any()).setValue(LightningRodBlock.FACING, Direction.UP)).setValue(LightningRodBlock.WATERLOGGED, false)).setValue(LightningRodBlock.POWERED, false)); ++ public LightningRodBlock(BlockBehaviour.Properties properties) { ++ super(properties); ++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(LightningRodBlock.FACING, Direction.UP)).setValue(LightningRodBlock.WATERLOGGED, false)).setValue(LightningRodBlock.POWERED, false)); + } + + @Override +- @Override +- public BlockState getStateForPlacement(BlockPlaceContext blockplacecontext) { +- FluidState fluidstate = blockplacecontext.getLevel().getFluidState(blockplacecontext.getClickedPos()); +- boolean flag = fluidstate.getType() == Fluids.WATER; ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ FluidState fluid = context.getLevel().getFluidState(context.getClickedPos()); ++ boolean flag = fluid.getType() == Fluids.WATER; + +- return (BlockState) ((BlockState) this.defaultBlockState().setValue(LightningRodBlock.FACING, blockplacecontext.getClickedFace())).setValue(LightningRodBlock.WATERLOGGED, flag); ++ return (IBlockData) ((IBlockData) this.defaultBlockState().setValue(LightningRodBlock.FACING, context.getClickedFace())).setValue(LightningRodBlock.WATERLOGGED, flag); + } + + @Override +- @Override +- public BlockState updateShape(BlockState blockstate, Direction direction, BlockState blockstate1, LevelAccessor levelaccessor, BlockPos blockpos, BlockPos blockpos1) { +- if ((Boolean) blockstate.getValue(LightningRodBlock.WATERLOGGED)) { +- levelaccessor.scheduleTick(blockpos, (Fluid) Fluids.WATER, Fluids.WATER.getTickDelay(levelaccessor)); ++ public IBlockData updateShape(IBlockData state, Direction direction, IBlockData neighborState, LevelAccessor level, BlockPos pos, BlockPos neighborPos) { ++ if ((Boolean) state.getValue(LightningRodBlock.WATERLOGGED)) { ++ level.scheduleTick(pos, (Fluid) Fluids.WATER, Fluids.WATER.getTickDelay(level)); + } + +- return super.updateShape(blockstate, direction, blockstate1, levelaccessor, blockpos, blockpos1); ++ return super.updateShape(state, direction, neighborState, level, pos, neighborPos); + } + + @Override +- @Override +- public FluidState getFluidState(BlockState blockstate) { +- return (Boolean) blockstate.getValue(LightningRodBlock.WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(blockstate); ++ public FluidState getFluidState(IBlockData state) { ++ return (Boolean) state.getValue(LightningRodBlock.WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state); + } + + @Override +- @Override +- public int getSignal(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, Direction direction) { +- return (Boolean) blockstate.getValue(LightningRodBlock.POWERED) ? 15 : 0; ++ public int getSignal(IBlockData state, BlockGetter level, BlockPos pos, Direction direction) { ++ return (Boolean) state.getValue(LightningRodBlock.POWERED) ? 15 : 0; + } + + @Override +- @Override +- public int getDirectSignal(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos, Direction direction) { +- return (Boolean) blockstate.getValue(LightningRodBlock.POWERED) && blockstate.getValue(LightningRodBlock.FACING) == direction ? 15 : 0; ++ public int getDirectSignal(IBlockData state, BlockGetter level, BlockPos pos, Direction direction) { ++ return (Boolean) state.getValue(LightningRodBlock.POWERED) && state.getValue(LightningRodBlock.FACING) == direction ? 15 : 0; + } + +- public void onLightningStrike(BlockState blockstate, Level level, BlockPos blockpos) { +- level.setBlock(blockpos, (BlockState) blockstate.setValue(LightningRodBlock.POWERED, true), 3); +- this.updateNeighbours(blockstate, level, blockpos); +- level.scheduleTick(blockpos, (Block) this, 8); +- level.levelEvent(3002, blockpos, ((Direction) blockstate.getValue(LightningRodBlock.FACING)).getAxis().ordinal()); ++ public void onLightningStrike(IBlockData state, Level level, BlockPos pos) { ++ // CraftBukkit start ++ boolean powered = state.getValue(LightningRodBlock.POWERED); ++ int old = (powered) ? 15 : 0; ++ int current = (!powered) ? 15 : 0; ++ ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(CraftBlock.at(level, pos), old, current); ++ level.getCraftServer().getPluginManager().callEvent(eventRedstone); ++ ++ if (eventRedstone.getNewCurrent() <= 0) { ++ return; ++ } ++ // CraftBukkit end ++ level.setBlock(pos, (IBlockData) state.setValue(LightningRodBlock.POWERED, true), 3); ++ this.updateNeighbours(state, level, pos); ++ level.scheduleTick(pos, (Block) this, 8); ++ level.levelEvent(3002, pos, ((Direction) state.getValue(LightningRodBlock.FACING)).getAxis().ordinal()); + } + +- private void updateNeighbours(BlockState blockstate, Level level, BlockPos blockpos) { +- level.updateNeighborsAt(blockpos.relative(((Direction) blockstate.getValue(LightningRodBlock.FACING)).getOpposite()), this); ++ private void updateNeighbours(IBlockData state, Level level, BlockPos pos) { ++ level.updateNeighborsAt(pos.relative(((Direction) state.getValue(LightningRodBlock.FACING)).getOpposite()), this); + } + + @Override +- @Override +- public void tick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- serverlevel.setBlock(blockpos, (BlockState) blockstate.setValue(LightningRodBlock.POWERED, false), 3); +- this.updateNeighbours(blockstate, serverlevel, blockpos); ++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ level.setBlock(pos, (IBlockData) state.setValue(LightningRodBlock.POWERED, false), 3); ++ this.updateNeighbours(state, level, pos); + } + + @Override +- @Override +- public void animateTick(BlockState blockstate, Level level, BlockPos blockpos, RandomSource randomsource) { +- if (level.isThundering() && (long) level.random.nextInt(200) <= level.getGameTime() % 200L && blockpos.getY() == level.getHeight(Heightmap.Types.WORLD_SURFACE, blockpos.getX(), blockpos.getZ()) - 1) { +- ParticleUtils.spawnParticlesAlongAxis(((Direction) blockstate.getValue(LightningRodBlock.FACING)).getAxis(), level, blockpos, 0.125D, ParticleTypes.ELECTRIC_SPARK, UniformInt.of(1, 2)); ++ public void animateTick(IBlockData state, Level level, BlockPos pos, RandomSource random) { ++ if (level.isThundering() && (long) level.random.nextInt(200) <= level.getGameTime() % 200L && pos.getY() == level.getHeight(Heightmap.Types.WORLD_SURFACE, pos.getX(), pos.getZ()) - 1) { ++ ParticleUtils.spawnParticlesAlongAxis(((Direction) state.getValue(LightningRodBlock.FACING)).getAxis(), level, pos, 0.125D, ParticleTypes.ELECTRIC_SPARK, UniformInt.of(1, 2)); + } + } + + @Override +- @Override +- public void onRemove(BlockState blockstate, Level level, BlockPos blockpos, BlockState blockstate1, boolean flag) { +- if (!blockstate.is(blockstate1.getBlock())) { +- if ((Boolean) blockstate.getValue(LightningRodBlock.POWERED)) { +- this.updateNeighbours(blockstate, level, blockpos); ++ public void onRemove(IBlockData state, Level level, BlockPos pos, IBlockData newState, boolean movedByPiston) { ++ if (!state.is(newState.getBlock())) { ++ if ((Boolean) state.getValue(LightningRodBlock.POWERED)) { ++ this.updateNeighbours(state, level, pos); + } + +- super.onRemove(blockstate, level, blockpos, blockstate1, flag); ++ super.onRemove(state, level, pos, newState, movedByPiston); + } + } + + @Override +- @Override +- public void onPlace(BlockState blockstate, Level level, BlockPos blockpos, BlockState blockstate1, boolean flag) { +- if (!blockstate.is(blockstate1.getBlock())) { +- if ((Boolean) blockstate.getValue(LightningRodBlock.POWERED) && !level.getBlockTicks().hasScheduledTick(blockpos, this)) { +- level.setBlock(blockpos, (BlockState) blockstate.setValue(LightningRodBlock.POWERED, false), 18); ++ public void onPlace(IBlockData state, Level level, BlockPos pos, IBlockData oldState, boolean movedByPiston) { ++ if (!state.is(oldState.getBlock())) { ++ if ((Boolean) state.getValue(LightningRodBlock.POWERED) && !level.getBlockTicks().hasScheduledTick(pos, this)) { ++ level.setBlock(pos, (IBlockData) state.setValue(LightningRodBlock.POWERED, false), 18); + } + + } + } + + @Override +- @Override +- public void onProjectileHit(Level level, BlockState blockstate, BlockHitResult blockhitresult, Projectile projectile) { ++ public void onProjectileHit(Level level, IBlockData state, BlockHitResult hit, Projectile projectile) { + if (level.isThundering() && projectile instanceof ThrownTrident && ((ThrownTrident) projectile).isChanneling()) { +- BlockPos blockpos = blockhitresult.getBlockPos(); ++ BlockPos blockposition = hit.getBlockPos(); + +- if (level.canSeeSky(blockpos)) { +- LightningBolt lightningbolt = (LightningBolt) EntityType.LIGHTNING_BOLT.create(level); ++ if (level.canSeeSky(blockposition)) { ++ LightningBolt entitylightning = (LightningBolt) EntityType.LIGHTNING_BOLT.create(level); + +- if (lightningbolt != null) { +- lightningbolt.moveTo(Vec3.atBottomCenterOf(blockpos.above())); ++ if (entitylightning != null) { ++ entitylightning.moveTo(Vec3.atBottomCenterOf(blockposition.above())); + Entity entity = projectile.getOwner(); + +- lightningbolt.setCause(entity instanceof ServerPlayer ? (ServerPlayer) entity : null); +- level.addFreshEntity(lightningbolt); ++ entitylightning.setCause(entity instanceof ServerPlayer ? (ServerPlayer) entity : null); ++ ((ServerLevel) level).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit + } + +- level.playSound((Player) null, blockpos, SoundEvents.TRIDENT_THUNDER, SoundSource.WEATHER, 5.0F, 1.0F); ++ level.playSound((Player) null, blockposition, SoundEvents.TRIDENT_THUNDER, SoundSource.WEATHER, 5.0F, 1.0F); + } + } + + } + + @Override +- @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) { +- statedefinition_builder.add(LightningRodBlock.FACING, LightningRodBlock.POWERED, LightningRodBlock.WATERLOGGED); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(LightningRodBlock.FACING, LightningRodBlock.POWERED, LightningRodBlock.WATERLOGGED); + } + + @Override +- @Override +- public boolean isSignalSource(BlockState blockstate) { ++ public boolean isSignalSource(IBlockData state) { + return true; + } + } |