change mob spawners

This commit is contained in:
Sen 2025-06-16 17:58:55 +02:00
parent 9e5ca9dd95
commit d45a1a8c4a
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
22 changed files with 190 additions and 459 deletions

View file

@ -27,6 +27,6 @@ public class GuiTile extends GuiContainer
this.drawString(this.tile.getStatus().color + this.tileInv.getCommandName() + " - " + this.tile.getStatus().name, 8, 6); this.drawString(this.tile.getStatus().color + this.tileInv.getCommandName() + " - " + this.tile.getStatus().name, 8, 6);
this.drawString(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2); this.drawString(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
this.drawString(String.format("Temperatur: %d °", this.tile.getTemperature()), 8, 18); this.drawString(String.format("Temperatur: %d °", this.tile.getTemperature()), 8, 18);
this.drawString(this.tile.formatDisplay(), 8, 28); this.drawString(this.tile.formatDisplay((ContainerTile)this.inventorySlots), 8, 28);
} }
} }

View file

@ -168,8 +168,8 @@ public class ClientLoginHandler implements IClientLoginHandler {
this.connection.closeChannel("Der Server unterstützt keine der vorhandenen\nAuthentifizierungsmethoden\n\nUnterstützt vom Server: " + this.connection.closeChannel("Der Server unterstützt keine der vorhandenen\nAuthentifizierungsmethoden\n\nUnterstützt vom Server: " +
(!passwordAuth && !pubkeyAuth ? "Keine" : ((passwordAuth ? "Passwort" : "") + (passwordAuth && pubkeyAuth ? " und " : "") + (pubkeyAuth ? "Pubkey" : ""))) + (!passwordAuth && !pubkeyAuth ? "Keine" : ((passwordAuth ? "Passwort" : "") + (passwordAuth && pubkeyAuth ? " und " : "") + (pubkeyAuth ? "Pubkey" : ""))) +
"\n\nVorhanden in Konfiguration für '" + this.server.getName() + "': " + (this.server.getPassword().isEmpty() && this.server.getKeypair() == null ? "Keine" : "\n\nVorhanden in Konfiguration für '" + this.server.getName() + "': " + (this.server.getPassword().isEmpty() && this.server.getKeypair() == null ? "Keine" :
((this.server.getPassword().isEmpty() ? "Passwort" : "") + ((!this.server.getPassword().isEmpty() ? "Passwort" : "") +
(this.server.getPassword().isEmpty() && this.server.getKeypair() != null ? " und " : "") + (this.server.getKeypair() != null ? "Pubkey" : "")))); (!this.server.getPassword().isEmpty() && this.server.getKeypair() != null ? " und " : "") + (this.server.getKeypair() != null ? "Pubkey" : ""))));
return; return;
} }
if(auth && pubkeyAuth && this.server.getKeypair() != null) { if(auth && pubkeyAuth && this.server.getKeypair() != null) {

View file

@ -1,38 +0,0 @@
package client.renderer.tileentity;
import org.lwjgl.opengl.GL11;
import client.Client;
import common.entity.Entity;
import common.tileentity.TileEntityMobSpawner;
public class TileEntityMobSpawnerRenderer extends TileEntitySpecialRenderer<TileEntityMobSpawner>
{
public void renderTileEntityAt(TileEntityMobSpawner te, double x, double y, double z, float partialTicks, int destroyStage)
{
GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y, (float)z + 0.5F);
renderMob(te, x, y, z, partialTicks);
GL11.glPopMatrix();
}
/**
* Render the mob inside the mob spawner.
*/
public static void renderMob(TileEntityMobSpawner mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks)
{
Entity entity = mobSpawnerLogic.createRenderEntity(mobSpawnerLogic.getWorld());
if (entity != null)
{
float f = 0.4375F;
GL11.glTranslatef(0.0F, 0.4F, 0.0F);
GL11.glRotatef((float)(mobSpawnerLogic.getPrevMobRotation() + (mobSpawnerLogic.getMobRotation() - mobSpawnerLogic.getPrevMobRotation()) * (double)partialTicks) * 10.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F);
GL11.glTranslatef(0.0F, -0.4F, 0.0F);
GL11.glScalef(f, f, f);
entity.setLocationAndAngles(posX, posY, posZ, 0.0F, 0.0F);
Client.CLIENT.getRenderManager().renderEntity(entity, 0.0D, 0.0D, 0.0D, partialTicks);
}
}
}

View file

@ -11,7 +11,6 @@ import common.entity.Entity;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityBanner; import common.tileentity.TileEntityBanner;
import common.tileentity.TileEntityChest; import common.tileentity.TileEntityChest;
import common.tileentity.TileEntityMobSpawner;
import common.tileentity.TileEntityPiston; import common.tileentity.TileEntityPiston;
import common.tileentity.TileEntitySign; import common.tileentity.TileEntitySign;
import common.util.BlockPos; import common.util.BlockPos;
@ -47,7 +46,6 @@ public class TileEntityRendererDispatcher
private TileEntityRendererDispatcher() private TileEntityRendererDispatcher()
{ {
this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer()); this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer());
this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer()); this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer());
this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer()); this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer()); this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer());

View file

