change mob spawners
This commit is contained in:
parent
9e5ca9dd95
commit
d45a1a8c4a
22 changed files with 190 additions and 459 deletions
|
@ -1,22 +1,28 @@
|
|||
package server.worldgen;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import common.block.Material;
|
||||
import common.entity.npc.EntityArachnoid;
|
||||
import common.entity.npc.EntityUndead;
|
||||
import common.entity.npc.EntityZombie;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.init.Blocks;
|
||||
import common.init.Items;
|
||||
import common.item.RngLoot;
|
||||
import common.log.Log;
|
||||
import common.rng.Random;
|
||||
import common.rng.WeightedList;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.tileentity.TileEntityChest;
|
||||
import common.tileentity.TileEntityMobSpawner;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import common.world.World;
|
||||
import server.vars.SVars;
|
||||
import server.world.WorldServer;
|
||||
|
||||
public class FeatureDungeons
|
||||
{
|
||||
private static final String[] SPAWNERTYPES = new String[] {"Undead", "Zombie", "Zombie", "Arachnoid"};
|
||||
private static final Class<? extends EntityLiving>[] MOB_TYPES = new Class[] {EntityUndead.class, EntityZombie.class, EntityZombie.class, EntityArachnoid.class};
|
||||
|
||||
private final int chance;
|
||||
|
||||
|
@ -148,16 +154,15 @@ public class FeatureDungeons
|
|||
}
|
||||
}
|
||||
|
||||
worldIn.setState(position, Blocks.mob_spawner.getState(), 2);
|
||||
TileEntity tileentity = worldIn.getTileEntity(position);
|
||||
|
||||
if (tileentity instanceof TileEntityMobSpawner)
|
||||
{
|
||||
((TileEntityMobSpawner)tileentity).setEntityName(this.pickMobSpawner(rand));
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.TICK.warn("Konnte kein Mob-Spawner-Objekt bei (" + position.getX() + ", " + position.getY() + ", " + position.getZ() + ") erstellen");
|
||||
if(SVars.mobs && SVars.spawnDungeonMobs > 0) {
|
||||
for(int z = 0; z < SVars.spawnDungeonMobs; z++) {
|
||||
EntityLiving entity = this.pickMobSpawner(rand, worldIn);
|
||||
entity.setLocationAndAngles((double)position.getX() + rand.doublev(), (double)position.getY(), (double)position.getZ() + rand.doublev(), worldIn.rand.floatv() * 360.0F, 0.0F);
|
||||
entity.onInitialSpawn(null);
|
||||
worldIn.spawnEntityInWorld(entity);
|
||||
if(rand.chance(5))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -168,11 +173,13 @@ public class FeatureDungeons
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly decides which spawner to use in a dungeon
|
||||
*/
|
||||
private String pickMobSpawner(Random p_76543_1_)
|
||||
private EntityLiving pickMobSpawner(Random rand, WorldServer world)
|
||||
{
|
||||
return SPAWNERTYPES[p_76543_1_.zrange(SPAWNERTYPES.length)];
|
||||
try {
|
||||
return rand.pick(MOB_TYPES).getConstructor(World.class).newInstance(world);
|
||||
}
|
||||
catch(InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue