diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/BeehiveBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/BeehiveBlock.java.patch | 442 |
1 files changed, 442 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/BeehiveBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/BeehiveBlock.java.patch new file mode 100644 index 0000000000..86061ad004 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/BeehiveBlock.java.patch @@ -0,0 +1,442 @@ +--- a/net/minecraft/world/level/block/BeehiveBlock.java ++++ b/net/minecraft/world/level/block/BeehiveBlock.java +@@ -1,6 +1,7 @@ + package net.minecraft.world.level.block; + + import com.mojang.serialization.MapCodec; ++import java.util.Iterator; + import java.util.List; + import javax.annotation.Nullable; + import net.minecraft.Util; +@@ -16,7 +17,7 @@ + import net.minecraft.tags.BlockTags; + import net.minecraft.util.Mth; + 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.animal.Bee; +@@ -42,7 +43,7 @@ + import net.minecraft.world.level.block.entity.BlockEntityTicker; + import net.minecraft.world.level.block.entity.BlockEntityType; + 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.DirectionProperty; +@@ -55,6 +56,7 @@ + import net.minecraft.world.phys.shapes.VoxelShape; + + public class BeehiveBlock extends BaseEntityBlock { ++ + public static final MapCodec<BeehiveBlock> CODEC = simpleCodec(BeehiveBlock::new); + public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; + public static final IntegerProperty HONEY_LEVEL = BlockStateProperties.LEVEL_HONEY; +@@ -63,54 +65,65 @@ + + @Override + public MapCodec<BeehiveBlock> codec() { +- return CODEC; ++ return BeehiveBlock.CODEC; + } + + public BeehiveBlock(BlockBehaviour.Properties properties) { + super(properties); +- this.registerDefaultState(this.stateDefinition.any().setValue(HONEY_LEVEL, Integer.valueOf(0)).setValue(FACING, Direction.NORTH)); ++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(BeehiveBlock.HONEY_LEVEL, 0)).setValue(BeehiveBlock.FACING, Direction.NORTH)); + } + + @Override +- public boolean hasAnalogOutputSignal(BlockState state) { ++ public boolean hasAnalogOutputSignal(IBlockData state) { + return true; + } + + @Override +- public int getAnalogOutputSignal(BlockState blockState, Level level, BlockPos pos) { +- return blockState.getValue(HONEY_LEVEL); ++ public int getAnalogOutputSignal(IBlockData blockState, Level level, BlockPos pos) { ++ return (Integer) blockState.getValue(BeehiveBlock.HONEY_LEVEL); + } + + @Override +- public void playerDestroy(Level level, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity te, ItemStack stack) { ++ public void playerDestroy(Level level, Player player, BlockPos pos, IBlockData state, @Nullable BlockEntity te, ItemStack stack) { + super.playerDestroy(level, player, pos, state, te, stack); +- if (!level.isClientSide && te instanceof BeehiveBlockEntity beehiveBlockEntity) { ++ if (!level.isClientSide && te instanceof BeehiveBlockEntity) { ++ BeehiveBlockEntity tileentitybeehive = (BeehiveBlockEntity) te; ++ + if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) == 0) { +- beehiveBlockEntity.emptyAllLivingFromHive(player, state, BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY); ++ tileentitybeehive.emptyAllLivingFromHive(player, state, BeehiveBlockEntity.ReleaseStatus.EMERGENCY); + level.updateNeighbourForOutputSignal(pos, this); + this.angerNearbyBees(level, pos); + } + +- CriteriaTriggers.BEE_NEST_DESTROYED.trigger((ServerPlayer)player, state, stack, beehiveBlockEntity.getOccupantCount()); ++ CriteriaTriggers.BEE_NEST_DESTROYED.trigger((ServerPlayer) player, state, stack, tileentitybeehive.getOccupantCount()); + } ++ + } + + private void angerNearbyBees(Level level, BlockPos pos) { +- AABB aABB = new AABB(pos).inflate(8.0, 6.0, 8.0); +- List<Bee> entitiesOfClass = level.getEntitiesOfClass(Bee.class, aABB); +- if (!entitiesOfClass.isEmpty()) { +- List<Player> entitiesOfClass1 = level.getEntitiesOfClass(Player.class, aABB); +- if (entitiesOfClass1.isEmpty()) { ++ AABB axisalignedbb = (new AABB(pos)).inflate(8.0D, 6.0D, 8.0D); ++ List<Bee> list = level.getEntitiesOfClass(Bee.class, axisalignedbb); ++ ++ if (!list.isEmpty()) { ++ List<Player> list1 = level.getEntitiesOfClass(Player.class, axisalignedbb); ++ ++ if (list1.isEmpty()) { + return; + } + +- for (Bee bee : entitiesOfClass) { +- if (bee.getTarget() == null) { +- Player player = Util.getRandom(entitiesOfClass1, level.random); +- bee.setTarget(player); ++ Iterator iterator = list.iterator(); ++ ++ while (iterator.hasNext()) { ++ Bee entitybee = (Bee) iterator.next(); ++ ++ if (entitybee.getTarget() == null) { ++ Player entityhuman = (Player) Util.getRandom(list1, level.random); ++ ++ entitybee.setTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit + } + } + } ++ + } + + public static void dropHoneycomb(Level level, BlockPos pos) { +@@ -118,29 +131,33 @@ + } + + @Override +- public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { +- ItemStack itemInHand = player.getItemInHand(hand); +- int i = state.getValue(HONEY_LEVEL); ++ public InteractionResult use(IBlockData state, Level level, BlockPos pos, Player player, EnumHand hand, BlockHitResult hit) { ++ ItemStack itemstack = player.getItemInHand(hand); ++ int i = (Integer) state.getValue(BeehiveBlock.HONEY_LEVEL); + boolean flag = false; ++ + if (i >= 5) { +- Item item = itemInHand.getItem(); +- if (itemInHand.is(Items.SHEARS)) { ++ Item item = itemstack.getItem(); ++ ++ if (itemstack.is(Items.SHEARS)) { + level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BEEHIVE_SHEAR, SoundSource.BLOCKS, 1.0F, 1.0F); + dropHoneycomb(level, pos); +- itemInHand.hurtAndBreak(1, player, user -> user.broadcastBreakEvent(hand)); ++ itemstack.hurtAndBreak(1, player, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(hand); ++ }); + flag = true; +- level.gameEvent(player, GameEvent.SHEAR, pos); +- } else if (itemInHand.is(Items.GLASS_BOTTLE)) { +- itemInHand.shrink(1); ++ level.gameEvent((Entity) player, GameEvent.SHEAR, pos); ++ } else if (itemstack.is(Items.GLASS_BOTTLE)) { ++ itemstack.shrink(1); + level.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BOTTLE_FILL, SoundSource.BLOCKS, 1.0F, 1.0F); +- if (itemInHand.isEmpty()) { ++ if (itemstack.isEmpty()) { + player.setItemInHand(hand, new ItemStack(Items.HONEY_BOTTLE)); + } else if (!player.getInventory().add(new ItemStack(Items.HONEY_BOTTLE))) { + player.drop(new ItemStack(Items.HONEY_BOTTLE), false); + } + + flag = true; +- level.gameEvent(player, GameEvent.FLUID_PICKUP, pos); ++ level.gameEvent((Entity) player, GameEvent.FLUID_PICKUP, pos); + } + + if (!level.isClientSide() && flag) { +@@ -154,7 +171,7 @@ + this.angerNearbyBees(level, pos); + } + +- this.releaseBeesAndResetHoneyLevel(level, state, pos, player, BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY); ++ this.releaseBeesAndResetHoneyLevel(level, state, pos, player, BeehiveBlockEntity.ReleaseStatus.EMERGENCY); + } else { + this.resetHoneyLevel(level, state, pos); + } +@@ -166,141 +183,148 @@ + } + + private boolean hiveContainsBees(Level level, BlockPos pos) { +- return level.getBlockEntity(pos) instanceof BeehiveBlockEntity beehiveBlockEntity && !beehiveBlockEntity.isEmpty(); ++ BlockEntity tileentity = level.getBlockEntity(pos); ++ ++ if (tileentity instanceof BeehiveBlockEntity) { ++ BeehiveBlockEntity tileentitybeehive = (BeehiveBlockEntity) tileentity; ++ ++ return !tileentitybeehive.isEmpty(); ++ } else { ++ return false; ++ } + } + +- public void releaseBeesAndResetHoneyLevel( +- Level level, BlockState state, BlockPos pos, @Nullable Player player, BeehiveBlockEntity.BeeReleaseStatus beeReleaseStatus +- ) { ++ public void releaseBeesAndResetHoneyLevel(Level level, IBlockData state, BlockPos pos, @Nullable Player player, BeehiveBlockEntity.ReleaseStatus beeReleaseStatus) { + this.resetHoneyLevel(level, state, pos); +- if (level.getBlockEntity(pos) instanceof BeehiveBlockEntity beehiveBlockEntity) { +- beehiveBlockEntity.emptyAllLivingFromHive(player, state, beeReleaseStatus); ++ BlockEntity tileentity = level.getBlockEntity(pos); ++ ++ if (tileentity instanceof BeehiveBlockEntity) { ++ BeehiveBlockEntity tileentitybeehive = (BeehiveBlockEntity) tileentity; ++ ++ tileentitybeehive.emptyAllLivingFromHive(player, state, beeReleaseStatus); + } ++ + } + +- public void resetHoneyLevel(Level level, BlockState state, BlockPos pos) { +- level.setBlock(pos, state.setValue(HONEY_LEVEL, Integer.valueOf(0)), 3); ++ public void resetHoneyLevel(Level level, IBlockData state, BlockPos pos) { ++ level.setBlock(pos, (IBlockData) state.setValue(BeehiveBlock.HONEY_LEVEL, 0), 3); + } + + @Override +- public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { +- if (state.getValue(HONEY_LEVEL) >= 5) { +- for (int i = 0; i < random.nextInt(1) + 1; i++) { ++ public void animateTick(IBlockData state, Level level, BlockPos pos, RandomSource random) { ++ if ((Integer) state.getValue(BeehiveBlock.HONEY_LEVEL) >= 5) { ++ for (int i = 0; i < random.nextInt(1) + 1; ++i) { + this.trySpawnDripParticles(level, pos, state); + } + } ++ + } + +- private void trySpawnDripParticles(Level level, BlockPos pos, BlockState state) { +- if (state.getFluidState().isEmpty() && !(level.random.nextFloat() < 0.3F)) { +- VoxelShape collisionShape = state.getCollisionShape(level, pos); +- double d = collisionShape.max(Direction.Axis.Y); +- if (d >= 1.0 && !state.is(BlockTags.IMPERMEABLE)) { +- double d1 = collisionShape.min(Direction.Axis.Y); +- if (d1 > 0.0) { +- this.spawnParticle(level, pos, collisionShape, (double)pos.getY() + d1 - 0.05); ++ private void trySpawnDripParticles(Level level, BlockPos pos, IBlockData state) { ++ if (state.getFluidState().isEmpty() && level.random.nextFloat() >= 0.3F) { ++ VoxelShape voxelshape = state.getCollisionShape(level, pos); ++ double d0 = voxelshape.max(Direction.Axis.Y); ++ ++ if (d0 >= 1.0D && !state.is(BlockTags.IMPERMEABLE)) { ++ double d1 = voxelshape.min(Direction.Axis.Y); ++ ++ if (d1 > 0.0D) { ++ this.spawnParticle(level, pos, voxelshape, (double) pos.getY() + d1 - 0.05D); + } else { +- BlockPos blockPos = pos.below(); +- BlockState blockState = level.getBlockState(blockPos); +- VoxelShape collisionShape1 = blockState.getCollisionShape(level, blockPos); +- double d2 = collisionShape1.max(Direction.Axis.Y); +- if ((d2 < 1.0 || !blockState.isCollisionShapeFullBlock(level, blockPos)) && blockState.getFluidState().isEmpty()) { +- this.spawnParticle(level, pos, collisionShape, (double)pos.getY() - 0.05); ++ BlockPos blockposition1 = pos.below(); ++ IBlockData iblockdata1 = level.getBlockState(blockposition1); ++ VoxelShape voxelshape1 = iblockdata1.getCollisionShape(level, blockposition1); ++ double d2 = voxelshape1.max(Direction.Axis.Y); ++ ++ if ((d2 < 1.0D || !iblockdata1.isCollisionShapeFullBlock(level, blockposition1)) && iblockdata1.getFluidState().isEmpty()) { ++ this.spawnParticle(level, pos, voxelshape, (double) pos.getY() - 0.05D); + } + } + } ++ + } + } + + private void spawnParticle(Level level, BlockPos pos, VoxelShape shape, double y) { +- this.spawnFluidParticle( +- level, +- (double)pos.getX() + shape.min(Direction.Axis.X), +- (double)pos.getX() + shape.max(Direction.Axis.X), +- (double)pos.getZ() + shape.min(Direction.Axis.Z), +- (double)pos.getZ() + shape.max(Direction.Axis.Z), +- y +- ); ++ this.spawnFluidParticle(level, (double) pos.getX() + shape.min(Direction.Axis.X), (double) pos.getX() + shape.max(Direction.Axis.X), (double) pos.getZ() + shape.min(Direction.Axis.Z), (double) pos.getZ() + shape.max(Direction.Axis.Z), y); + } + +- private void spawnFluidParticle(Level particleData, double x1, double x2, double z1, double z2, double y) { +- particleData.addParticle( +- ParticleTypes.DRIPPING_HONEY, +- Mth.lerp(particleData.random.nextDouble(), x1, x2), +- y, +- Mth.lerp(particleData.random.nextDouble(), z1, z2), +- 0.0, +- 0.0, +- 0.0 +- ); ++ private void spawnFluidParticle(Level particleData, double x1, double d1, double x2, double d3, double z1) { ++ particleData.addParticle(ParticleTypes.DRIPPING_HONEY, Mth.lerp(particleData.random.nextDouble(), x1, d1), z1, Mth.lerp(particleData.random.nextDouble(), x2, d3), 0.0D, 0.0D, 0.0D); + } + + @Override +- public BlockState getStateForPlacement(BlockPlaceContext context) { +- return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()); ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ return (IBlockData) this.defaultBlockState().setValue(BeehiveBlock.FACING, context.getHorizontalDirection().getOpposite()); + } + + @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { +- builder.add(HONEY_LEVEL, FACING); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(BeehiveBlock.HONEY_LEVEL, BeehiveBlock.FACING); + } + + @Override +- public RenderShape getRenderShape(BlockState state) { +- return RenderShape.MODEL; ++ public EnumRenderType getRenderShape(IBlockData state) { ++ return EnumRenderType.MODEL; + } + + @Nullable + @Override +- public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { ++ public BlockEntity newBlockEntity(BlockPos pos, IBlockData state) { + return new BeehiveBlockEntity(pos, state); + } + + @Nullable + @Override +- public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) { ++ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, IBlockData state, BlockEntityType<T> blockEntityType) { + return level.isClientSide ? null : createTickerHelper(blockEntityType, BlockEntityType.BEEHIVE, BeehiveBlockEntity::serverTick); + } + + @Override +- public BlockState playerWillDestroy(Level level, BlockPos blockPos, BlockState blockState, Player player) { +- if (!level.isClientSide +- && player.isCreative() +- && level.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) +- && level.getBlockEntity(blockPos) instanceof BeehiveBlockEntity beehiveBlockEntity) { +- ItemStack itemStack = new ItemStack(this); +- int i = blockState.getValue(HONEY_LEVEL); +- boolean flag = !beehiveBlockEntity.isEmpty(); +- if (flag || i > 0) { +- if (flag) { +- CompoundTag compoundTag = new CompoundTag(); +- compoundTag.put("Bees", beehiveBlockEntity.writeBees()); +- BlockItem.setBlockEntityData(itemStack, BlockEntityType.BEEHIVE, compoundTag); +- } ++ public IBlockData playerWillDestroy(Level world, BlockPos blockposition, IBlockData iblockdata, Player entityhuman) { ++ if (!world.isClientSide && entityhuman.isCreative() && world.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { ++ BlockEntity tileentity = world.getBlockEntity(blockposition); + +- CompoundTag compoundTag = new CompoundTag(); +- compoundTag.putInt("honey_level", i); +- itemStack.addTagElement("BlockStateTag", compoundTag); +- ItemEntity itemEntity = new ItemEntity(level, (double)blockPos.getX(), (double)blockPos.getY(), (double)blockPos.getZ(), itemStack); +- itemEntity.setDefaultPickUpDelay(); +- level.addFreshEntity(itemEntity); ++ if (tileentity instanceof BeehiveBlockEntity) { ++ BeehiveBlockEntity tileentitybeehive = (BeehiveBlockEntity) tileentity; ++ ItemStack itemstack = new ItemStack(this); ++ int i = (Integer) iblockdata.getValue(BeehiveBlock.HONEY_LEVEL); ++ boolean flag = !tileentitybeehive.isEmpty(); ++ ++ if (flag || i > 0) { ++ CompoundTag nbttagcompound; ++ ++ if (flag) { ++ nbttagcompound = new CompoundTag(); ++ nbttagcompound.put("Bees", tileentitybeehive.writeBees()); ++ BlockItem.setBlockEntityData(itemstack, BlockEntityType.BEEHIVE, nbttagcompound); ++ } ++ ++ nbttagcompound = new CompoundTag(); ++ nbttagcompound.putInt("honey_level", i); ++ itemstack.addTagElement("BlockStateTag", nbttagcompound); ++ ItemEntity entityitem = new ItemEntity(world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack); ++ ++ entityitem.setDefaultPickUpDelay(); ++ world.addFreshEntity(entityitem); ++ } + } + } + +- return super.playerWillDestroy(level, blockPos, blockState, player); ++ return super.playerWillDestroy(world, blockposition, iblockdata, entityhuman); + } + + @Override +- public List<ItemStack> getDrops(BlockState state, LootParams.Builder params) { +- Entity entity = params.getOptionalParameter(LootContextParams.THIS_ENTITY); +- if (entity instanceof PrimedTnt +- || entity instanceof Creeper +- || entity instanceof WitherSkull +- || entity instanceof WitherBoss +- || entity instanceof MinecartTNT) { +- BlockEntity blockEntity = params.getOptionalParameter(LootContextParams.BLOCK_ENTITY); +- if (blockEntity instanceof BeehiveBlockEntity beehiveBlockEntity) { +- beehiveBlockEntity.emptyAllLivingFromHive(null, state, BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY); ++ public List<ItemStack> getDrops(IBlockData state, LootParams.Builder params) { ++ Entity entity = (Entity) params.getOptionalParameter(LootContextParams.THIS_ENTITY); ++ ++ if (entity instanceof PrimedTnt || entity instanceof Creeper || entity instanceof WitherSkull || entity instanceof WitherBoss || entity instanceof MinecartTNT) { ++ BlockEntity tileentity = (BlockEntity) params.getOptionalParameter(LootContextParams.BLOCK_ENTITY); ++ ++ if (tileentity instanceof BeehiveBlockEntity) { ++ BeehiveBlockEntity tileentitybeehive = (BeehiveBlockEntity) tileentity; ++ ++ tileentitybeehive.emptyAllLivingFromHive((Player) null, state, BeehiveBlockEntity.ReleaseStatus.EMERGENCY); + } + } + +@@ -308,23 +332,27 @@ + } + + @Override +- public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { +- if (level.getBlockState(facingPos).getBlock() instanceof FireBlock && level.getBlockEntity(currentPos) instanceof BeehiveBlockEntity beehiveBlockEntity +- ) +- { +- beehiveBlockEntity.emptyAllLivingFromHive(null, state, BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY); ++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { ++ if (level.getBlockState(facingPos).getBlock() instanceof FireBlock) { ++ BlockEntity tileentity = level.getBlockEntity(currentPos); ++ ++ if (tileentity instanceof BeehiveBlockEntity) { ++ BeehiveBlockEntity tileentitybeehive = (BeehiveBlockEntity) tileentity; ++ ++ tileentitybeehive.emptyAllLivingFromHive((Player) null, state, BeehiveBlockEntity.ReleaseStatus.EMERGENCY); ++ } + } + + return super.updateShape(state, facing, facingState, level, currentPos, facingPos); + } + + @Override +- public BlockState rotate(BlockState state, Rotation rotation) { +- return state.setValue(FACING, rotation.rotate(state.getValue(FACING))); ++ public IBlockData rotate(IBlockData state, Rotation rotation) { ++ return (IBlockData) state.setValue(BeehiveBlock.FACING, rotation.rotate((Direction) state.getValue(BeehiveBlock.FACING))); + } + + @Override +- public BlockState mirror(BlockState state, Mirror mirror) { +- return state.rotate(mirror.getRotation(state.getValue(FACING))); ++ public IBlockData mirror(IBlockData state, Mirror mirror) { ++ return state.rotate(mirror.getRotation((Direction) state.getValue(BeehiveBlock.FACING))); + } + } |