@ -695,18 +695,6 @@ public class WorldClient extends AWorldClient
this.playSoundAtPos(blockPosIn, SoundEvent.GLASS, 1.0F); this.playSoundAtPos(blockPosIn, SoundEvent.GLASS, 1.0F);
break; break;
case 2004:
for (int k = 0; k < 20; ++k)
{
double d3 = (double)blockPosIn.getX() + 0.5D + ((double)this.rand.floatv() - 0.5D) * 2.0D;
double d5 = (double)blockPosIn.getY() + 0.5D + ((double)this.rand.floatv() - 0.5D) * 2.0D;
double d7 = (double)blockPosIn.getZ() + 0.5D + ((double)this.rand.floatv() - 0.5D) * 2.0D;
this.spawnParticle(ParticleType.SMOKE_NORMAL, d3, d5, d7, 0.0D, 0.0D, 0.0D);
this.spawnParticle(ParticleType.FLAME, d3, d5, d7, 0.0D, 0.0D, 0.0D);
}
return;
case 2005: case 2005:
ItemDye.spawnBonemealParticles(this, blockPosIn, data); ItemDye.spawnBonemealParticles(this, blockPosIn, data);
} }

View file

@ -1,91 +1,16 @@
package common.block.tech; package common.block.tech;
import common.block.BlockContainer;
import common.block.Material;
import common.item.CheatTab;
import common.item.Item;
import common.model.BlockLayer; import common.model.BlockLayer;
import common.rng.Random;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityMobSpawner; import common.tileentity.TileEntityMobSpawner;
import common.util.BlockPos;
import common.world.State;
import common.world.World; import common.world.World;
public class BlockMobSpawner extends BlockContainer public class BlockMobSpawner extends BlockMachine {
{ public TileEntity createNewTileEntity(World world) {
public BlockMobSpawner() return new TileEntityMobSpawner();
{ }
super(Material.SOLID);
this.setTab(CheatTab.TECHNOLOGY);
}
/** public BlockLayer getBlockLayer() {
* Returns a new instance of a block's tile entity class. Called on placing the block. return BlockLayer.CUTOUT;
*/ }
public TileEntity createNewTileEntity(World worldIn)
{
return new TileEntityMobSpawner();
}
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(State state, Random rand, int fortune)
{
return null;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random random)
{
return 0;
}
/**
* Spawns this Block's drops into the World as EntityItems.
*/
public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, State state, float chance, int fortune)
{
super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune);
int i = worldIn.rand.rangeBonus(15, 29, 14);
this.dropXpOnBlockBreak(worldIn, pos, i);
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
*/
public int getRenderType()
{
return 3;
}
public BlockLayer getBlockLayer()
{
return BlockLayer.CUTOUT;
}
public Item getItem(World worldIn, BlockPos pos)
{
return null;
}
public boolean isXrayVisible()
{
return true;
}
public boolean isMagnetic() {
return true;
}
} }

View file

