diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch new file mode 100644 index 0000000000..21311a74b2 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch @@ -0,0 +1,146 @@ +--- a/net/minecraft/world/level/levelgen/PatrolSpawner.java ++++ b/net/minecraft/world/level/levelgen/PatrolSpawner.java +@@ -7,15 +7,15 @@ + import net.minecraft.tags.BiomeTags; + import net.minecraft.util.RandomSource; + import net.minecraft.world.entity.EntityType; +-import net.minecraft.world.entity.MobSpawnType; +-import net.minecraft.world.entity.SpawnGroupData; ++import net.minecraft.world.entity.EnumMobSpawn; ++import net.minecraft.world.entity.GroupDataEntity; + import net.minecraft.world.entity.monster.PatrollingMonster; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.level.CustomSpawner; + import net.minecraft.world.level.GameRules; + import net.minecraft.world.level.NaturalSpawner; + import net.minecraft.world.level.biome.Biome; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + + public class PatrolSpawner implements CustomSpawner { + +@@ -24,67 +24,66 @@ + public PatrolSpawner() {} + + @Override +- @Override +- public int tick(ServerLevel serverlevel, boolean flag, boolean flag1) { +- if (!flag) { ++ public int tick(ServerLevel level, boolean spawnEnemies, boolean spawnFriendlies) { ++ if (!spawnEnemies) { + return 0; +- } else if (!serverlevel.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) { ++ } else if (!level.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) { + return 0; + } else { +- RandomSource randomsource = serverlevel.random; ++ RandomSource randomsource = level.random; + + --this.nextTick; + if (this.nextTick > 0) { + return 0; + } else { + this.nextTick += 12000 + randomsource.nextInt(1200); +- long i = serverlevel.getDayTime() / 24000L; ++ long i = level.getDayTime() / 24000L; + +- if (i >= 5L && serverlevel.isDay()) { ++ if (i >= 5L && level.isDay()) { + if (randomsource.nextInt(5) != 0) { + return 0; + } else { +- int j = serverlevel.players().size(); ++ int j = level.players().size(); + + if (j < 1) { + return 0; + } else { +- Player player = (Player) serverlevel.players().get(randomsource.nextInt(j)); ++ Player entityhuman = (Player) level.players().get(randomsource.nextInt(j)); + +- if (player.isSpectator()) { ++ if (entityhuman.isSpectator()) { + return 0; +- } else if (serverlevel.isCloseToVillage(player.blockPosition(), 2)) { ++ } else if (level.isCloseToVillage(entityhuman.blockPosition(), 2)) { + return 0; + } else { + int k = (24 + randomsource.nextInt(24)) * (randomsource.nextBoolean() ? -1 : 1); + int l = (24 + randomsource.nextInt(24)) * (randomsource.nextBoolean() ? -1 : 1); +- BlockPos.MutableBlockPos blockpos_mutableblockpos = player.blockPosition().mutable().move(k, 0, l); ++ BlockPos.MutableBlockPos blockposition_mutableblockposition = entityhuman.blockPosition().mutable().move(k, 0, l); + boolean flag2 = true; + +- if (!serverlevel.hasChunksAt(blockpos_mutableblockpos.getX() - 10, blockpos_mutableblockpos.getZ() - 10, blockpos_mutableblockpos.getX() + 10, blockpos_mutableblockpos.getZ() + 10)) { ++ if (!level.hasChunksAt(blockposition_mutableblockposition.getX() - 10, blockposition_mutableblockposition.getZ() - 10, blockposition_mutableblockposition.getX() + 10, blockposition_mutableblockposition.getZ() + 10)) { + return 0; + } else { +- Holder<Biome> holder = serverlevel.getBiome(blockpos_mutableblockpos); ++ Holder<Biome> holder = level.getBiome(blockposition_mutableblockposition); + + if (holder.is(BiomeTags.WITHOUT_PATROL_SPAWNS)) { + return 0; + } else { + int i1 = 0; +- int j1 = (int) Math.ceil((double) serverlevel.getCurrentDifficultyAt(blockpos_mutableblockpos).getEffectiveDifficulty()) + 1; ++ int j1 = (int) Math.ceil((double) level.getCurrentDifficultyAt(blockposition_mutableblockposition).getEffectiveDifficulty()) + 1; + + for (int k1 = 0; k1 < j1; ++k1) { + ++i1; +- blockpos_mutableblockpos.setY(serverlevel.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, blockpos_mutableblockpos).getY()); ++ blockposition_mutableblockposition.setY(level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, blockposition_mutableblockposition).getY()); + if (k1 == 0) { +- if (!this.spawnPatrolMember(serverlevel, blockpos_mutableblockpos, randomsource, true)) { ++ if (!this.spawnPatrolMember(level, blockposition_mutableblockposition, randomsource, true)) { + break; + } + } else { +- this.spawnPatrolMember(serverlevel, blockpos_mutableblockpos, randomsource, false); ++ this.spawnPatrolMember(level, blockposition_mutableblockposition, randomsource, false); + } + +- blockpos_mutableblockpos.setX(blockpos_mutableblockpos.getX() + randomsource.nextInt(5) - randomsource.nextInt(5)); +- blockpos_mutableblockpos.setZ(blockpos_mutableblockpos.getZ() + randomsource.nextInt(5) - randomsource.nextInt(5)); ++ blockposition_mutableblockposition.setX(blockposition_mutableblockposition.getX() + randomsource.nextInt(5) - randomsource.nextInt(5)); ++ blockposition_mutableblockposition.setZ(blockposition_mutableblockposition.getZ() + randomsource.nextInt(5) - randomsource.nextInt(5)); + } + + return i1; +@@ -100,25 +99,25 @@ + } + } + +- private boolean spawnPatrolMember(ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource, boolean flag) { +- BlockState blockstate = serverlevel.getBlockState(blockpos); ++ private boolean spawnPatrolMember(ServerLevel level, BlockPos pos, RandomSource random, boolean leader) { ++ IBlockData iblockdata = level.getBlockState(pos); + +- if (!NaturalSpawner.isValidEmptySpawnBlock(serverlevel, blockpos, blockstate, blockstate.getFluidState(), EntityType.PILLAGER)) { ++ if (!NaturalSpawner.isValidEmptySpawnBlock(level, pos, iblockdata, iblockdata.getFluidState(), EntityType.PILLAGER)) { + return false; +- } else if (!PatrollingMonster.checkPatrollingMonsterSpawnRules(EntityType.PILLAGER, serverlevel, MobSpawnType.PATROL, blockpos, randomsource)) { ++ } else if (!PatrollingMonster.checkPatrollingMonsterSpawnRules(EntityType.PILLAGER, level, EnumMobSpawn.PATROL, pos, random)) { + return false; + } else { +- PatrollingMonster patrollingmonster = (PatrollingMonster) EntityType.PILLAGER.create(serverlevel); ++ PatrollingMonster entitymonsterpatrolling = (PatrollingMonster) EntityType.PILLAGER.create(level); + +- if (patrollingmonster != null) { +- if (flag) { +- patrollingmonster.setPatrolLeader(true); +- patrollingmonster.findPatrolTarget(); ++ if (entitymonsterpatrolling != null) { ++ if (leader) { ++ entitymonsterpatrolling.setPatrolLeader(true); ++ entitymonsterpatrolling.findPatrolTarget(); + } + +- patrollingmonster.setPos((double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ()); +- patrollingmonster.finalizeSpawn(serverlevel, serverlevel.getCurrentDifficultyAt(blockpos), MobSpawnType.PATROL, (SpawnGroupData) null, (CompoundTag) null); +- serverlevel.addFreshEntityWithPassengers(patrollingmonster); ++ entitymonsterpatrolling.setPos((double) pos.getX(), (double) pos.getY(), (double) pos.getZ()); ++ entitymonsterpatrolling.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EnumMobSpawn.PATROL, (GroupDataEntity) null, (CompoundTag) null); ++ level.addFreshEntityWithPassengers(entitymonsterpatrolling, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PATROL); // CraftBukkit + return true; + } else { + return false; |