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.

[1.7.2] How to use player.addChatMessage

Featured Replies

Posted

Hello, i have 2 question

question 1: how to use player.addChatMessage

question 2: with the event EntityItemPickupEvent. How get what item is picked up?

 

here's my event handler code:

 

package com.karelmikie3.BioChemistry.events;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.util.IChatComponent;

import net.minecraftforge.event.entity.player.EntityItemPickupEvent;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

 

public class EventMobPrepCollector {

@SubscribeEvent

public void onItemPickup(EntityItemPickupEvent event){

event.entityPlayer.addChatMessage();

}

}

 

 

  • Author

for question 1 i ment it says that you need to use a IChatCompent, how do i use that if i want to send a string?

for question 2: how do i compare the item picked to if it is iquel to a item a created?

entityPlayer.addChatMessage(new ChatComponentTranslation("msg.message_name.txt"));

 

You need to create a language file (make sure its UTF-8 encoded)

assets/<modID>/lang/<langID>.lang

 

Example File: en_US.lang

 

msg.message_name.txt=Displayed Message

  • Author

get item doesn't seem to work.

 

I tried this:

 

package com.karelmikie3.BioChemistry.events;

 

import com.karelmikie3.BioChemistry.BioChemistry;

import com.karelmikie3.BioChemistry.Items.ItemMobPrepCollector;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.util.ChatComponentTranslation;

import net.minecraft.util.IChatComponent;

import net.minecraftforge.event.entity.player.EntityItemPickupEvent;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

 

public class EventMobPrepCollector {

@SubscribeEvent

public void onItemPickup(EntityItemPickupEvent event){

if(event.item = BioChemistry.itemMobPrepCollector.getItem()){

System.out.println("hello");

}

event.entityPlayer.addChatMessage(new ChatComponentTranslation("msg.test_text"));

}

}

 

 

 

it says: The method getItem() is undefined for the type Item

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.