@ -11,7 +11,7 @@ import common.world.State;
import common.world.World; import common.world.World;
public class BlockTianReactor extends BlockMachine { public class BlockTianReactor extends BlockMachine {
public TileEntity createNewTileEntity(World worldIn) { public TileEntity createNewTileEntity(World world) {
return new TileEntityTianReactor(); return new TileEntityTianReactor();
} }

View file

@ -610,7 +610,7 @@ public abstract class BlockRegistry {
registerBlock(2000, "core", new BlockCore().setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE) registerBlock(2000, "core", new BlockCore().setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE)
.setDisplay("Chunk-Lade-Kern")); .setDisplay("Chunk-Lade-Kern"));
registerBlock(2001, "mob_spawner", registerBlock(2001, "mob_spawner",
(new BlockMobSpawner()).setHardness(5.0F).setStepSound(SoundType.STONE).setDisplay("Monsterspawner")); (new BlockMobSpawner()).setHardness(3.0F).setResistance(8.0F).setStepSound(SoundType.STONE).setDisplay("Mob-Spawner"));
registerBlock(2002, "workbench", (new BlockWorkbench(3)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Werkbank")); registerBlock(2002, "workbench", (new BlockWorkbench(3)).setHardness(2.5F).setStepSound(SoundType.WOOD).setDisplay("Werkbank"));
registerBlock(2003, "furnace", (new BlockFurnace(false)).setHardness(3.5F).setStepSound(SoundType.STONE).setDisplay("Ofen") registerBlock(2003, "furnace", (new BlockFurnace(false)).setHardness(3.5F).setStepSound(SoundType.STONE).setDisplay("Ofen")
.setTab(CheatTab.TECHNOLOGY)); .setTab(CheatTab.TECHNOLOGY));

View file

@ -41,7 +41,6 @@ public abstract class TileRegistry {
addMapping(TileEntityDispenser.class, "Trap"); addMapping(TileEntityDispenser.class, "Trap");
addMapping(TileEntityDropper.class, "Dropper"); addMapping(TileEntityDropper.class, "Dropper");
addMapping(TileEntitySign.class, "Sign"); addMapping(TileEntitySign.class, "Sign");
addMapping(TileEntityMobSpawner.class, "MobSpawner");
addMapping(TileEntityPiston.class, "Piston"); addMapping(TileEntityPiston.class, "Piston");
addMapping(TileEntityBrewingStand.class, "Cauldron"); addMapping(TileEntityBrewingStand.class, "Cauldron");
addMapping(TileEntityEnchantmentTable.class, "EnchantTable"); addMapping(TileEntityEnchantmentTable.class, "EnchantTable");
@ -51,5 +50,6 @@ public abstract class TileRegistry {
addMapping(TileEntityComparator.class, "Comparator"); addMapping(TileEntityComparator.class, "Comparator");
addMapping(TileEntityBanner.class, "Banner"); addMapping(TileEntityBanner.class, "Banner");
addMapping(TileEntityTianReactor.class, "TianReactor"); addMapping(TileEntityTianReactor.class, "TianReactor");
addMapping(TileEntityMobSpawner.class, "MobSpawner");
} }
} }

View file

@ -99,7 +99,11 @@ public class ContainerTile extends Container
public void onCraftGuiOpened(ICrafting listener) public void onCraftGuiOpened(ICrafting listener)
{ {
super.onCraftGuiOpened(listener); super.onCraftGuiOpened(listener);
// listener.sendAllWindowProperties(this, this.machine); listener.sendProgressBarUpdate(this, this.resources.length, this.tile.getTemperature());
listener.sendProgressBarUpdate(this, this.resources.length + 1, this.tile.getStatus().ordinal());
for(int z = 0; z < this.resources.length; z++) {
listener.sendProgressBarUpdate(this, z, this.tile.getResource(z).getValue());
}
} }
public void updateProgressBar(int id, int data) public void updateProgressBar(int id, int data)
@ -118,14 +122,14 @@ public class ContainerTile extends Container
for (int i = 0; i < this.crafters.size(); ++i) for (int i = 0; i < this.crafters.size(); ++i)
{ {
ICrafting icrafting = (ICrafting)this.crafters.get(i); ICrafting listener = this.crafters.get(i);
if(this.temperature != this.tile.getTemperature()) if(this.temperature != this.tile.getTemperature())
icrafting.sendProgressBarUpdate(this, this.resources.length, this.tile.getTemperature()); listener.sendProgressBarUpdate(this, this.resources.length, this.tile.getTemperature());
if(this.status != this.tile.getStatus()) if(this.status != this.tile.getStatus())
icrafting.sendProgressBarUpdate(this, this.resources.length + 1, this.tile.getStatus().ordinal()); listener.sendProgressBarUpdate(this, this.resources.length + 1, this.tile.getStatus().ordinal());
for(int z = 0; z < this.resources.length; z++) { for(int z = 0; z < this.resources.length; z++) {
if(this.resources[z] != this.tile.getResource(z).getValue()) if(this.resources[z] != this.tile.getResource(z).getValue())
icrafting.sendProgressBarUpdate(this, z, this.tile.getResource(z).getValue()); listener.sendProgressBarUpdate(this, z, this.tile.getResource(z).getValue());
} }
} }

View file

@ -9,14 +9,11 @@ import common.dimension.Dimension;
import common.entity.Entity; import common.entity.Entity;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.init.EntityInfo; import common.init.EntityInfo;
import common.init.EntityRegistry; import common.init.EntityRegistry;
import common.init.UniverseRegistry; import common.init.UniverseRegistry;
import common.model.Model; import common.model.Model;
import common.model.ModelProvider; import common.model.ModelProvider;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityMobSpawner;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.ExtMath; import common.util.ExtMath;
import common.util.Facing; import common.util.Facing;
@ -83,26 +80,6 @@ public class ItemMonsterPlacer extends Item
{ {
State iblockstate = worldIn.getState(pos); State iblockstate = worldIn.getState(pos);
if (iblockstate.getBlock() == Blocks.mob_spawner)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityMobSpawner)
{
// MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic();
((TileEntityMobSpawner)tileentity).setEntityName(this.entityId);
tileentity.markDirty();
worldIn.markBlockForUpdate(pos);
// if (!playerIn.creative)
// {
--stack.size;
// }
return true;
}
}
pos = pos.offset(side); pos = pos.offset(side);
double d0 = 0.0D; double d0 = 0.0D;
@ -207,38 +184,21 @@ public class ItemMonsterPlacer extends Item
} }
} }
/** public static EntityLiving spawnCreature(World worldIn, String entityID, double x, double y, double z) {
* Spawns the creature specified by the egg's type in the location specified by the last three parameters.
* Parameters: world, entityID, x, y, z.
*/
public static Entity spawnCreature(World worldIn, String entityID, double x, double y, double z)
{
if (!EntityRegistry.SPAWN_EGGS.containsKey(entityID)) if (!EntityRegistry.SPAWN_EGGS.containsKey(entityID))
{
return null; return null;
} Entity entity = EntityRegistry.createEntityByName(entityID, worldIn);
else if(!(entity instanceof EntityLiving living))
{ return null;
Entity entity = null; living.setLocationAndAngles(x, y, z, ExtMath.wrapf(worldIn.rand.floatv() * 360.0F), 0.0F);
if(!living.isNotColliding())
for (int i = 0; i < 1; ++i) return null;
{ living.headYaw = living.rotYaw;
entity = EntityRegistry.createEntityByName(entityID, worldIn); living.yawOffset = living.rotYaw;
living.onInitialSpawn(null);
if (entity instanceof EntityLiving) worldIn.spawnEntityInWorld(living);
{ living.playLivingSound();
EntityLiving entityliving = (EntityLiving)entity; return living;
entity.setLocationAndAngles(x, y, z, ExtMath.wrapf(worldIn.rand.floatv() * 360.0F), 0.0F);
entityliving.headYaw = entityliving.rotYaw;
entityliving.yawOffset = entityliving.rotYaw;
entityliving.onInitialSpawn(null);
worldIn.spawnEntityInWorld(entity);
entityliving.playLivingSound();
}
}
return entity;
}
} }
// /** // /**

View file

