change mob spawners
This commit is contained in:
parent
9e5ca9dd95
commit
d45a1a8c4a
22 changed files with 190 additions and 459 deletions
|
@ -11,7 +11,13 @@ public abstract class SVars extends Vars {
|
|||
@Var(name = "spawnVillagers")
|
||||
public static boolean spawnVillager = true;
|
||||
@Var(name = "spawnCagedVillagers")
|
||||
public static boolean spawnCagedVillager = true;
|
||||
public static boolean spawnCageMobs = true;
|
||||
@Var(name = "spawnBridgeMages")
|
||||
public static boolean spawnBridgeMobs = true;
|
||||
@Var(name = "spawnMineshaftArachnoids")
|
||||
public static boolean spawnMineshaftMobs = true;
|
||||
@Var(name = "spawnStrongholdHaunters")
|
||||
public static boolean spawnStrongholdMobs = true;
|
||||
@Var(name = "spawnHutMages")
|
||||
public static boolean spawnHutMage = true;
|
||||
@Var(name = "daylightCycle")
|
||||
|
@ -82,6 +88,8 @@ public abstract class SVars extends Vars {
|
|||
public static int minPassLength = 8;
|
||||
@Var(name = "port", min = 1024, max = 32767, nonDefault = true)
|
||||
public static int port = -1;
|
||||
@Var(name = "spawnDungeonMobs")
|
||||
public static int spawnDungeonMobs = 4;
|
||||
|
||||
@Var(name = "gravity")
|
||||
public static float gravity = 1.0f;
|
||||
|
|
|
@ -78,7 +78,6 @@ import common.tileentity.TileEntityDropper;
|
|||
import common.tileentity.TileEntityEnchantmentTable;
|
||||
import common.tileentity.TileEntityFurnace;
|
||||
import common.tileentity.TileEntityHopper;
|
||||
import common.tileentity.TileEntityMobSpawner;
|
||||
import common.tileentity.TileEntitySign;
|
||||
import common.util.Facing;
|
||||
import common.util.NibbleArray;
|
||||
|
@ -343,7 +342,6 @@ public abstract class Converter {
|
|||
mapTile(TileEntityDispenser.class, "Trap", "dispenser");
|
||||
mapTile(TileEntityDropper.class, "Dropper", "dropper");
|
||||
mapTile(TileEntitySign.class, "Sign", "sign");
|
||||
mapTile(TileEntityMobSpawner.class, "MobSpawner", "mob_spawner");
|
||||
// mapTile(TileEntityPiston.class, "Piston", "piston");
|
||||
mapTile(TileEntityEnchantmentTable.class, "EnchantTable", "enchanting_table");
|
||||
mapTile(TileEntityBeacon.class, "Beacon", "beacon");
|
||||
|
@ -576,7 +574,7 @@ public abstract class Converter {
|
|||
return Blocks.fire.getState().withProperty(BlockFire.AGE, data);
|
||||
}
|
||||
}, 51);
|
||||
mapBlock(Blocks.mob_spawner, 52);
|
||||
mapBlock(Blocks.iron_bars, 52);
|
||||
mapBlockData(Blocks.oak_stairs, 53);
|
||||
mapBlockData(Blocks.chest, 54);
|
||||
mapBlockData(Blocks.redstone, 55);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@ package server.worldgen.structure;
|
|||
import java.util.List;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.entity.npc.EntityDarkMage;
|
||||
import common.init.Blocks;
|
||||
import common.rng.Random;
|
||||
import common.tags.TagObject;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.tileentity.TileEntityMobSpawner;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import server.vars.SVars;
|
||||
import server.world.WorldServer;
|
||||
import server.worldgen.LootConstants;
|
||||
|
||||
|
@ -1364,20 +1364,17 @@ public class StructureBridge
|
|||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 6, 8, 5, 7, 8, Blocks.blood_brick_fence.getState(), Blocks.blood_brick_fence.getState(), false);
|
||||
this.fillWithBlocks(worldIn, structureBoundingBoxIn, 2, 8, 8, 4, 8, 8, Blocks.blood_brick_fence.getState(), Blocks.blood_brick_fence.getState(), false);
|
||||
|
||||
if (!this.hasSpawner)
|
||||
if (!this.hasSpawner && SVars.mobs && SVars.spawnBridgeMobs)
|
||||
{
|
||||
BlockPos blockpos = new BlockPos(this.getXWithOffset(3, 5), this.getYWithOffset(5), this.getZWithOffset(3, 5));
|
||||
|
||||
if (structureBoundingBoxIn.isVecInside(blockpos))
|
||||
{
|
||||
this.hasSpawner = true;
|
||||
worldIn.setState(blockpos, Blocks.mob_spawner.getState(), 2);
|
||||
TileEntity tileentity = worldIn.getTileEntity(blockpos);
|
||||
|
||||
if (tileentity instanceof TileEntityMobSpawner)
|
||||
{
|
||||
((TileEntityMobSpawner)tileentity).setEntityName("DarkMage");
|
||||
}
|
||||
EntityDarkMage entity = new EntityDarkMage(worldIn);
|
||||
entity.setLocationAndAngles((double)blockpos.getX() + 0.5D, (double)blockpos.getY(), (double)blockpos.getZ() + 0.5D, worldIn.rand.floatv() * 360.0F, 0.0F);
|
||||
entity.onInitialSpawn(null);
|
||||
worldIn.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,17 +4,17 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
|
||||
import common.entity.item.EntityChestCart;
|
||||
import common.entity.npc.EntityArachnoid;
|
||||
import common.init.Blocks;
|
||||
import common.init.Items;
|
||||
import common.item.RngLoot;
|
||||
import common.rng.Random;
|
||||
import common.rng.WeightedList;
|
||||
import common.tags.TagObject;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.tileentity.TileEntityMobSpawner;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import common.world.State;
|
||||
import server.vars.SVars;
|
||||
import server.world.WorldServer;
|
||||
import server.worldgen.LootConstants;
|
||||
|
||||
|
@ -360,7 +360,7 @@ public class StructureMineshaft
|
|||
this.generateChestContents(worldIn, structureBoundingBoxIn, randomIn, 0, 0, k1 + 1, RngLoot.addToList(LootConstants.MINESHAFT_CHEST, Items.enchanted_book.getRandom(randomIn)), 3 + randomIn.zrange(4));
|
||||
}
|
||||
|
||||
if (this.hasSpiders && !this.spawnerPlaced)
|
||||
if (this.hasSpiders && !this.spawnerPlaced && SVars.mobs && SVars.spawnMineshaftMobs)
|
||||
{
|
||||
int l1 = this.getYWithOffset(0);
|
||||
int i2 = k1 - 1 + randomIn.zrange(3);
|
||||
|
@ -371,13 +371,10 @@ public class StructureMineshaft
|
|||
if (structureBoundingBoxIn.isVecInside(blockpos))
|
||||
{
|
||||
this.spawnerPlaced = true;
|
||||
worldIn.setState(blockpos, Blocks.mob_spawner.getState(), 2);
|
||||
TileEntity tileentity = worldIn.getTileEntity(blockpos);
|
||||
|
||||
if (tileentity instanceof TileEntityMobSpawner)
|
||||
{
|
||||
((TileEntityMobSpawner)tileentity).setEntityName("Arachnoid");
|
||||
}
|
||||
EntityArachnoid entity = new EntityArachnoid(worldIn);
|
||||
entity.setLocationAndAngles((double)blockpos.getX() + 0.5D, (double)blockpos.getY(), (double)blockpos.getZ() + 0.5D, worldIn.rand.floatv() * 360.0F, 0.0F);
|
||||
entity.onInitialSpawn(null);
|
||||
worldIn.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,15 +7,15 @@ import common.block.artificial.BlockSlab;
|
|||
import common.block.artificial.BlockStoneBrick;
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.entity.npc.EntityHaunter;
|
||||
import common.init.Blocks;
|
||||
import common.init.Items;
|
||||
import common.item.RngLoot;
|
||||
import common.rng.Random;
|
||||
import common.tags.TagObject;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.tileentity.TileEntityMobSpawner;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import server.vars.SVars;
|
||||
import server.world.WorldServer;
|
||||
import server.worldgen.LootConstants;
|
||||
|
||||
|
@ -899,7 +899,7 @@ public class StructureStronghold
|
|||
// this.setBlockState(worldIn, Blocks.end_portal_frame.getStateFromMeta(j1).withProperty(BlockPortalFrame.ORB, Boolean.valueOf(randomIn.floatv() > 0.9F)), 7, 3, 10, structureBoundingBoxIn);
|
||||
// this.setBlockState(worldIn, Blocks.end_portal_frame.getStateFromMeta(j1).withProperty(BlockPortalFrame.ORB, Boolean.valueOf(randomIn.floatv() > 0.9F)), 7, 3, 11, structureBoundingBoxIn);
|
||||
|
||||
if (!this.hasSpawner)
|
||||
if (!this.hasSpawner && SVars.mobs && SVars.spawnStrongholdMobs)
|
||||
{
|
||||
i = this.getYWithOffset(3);
|
||||
BlockPos blockpos = new BlockPos(this.getXWithOffset(5, 6), i, this.getZWithOffset(5, 6));
|
||||
|
@ -907,13 +907,10 @@ public class StructureStronghold
|
|||
if (structureBoundingBoxIn.isVecInside(blockpos))
|
||||
{
|
||||
this.hasSpawner = true;
|
||||
worldIn.setState(blockpos, Blocks.mob_spawner.getState(), 2);
|
||||
TileEntity tileentity = worldIn.getTileEntity(blockpos);
|
||||
|
||||
if (tileentity instanceof TileEntityMobSpawner)
|
||||
{
|
||||
((TileEntityMobSpawner)tileentity).setEntityName("Haunter");
|
||||
}
|
||||
EntityHaunter entity = new EntityHaunter(worldIn);
|
||||
entity.setLocationAndAngles((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 1.0D, (double)blockpos.getZ() + 0.5D, worldIn.rand.floatv() * 360.0F, 0.0F);
|
||||
entity.onInitialSpawn(null);
|
||||
worldIn.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1921,7 +1921,7 @@ public class StructureVillage
|
|||
|
||||
protected void spawnVillager(WorldServer worldIn, StructureBoundingBox p_74893_2_, int x, int y, int z)
|
||||
{
|
||||
if (!this.villagerSpawned && SVars.mobs && SVars.spawnCagedVillager)
|
||||
if (!this.villagerSpawned && SVars.mobs && SVars.spawnCageMobs)
|
||||
{
|
||||
int j = this.getXWithOffset(x, z);
|
||||
int k = this.getYWithOffset(y);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue