Fix #1311 Crash with WAILA and butterfly or using butterfly kill command

This commit is contained in:
mezz committed 2016-06-09 16:35:33 -07:00
1 parent 4ba3370fc9
commit ab88e7d57c
3 files changed
+10 -9

No files matched your search

@@ -13,6 +13,7 @@ package forestry.lepidopterology.commands;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.EntitySelectors;
import forestry.core.commands.CommandHelpers;
import forestry.core.commands.SubCommand;
@@ -43,10 +44,8 @@ public class CommandButterfly extends SubCommand {
CommandHelpers.throwWrongUsage(sender, this);
}
for (Object entity : sender.getEntityWorld().getLoadedEntityList()) {
if (entity instanceof EntityButterfly) {
((EntityButterfly) entity).setDead();
}
for (EntityButterfly butterfly : sender.getEntityWorld().getEntities(EntityButterfly.class, EntitySelectors.IS_ALIVE)) {
butterfly.setDead();
}
}
@@ -131,9 +131,11 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
public void writeEntityToNBT(NBTTagCompound nbttagcompound) {
super.writeEntityToNBT(nbttagcompound);
NBTTagCompound bio = new NBTTagCompound();
contained.writeToNBT(bio);
nbttagcompound.setTag("BTFLY", bio);
if (contained != null) {
NBTTagCompound bio = new NBTTagCompound();
contained.writeToNBT(bio);
nbttagcompound.setTag("BTFLY", bio);
}
if (pollen != null) {
NBTTagCompound pln = new NBTTagCompound();