mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
80 lines
5.7 KiB
Diff
80 lines
5.7 KiB
Diff
--- a/net/minecraft/world/WorldEntitySpawner.java
|
|
+++ b/net/minecraft/world/WorldEntitySpawner.java
|
|
@@ -72,12 +72,14 @@
|
|
for(EnumCreatureType enumcreaturetype : EnumCreatureType.values()) {
|
|
if ((!enumcreaturetype.func_75599_d() || p_77192_3_) && (enumcreaturetype.func_75599_d() || p_77192_2_) && (!enumcreaturetype.func_82705_e() || p_77192_4_)) {
|
|
int l4 = enumcreaturetype.func_75601_b() * i / field_180268_a;
|
|
- int i5 = p_77192_1_.func_72907_a(enumcreaturetype.func_75598_a(), l4);
|
|
+ int i5 = p_77192_1_.countEntities(enumcreaturetype, l4, true);
|
|
if (i5 <= l4) {
|
|
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
|
|
|
+ java.util.ArrayList<ChunkPos> shuffled = new java.util.ArrayList<>(this.field_77193_b);
|
|
+ java.util.Collections.shuffle(shuffled);
|
|
label158:
|
|
- for(ChunkPos chunkpos1 : this.field_77193_b) {
|
|
+ for(ChunkPos chunkpos1 : shuffled) {
|
|
BlockPos blockpos = func_180621_a(p_77192_1_, chunkpos1.field_77276_a, chunkpos1.field_77275_b);
|
|
int k1 = blockpos.func_177958_n();
|
|
int l1 = blockpos.func_177956_o();
|
|
@@ -128,7 +130,9 @@
|
|
}
|
|
|
|
entityliving.func_70012_b((double)f, (double)i3, (double)f1, p_77192_1_.field_73012_v.nextFloat() * 360.0F, 0.0F);
|
|
- if ((d0 <= 16384.0D || !entityliving.func_70692_ba()) && entityliving.func_205020_a(p_77192_1_, false) && entityliving.func_205019_a(p_77192_1_)) {
|
|
+ int canSpawn = net.minecraftforge.common.ForgeHooks.canEntitySpawn(entityliving, p_77192_1_, f, i3, f1, null);
|
|
+ if ((d0 <= 16384.0D || !entityliving.func_70692_ba()) && (canSpawn == 1 || (canSpawn == 0 && entityliving.func_205020_a(p_77192_1_, false) && entityliving.func_205019_a(p_77192_1_)))) {
|
|
+ if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(entityliving, p_77192_1_, f, i3, f1, null))
|
|
ientitylivingdata = entityliving.func_204210_a(p_77192_1_.func_175649_E(new BlockPos(entityliving)), ientitylivingdata, (NBTTagCompound)null);
|
|
if (entityliving.func_205019_a(p_77192_1_)) {
|
|
++j2;
|
|
@@ -138,7 +142,7 @@
|
|
entityliving.func_70106_y();
|
|
}
|
|
|
|
- if (j2 >= entityliving.func_70641_bl()) {
|
|
+ if (j2 >= net.minecraftforge.event.ForgeEventFactory.getMaxSpawnPackSize(entityliving)) {
|
|
continue label158;
|
|
}
|
|
|
|
@@ -187,6 +191,13 @@
|
|
|
|
public static boolean func_209382_a(EntitySpawnPlacementRegistry.SpawnPlacementType p_209382_0_, IWorldReaderBase p_209382_1_, BlockPos p_209382_2_, @Nullable EntityType<? extends EntityLiving> p_209382_3_) {
|
|
if (p_209382_3_ != null && p_209382_1_.func_175723_af().func_177746_a(p_209382_2_)) {
|
|
+ return p_209382_0_.canSpawnAt(p_209382_1_, p_209382_2_, p_209382_3_);
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
+
|
|
+ public static boolean canSpawnAtBody(EntitySpawnPlacementRegistry.SpawnPlacementType p_209382_0_, IWorldReaderBase p_209382_1_, BlockPos p_209382_2_, @Nullable EntityType<? extends EntityLiving> p_209382_3_) {
|
|
+ {
|
|
IBlockState iblockstate = p_209382_1_.func_180495_p(p_209382_2_);
|
|
IFluidState ifluidstate = p_209382_1_.func_204610_c(p_209382_2_);
|
|
switch(p_209382_0_) {
|
|
@@ -195,7 +206,7 @@
|
|
case ON_GROUND:
|
|
default:
|
|
IBlockState iblockstate1 = p_209382_1_.func_180495_p(p_209382_2_.func_177977_b());
|
|
- if (iblockstate1.func_185896_q() || p_209382_3_ != null && EntitySpawnPlacementRegistry.func_209345_a(p_209382_3_, iblockstate1)) {
|
|
+ if (iblockstate1.canCreatureSpawn(p_209382_1_, p_209382_2_.func_177977_b(), p_209382_0_, p_209382_3_)) {
|
|
Block block = iblockstate1.func_177230_c();
|
|
boolean flag = block != Blocks.field_150357_h && block != Blocks.field_180401_cv;
|
|
return flag && func_206851_a(iblockstate, ifluidstate) && func_206851_a(p_209382_1_.func_180495_p(p_209382_2_.func_177984_a()), p_209382_1_.func_204610_c(p_209382_2_.func_177984_a()));
|
|
@@ -203,8 +214,6 @@
|
|
return false;
|
|
}
|
|
}
|
|
- } else {
|
|
- return false;
|
|
}
|
|
}
|
|
|
|
@@ -239,6 +248,7 @@
|
|
|
|
double d0 = MathHelper.func_151237_a((double)l, (double)i + (double)entityliving.field_70130_N, (double)i + 16.0D - (double)entityliving.field_70130_N);
|
|
double d1 = MathHelper.func_151237_a((double)i1, (double)j + (double)entityliving.field_70130_N, (double)j + 16.0D - (double)entityliving.field_70130_N);
|
|
+ if (net.minecraftforge.common.ForgeHooks.canEntitySpawn(entityliving, p_77191_0_, d0, blockpos.func_177956_o(), d1, null) == -1) continue;
|
|
entityliving.func_70012_b(d0, (double)blockpos.func_177956_o(), d1, p_77191_4_.nextFloat() * 360.0F, 0.0F);
|
|
if (entityliving.func_205020_a(p_77191_0_, false) && entityliving.func_205019_a(p_77191_0_)) {
|
|
ientitylivingdata = entityliving.func_204210_a(p_77191_0_.func_175649_E(new BlockPos(entityliving)), ientitylivingdata, (NBTTagCompound)null);
|