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

Hello everyone!

I'm making a mod with a story line about a penguin war. The righteous penguins are at war with the evil penguins. You craft a dictionary to be able to understand the penguins so you can do quests for them and talk to them. I am trying to make it so that the penguins' names are consistent, as in the name tag is the same as the name it displays in chat when you talk to them. Inside the PenguinDictionary class:

@Override
	public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
	{
		ItemStack itemstack = playerIn.getHeldItem(handIn);
		
		Minecraft mc = Minecraft.getMinecraft();
		
		RayTraceResult objectMouseOver = mc.objectMouseOver;
				
		if (delay == 0) {
			if (itemstack.getItem() == themodtostartallmods.penguinDictionary)
			{
				if(mc.objectMouseOver != null && mc.objectMouseOver.entityHit != null) 
				{
					Entity Target = objectMouseOver.entityHit;
					
					if(Target instanceof EntityPenguinRighteous) 
					{
						if (EntityPenguinRighteous.trust >= 500)
						{
							if (Quest.hasQuest == false) 
							{
      							//This part gives me the error
								playerIn.sendMessage(new TextComponentString(EntityPenguinRighteous.getCustomNameTag() + ": " + Quest.getQuest()));
								Quest.hasQuest = true;
							} 
						} else
						{
      						//This part gives me the error
							playerIn.sendMessage(new TextComponentString(EntityPenguinRighteous.getCustomNameTag() + ": " + Quest.getDialogue()));
							EntityPenguinRighteous.trust += 10;
						}
					}
				}
			}
			if (Quest.checkIfQuestFinished()) 
			{
				playerIn.sendMessage(new TextComponentString(Quest.messageWhenDoneQuest()));
				playerIn.inventory.addItemStackToInventory(new ItemStack(Items.DIAMOND, 1));
				EntityPenguinRighteous.trust += 50;
				Quest.hasQuest = false;
			}
			if (Quest.hasQuest) 
			{
				playerIn.sendMessage(new TextComponentString(Quest.getName() + ": You already have a quest!"));
			}
			delay = 50;
		}
		return new ActionResult(EnumActionResult.SUCCESS, itemstack);
	}

(Sorry for the long code, I didn't want to leave it out of context)

EntityPenguinRighteous.getCustomNameTag() gives me an error because I did not instantiate EntityPenguinRighteous, and I can not instantiate EntityPenguinRighteous without running into the following problems:

 

If I instantiate EntityPenguinRighteous inside of this method it will generate a random name in chat every time you attempt to talk to the penguin. For example: Waddles: You are quite tall! and then if you talk to them again it will say Wiggles: You look funny! when the name tag displays Tux.

 

If I instantiate EntityPenguinRighteous at the top of this class, I need to write this line of code:

EntityPenguinRighteous epr = new EntityPenguinRighteous(World);

However, I need to pass in a World type, which it does not let me instantiate (It gives me the error World can not be instantiated) and I can only use it if I pass the parameters World worldIn inside a method, which I previously explained I can not do or it would generate a different name each time.

 

If I put the string penguinName inside of the constructor rather than at the top of the class it would not be publicly accessible.

 

Is there any way I could make the chat name display the same string as the name tag? Any help is appreciated!

Edited by jomoetnt

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.