@ -33,16 +33,25 @@ public class ItemNpcSpawner extends Item
this.setTab(CheatTab.SPAWNERS); this.setTab(CheatTab.SPAWNERS);
this.spawned = spawned; this.spawned = spawned;
} }
public String getDisplay(ItemStack stack) public CharacterInfo getSpawnedChar() {
{ return this.spawned;
String item = "Erschaffe"; }
CharacterInfo info = this.spawned; // SpeciesRegistry.CHARACTERS.get(stack.getMetadata() % SpeciesRegistry.CHARACTERS.size());
public String getCharName() {
CharacterInfo info = this.spawned; // SpeciesRegistry.CHARACTERS.get(stack.getMetadata() % SpeciesRegistry.CHARACTERS.size());
String species = EntityRegistry.getEntityName(info.species.id); String species = EntityRegistry.getEntityName(info.species.id);
if(info.species.prefix && info.type != null && !info.type.toString().isEmpty()) if(info.species.prefix && info.type != null && !info.type.toString().isEmpty())
species = info.type.toString(); species = info.type.toString();
String character = info.name; String character = info.name;
item = item + " " + species + (character.isEmpty() ? "" : (" " + character)); return species + (character.isEmpty() ? "" : (" " + character));
}
public String getDisplay(ItemStack stack)
{
String item = "Erschaffe";
item = item + " " + this.getCharName();
return item; return item;
} }
@ -161,9 +170,8 @@ public class ItemNpcSpawner extends Item
} }
} }
public static Entity spawnNpc(World worldIn, CharacterInfo character, double x, double y, double z) public static EntityNPC spawnNpc(World worldIn, CharacterInfo character, double x, double y, double z)
{ {
// CharacterInfo character = SpeciesRegistry.CHARACTERS.get(entityID % SpeciesRegistry.CHARACTERS.size());
EntityNPC entity; EntityNPC entity;
try { try {
entity = character.species.clazz.getConstructor(World.class).newInstance(worldIn); entity = character.species.clazz.getConstructor(World.class).newInstance(worldIn);
@ -172,10 +180,11 @@ public class ItemNpcSpawner extends Item
throw new RuntimeException(e); throw new RuntimeException(e);
} }
entity.setLocationAndAngles(x, y, z, ExtMath.wrapf(worldIn.rand.floatv() * 360.0F), 0.0F); entity.setLocationAndAngles(x, y, z, ExtMath.wrapf(worldIn.rand.floatv() * 360.0F), 0.0F);
if(!entity.isNotColliding())
return null;
entity.headYaw = entity.rotYaw; entity.headYaw = entity.rotYaw;
entity.yawOffset = entity.rotYaw; entity.yawOffset = entity.rotYaw;
entity.onInitialSpawn(new CharacterTypeData(character)); entity.onInitialSpawn(new CharacterTypeData(character));
// entity.setFromInfo(character);
worldIn.spawnEntityInWorld(entity); worldIn.spawnEntityInWorld(entity);
return entity; return entity;
} }

View file

