Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted
	/**
	 * 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.

  • 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());
   }
	}

 

  • 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?

  • 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

  • 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);
			}
		}
	}

 

  • 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));
    }

 

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.