Natural Spawn Entries:

-Added GUI options for new natural spawn attributes.
-Added 4 more entity options
-Fixed natural spawning not working at night
This commit is contained in:
Luis C.M committed 2022-06-29 14:21:55 -05:00
1 parent 55b21de050
commit dd700c677b
5 files changed
+221 -17

No files matched your search

@@ -21,6 +21,10 @@ public class SpawnData extends WeightedRandom.Item implements INaturalSpawn {
public int id = -1;
public String name = "";
public NBTTagCompound compound1 = new NBTTagCompound();
public NBTTagCompound compound2 = new NBTTagCompound();
public NBTTagCompound compound3 = new NBTTagCompound();
public NBTTagCompound compound4 = new NBTTagCompound();
public NBTTagCompound compound5 = new NBTTagCompound();
public boolean animalSpawning = true;
public boolean monsterSpawning = false;
@@ -43,6 +47,10 @@ public class SpawnData extends WeightedRandom.Item implements INaturalSpawn {
biomes = NBTTags.getStringList(compound.getTagList("SpawnBiomes", 10));
compound1 = compound.getCompoundTag("SpawnCompound1");
compound2 = compound.getCompoundTag("SpawnCompound2");
compound3 = compound.getCompoundTag("SpawnCompound3");
compound4 = compound.getCompoundTag("SpawnCompound4");
compound5 = compound.getCompoundTag("SpawnCompound5");
animalSpawning = compound.getBoolean("AnimalSpawning");
monsterSpawning = compound.getBoolean("MonsterSpawning");
@@ -64,6 +72,10 @@ public class SpawnData extends WeightedRandom.Item implements INaturalSpawn {
compound.setTag("SpawnBiomes", NBTTags.nbtStringList(biomes));
compound.setTag("SpawnCompound1", compound1);
compound.setTag("SpawnCompound2", compound2);
compound.setTag("SpawnCompound3", compound3);
compound.setTag("SpawnCompound4", compound4);
compound.setTag("SpawnCompound5", compound5);
compound.setBoolean("AnimalSpawning", animalSpawning);
compound.setBoolean("MonsterSpawning", monsterSpawning);
@@ -85,19 +97,68 @@ public class SpawnData extends WeightedRandom.Item implements INaturalSpawn {
return this.name;
}
public void setEntity(IEntity entity) {
public void setEntity(IEntity entity, int slot) {
if (slot < 1)
slot = 1;
if (slot > 5)
slot = 5;
NBTTagCompound compound = new NBTTagCompound();
if (!entity.getMCEntity().writeToNBTOptional(compound)) {
throw new CustomNPCsException("Entity could not be written to NBT");
} else {
ServerCloneController.Instance.cleanTags(compound1);
compound1 = compound;
switch (slot) {
case 1:
ServerCloneController.Instance.cleanTags(compound1);
compound1 = compound;
break;
case 2:
ServerCloneController.Instance.cleanTags(compound2);
compound2 = compound;
break;
case 3:
ServerCloneController.Instance.cleanTags(compound3);
compound3 = compound;
break;
case 4:
ServerCloneController.Instance.cleanTags(compound4);
compound4 = compound;
break;
case 5:
ServerCloneController.Instance.cleanTags(compound5);
compound5 = compound;
break;
}
}
}
public IEntity getEntity(IWorld world) {
public IEntity getEntity(IWorld world, int slot) {
if (slot < 1)
slot = 1;
if (slot > 5)
slot = 5;
try {
Entity entity = EntityList.createEntityFromNBT(compound1, world.getMCWorld());
NBTTagCompound compound = new NBTTagCompound();
switch (slot) {
case 1:
compound = compound1;
break;
case 2:
compound = compound2;
break;
case 3:
compound = compound3;
break;
case 4:
compound = compound4;
break;
case 5:
compound = compound5;
break;
}
Entity entity = EntityList.createEntityFromNBT(compound, world.getMCWorld());
return NpcAPI.Instance().getIEntity(entity);
} catch (Exception e) {
throw new CustomNPCsException("Error creating entity from spawn data:\n" + e.getMessage());