@ -42,9 +42,18 @@ public abstract class TileEntityDevice extends TileEntityLockable implements IHo
this.resources = resources; this.resources = resources;
} }
protected abstract int getTempIncrement(); protected int getTempIncrement() {
protected abstract int getTempDecrement(); return -1;
protected abstract int getMaxTemp(); }
protected int getTempDecrement() {
return -1;
}
protected int getMaxTemp() {
return Integer.MAX_VALUE;
}
protected abstract boolean executeFunction(); protected abstract boolean executeFunction();
public MachineResource getResource(int slot) { public MachineResource getResource(int slot) {
@ -203,7 +212,10 @@ public abstract class TileEntityDevice extends TileEntityLockable implements IHo
if(this.worldObj != null && !this.worldObj.client && this.status != Status.BROKEN) { if(this.worldObj != null && !this.worldObj.client && this.status != Status.BROKEN) {
int envTemp = (int)this.worldObj.getTemperatureC(this.getPos()); int envTemp = (int)this.worldObj.getTemperatureC(this.getPos());
if(this.executeFunction()) { if(this.executeFunction()) {
this.temperature += this.getTempIncrement(); if(this.getTempIncrement() < 0)
this.temperature = envTemp;
else
this.temperature += this.getTempIncrement();
this.status = this.temperature >= (this.getMaxTemp() * 9) / 10 ? Status.OVERHEAT : Status.RUNNING; this.status = this.temperature >= (this.getMaxTemp() * 9) / 10 ? Status.OVERHEAT : Status.RUNNING;
if(this.temperature > this.getMaxTemp()) { if(this.temperature > this.getMaxTemp()) {
this.status = Status.BROKEN; this.status = Status.BROKEN;
@ -219,7 +231,10 @@ public abstract class TileEntityDevice extends TileEntityLockable implements IHo
int dec = this.getTempDecrement(); int dec = this.getTempDecrement();
if(dec != 0) { if(dec != 0) {
int prev = this.temperature; int prev = this.temperature;
this.temperature -= dec; if(dec < 0)
this.temperature = envTemp;
else
this.temperature -= dec;
this.temperature = ExtMath.clampi(this.temperature, envTemp, Integer.MAX_VALUE); this.temperature = ExtMath.clampi(this.temperature, envTemp, Integer.MAX_VALUE);
if(prev != this.temperature) if(prev != this.temperature)
this.markDirty(); this.markDirty();
@ -318,5 +333,5 @@ public abstract class TileEntityDevice extends TileEntityLockable implements IHo
return 0x8080ff; return 0x8080ff;
} }
public abstract String formatDisplay(); public abstract String formatDisplay(ContainerTile inv);
} }

View file

@ -1,150 +1,70 @@
package common.tileentity; package common.tileentity;
import common.entity.Entity;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.init.EntityRegistry; import common.init.EntityRegistry;
import common.model.ParticleType; import common.inventory.ContainerTile;
import common.network.Packet; import common.item.ItemMonsterPlacer;
import common.packet.SPacketUpdateTileEntity; import common.item.ItemNpcSpawner;
import common.item.ItemStack;
import common.tags.TagObject; import common.tags.TagObject;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.vars.Vars; import common.vars.Vars;
import common.world.World;
public class TileEntityMobSpawner extends TileEntity implements ITickable public class TileEntityMobSpawner extends TileEntityDevice implements ITickable
{ {
private int spawnDelay = 20; public TileEntityMobSpawner() {
private String mobID = "Pig"; super(1);
private double mobRotation; }
private double prevMobRotation;
private int spawnDelay = 20;
private int minSpawnDelay = 200; private int minSpawnDelay = 200;
private int maxSpawnDelay = 800; private int maxSpawnDelay = 800;
private int spawnCount = 4;
private Entity cachedEntity;
private int maxNearbyEntities = 6;
private int activatingRangeFromPlayer = 16;
private int spawnRange = 4; private int spawnRange = 4;
public Packet getDescriptionPacket()
{
return new SPacketUpdateTileEntity(this);
}
public boolean receiveClientEvent(int id, int type) public boolean isItemValidForSlot(int index, ItemStack stack) {
{ return index == 0 ? stack.getItem() instanceof ItemMonsterPlacer || stack.getItem() instanceof ItemNpcSpawner : false;
if (id == 1 && this.worldObj.client) }
{
this.spawnDelay = this.minSpawnDelay; public String getName() {
return "Mob-Spawner";
}
public String getGuiID() {
return "mob_spawner";
}
public String formatDisplay(ContainerTile inv) {
ItemStack stack = inv.getSlot(0).getStack();
if(stack == null)
return "Kein Spawner vorhanden";
return String.format("Erschaffe: %s", stack.getItem() instanceof ItemMonsterPlacer egg ? EntityRegistry.getEntityName(egg.getSpawnedId()) : ((stack.getItem() instanceof ItemNpcSpawner egg ? egg.getCharName() : "<?>")));
}
protected boolean executeFunction() {
if(!Vars.mobs || !Vars.spawners || !this.hasAmount(0, 1))
return false;
if (this.spawnDelay == -1)
this.resetTimer();
if (this.spawnDelay > 0) {
--this.spawnDelay;
return true; return true;
} }
else ItemStack stack = this.getStackInSlot(0);
{ if(stack == null)
return super.receiveClientEvent(id, type); return true;
} double x = (double)this.pos.getX() + (this.worldObj.rand.doublev() - this.worldObj.rand.doublev()) * (double)this.spawnRange + 0.5D;
} double y = (double)(this.pos.getY() + this.worldObj.rand.zrange(3) - 1);
double z = (double)this.pos.getZ() + (this.worldObj.rand.doublev() - this.worldObj.rand.doublev()) * (double)this.spawnRange + 0.5D;
// public boolean hasSpecialNBT() EntityLiving entity = null;
// { if(stack.getItem() instanceof ItemMonsterPlacer egg)
// return true; entity = ItemMonsterPlacer.spawnCreature(this.worldObj, egg.getSpawnedId(), x, y, z);
// } else if(stack.getItem() instanceof ItemNpcSpawner egg)
entity = ItemNpcSpawner.spawnNpc(this.worldObj, egg.getSpawnedChar(), x, y, z);
public int getColor() { if (entity == null)
return 0xff0000; return true;
} this.decrStackSize(0, 1);
entity.spawnExplosionParticle();
public void update() this.resetTimer();
{ return true;
BlockPos blockpos = this.pos;
if (this.worldObj.isAnyPlayerWithinRangeAt((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D, (double)this.activatingRangeFromPlayer))
{
if (this.worldObj.client)
{
double d3 = (double)((float)blockpos.getX() + this.worldObj.rand.floatv());
double d4 = (double)((float)blockpos.getY() + this.worldObj.rand.floatv());
double d5 = (double)((float)blockpos.getZ() + this.worldObj.rand.floatv());
this.worldObj.spawnParticle(ParticleType.SMOKE_NORMAL, d3, d4, d5, 0.0D, 0.0D, 0.0D);
this.worldObj.spawnParticle(ParticleType.FLAME, d3, d4, d5, 0.0D, 0.0D, 0.0D);
if (this.spawnDelay > 0)
{
--this.spawnDelay;
}
this.prevMobRotation = this.mobRotation;
this.mobRotation = (this.mobRotation + (double)(1000.0F / ((float)this.spawnDelay + 200.0F))) % 360.0D;
}
else
{
if(!Vars.mobs || !Vars.spawners) {
return;
}
if (this.spawnDelay == -1)
{
this.resetTimer();
}
if (this.spawnDelay > 0)
{
--this.spawnDelay;
return;
}
boolean flag = false;
for (int i = 0; i < this.spawnCount; ++i)
{
Entity entity = EntityRegistry.createEntityByName(this.mobID, this.worldObj);
if (entity == null)
{
return;
}
int j = this.worldObj.getEntitiesWithinAABB(entity.getClass(), (new BoundingBox((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ(), (double)(blockpos.getX() + 1), (double)(blockpos.getY() + 1), (double)(blockpos.getZ() + 1))).expand((double)this.spawnRange, (double)this.spawnRange, (double)this.spawnRange)).size();
if (j >= this.maxNearbyEntities)
{
this.resetTimer();
return;
}
double d0 = (double)blockpos.getX() + (this.worldObj.rand.doublev() - this.worldObj.rand.doublev()) * (double)this.spawnRange + 0.5D;
double d1 = (double)(blockpos.getY() + this.worldObj.rand.zrange(3) - 1);
double d2 = (double)blockpos.getZ() + (this.worldObj.rand.doublev() - this.worldObj.rand.doublev()) * (double)this.spawnRange + 0.5D;
EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving)entity : null;
entity.setLocationAndAngles(d0, d1, d2, this.worldObj.rand.floatv() * 360.0F, 0.0F);
if (entityliving == null || entityliving.getCanSpawnHere() && entityliving.isNotColliding())
{
if (entity instanceof EntityLiving && entity.worldObj != null)
{
// if (entity instanceof EntityLiving)
// {
((EntityLiving)entity).onInitialSpawn(null);
// }
entity.worldObj.spawnEntityInWorld(entity);
}
this.worldObj.playAuxSFX(2004, blockpos, 0);
if (entityliving != null)
{
entityliving.spawnExplosionParticle();
}
flag = true;
}
}
if (flag)
{
this.resetTimer();
}
}
}
} }
private void resetTimer() private void resetTimer()
@ -158,86 +78,31 @@ public class TileEntityMobSpawner extends TileEntity implements ITickable
int i = this.maxSpawnDelay - this.minSpawnDelay; int i = this.maxSpawnDelay - this.minSpawnDelay;
this.spawnDelay = this.minSpawnDelay + this.worldObj.rand.zrange(i); this.spawnDelay = this.minSpawnDelay + this.worldObj.rand.zrange(i);
} }
this.worldObj.addBlockEvent(TileEntityMobSpawner.this.pos, Blocks.mob_spawner, 1, 0);
} }
public void readTags(TagObject nbt) public void readTags(TagObject nbt)
{ {
super.readTags(nbt); super.readTags(nbt);
this.mobID = nbt.getString("EntityId");
this.spawnDelay = nbt.getShort("Delay"); this.spawnDelay = nbt.getShort("Delay");
if (nbt.hasShort("MinSpawnDelay")) if (nbt.hasShort("MinSpawnDelay"))
{ {
this.minSpawnDelay = nbt.getShort("MinSpawnDelay"); this.minSpawnDelay = nbt.getShort("MinSpawnDelay");
this.maxSpawnDelay = nbt.getShort("MaxSpawnDelay"); this.maxSpawnDelay = nbt.getShort("MaxSpawnDelay");
this.spawnCount = nbt.getShort("SpawnCount");
}
if (nbt.hasShort("MaxNearbyEntities"))
{
this.maxNearbyEntities = nbt.getShort("MaxNearbyEntities");
this.activatingRangeFromPlayer = nbt.getShort("RequiredPlayerRange");
} }
if (nbt.hasShort("SpawnRange")) if (nbt.hasShort("SpawnRange"))
{ {
this.spawnRange = nbt.getShort("SpawnRange"); this.spawnRange = nbt.getShort("SpawnRange");
} }
if (this.worldObj != null)
{
this.cachedEntity = null;
}
} }
public void writeTags(TagObject nbt) public void writeTags(TagObject nbt)
{ {
super.writeTags(nbt); super.writeTags(nbt);
String s = this.mobID; nbt.setShort("Delay", (short)this.spawnDelay);
nbt.setShort("MinSpawnDelay", (short)this.minSpawnDelay);
if (s != null && !s.isEmpty()) nbt.setShort("MaxSpawnDelay", (short)this.maxSpawnDelay);
{ nbt.setShort("SpawnRange", (short)this.spawnRange);
nbt.setString("EntityId", s);
nbt.setShort("Delay", (short)this.spawnDelay);
nbt.setShort("MinSpawnDelay", (short)this.minSpawnDelay);
nbt.setShort("MaxSpawnDelay", (short)this.maxSpawnDelay);
nbt.setShort("SpawnCount", (short)this.spawnCount);
nbt.setShort("MaxNearbyEntities", (short)this.maxNearbyEntities);
nbt.setShort("RequiredPlayerRange", (short)this.activatingRangeFromPlayer);
nbt.setShort("SpawnRange", (short)this.spawnRange);
}
}
public Entity createRenderEntity(World worldIn)
{
if (this.cachedEntity == null)
{
this.cachedEntity = EntityRegistry.createEntityByName(this.mobID, worldIn);
// if (entity != null)
// {
//// entity = this.spawnNewEntity(entity, false);
// this.cachedEntity = entity;
// }
}
return this.cachedEntity;
}
public double getMobRotation()
{
return this.mobRotation;
}
public double getPrevMobRotation()
{
return this.prevMobRotation;
}
public void setEntityName(String name)
{
this.mobID = name;
} }
} }

View file

@ -3,6 +3,7 @@ package common.tileentity;
import common.init.Blocks; import common.init.Blocks;
import common.init.ItemRegistry; import common.init.ItemRegistry;
import common.init.Items; import common.init.Items;
import common.inventory.ContainerTile;
import common.item.ItemStack; import common.item.ItemStack;
import common.tileentity.MachineResource.Type; import common.tileentity.MachineResource.Type;
@ -46,7 +47,7 @@ public class TileEntityTianReactor extends TileEntityDevice {
return "tian_reactor"; return "tian_reactor";
} }
public String formatDisplay() { public String formatDisplay(ContainerTile inv) {
return String.format("Gespeicherte Energie: %d TF", this.getResource(0).getValue()); return String.format("Gespeicherte Energie: %d TF", this.getResource(0).getValue());
} }

View file

@ -11,7 +11,13 @@ public abstract class SVars extends Vars {
@Var(name = "spawnVillagers") @Var(name = "spawnVillagers")
public static boolean spawnVillager = true; public static boolean spawnVillager = true;
@Var(name = "spawnCagedVillagers") @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") @Var(name = "spawnHutMages")
public static boolean spawnHutMage = true; public static boolean spawnHutMage = true;
@Var(name = "daylightCycle") @Var(name = "daylightCycle")
@ -82,6 +88,8 @@ public abstract class SVars extends Vars {
public static int minPassLength = 8; public static int minPassLength = 8;
@Var(name = "port", min = 1024, max = 32767, nonDefault = true) @Var(name = "port", min = 1024, max = 32767, nonDefault = true)
public static int port = -1; public static int port = -1;
@Var(name = "spawnDungeonMobs")
public static int spawnDungeonMobs = 4;
@Var(name = "gravity") @Var(name = "gravity")
public static float gravity = 1.0f; public static float gravity = 1.0f;

View file

@ -78,7 +78,6 @@ import common.tileentity.TileEntityDropper;
import common.tileentity.TileEntityEnchantmentTable; import common.tileentity.TileEntityEnchantmentTable;
import common.tileentity.TileEntityFurnace; import common.tileentity.TileEntityFurnace;
import common.tileentity.TileEntityHopper; import common.tileentity.TileEntityHopper;
import common.tileentity.TileEntityMobSpawner;
import common.tileentity.TileEntitySign; import common.tileentity.TileEntitySign;
import common.util.Facing; import common.util.Facing;
import common.util.NibbleArray; import common.util.NibbleArray;
@ -343,7 +342,6 @@ public abstract class Converter {
mapTile(TileEntityDispenser.class, "Trap", "dispenser"); mapTile(TileEntityDispenser.class, "Trap", "dispenser");
mapTile(TileEntityDropper.class, "Dropper", "dropper"); mapTile(TileEntityDropper.class, "Dropper", "dropper");
mapTile(TileEntitySign.class, "Sign", "sign"); mapTile(TileEntitySign.class, "Sign", "sign");
mapTile(TileEntityMobSpawner.class, "MobSpawner", "mob_spawner");
// mapTile(TileEntityPiston.class, "Piston", "piston"); // mapTile(TileEntityPiston.class, "Piston", "piston");
mapTile(TileEntityEnchantmentTable.class, "EnchantTable", "enchanting_table"); mapTile(TileEntityEnchantmentTable.class, "EnchantTable", "enchanting_table");
mapTile(TileEntityBeacon.class, "Beacon", "beacon"); mapTile(TileEntityBeacon.class, "Beacon", "beacon");
@ -576,7 +574,7 @@ public abstract class Converter {
return Blocks.fire.getState().withProperty(BlockFire.AGE, data); return Blocks.fire.getState().withProperty(BlockFire.AGE, data);
} }
}, 51); }, 51);
mapBlock(Blocks.mob_spawner, 52); mapBlock(Blocks.iron_bars, 52);
mapBlockData(Blocks.oak_stairs, 53); mapBlockData(Blocks.oak_stairs, 53);
mapBlockData(Blocks.chest, 54); mapBlockData(Blocks.chest, 54);
mapBlockData(Blocks.redstone, 55); mapBlockData(Blocks.redstone, 55);

