From f2c4f0ccaf76edfd69d2c493e9ce581fc585be60 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Wed, 29 Jun 2022 14:22:27 -0500 Subject: [PATCH] Missed files in the last commit. --- src/main/java/noppes/npcs/NPCSpawning.java | 29 ++++++++++++++----- .../gui/mainmenu/GuiNPCGlobalMainMenu.java | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/main/java/noppes/npcs/NPCSpawning.java b/src/main/java/noppes/npcs/NPCSpawning.java index c5f97607c..629c3d736 100644 --- a/src/main/java/noppes/npcs/NPCSpawning.java +++ b/src/main/java/noppes/npcs/NPCSpawning.java @@ -15,6 +15,7 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MathHelper; import net.minecraft.util.math.BlockPos; import net.minecraft.world.*; @@ -150,13 +151,27 @@ public class NPCSpawning { EntityLiving entityliving; try{ - Entity entity = EntityList.createEntityFromNBT(data.compound1, world); - if(entity == null || !(entity instanceof EntityLiving)) + NBTTagCompound[] allCompoundList = new NBTTagCompound[]{data.compound1,data.compound2,data.compound3,data.compound4,data.compound5}; + ArrayList entities = new ArrayList<>(); + for (NBTTagCompound compound : allCompoundList) { + Entity entity; + try { + entity = EntityList.createEntityFromNBT(compound, world); + } catch (Exception e) { + continue; + } + entities.add(entity); + } + + Entity spawnEntity = entities.get((int)Math.floor(Math.random()*entities.size())); + + if(!(spawnEntity instanceof EntityLiving)) return false; - entityliving = (EntityLiving) entity; + + entityliving = (EntityLiving) spawnEntity; - if(entity instanceof EntityCustomNpc){ - EntityCustomNpc npc = (EntityCustomNpc) entity; + if(spawnEntity instanceof EntityCustomNpc){ + EntityCustomNpc npc = (EntityCustomNpc) spawnEntity; npc.stats.spawnCycle = 3; npc.ai.returnToStart = false; npc.ai.startPos = new int[]{x,y, z}; @@ -164,7 +179,7 @@ public class NPCSpawning { npc.updateClient = true; npc.getNavigator().clearPathEntity(); } - entity.setLocationAndAngles(x + 0.5, y, z + 0.5, world.rand.nextFloat() * 360.0F, 0.0F); + spawnEntity.setLocationAndAngles(x + 0.5, y, z + 0.5, world.rand.nextFloat() * 360.0F, 0.0F); } catch (Exception exception){ exception.printStackTrace(); @@ -194,7 +209,7 @@ public class NPCSpawning { public static boolean canCreatureTypeSpawnAtLocation(SpawnData data, World world, int x, int y, int z){ Block block = world.getBlock(x, y - 1, z); - boolean hasSolidSurface = !World.doesBlockHaveSolidTopSurface(world, x, y - 1, z); + boolean hasSolidSurface = World.doesBlockHaveSolidTopSurface(world, x, y - 1, z); boolean spawnBlockCreature = block.canCreatureSpawn(EnumCreatureType.creature, world, x, y - 1, z); boolean spawnBlockMonster = block.canCreatureSpawn(EnumCreatureType.monster, world, x, y - 1, z); diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCGlobalMainMenu.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCGlobalMainMenu.java index aa246d9c2..771bb6531 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCGlobalMainMenu.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCGlobalMainMenu.java @@ -28,7 +28,7 @@ public class GuiNPCGlobalMainMenu extends GuiNPCInterface2{ this.addButton(new GuiNpcButton(12, guiLeft + 85, y += 22, "global.transport")); this.addButton(new GuiNpcButton(13, guiLeft + 85, y += 22, "global.playerdata")); this.addButton(new GuiNpcButton(14, guiLeft + 85, y += 22, "global.recipes")); - this.addButton(new GuiNpcButton(15, guiLeft + 85, y += 22, NoppesStringUtils.translate("global.naturalspawn", "(WIP)"))); + this.addButton(new GuiNpcButton(15, guiLeft + 85, y += 22, NoppesStringUtils.translate("global.naturalspawn"))); this.addButton(new GuiNpcButton(16, guiLeft + 85, y += 22, "global.linked")); }