diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/ChangeOverTimeBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/ChangeOverTimeBlock.java.patch | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/ChangeOverTimeBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/ChangeOverTimeBlock.java.patch new file mode 100644 index 0000000000..c304f14ee0 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/ChangeOverTimeBlock.java.patch @@ -0,0 +1,101 @@ +--- a/net/minecraft/world/level/block/ChangeOverTimeBlock.java ++++ b/net/minecraft/world/level/block/ChangeOverTimeBlock.java +@@ -1,57 +1,74 @@ + package net.minecraft.world.level.block; + ++import java.util.Iterator; + import java.util.Optional; + import net.minecraft.core.BlockPos; + import net.minecraft.server.level.ServerLevel; + import net.minecraft.util.RandomSource; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + + public interface ChangeOverTimeBlock<T extends Enum<T>> { ++ + int SCAN_DISTANCE = 4; + +- Optional<BlockState> getNext(BlockState state); ++ Optional<IBlockData> getNext(IBlockData state); + + float getChanceModifier(); + +- default void changeOverTime(BlockState blockState, ServerLevel serverLevel, BlockPos blockPos, RandomSource randomSource) { ++ default void changeOverTime(IBlockData iblockdata, ServerLevel worldserver, BlockPos blockposition, RandomSource randomsource) { + float f = 0.05688889F; +- if (randomSource.nextFloat() < 0.05688889F) { +- this.getNextState(blockState, serverLevel, blockPos, randomSource).ifPresent(blockState1 -> serverLevel.setBlockAndUpdate(blockPos, blockState1)); ++ ++ if (randomsource.nextFloat() < 0.05688889F) { ++ this.getNextState(iblockdata, worldserver, blockposition, randomsource).ifPresent((iblockdata1) -> { ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(worldserver, blockposition, iblockdata1); // CraftBukkit ++ }); + } ++ + } + + T getAge(); + +- default Optional<BlockState> getNextState(BlockState blockState, ServerLevel serverLevel, BlockPos blockPos, RandomSource randomSource) { ++ default Optional<IBlockData> getNextState(IBlockData iblockdata, ServerLevel worldserver, BlockPos blockposition, RandomSource randomsource) { + int i = this.getAge().ordinal(); +- int i1 = 0; +- int i2 = 0; ++ int j = 0; ++ int k = 0; ++ Iterator iterator = BlockPos.withinManhattan(blockposition, 4, 4, 4).iterator(); + +- for (BlockPos blockPos1 : BlockPos.withinManhattan(blockPos, 4, 4, 4)) { +- int i3 = blockPos1.distManhattan(blockPos); +- if (i3 > 4) { ++ while (iterator.hasNext()) { ++ BlockPos blockposition1 = (BlockPos) iterator.next(); ++ int l = blockposition1.distManhattan(blockposition); ++ ++ if (l > 4) { + break; + } + +- if (!blockPos1.equals(blockPos) && serverLevel.getBlockState(blockPos1).getBlock() instanceof ChangeOverTimeBlock<?> changeOverTimeBlock) { +- Enum<?> age = changeOverTimeBlock.getAge(); +- if (this.getAge().getClass() == age.getClass()) { +- int i4 = age.ordinal(); +- if (i4 < i) { +- return Optional.empty(); +- } ++ if (!blockposition1.equals(blockposition)) { ++ Block block = worldserver.getBlockState(blockposition1).getBlock(); + +- if (i4 > i) { +- i2++; +- } else { +- i1++; ++ if (block instanceof ChangeOverTimeBlock) { ++ ChangeOverTimeBlock<?> changeovertimeblock = (ChangeOverTimeBlock) block; ++ Enum<?> oenum = changeovertimeblock.getAge(); ++ ++ if (this.getAge().getClass() == oenum.getClass()) { ++ int i1 = oenum.ordinal(); ++ ++ if (i1 < i) { ++ return Optional.empty(); ++ } ++ ++ if (i1 > i) { ++ ++k; ++ } else { ++ ++j; ++ } + } + } + } + } + +- float f = (float)(i2 + 1) / (float)(i2 + i1 + 1); ++ float f = (float) (k + 1) / (float) (k + j + 1); + float f1 = f * f * this.getChanceModifier(); +- return randomSource.nextFloat() < f1 ? this.getNext(blockState) : Optional.empty(); ++ ++ return randomsource.nextFloat() < f1 ? this.getNext(iblockdata) : Optional.empty(); + } + } |