View file

@ -1,22 +1,28 @@
package server.worldgen; package server.worldgen;
import java.lang.reflect.InvocationTargetException;
import common.block.Material; 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.Blocks;
import common.init.Items; import common.init.Items;
import common.item.RngLoot; import common.item.RngLoot;
import common.log.Log;
import common.rng.Random; import common.rng.Random;
import common.rng.WeightedList; import common.rng.WeightedList;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest; import common.tileentity.TileEntityChest;
import common.tileentity.TileEntityMobSpawner;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.Facing; import common.util.Facing;
import common.world.World;
import server.vars.SVars;
import server.world.WorldServer; import server.world.WorldServer;
public class FeatureDungeons 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; private final int chance;
@ -148,16 +154,15 @@ public class FeatureDungeons
} }
} }
worldIn.setState(position, Blocks.mob_spawner.getState(), 2); if(SVars.mobs && SVars.spawnDungeonMobs > 0) {
TileEntity tileentity = worldIn.getTileEntity(position); for(int z = 0; z < SVars.spawnDungeonMobs; z++) {
EntityLiving entity = this.pickMobSpawner(rand, worldIn);
if (tileentity instanceof TileEntityMobSpawner) 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);
((TileEntityMobSpawner)tileentity).setEntityName(this.pickMobSpawner(rand)); worldIn.spawnEntityInWorld(entity);
} if(rand.chance(5))
else break;
{ }
Log.TICK.warn("Konnte kein Mob-Spawner-Objekt bei (" + position.getX() + ", " + position.getY() + ", " + position.getZ() + ") erstellen");
} }
return true; return true;
@ -168,11 +173,13 @@ public class FeatureDungeons
} }
} }
/** private EntityLiving pickMobSpawner(Random rand, WorldServer world)
* Randomly decides which spawner to use in a dungeon
*/
private String pickMobSpawner(Random p_76543_1_)
{ {
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);
}
} }
} }

