diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/MushroomBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/MushroomBlock.java.patch | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/MushroomBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/MushroomBlock.java.patch new file mode 100644 index 0000000000..8f59742221 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/MushroomBlock.java.patch @@ -0,0 +1,168 @@ +--- a/net/minecraft/world/level/block/MushroomBlock.java ++++ b/net/minecraft/world/level/block/MushroomBlock.java +@@ -2,7 +2,7 @@ + + import com.mojang.serialization.MapCodec; + import com.mojang.serialization.codecs.RecordCodecBuilder; +-import com.mojang.serialization.codecs.RecordCodecBuilder.Instance; ++import java.util.Iterator; + import java.util.Optional; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Holder; +@@ -15,88 +15,97 @@ + import net.minecraft.world.level.Level; + import net.minecraft.world.level.LevelReader; + 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.levelgen.feature.ConfiguredFeature; + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.VoxelShape; ++// CraftBukkit start ++import org.bukkit.TreeType; ++// CraftBukkit end + + public class MushroomBlock extends BushBlock implements BonemealableBlock { +- public static final MapCodec<MushroomBlock> CODEC = RecordCodecBuilder.mapCodec( +- instance -> instance.group( +- ResourceKey.codec(Registries.CONFIGURED_FEATURE).fieldOf("feature").forGetter(mushroomBlock -> mushroomBlock.feature), propertiesCodec() +- ) +- .apply(instance, MushroomBlock::new) +- ); ++ ++ public static final MapCodec<MushroomBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> { ++ return instance.group(ResourceKey.codec(Registries.CONFIGURED_FEATURE).fieldOf("feature").forGetter((blockmushroom) -> { ++ return blockmushroom.feature; ++ }), propertiesCodec()).apply(instance, MushroomBlock::new); ++ }); + protected static final float AABB_OFFSET = 3.0F; +- protected static final VoxelShape SHAPE = Block.box(5.0, 0.0, 5.0, 11.0, 6.0, 11.0); ++ protected static final VoxelShape SHAPE = Block.box(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D); + private final ResourceKey<ConfiguredFeature<?, ?>> feature; + + @Override + public MapCodec<MushroomBlock> codec() { +- return CODEC; ++ return MushroomBlock.CODEC; + } + +- public MushroomBlock(ResourceKey<ConfiguredFeature<?, ?>> resourceKey, BlockBehaviour.Properties properties) { +- super(properties); +- this.feature = resourceKey; ++ public MushroomBlock(ResourceKey<ConfiguredFeature<?, ?>> resourcekey, BlockBehaviour.Properties blockbase_info) { ++ super(blockbase_info); ++ this.feature = resourcekey; + } + + @Override +- public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { +- return SHAPE; ++ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) { ++ return MushroomBlock.SHAPE; + } + + @Override +- public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { ++ public void randomTick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { + if (random.nextInt(25) == 0) { + int i = 5; +- int i1 = 4; ++ boolean flag = true; ++ Iterator iterator = BlockPos.betweenClosed(pos.offset(-4, -1, -4), pos.offset(4, 1, 4)).iterator(); + +- for (BlockPos blockPos : BlockPos.betweenClosed(pos.offset(-4, -1, -4), pos.offset(4, 1, 4))) { +- if (level.getBlockState(blockPos).is(this)) { +- if (--i <= 0) { ++ while (iterator.hasNext()) { ++ BlockPos blockposition1 = (BlockPos) iterator.next(); ++ ++ if (level.getBlockState(blockposition1).is((Block) this)) { ++ --i; ++ if (i <= 0) { + return; + } + } + } + +- BlockPos blockPos1 = pos.offset(random.nextInt(3) - 1, random.nextInt(2) - random.nextInt(2), random.nextInt(3) - 1); ++ BlockPos blockposition2 = pos.offset(random.nextInt(3) - 1, random.nextInt(2) - random.nextInt(2), random.nextInt(3) - 1); + +- for (int i2 = 0; i2 < 4; i2++) { +- if (level.isEmptyBlock(blockPos1) && state.canSurvive(level, blockPos1)) { +- pos = blockPos1; ++ for (int j = 0; j < 4; ++j) { ++ if (level.isEmptyBlock(blockposition2) && state.canSurvive(level, blockposition2)) { ++ pos = blockposition2; + } + +- blockPos1 = pos.offset(random.nextInt(3) - 1, random.nextInt(2) - random.nextInt(2), random.nextInt(3) - 1); ++ blockposition2 = pos.offset(random.nextInt(3) - 1, random.nextInt(2) - random.nextInt(2), random.nextInt(3) - 1); + } + +- if (level.isEmptyBlock(blockPos1) && state.canSurvive(level, blockPos1)) { +- level.setBlock(blockPos1, state, 2); ++ if (level.isEmptyBlock(blockposition2) && state.canSurvive(level, blockposition2)) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockposition2, state, 2); // CraftBukkit + } + } ++ + } + + @Override +- protected boolean mayPlaceOn(BlockState state, BlockGetter level, BlockPos pos) { ++ protected boolean mayPlaceOn(IBlockData state, BlockGetter level, BlockPos pos) { + return state.isSolidRender(level, pos); + } + + @Override +- public boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) { +- BlockPos blockPos = pos.below(); +- BlockState blockState = level.getBlockState(blockPos); +- return blockState.is(BlockTags.MUSHROOM_GROW_BLOCK) || level.getRawBrightness(pos, 0) < 13 && this.mayPlaceOn(blockState, level, blockPos); ++ public boolean canSurvive(IBlockData state, LevelReader level, BlockPos pos) { ++ BlockPos blockposition1 = pos.below(); ++ IBlockData iblockdata1 = level.getBlockState(blockposition1); ++ ++ return iblockdata1.is(BlockTags.MUSHROOM_GROW_BLOCK) ? true : level.getRawBrightness(pos, 0) < 13 && this.mayPlaceOn(iblockdata1, level, blockposition1); + } + +- public boolean growMushroom(ServerLevel level, BlockPos pos, BlockState state, RandomSource random) { +- Optional<? extends Holder<ConfiguredFeature<?, ?>>> holder = level.registryAccess() +- .registryOrThrow(Registries.CONFIGURED_FEATURE) +- .getHolder(this.feature); +- if (holder.isEmpty()) { ++ public boolean growMushroom(ServerLevel level, BlockPos pos, IBlockData state, RandomSource random) { ++ Optional<? extends Holder<ConfiguredFeature<?, ?>>> optional = level.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE).getHolder(this.feature); ++ ++ if (optional.isEmpty()) { + return false; + } else { + level.removeBlock(pos, false); +- if (holder.get().value().place(level, level.getChunkSource().getGenerator(), random, pos)) { ++ SaplingBlock.treeType = (this == Blocks.BROWN_MUSHROOM) ? TreeType.BROWN_MUSHROOM : TreeType.BROWN_MUSHROOM; // CraftBukkit ++ if (((ConfiguredFeature) ((Holder) optional.get()).value()).place(level, level.getChunkSource().getGenerator(), random, pos)) { + return true; + } else { + level.setBlock(pos, state, 3); +@@ -106,17 +115,17 @@ + } + + @Override +- public boolean isValidBonemealTarget(LevelReader levelReader, BlockPos blockPos, BlockState blockState) { ++ public boolean isValidBonemealTarget(LevelReader iworldreader, BlockPos blockposition, IBlockData iblockdata) { + return true; + } + + @Override +- public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, BlockState state) { +- return (double)random.nextFloat() < 0.4; ++ public boolean isBonemealSuccess(Level level, RandomSource random, BlockPos pos, IBlockData state) { ++ return (double) random.nextFloat() < 0.4D; + } + + @Override +- public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) { ++ public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, IBlockData state) { + this.growMushroom(level, pos, state, random); + } + } |