diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch | 175 |
1 files changed, 175 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch new file mode 100644 index 0000000000..d68ddd74f3 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch @@ -0,0 +1,175 @@ +--- a/net/minecraft/world/level/levelgen/PatrolSpawner.java ++++ b/net/minecraft/world/level/levelgen/PatrolSpawner.java +@@ -2,22 +2,27 @@ + + import net.minecraft.core.BlockPos; + import net.minecraft.core.Holder; ++import net.minecraft.nbt.CompoundTag; + import net.minecraft.server.level.ServerLevel; + 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.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 { ++ + private int nextTick; + ++ public PatrolSpawner() {} ++ + @Override + public int tick(ServerLevel level, boolean spawnEnemies, boolean spawnFriendlies) { + if (!spawnEnemies) { +@@ -25,86 +30,94 @@ + } else if (!level.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) { + return 0; + } else { +- RandomSource randomSource = level.random; +- this.nextTick--; ++ RandomSource randomsource = level.random; ++ ++ --this.nextTick; + if (this.nextTick > 0) { + return 0; + } else { +- this.nextTick = this.nextTick + 12000 + randomSource.nextInt(1200); +- long l = level.getDayTime() / 24000L; +- if (l < 5L || !level.isDay()) { +- return 0; +- } else if (randomSource.nextInt(5) != 0) { +- return 0; +- } else { +- int size = level.players().size(); +- if (size < 1) { ++ this.nextTick += 12000 + randomsource.nextInt(1200); ++ long i = level.getDayTime() / 24000L; ++ ++ if (i >= 5L && level.isDay()) { ++ if (randomsource.nextInt(5) != 0) { + return 0; + } else { +- Player player = level.players().get(randomSource.nextInt(size)); +- if (player.isSpectator()) { ++ int j = level.players().size(); ++ ++ if (j < 1) { + return 0; +- } else if (level.isCloseToVillage(player.blockPosition(), 2)) { +- return 0; + } else { +- int i = (24 + randomSource.nextInt(24)) * (randomSource.nextBoolean() ? -1 : 1); +- int i1 = (24 + randomSource.nextInt(24)) * (randomSource.nextBoolean() ? -1 : 1); +- BlockPos.MutableBlockPos mutableBlockPos = player.blockPosition().mutable().move(i, 0, i1); +- int i2 = 10; +- if (!level.hasChunksAt( +- mutableBlockPos.getX() - 10, mutableBlockPos.getZ() - 10, mutableBlockPos.getX() + 10, mutableBlockPos.getZ() + 10 +- )) { ++ Player entityhuman = (Player) level.players().get(randomsource.nextInt(j)); ++ ++ if (entityhuman.isSpectator()) { + return 0; ++ } else if (level.isCloseToVillage(entityhuman.blockPosition(), 2)) { ++ return 0; + } else { +- Holder<Biome> biome = level.getBiome(mutableBlockPos); +- if (biome.is(BiomeTags.WITHOUT_PATROL_SPAWNS)) { ++ int k = (24 + randomsource.nextInt(24)) * (randomsource.nextBoolean() ? -1 : 1); ++ int l = (24 + randomsource.nextInt(24)) * (randomsource.nextBoolean() ? -1 : 1); ++ BlockPos.MutableBlockPos blockposition_mutableblockposition = entityhuman.blockPosition().mutable().move(k, 0, l); ++ boolean flag2 = true; ++ ++ if (!level.hasChunksAt(blockposition_mutableblockposition.getX() - 10, blockposition_mutableblockposition.getZ() - 10, blockposition_mutableblockposition.getX() + 10, blockposition_mutableblockposition.getZ() + 10)) { + return 0; + } else { +- int i3 = 0; +- int i4 = (int)Math.ceil((double)level.getCurrentDifficultyAt(mutableBlockPos).getEffectiveDifficulty()) + 1; ++ Holder<Biome> holder = level.getBiome(blockposition_mutableblockposition); + +- for (int i5 = 0; i5 < i4; i5++) { +- i3++; +- mutableBlockPos.setY(level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, mutableBlockPos).getY()); +- if (i5 == 0) { +- if (!this.spawnPatrolMember(level, mutableBlockPos, randomSource, true)) { +- break; ++ if (holder.is(BiomeTags.WITHOUT_PATROL_SPAWNS)) { ++ return 0; ++ } else { ++ int i1 = 0; ++ int j1 = (int) Math.ceil((double) level.getCurrentDifficultyAt(blockposition_mutableblockposition).getEffectiveDifficulty()) + 1; ++ ++ for (int k1 = 0; k1 < j1; ++k1) { ++ ++i1; ++ blockposition_mutableblockposition.setY(level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, blockposition_mutableblockposition).getY()); ++ if (k1 == 0) { ++ if (!this.spawnPatrolMember(level, blockposition_mutableblockposition, randomsource, true)) { ++ break; ++ } ++ } else { ++ this.spawnPatrolMember(level, blockposition_mutableblockposition, randomsource, false); + } +- } else { +- this.spawnPatrolMember(level, mutableBlockPos, randomSource, false); ++ ++ blockposition_mutableblockposition.setX(blockposition_mutableblockposition.getX() + randomsource.nextInt(5) - randomsource.nextInt(5)); ++ blockposition_mutableblockposition.setZ(blockposition_mutableblockposition.getZ() + randomsource.nextInt(5) - randomsource.nextInt(5)); + } + +- mutableBlockPos.setX(mutableBlockPos.getX() + randomSource.nextInt(5) - randomSource.nextInt(5)); +- mutableBlockPos.setZ(mutableBlockPos.getZ() + randomSource.nextInt(5) - randomSource.nextInt(5)); ++ return i1; + } +- +- return i3; + } + } + } + } ++ } else { ++ return 0; + } + } + } + } + + private boolean spawnPatrolMember(ServerLevel level, BlockPos pos, RandomSource random, boolean leader) { +- BlockState blockState = level.getBlockState(pos); +- if (!NaturalSpawner.isValidEmptySpawnBlock(level, pos, blockState, blockState.getFluidState(), EntityType.PILLAGER)) { ++ IBlockData iblockdata = level.getBlockState(pos); ++ ++ if (!NaturalSpawner.isValidEmptySpawnBlock(level, pos, iblockdata, iblockdata.getFluidState(), EntityType.PILLAGER)) { + return false; +- } else if (!PatrollingMonster.checkPatrollingMonsterSpawnRules(EntityType.PILLAGER, level, MobSpawnType.PATROL, pos, random)) { ++ } else if (!PatrollingMonster.checkPatrollingMonsterSpawnRules(EntityType.PILLAGER, level, EnumMobSpawn.PATROL, pos, random)) { + return false; + } else { +- PatrollingMonster patrollingMonster = EntityType.PILLAGER.create(level); +- if (patrollingMonster != null) { ++ PatrollingMonster entitymonsterpatrolling = (PatrollingMonster) EntityType.PILLAGER.create(level); ++ ++ if (entitymonsterpatrolling != null) { + if (leader) { +- patrollingMonster.setPatrolLeader(true); +- patrollingMonster.findPatrolTarget(); ++ entitymonsterpatrolling.setPatrolLeader(true); ++ entitymonsterpatrolling.findPatrolTarget(); + } + +- patrollingMonster.setPos((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()); +- patrollingMonster.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), MobSpawnType.PATROL, null, null); +- level.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; |