View file

@ -3,13 +3,13 @@ package server.worldgen.structure;
import java.util.List; import java.util.List;
import common.collect.Lists; import common.collect.Lists;
import common.entity.npc.EntityDarkMage;
import common.init.Blocks; import common.init.Blocks;
import common.rng.Random; import common.rng.Random;
import common.tags.TagObject; import common.tags.TagObject;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityMobSpawner;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.Facing; import common.util.Facing;
import server.vars.SVars;
import server.world.WorldServer; import server.world.WorldServer;
import server.worldgen.LootConstants; 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, 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); 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)); BlockPos blockpos = new BlockPos(this.getXWithOffset(3, 5), this.getYWithOffset(5), this.getZWithOffset(3, 5));
if (structureBoundingBoxIn.isVecInside(blockpos)) if (structureBoundingBoxIn.isVecInside(blockpos))
{ {
this.hasSpawner = true; this.hasSpawner = true;
worldIn.setState(blockpos, Blocks.mob_spawner.getState(), 2); EntityDarkMage entity = new EntityDarkMage(worldIn);
TileEntity tileentity = worldIn.getTileEntity(blockpos); 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);
if (tileentity instanceof TileEntityMobSpawner) worldIn.spawnEntityInWorld(entity);
{
((TileEntityMobSpawner)tileentity).setEntityName("DarkMage");
}
} }
} }

