Jump to content

Recommended Posts

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

}

}

 

 

Posted

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?

Posted

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

Posted

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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