1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
--- a/net/minecraft/util/SpawnUtil.java
+++ b/net/minecraft/util/SpawnUtil.java
@@ -20,16 +18,29 @@
) {
BlockPos.MutableBlockPos mutableBlockPos = pos.mutable();
- for (int i1 = 0; i1 < attempts; i1++) {
- int i2 = Mth.randomBetweenInclusive(level.random, -i, i);
- int i3 = Mth.randomBetweenInclusive(level.random, -i, i);
- mutableBlockPos.setWithOffset(pos, i2, yOffset, i3);
- if (level.getWorldBorder().isWithinBounds(mutableBlockPos) && moveToPossibleSpawnPosition(level, yOffset, mutableBlockPos, strategy)) {
- T mob = (T)entityType.create(level, null, null, mutableBlockPos, spawnType, false, false);
- if (mob != null) {
- if (mob.checkSpawnRules(level, spawnType) && mob.checkSpawnObstruction(level)) {
- level.addFreshEntityWithPassengers(mob);
- return Optional.of(mob);
+ public SpawnUtil() {}
+
+ public static <T extends Mob> Optional<T> trySpawnMob(EntityType<T> entityType, EnumMobSpawn spawnType, ServerLevel level, BlockPos pos, int attempts, int j, int yOffset, SpawnUtil.Strategy strategy) {
+ // CraftBukkit start
+ return trySpawnMob(entityType, spawnType, level, pos, attempts, j, yOffset, strategy, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+
+ public static <T extends Mob> Optional<T> trySpawnMob(EntityType<T> entitytypes, EnumMobSpawn enummobspawn, ServerLevel worldserver, BlockPos blockposition, int i, int j, int k, SpawnUtil.Strategy spawnutil_a, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
+ // CraftBukkit end
+ BlockPos.MutableBlockPos blockposition_mutableblockposition = blockposition.mutable();
+
+ for (int l = 0; l < i; ++l) {
+ int i1 = Mth.randomBetweenInclusive(worldserver.random, -j, j);
+ int j1 = Mth.randomBetweenInclusive(worldserver.random, -j, j);
+
+ blockposition_mutableblockposition.setWithOffset(blockposition, i1, k, j1);
+ if (worldserver.getWorldBorder().isWithinBounds((BlockPos) blockposition_mutableblockposition) && moveToPossibleSpawnPosition(worldserver, k, blockposition_mutableblockposition, spawnutil_a)) {
+ T t0 = entitytypes.create(worldserver, (CompoundTag) null, null, blockposition_mutableblockposition, enummobspawn, false, false); // CraftBukkit - decompile error
+
+ if (t0 != null) {
+ if (t0.checkSpawnRules(worldserver, enummobspawn) && t0.checkSpawnObstruction(worldserver)) {
+ worldserver.addFreshEntityWithPassengers(t0, reason); // CraftBukkit
+ return Optional.of(t0);
}
mob.discard();
|