View file

@ -4,17 +4,17 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import common.entity.item.EntityChestCart; import common.entity.item.EntityChestCart;
import common.entity.npc.EntityArachnoid;
import common.init.Blocks; import common.init.Blocks;
import common.init.Items; import common.init.Items;
import common.item.RngLoot; import common.item.RngLoot;
import common.rng.Random; import common.rng.Random;
import common.rng.WeightedList; import common.rng.WeightedList;
import common.tags.TagObject; import common.tags.TagObject;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityMobSpawner;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.Facing; import common.util.Facing;
import common.world.State; import common.world.State;
import server.vars.SVars;
import server.world.WorldServer; import server.world.WorldServer;
import server.worldgen.LootConstants; 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)); 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 l1 = this.getYWithOffset(0);
int i2 = k1 - 1 + randomIn.zrange(3); int i2 = k1 - 1 + randomIn.zrange(3);
@ -371,13 +371,10 @@ public class StructureMineshaft
if (structureBoundingBoxIn.isVecInside(blockpos)) if (structureBoundingBoxIn.isVecInside(blockpos))
{ {
this.spawnerPlaced = true; this.spawnerPlaced = true;
worldIn.setState(blockpos, Blocks.mob_spawner.getState(), 2); EntityArachnoid entity = new EntityArachnoid(worldIn);
TileEntity tileentity = worldIn.getTileEntity(blockpos); 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);
if (tileentity instanceof TileEntityMobSpawner) worldIn.spawnEntityInWorld(entity);
{
((TileEntityMobSpawner)tileentity).setEntityName("Arachnoid");
}
} }
} }
} }

View file

@ -7,15 +7,15 @@ import common.block.artificial.BlockSlab;
import common.block.artificial.BlockStoneBrick; import common.block.artificial.BlockStoneBrick;
import common.collect.Lists; import common.collect.Lists;
import common.collect.Maps; import common.collect.Maps;
import common.entity.npc.EntityHaunter;
import common.init.Blocks; import common.init.Blocks;
import common.init.Items; import common.init.Items;
import common.item.RngLoot; import common.item.RngLoot;
import common.rng.Random; import common.rng.Random;
import common.tags.TagObject; import common.tags.TagObject;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityMobSpawner;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.Facing; import common.util.Facing;
import server.vars.SVars;
import server.world.WorldServer; import server.world.WorldServer;
import server.worldgen.LootConstants; 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, 10, structureBoundingBoxIn);
// this.setBlockState(worldIn, Blocks.end_portal_frame.getStateFromMeta(j1).withProperty(BlockPortalFrame.ORB, Boolean.valueOf(randomIn.floatv() > 0.9F)), 7, 3, 11, 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); i = this.getYWithOffset(3);
BlockPos blockpos = new BlockPos(this.getXWithOffset(5, 6), i, this.getZWithOffset(5, 6)); BlockPos blockpos = new BlockPos(this.getXWithOffset(5, 6), i, this.getZWithOffset(5, 6));
@ -907,13 +907,10 @@ public class StructureStronghold
if (structureBoundingBoxIn.isVecInside(blockpos)) if (structureBoundingBoxIn.isVecInside(blockpos))
{ {
this.hasSpawner = true; this.hasSpawner = true;
worldIn.setState(blockpos, Blocks.mob_spawner.getState(), 2); EntityHaunter entity = new EntityHaunter(worldIn);
TileEntity tileentity = worldIn.getTileEntity(blockpos); 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);
if (tileentity instanceof TileEntityMobSpawner) worldIn.spawnEntityInWorld(entity);
{
((TileEntityMobSpawner)tileentity).setEntityName("Haunter");
}
} }
} }

View file

@ -1921,7 +1921,7 @@ public class StructureVillage
protected void spawnVillager(WorldServer worldIn, StructureBoundingBox p_74893_2_, int x, int y, int z) 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 j = this.getXWithOffset(x, z);
int k = this.getYWithOffset(y); int k = this.getYWithOffset(y);