Posted February 1, 20196 yr /** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource src) { super.onDeath(src); if (dragonInv != null && !this.world.isRemote && !isEgg()) { for (int i = 0; i < dragonInv.getSizeInventory(); ++i) { ItemStack itemstack = dragonInv.getStackInSlot(i); if (!itemstack.isEmpty()) { this.entityDropItem(itemstack, 0.0F); } } } if(!this.world.isRemote) { if(this.isTamed()) { ItemDragonEssence essence = dragonEssence(); essence.setDragonNBT(this); entityDropItem(new ItemStack(essence), 1); } } } public void setDragonNBT(EntityTameableDragon dragon) { ItemStack stack = new ItemStack(this); NBTTagCompound nbt = stack.getTagCompound(); if (stack.hasTagCompound()) { nbt = stack.getTagCompound(); } else { nbt = new NBTTagCompound(); } stack.setTagCompound(nbt); if(stack.getTagCompound() != null) { nbt.setUniqueId("essenceDragonId", dragon.getUniqueID()); nbt.setUniqueId("essenceOwnerId" , dragon.getOwnerId ()); if(dragon.hasCustomName()) nbt.setString("name", dragon.getCustomNameTag()); } } So if a dragon is tamed and it dies, it will store its uuid and owner uuid so that players can respawn it.
February 1, 20196 yr Author somehow it doesnt work when it dies, you can respawn it by right clicking it on the ground public void setDragonNBT(EntityTameableDragon dragon) { ItemStack stack = new ItemStack(this); NBTTagCompound nbt = stack.getTagCompound(); if (stack.hasTagCompound()) { nbt = stack.getTagCompound(); } else { nbt = new NBTTagCompound(); } stack.setTagCompound(nbt); if(stack.getTagCompound() != null) { nbt.setUniqueId("essenceDragonId", dragon.getUniqueID()); nbt.setUniqueId("essenceOwnerId" , dragon.getOwnerId ()); if(dragon.hasCustomName()) nbt.setString("name", dragon.getCustomNameTag()); } }
February 1, 20196 yr Author Just now, diesieben07 said: Your setDragonNBT does nothing. Well, it does, but nothing useful. It creates an ItemStack, writes some data to it and then discards it, leaving it completely unused. Your onDeath then goes and creates a new ItemStack of the essence (without any data written to it) and drops that into the world. ohhhh, so what should I do?
February 1, 20196 yr Author public void setDragonNBT(EntityTameableDragon dragon, ItemStack stack) { NBTTagCompound nbt = stack.getTagCompound(); if (stack.hasTagCompound()) { nbt = stack.getTagCompound(); } else { nbt = new NBTTagCompound(); } stack.setTagCompound(nbt); if(stack.getTagCompound() != null) { nbt.setUniqueId("essenceDragonId", dragon.getUniqueID()); nbt.setUniqueId("essenceOwnerId" , dragon.getOwnerId ()); if(dragon.hasCustomName()) nbt.setString("name", dragon.getCustomNameTag()); } } like this, they drop but they wont spawn
February 1, 20196 yr Author Just now, diesieben07 said: Post the code where you actually drop the item. And please use the code option in the editor. /** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource src) { super.onDeath(src); if (dragonInv != null && !this.world.isRemote && !isEgg()) { for (int i = 0; i < dragonInv.getSizeInventory(); ++i) { ItemStack itemstack = dragonInv.getStackInSlot(i); if (!itemstack.isEmpty()) { this.entityDropItem(itemstack, 0.0F); } } } if(!this.world.isRemote) { if(this.isTamed()) { ItemDragonEssence essence = dragonEssence(); ItemStack essence1 = new ItemStack(essence); essence.setDragonNBT(this, essence1); entityDropItem(essence1, 1); } } }
February 1, 20196 yr Author they drop the item but when you right click the item it doesnt spawn as if the uuid was null.
February 1, 20196 yr Author Also away from this I have a new truble is EntityAITasks.EntityAITAskEntry became private? java.lang.BootstrapMethodError: java.lang.IllegalAccessError: Class 'com.TheRPGAdventurer.ROTD.server.entity.helper.DragonBrain' no access to: class 'net.minecraft.entity.ai.EntityAITasks$EntityAITaskEntry' I get this error from this public void clearTasks() { clearTasks(tasks); clearTasks(targetTasks); } public void clearTasks(EntityAITasks tasks) { List<EntityAITaskEntry> taskEntries = new ArrayList<>(tasks.taskEntries); taskEntries.forEach(entry -> tasks.removeTask(entry.action)); }
February 1, 20196 yr Author I am exporting my mod with gradlew build, i dont have that issue, i only have that issue in someone elses server. I downloaded it from forge Crash: https://pastebin.com/ChA0tJ8J DragonBrain: https://pastebin.com/kfAs5caP DragonLifeStageHelper: https://pastebin.com/hFG5927b
February 1, 20196 yr Author OpenJ9 has fancy graphics I see, call me judgemental but once a software put more emphasis on their graphics rather than their actual work is a problematic software
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.