Posted February 16, 201411 yr 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(); } }
February 16, 201411 yr 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?
February 16, 201411 yr 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
February 16, 201411 yr 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.