diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/InfestedBlock.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/block/InfestedBlock.java.patch | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/InfestedBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/InfestedBlock.java.patch new file mode 100644 index 0000000000..e55610e754 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/InfestedBlock.java.patch @@ -0,0 +1,117 @@ +--- a/net/minecraft/world/level/block/InfestedBlock.java ++++ b/net/minecraft/world/level/block/InfestedBlock.java +@@ -16,8 +16,9 @@ + import net.minecraft.world.item.enchantment.Enchantments; + import net.minecraft.world.level.GameRules; + 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.Property; ++import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit + + public class InfestedBlock extends Block { + +@@ -26,73 +27,71 @@ + }); + private final Block hostBlock; + private static final Map<Block, Block> BLOCK_BY_HOST_BLOCK = Maps.newIdentityHashMap(); +- private static final Map<BlockState, BlockState> HOST_TO_INFESTED_STATES = Maps.newIdentityHashMap(); +- private static final Map<BlockState, BlockState> INFESTED_TO_HOST_STATES = Maps.newIdentityHashMap(); ++ private static final Map<IBlockData, IBlockData> HOST_TO_INFESTED_STATES = Maps.newIdentityHashMap(); ++ private static final Map<IBlockData, IBlockData> INFESTED_TO_HOST_STATES = Maps.newIdentityHashMap(); + + @Override +- @Override + public MapCodec<? extends InfestedBlock> codec() { + return InfestedBlock.CODEC; + } + +- public InfestedBlock(Block block, BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties.destroyTime(block.defaultDestroyTime() / 2.0F).explosionResistance(0.75F)); +- this.hostBlock = block; +- InfestedBlock.BLOCK_BY_HOST_BLOCK.put(block, this); ++ public InfestedBlock(Block hostBlock, BlockBehaviour.Properties properties) { ++ super(properties.destroyTime(hostBlock.defaultDestroyTime() / 2.0F).explosionResistance(0.75F)); ++ this.hostBlock = hostBlock; ++ InfestedBlock.BLOCK_BY_HOST_BLOCK.put(hostBlock, this); + } + + public Block getHostBlock() { + return this.hostBlock; + } + +- public static boolean isCompatibleHostBlock(BlockState blockstate) { +- return InfestedBlock.BLOCK_BY_HOST_BLOCK.containsKey(blockstate.getBlock()); ++ public static boolean isCompatibleHostBlock(IBlockData state) { ++ return InfestedBlock.BLOCK_BY_HOST_BLOCK.containsKey(state.getBlock()); + } + +- private void spawnInfestation(ServerLevel serverlevel, BlockPos blockpos) { +- Silverfish silverfish = (Silverfish) EntityType.SILVERFISH.create(serverlevel); ++ private void spawnInfestation(ServerLevel level, BlockPos pos) { ++ Silverfish entitysilverfish = (Silverfish) EntityType.SILVERFISH.create(level); + +- if (silverfish != null) { +- silverfish.moveTo((double) blockpos.getX() + 0.5D, (double) blockpos.getY(), (double) blockpos.getZ() + 0.5D, 0.0F, 0.0F); +- serverlevel.addFreshEntity(silverfish); +- silverfish.spawnAnim(); ++ if (entitysilverfish != null) { ++ entitysilverfish.moveTo((double) pos.getX() + 0.5D, (double) pos.getY(), (double) pos.getZ() + 0.5D, 0.0F, 0.0F); ++ level.addFreshEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason ++ entitysilverfish.spawnAnim(); + } + + } + + @Override +- @Override +- public void spawnAfterBreak(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, ItemStack itemstack, boolean flag) { +- super.spawnAfterBreak(blockstate, serverlevel, blockpos, itemstack, flag); +- if (serverlevel.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { +- this.spawnInfestation(serverlevel, blockpos); ++ public void spawnAfterBreak(IBlockData state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { ++ super.spawnAfterBreak(state, level, pos, stack, dropExperience); ++ if (level.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS) && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) == 0) { ++ this.spawnInfestation(level, pos); + } + + } + +- public static BlockState infestedStateByHost(BlockState blockstate) { +- return getNewStateWithProperties(InfestedBlock.HOST_TO_INFESTED_STATES, blockstate, () -> { +- return ((Block) InfestedBlock.BLOCK_BY_HOST_BLOCK.get(blockstate.getBlock())).defaultBlockState(); ++ public static IBlockData infestedStateByHost(IBlockData host) { ++ return getNewStateWithProperties(InfestedBlock.HOST_TO_INFESTED_STATES, host, () -> { ++ return ((Block) InfestedBlock.BLOCK_BY_HOST_BLOCK.get(host.getBlock())).defaultBlockState(); + }); + } + +- public BlockState hostStateByInfested(BlockState blockstate) { +- return getNewStateWithProperties(InfestedBlock.INFESTED_TO_HOST_STATES, blockstate, () -> { ++ public IBlockData hostStateByInfested(IBlockData infested) { ++ return getNewStateWithProperties(InfestedBlock.INFESTED_TO_HOST_STATES, infested, () -> { + return this.getHostBlock().defaultBlockState(); + }); + } + +- private static BlockState getNewStateWithProperties(Map<BlockState, BlockState> map, BlockState blockstate, Supplier<BlockState> supplier) { +- return (BlockState) map.computeIfAbsent(blockstate, (blockstate1) -> { +- BlockState blockstate2 = (BlockState) supplier.get(); ++ private static IBlockData getNewStateWithProperties(Map<IBlockData, IBlockData> stateMap, IBlockData state, Supplier<IBlockData> supplier) { ++ return (IBlockData) stateMap.computeIfAbsent(state, (iblockdata1) -> { ++ IBlockData iblockdata2 = (IBlockData) supplier.get(); + +- Property property; ++ Property iblockstate; + +- for (Iterator iterator = blockstate1.getProperties().iterator(); iterator.hasNext(); blockstate2 = blockstate2.hasProperty(property) ? (BlockState) blockstate2.setValue(property, blockstate1.getValue(property)) : blockstate2) { +- property = (Property) iterator.next(); ++ for (Iterator iterator = iblockdata1.getProperties().iterator(); iterator.hasNext(); iblockdata2 = iblockdata2.hasProperty(iblockstate) ? (IBlockData) iblockdata2.setValue(iblockstate, iblockdata1.getValue(iblockstate)) : iblockdata2) { ++ iblockstate = (Property) iterator.next(); + } + +- return blockstate2; ++ return iblockdata2; + }); + } + } |