diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/AbstractCandleBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/AbstractCandleBlock.java.patch | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/AbstractCandleBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/AbstractCandleBlock.java.patch new file mode 100644 index 0000000000..0dc1410719 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/AbstractCandleBlock.java.patch @@ -0,0 +1,148 @@ +--- a/net/minecraft/world/level/block/AbstractCandleBlock.java ++++ b/net/minecraft/world/level/block/AbstractCandleBlock.java +@@ -9,6 +9,7 @@ + import net.minecraft.sounds.SoundSource; + import net.minecraft.tags.BlockTags; + import net.minecraft.util.RandomSource; ++import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.entity.projectile.Projectile; + import net.minecraft.world.item.ItemStack; +@@ -16,7 +17,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.properties.BlockStateProperties; + import net.minecraft.world.level.block.state.properties.BooleanProperty; + import net.minecraft.world.level.gameevent.GameEvent; +@@ -24,6 +25,7 @@ + import net.minecraft.world.phys.Vec3; + + public abstract class AbstractCandleBlock extends Block { ++ + public static final int LIGHT_PER_CANDLE = 3; + public static final BooleanProperty LIT = BlockStateProperties.LIT; + +@@ -34,84 +36,73 @@ + super(properties); + } + +- protected abstract Iterable<Vec3> getParticleOffsets(BlockState state); ++ protected abstract Iterable<Vec3> getParticleOffsets(IBlockData state); + +- public static boolean isLit(BlockState state) { +- return state.hasProperty(LIT) && (state.is(BlockTags.CANDLES) || state.is(BlockTags.CANDLE_CAKES)) && state.getValue(LIT); ++ public static boolean isLit(IBlockData state) { ++ return state.hasProperty(AbstractCandleBlock.LIT) && (state.is(BlockTags.CANDLES) || state.is(BlockTags.CANDLE_CAKES)) && (Boolean) state.getValue(AbstractCandleBlock.LIT); + } + + @Override +- public void onProjectileHit(Level level, BlockState state, BlockHitResult hit, Projectile projectile) { ++ public void onProjectileHit(Level level, IBlockData state, BlockHitResult hit, Projectile projectile) { + if (!level.isClientSide && projectile.isOnFire() && this.canBeLit(state)) { ++ // CraftBukkit start ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, hit.getBlockPos(), projectile).isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + setLit(level, state, hit.getBlockPos(), true); + } ++ + } + +- protected boolean canBeLit(BlockState state) { +- return !state.getValue(LIT); ++ protected boolean canBeLit(IBlockData state) { ++ return !(Boolean) state.getValue(AbstractCandleBlock.LIT); + } + + @Override +- public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { +- if (state.getValue(LIT)) { +- this.getParticleOffsets(state) +- .forEach(offset -> addParticlesAndSound(level, offset.add((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()), random)); ++ public void animateTick(IBlockData state, Level level, BlockPos pos, RandomSource random) { ++ if ((Boolean) state.getValue(AbstractCandleBlock.LIT)) { ++ this.getParticleOffsets(state).forEach((vec3d) -> { ++ addParticlesAndSound(level, vec3d.add((double) pos.getX(), (double) pos.getY(), (double) pos.getZ()), random); ++ }); + } + } + + private static void addParticlesAndSound(Level level, Vec3 offset, RandomSource random) { +- float randomFloat = random.nextFloat(); +- if (randomFloat < 0.3F) { +- level.addParticle(ParticleTypes.SMOKE, offset.x, offset.y, offset.z, 0.0, 0.0, 0.0); +- if (randomFloat < 0.17F) { +- level.playLocalSound( +- offset.x + 0.5, +- offset.y + 0.5, +- offset.z + 0.5, +- SoundEvents.CANDLE_AMBIENT, +- SoundSource.BLOCKS, +- 1.0F + random.nextFloat(), +- random.nextFloat() * 0.7F + 0.3F, +- false +- ); ++ float f = random.nextFloat(); ++ ++ if (f < 0.3F) { ++ level.addParticle(ParticleTypes.SMOKE, offset.x, offset.y, offset.z, 0.0D, 0.0D, 0.0D); ++ if (f < 0.17F) { ++ level.playLocalSound(offset.x + 0.5D, offset.y + 0.5D, offset.z + 0.5D, SoundEvents.CANDLE_AMBIENT, SoundSource.BLOCKS, 1.0F + random.nextFloat(), random.nextFloat() * 0.7F + 0.3F, false); + } + } + +- level.addParticle(ParticleTypes.SMALL_FLAME, offset.x, offset.y, offset.z, 0.0, 0.0, 0.0); ++ level.addParticle(ParticleTypes.SMALL_FLAME, offset.x, offset.y, offset.z, 0.0D, 0.0D, 0.0D); + } + +- public static void extinguish(@Nullable Player player, BlockState state, LevelAccessor level, BlockPos pos) { ++ public static void extinguish(@Nullable Player player, IBlockData state, LevelAccessor level, BlockPos pos) { + setLit(level, state, pos, false); + if (state.getBlock() instanceof AbstractCandleBlock) { +- ((AbstractCandleBlock)state.getBlock()) +- .getParticleOffsets(state) +- .forEach( +- offset -> level.addParticle( +- ParticleTypes.SMOKE, +- (double)pos.getX() + offset.x(), +- (double)pos.getY() + offset.y(), +- (double)pos.getZ() + offset.z(), +- 0.0, +- 0.1F, +- 0.0 +- ) +- ); ++ ((AbstractCandleBlock) state.getBlock()).getParticleOffsets(state).forEach((vec3d) -> { ++ level.addParticle(ParticleTypes.SMOKE, (double) pos.getX() + vec3d.x(), (double) pos.getY() + vec3d.y(), (double) pos.getZ() + vec3d.z(), 0.0D, 0.10000000149011612D, 0.0D); ++ }); + } + +- level.playSound(null, pos, SoundEvents.CANDLE_EXTINGUISH, SoundSource.BLOCKS, 1.0F, 1.0F); +- level.gameEvent(player, GameEvent.BLOCK_CHANGE, pos); ++ level.playSound((Player) null, pos, SoundEvents.CANDLE_EXTINGUISH, SoundSource.BLOCKS, 1.0F, 1.0F); ++ level.gameEvent((Entity) player, GameEvent.BLOCK_CHANGE, pos); + } + +- private static void setLit(LevelAccessor level, BlockState state, BlockPos pos, boolean lit) { +- level.setBlock(pos, state.setValue(LIT, Boolean.valueOf(lit)), 11); ++ private static void setLit(LevelAccessor level, IBlockData state, BlockPos pos, boolean lit) { ++ level.setBlock(pos, (IBlockData) state.setValue(AbstractCandleBlock.LIT, lit), 11); + } + + @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(LIT)) { +- extinguish(null, 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() && (Boolean) iblockdata.getValue(AbstractCandleBlock.LIT)) { ++ extinguish((Player) null, iblockdata, world, blockposition); + } + +- super.onExplosionHit(blockState, level, blockPos, explosion, biConsumer); ++ super.onExplosionHit(iblockdata, world, blockposition, explosion, biconsumer); + } + } |