diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/TntBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/TntBlock.java.patch | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/TntBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/TntBlock.java.patch new file mode 100644 index 0000000000..4605d24159 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/TntBlock.java.patch @@ -0,0 +1,202 @@ +--- a/net/minecraft/world/level/block/TntBlock.java ++++ b/net/minecraft/world/level/block/TntBlock.java +@@ -6,7 +6,7 @@ + import net.minecraft.sounds.SoundEvents; + import net.minecraft.sounds.SoundSource; + import net.minecraft.stats.Stats; +-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.LivingEntity; +@@ -19,12 +19,16 @@ + import net.minecraft.world.level.Explosion; + 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.gameevent.GameEvent; + import net.minecraft.world.phys.BlockHitResult; ++// CraftBukkit start ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++import org.bukkit.event.block.TNTPrimeEvent.PrimeCause; ++// CraftBukkit end + + public class TntBlock extends Block { + +@@ -32,90 +36,89 @@ + public static final BooleanProperty UNSTABLE = BlockStateProperties.UNSTABLE; + + @Override +- @Override + public MapCodec<TntBlock> codec() { + return TntBlock.CODEC; + } + +- public TntBlock(BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties); +- this.registerDefaultState((BlockState) this.defaultBlockState().setValue(TntBlock.UNSTABLE, false)); ++ public TntBlock(BlockBehaviour.Properties properties) { ++ super(properties); ++ this.registerDefaultState((IBlockData) this.defaultBlockState().setValue(TntBlock.UNSTABLE, false)); + } + + @Override +- @Override +- public void onPlace(BlockState blockstate, Level level, BlockPos blockpos, BlockState blockstate1, boolean flag) { +- if (!blockstate1.is(blockstate.getBlock())) { +- if (level.hasNeighborSignal(blockpos)) { +- explode(level, blockpos); +- level.removeBlock(blockpos, false); ++ public void onPlace(IBlockData state, Level level, BlockPos pos, IBlockData oldState, boolean isMoving) { ++ if (!oldState.is(state.getBlock())) { ++ if (level.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(level, pos, PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent ++ explode(level, pos); ++ level.removeBlock(pos, false); + } + + } + } + + @Override +- @Override +- public void neighborChanged(BlockState blockstate, Level level, BlockPos blockpos, Block block, BlockPos blockpos1, boolean flag) { +- if (level.hasNeighborSignal(blockpos)) { +- explode(level, blockpos); +- level.removeBlock(blockpos, false); ++ public void neighborChanged(IBlockData state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) { ++ if (level.hasNeighborSignal(pos) && CraftEventFactory.callTNTPrimeEvent(level, pos, PrimeCause.REDSTONE, null, fromPos)) { // CraftBukkit - TNTPrimeEvent ++ explode(level, pos); ++ level.removeBlock(pos, false); + } + + } + + @Override +- @Override +- public BlockState playerWillDestroy(Level level, BlockPos blockpos, BlockState blockstate, Player player) { +- if (!level.isClientSide() && !player.isCreative() && (Boolean) blockstate.getValue(TntBlock.UNSTABLE)) { +- explode(level, blockpos); ++ public IBlockData playerWillDestroy(Level world, BlockPos blockposition, IBlockData iblockdata, Player entityhuman) { ++ if (!world.isClientSide() && !entityhuman.isCreative() && (Boolean) iblockdata.getValue(TntBlock.UNSTABLE) && CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.BLOCK_BREAK, entityhuman, null)) { // CraftBukkit - TNTPrimeEvent ++ explode(world, blockposition); + } + +- return super.playerWillDestroy(level, blockpos, blockstate, player); ++ return super.playerWillDestroy(world, blockposition, iblockdata, entityhuman); + } + + @Override +- @Override +- public void wasExploded(Level level, BlockPos blockpos, Explosion explosion) { ++ public void wasExploded(Level level, BlockPos pos, Explosion explosion) { + if (!level.isClientSide) { +- PrimedTnt primedtnt = new PrimedTnt(level, (double) blockpos.getX() + 0.5D, (double) blockpos.getY(), (double) blockpos.getZ() + 0.5D, explosion.getIndirectSourceEntity()); +- int i = primedtnt.getFuse(); ++ PrimedTnt entitytntprimed = new PrimedTnt(level, (double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D, explosion.getIndirectSourceEntity()); ++ int i = entitytntprimed.getFuse(); + +- primedtnt.setFuse((short) (level.random.nextInt(i / 4) + i / 8)); +- level.addFreshEntity(primedtnt); ++ entitytntprimed.setFuse((short) (level.random.nextInt(i / 4) + i / 8)); ++ level.addFreshEntity(entitytntprimed); + } + } + +- public static void explode(Level level, BlockPos blockpos) { +- explode(level, blockpos, (LivingEntity) null); ++ public static void explode(Level level, BlockPos pos) { ++ explode(level, pos, (LivingEntity) null); + } + +- private static void explode(Level level, BlockPos blockpos, @Nullable LivingEntity livingentity) { ++ private static void explode(Level level, BlockPos pos, @Nullable LivingEntity entity) { + if (!level.isClientSide) { +- PrimedTnt primedtnt = new PrimedTnt(level, (double) blockpos.getX() + 0.5D, (double) blockpos.getY(), (double) blockpos.getZ() + 0.5D, livingentity); ++ PrimedTnt entitytntprimed = new PrimedTnt(level, (double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D, entity); + +- level.addFreshEntity(primedtnt); +- level.playSound((Player) null, primedtnt.getX(), primedtnt.getY(), primedtnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); +- level.gameEvent((Entity) livingentity, GameEvent.PRIME_FUSE, blockpos); ++ level.addFreshEntity(entitytntprimed); ++ level.playSound((Player) null, entitytntprimed.getX(), entitytntprimed.getY(), entitytntprimed.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); ++ level.gameEvent((Entity) entity, GameEvent.PRIME_FUSE, pos); + } + } + + @Override +- @Override +- public InteractionResult use(BlockState blockstate, Level level, BlockPos blockpos, Player player, InteractionHand interactionhand, BlockHitResult blockhitresult) { +- ItemStack itemstack = player.getItemInHand(interactionhand); ++ public InteractionResult use(IBlockData state, Level level, BlockPos pos, Player player, EnumHand hand, BlockHitResult hit) { ++ ItemStack itemstack = player.getItemInHand(hand); + + if (!itemstack.is(Items.FLINT_AND_STEEL) && !itemstack.is(Items.FIRE_CHARGE)) { +- return super.use(blockstate, level, blockpos, player, interactionhand, blockhitresult); ++ return super.use(state, level, pos, player, hand, hit); + } else { +- explode(level, blockpos, player); +- level.setBlock(blockpos, Blocks.AIR.defaultBlockState(), 11); ++ // CraftBukkit start - TNTPrimeEvent ++ if (!CraftEventFactory.callTNTPrimeEvent(level, pos, PrimeCause.PLAYER, player, null)) { ++ return InteractionResult.CONSUME; ++ } ++ // CraftBukkit end ++ explode(level, pos, player); ++ level.setBlock(pos, Blocks.AIR.defaultBlockState(), 11); + Item item = itemstack.getItem(); + + if (!player.isCreative()) { + if (itemstack.is(Items.FLINT_AND_STEEL)) { +- itemstack.hurtAndBreak(1, player, (player1) -> { +- player1.broadcastBreakEvent(interactionhand); ++ itemstack.hurtAndBreak(1, player, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(hand); + }); + } else { + itemstack.shrink(1); +@@ -128,29 +131,31 @@ + } + + @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.isClientSide) { +- BlockPos blockpos = blockhitresult.getBlockPos(); ++ BlockPos blockposition = hit.getBlockPos(); + Entity entity = projectile.getOwner(); + +- if (projectile.isOnFire() && projectile.mayInteract(level, blockpos)) { +- explode(level, blockpos, entity instanceof LivingEntity ? (LivingEntity) entity : null); +- level.removeBlock(blockpos, false); ++ if (projectile.isOnFire() && projectile.mayInteract(level, blockposition)) { ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, blockposition, Blocks.AIR.defaultBlockState()) || !CraftEventFactory.callTNTPrimeEvent(level, blockposition, PrimeCause.PROJECTILE, projectile, null)) { ++ return; ++ } ++ // CraftBukkit end ++ explode(level, blockposition, entity instanceof LivingEntity ? (LivingEntity) entity : null); ++ level.removeBlock(blockposition, false); + } + } + + } + + @Override +- @Override + public boolean dropFromExplosion(Explosion explosion) { + return false; + } + + @Override +- @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) { +- statedefinition_builder.add(TntBlock.UNSTABLE); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(TntBlock.UNSTABLE); + } + } |