diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch | 222 |
1 files changed, 222 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch new file mode 100644 index 0000000000..e1681937f0 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch @@ -0,0 +1,222 @@ +--- a/net/minecraft/world/level/block/CarvedPumpkinBlock.java ++++ b/net/minecraft/world/level/block/CarvedPumpkinBlock.java +@@ -1,6 +1,7 @@ + package net.minecraft.world.level.block; + + import com.mojang.serialization.MapCodec; ++import java.util.Iterator; + import java.util.function.Predicate; + import javax.annotation.Nullable; + import net.minecraft.advancements.CriteriaTriggers; +@@ -15,15 +16,19 @@ + 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.block.state.StateDefinition; + import net.minecraft.world.level.block.state.pattern.BlockInWorld; + import net.minecraft.world.level.block.state.pattern.BlockPattern; + import net.minecraft.world.level.block.state.pattern.BlockPatternBuilder; + import net.minecraft.world.level.block.state.predicate.BlockStatePredicate; + import net.minecraft.world.level.block.state.properties.DirectionProperty; ++// CraftBukkit start ++import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; ++// CraftBukkit end + + public class CarvedPumpkinBlock extends HorizontalDirectionalBlock { ++ + public static final MapCodec<CarvedPumpkinBlock> CODEC = simpleCodec(CarvedPumpkinBlock::new); + public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; + @Nullable +@@ -34,21 +39,22 @@ + private BlockPattern ironGolemBase; + @Nullable + private BlockPattern ironGolemFull; +- private static final Predicate<BlockState> PUMPKINS_PREDICATE = state -> state != null +- && (state.is(Blocks.CARVED_PUMPKIN) || state.is(Blocks.JACK_O_LANTERN)); ++ private static final Predicate<IBlockData> PUMPKINS_PREDICATE = (iblockdata) -> { ++ return iblockdata != null && (iblockdata.is(Blocks.CARVED_PUMPKIN) || iblockdata.is(Blocks.JACK_O_LANTERN)); ++ }; + + @Override + public MapCodec<? extends CarvedPumpkinBlock> codec() { +- return CODEC; ++ return CarvedPumpkinBlock.CODEC; + } + + protected CarvedPumpkinBlock(BlockBehaviour.Properties properties) { + super(properties); +- this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH)); ++ this.registerDefaultState((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(CarvedPumpkinBlock.FACING, Direction.NORTH)); + } + + @Override +- public void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) { ++ public void onPlace(IBlockData state, Level level, BlockPos pos, IBlockData oldState, boolean isMoving) { + if (!oldState.is(state.getBlock())) { + this.trySpawnGolem(level, pos); + } +@@ -59,71 +65,85 @@ + } + + private void trySpawnGolem(Level level, BlockPos pos) { +- BlockPattern.BlockPatternMatch blockPatternMatch = this.getOrCreateSnowGolemFull().find(level, pos); +- if (blockPatternMatch != null) { +- SnowGolem snowGolem = EntityType.SNOW_GOLEM.create(level); +- if (snowGolem != null) { +- spawnGolemInWorld(level, blockPatternMatch, snowGolem, blockPatternMatch.getBlock(0, 2, 0).getPos()); ++ BlockPattern.BlockPatternMatch shapedetector_shapedetectorcollection = this.getOrCreateSnowGolemFull().find(level, pos); ++ ++ if (shapedetector_shapedetectorcollection != null) { ++ SnowGolem entitysnowman = (SnowGolem) EntityType.SNOW_GOLEM.create(level); ++ ++ if (entitysnowman != null) { ++ spawnGolemInWorld(level, shapedetector_shapedetectorcollection, entitysnowman, shapedetector_shapedetectorcollection.getBlock(0, 2, 0).getPos()); + } + } else { +- BlockPattern.BlockPatternMatch blockPatternMatch1 = this.getOrCreateIronGolemFull().find(level, pos); +- if (blockPatternMatch1 != null) { +- IronGolem ironGolem = EntityType.IRON_GOLEM.create(level); +- if (ironGolem != null) { +- ironGolem.setPlayerCreated(true); +- spawnGolemInWorld(level, blockPatternMatch1, ironGolem, blockPatternMatch1.getBlock(1, 2, 0).getPos()); ++ BlockPattern.BlockPatternMatch shapedetector_shapedetectorcollection1 = this.getOrCreateIronGolemFull().find(level, pos); ++ ++ if (shapedetector_shapedetectorcollection1 != null) { ++ IronGolem entityirongolem = (IronGolem) EntityType.IRON_GOLEM.create(level); ++ ++ if (entityirongolem != null) { ++ entityirongolem.setPlayerCreated(true); ++ spawnGolemInWorld(level, shapedetector_shapedetectorcollection1, entityirongolem, shapedetector_shapedetectorcollection1.getBlock(1, 2, 0).getPos()); + } + } + } ++ + } + + private static void spawnGolemInWorld(Level level, BlockPattern.BlockPatternMatch patternMatch, Entity golem, BlockPos pos) { +- clearPatternBlocks(level, patternMatch); +- golem.moveTo((double)pos.getX() + 0.5, (double)pos.getY() + 0.05, (double)pos.getZ() + 0.5, 0.0F, 0.0F); +- level.addFreshEntity(golem); ++ // clearPatternBlocks(world, shapedetector_shapedetectorcollection); // CraftBukkit - moved down ++ golem.moveTo((double) pos.getX() + 0.5D, (double) pos.getY() + 0.05D, (double) pos.getZ() + 0.5D, 0.0F, 0.0F); ++ // CraftBukkit start ++ if (!level.addFreshEntity(golem, SpawnReason.BUILD_IRONGOLEM)) { ++ return; ++ } ++ clearPatternBlocks(level, patternMatch); // CraftBukkit - from above ++ // CraftBukkit end ++ Iterator iterator = level.getEntitiesOfClass(ServerPlayer.class, golem.getBoundingBox().inflate(5.0D)).iterator(); + +- for (ServerPlayer serverPlayer : level.getEntitiesOfClass(ServerPlayer.class, golem.getBoundingBox().inflate(5.0))) { +- CriteriaTriggers.SUMMONED_ENTITY.trigger(serverPlayer, golem); ++ while (iterator.hasNext()) { ++ ServerPlayer entityplayer = (ServerPlayer) iterator.next(); ++ ++ CriteriaTriggers.SUMMONED_ENTITY.trigger(entityplayer, golem); + } + + updatePatternBlocks(level, patternMatch); + } + + public static void clearPatternBlocks(Level level, BlockPattern.BlockPatternMatch patternMatch) { +- for (int i = 0; i < patternMatch.getWidth(); i++) { +- for (int i1 = 0; i1 < patternMatch.getHeight(); i1++) { +- BlockInWorld block = patternMatch.getBlock(i, i1, 0); +- level.setBlock(block.getPos(), Blocks.AIR.defaultBlockState(), 2); +- level.levelEvent(2001, block.getPos(), Block.getId(block.getState())); ++ for (int i = 0; i < patternMatch.getWidth(); ++i) { ++ for (int j = 0; j < patternMatch.getHeight(); ++j) { ++ BlockInWorld shapedetectorblock = patternMatch.getBlock(i, j, 0); ++ ++ level.setBlock(shapedetectorblock.getPos(), Blocks.AIR.defaultBlockState(), 2); ++ level.levelEvent(2001, shapedetectorblock.getPos(), Block.getId(shapedetectorblock.getState())); + } + } ++ + } + + public static void updatePatternBlocks(Level level, BlockPattern.BlockPatternMatch patternMatch) { +- for (int i = 0; i < patternMatch.getWidth(); i++) { +- for (int i1 = 0; i1 < patternMatch.getHeight(); i1++) { +- BlockInWorld block = patternMatch.getBlock(i, i1, 0); +- level.blockUpdated(block.getPos(), Blocks.AIR); ++ for (int i = 0; i < patternMatch.getWidth(); ++i) { ++ for (int j = 0; j < patternMatch.getHeight(); ++j) { ++ BlockInWorld shapedetectorblock = patternMatch.getBlock(i, j, 0); ++ ++ level.blockUpdated(shapedetectorblock.getPos(), Blocks.AIR); + } + } ++ + } + + @Override +- public BlockState getStateForPlacement(BlockPlaceContext context) { +- return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()); ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ return (IBlockData) this.defaultBlockState().setValue(CarvedPumpkinBlock.FACING, context.getHorizontalDirection().getOpposite()); + } + + @Override +- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { +- builder.add(FACING); ++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) { ++ builder.add(CarvedPumpkinBlock.FACING); + } + + private BlockPattern getOrCreateSnowGolemBase() { + if (this.snowGolemBase == null) { +- this.snowGolemBase = BlockPatternBuilder.start() +- .aisle(" ", "#", "#") +- .where('#', BlockInWorld.hasState(BlockStatePredicate.forBlock(Blocks.SNOW_BLOCK))) +- .build(); ++ this.snowGolemBase = BlockPatternBuilder.start().aisle(" ", "#", "#").where('#', BlockInWorld.hasState(BlockStatePredicate.forBlock(Blocks.SNOW_BLOCK))).build(); + } + + return this.snowGolemBase; +@@ -131,11 +151,7 @@ + + private BlockPattern getOrCreateSnowGolemFull() { + if (this.snowGolemFull == null) { +- this.snowGolemFull = BlockPatternBuilder.start() +- .aisle("^", "#", "#") +- .where('^', BlockInWorld.hasState(PUMPKINS_PREDICATE)) +- .where('#', BlockInWorld.hasState(BlockStatePredicate.forBlock(Blocks.SNOW_BLOCK))) +- .build(); ++ this.snowGolemFull = BlockPatternBuilder.start().aisle("^", "#", "#").where('^', BlockInWorld.hasState(CarvedPumpkinBlock.PUMPKINS_PREDICATE)).where('#', BlockInWorld.hasState(BlockStatePredicate.forBlock(Blocks.SNOW_BLOCK))).build(); + } + + return this.snowGolemFull; +@@ -143,11 +159,9 @@ + + private BlockPattern getOrCreateIronGolemBase() { + if (this.ironGolemBase == null) { +- this.ironGolemBase = BlockPatternBuilder.start() +- .aisle("~ ~", "###", "~#~") +- .where('#', BlockInWorld.hasState(BlockStatePredicate.forBlock(Blocks.IRON_BLOCK))) +- .where('~', block -> block.getState().isAir()) +- .build(); ++ this.ironGolemBase = BlockPatternBuilder.start().aisle("~ ~", "###", "~#~").where('#', BlockInWorld.hasState(BlockStatePredicate.forBlock(Blocks.IRON_BLOCK))).where('~', (shapedetectorblock) -> { ++ return shapedetectorblock.getState().isAir(); ++ }).build(); + } + + return this.ironGolemBase; +@@ -155,12 +169,9 @@ + + private BlockPattern getOrCreateIronGolemFull() { + if (this.ironGolemFull == null) { +- this.ironGolemFull = BlockPatternBuilder.start() +- .aisle("~^~", "###", "~#~") +- .where('^', BlockInWorld.hasState(PUMPKINS_PREDICATE)) +- .where('#', BlockInWorld.hasState(BlockStatePredicate.forBlock(Blocks.IRON_BLOCK))) +- .where('~', block -> block.getState().isAir()) +- .build(); ++ this.ironGolemFull = BlockPatternBuilder.start().aisle("~^~", "###", "~#~").where('^', BlockInWorld.hasState(CarvedPumpkinBlock.PUMPKINS_PREDICATE)).where('#', BlockInWorld.hasState(BlockStatePredicate.forBlock(Blocks.IRON_BLOCK))).where('~', (shapedetectorblock) -> { ++ return shapedetectorblock.getState().isAir(); ++ }).build(); + } + + return this.ironGolemFull; |