mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 03:15:07 +00:00
Some tweaks to life imbuer
This commit is contained in:
1 parent
a0494475dd
commit
727d0480df
1 file changed
+44
-36
@@ -51,6 +51,7 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver {
|
||||
MobSpawnerBaseLogic logic = spawner.getSpawnerBaseLogic();
|
||||
|
||||
try {
|
||||
// Directly drawn from MobSpawnerBaseLogic, with inverted isActivated check and mana consumption
|
||||
if(!((Boolean) isActivated.invoke(logic))) {
|
||||
if(!worldObj.isRemote)
|
||||
mana -= 6;
|
||||
@@ -65,54 +66,60 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver {
|
||||
|
||||
prevMobRotation.set(logic, logic.getMobRotation());
|
||||
mobRotation.set(logic, (logic.getMobRotation() + 1000.0F / (spawnDelay.getInt(logic) + 200.0F)) % 360.0D);
|
||||
} else if(spawnDelay.getInt(logic) == -1)
|
||||
resetTimer(logic);
|
||||
} else {
|
||||
if(spawnDelay.getInt(logic) == -1)
|
||||
resetTimer(logic);
|
||||
int delay = spawnDelay.getInt(logic);
|
||||
if(delay > 0) {
|
||||
spawnDelay.setInt(logic, delay - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
int delay = spawnDelay.getInt(logic);
|
||||
if(delay > 0) {
|
||||
spawnDelay.setInt(logic, delay - 1);
|
||||
return;
|
||||
}
|
||||
if(logic.getSpawnerWorld().isRemote)
|
||||
return;
|
||||
|
||||
boolean flag = false;
|
||||
boolean flag = false;
|
||||
|
||||
int spawnCount = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_COUNT);
|
||||
int spawnRange = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_RANGE);
|
||||
int maxNearbyEntities = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MAX_NEARBY_ENTITIES);
|
||||
int spawnCount = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_COUNT);
|
||||
int spawnRange = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.SPAWN_RANGE);
|
||||
int maxNearbyEntities = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MAX_NEARBY_ENTITIES);
|
||||
|
||||
for(int i = 0; i < spawnCount; ++i) {
|
||||
Entity entity = EntityList.createEntityByName(((String) getEntityNameToSpawn.invoke(logic)), logic.getSpawnerWorld());
|
||||
for(int i = 0; i < spawnCount; ++i) {
|
||||
Entity entity = EntityList.createEntityByName(((String) getEntityNameToSpawn.invoke(logic)), logic.getSpawnerWorld());
|
||||
|
||||
if (entity == null)
|
||||
return;
|
||||
if (entity == null)
|
||||
return;
|
||||
|
||||
int j = logic.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), new AxisAlignedBB(logic.getSpawnerPosition(), logic.getSpawnerPosition().add(1, 1, 1)).expand(spawnRange * 2, 4.0D, spawnRange * 2)).size();
|
||||
int j = logic.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), new AxisAlignedBB(logic.getSpawnerPosition(), logic.getSpawnerPosition().add(1, 1, 1)).expand(spawnRange * 2, 4.0D, spawnRange * 2)).size();
|
||||
|
||||
if (j >= maxNearbyEntities) {
|
||||
resetTimer(logic);
|
||||
return;
|
||||
}
|
||||
if (j >= maxNearbyEntities) {
|
||||
resetTimer(logic);
|
||||
return;
|
||||
}
|
||||
|
||||
double d2 = logic.getSpawnerPosition().getX() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange;
|
||||
double d3 = logic.getSpawnerPosition().getY() + logic.getSpawnerWorld().rand.nextInt(3) - 1;
|
||||
double d4 = logic.getSpawnerPosition().getZ() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange;
|
||||
EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving)entity : null;
|
||||
entity.setLocationAndAngles(d2, d3, d4, logic.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F);
|
||||
double d2 = logic.getSpawnerPosition().getX() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange;
|
||||
double d3 = logic.getSpawnerPosition().getY() + logic.getSpawnerWorld().rand.nextInt(3) - 1;
|
||||
double d4 = logic.getSpawnerPosition().getZ() + (logic.getSpawnerWorld().rand.nextDouble() - logic.getSpawnerWorld().rand.nextDouble()) * spawnRange;
|
||||
EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving)entity : null;
|
||||
entity.setLocationAndAngles(d2, d3, d4, logic.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F);
|
||||
|
||||
if(entityliving == null || entityliving.getCanSpawnHere()) {
|
||||
if(!worldObj.isRemote)
|
||||
spawnNewEntity.invoke(logic, entity, true);
|
||||
logic.getSpawnerWorld().playAuxSFX(2004, logic.getSpawnerPosition(), 0);
|
||||
if(entityliving == null || entityliving.getCanSpawnHere() && entityliving.isNotColliding()) {
|
||||
spawnNewEntity.invoke(logic, entity, true);
|
||||
this.getWorld().playAuxSFX(2004, logic.getSpawnerPosition(), 0);
|
||||
|
||||
if (entityliving != null)
|
||||
entityliving.spawnExplosionParticle();
|
||||
if(entityliving != null) {
|
||||
entityliving.spawnExplosionParticle();
|
||||
}
|
||||
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
resetTimer(logic);
|
||||
}
|
||||
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
resetTimer(logic);
|
||||
}
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
@@ -120,6 +127,7 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
// Direct copy of MobSpawnerBaseLogic.resetTimer()
|
||||
private void resetTimer(MobSpawnerBaseLogic logic) throws IllegalAccessException {
|
||||
int maxSpawnDelay = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MAX_SPAWN_DELAY);
|
||||
int minSpawnDelay = ReflectionHelper.getPrivateValue(MobSpawnerBaseLogic.class, logic, LibObfuscation.MIN_SPAWN_DELAY);
|
||||
|
||||
Reference in new issue
Block a user