Posted October 13, 201410 yr So, I am trying to create a mod (my knowledge of java at this point is very little), and I am trying to make a Interact Event that will do a bunch of things to a player. However, it does not seem to be working. @EventHandler public void onRightClick(PlayerInteractEvent e) { EntityClientPlayerMP p = Minecraft.getMinecraft().thePlayer; int courage = 0; if (e.action == e.action.RIGHT_CLICK_AIR && e.action == e.action.RIGHT_CLICK_BLOCK) { p.sendChatMessage("You feel the power of the triforce enter your body!"); p.addPotionEffect((new PotionEffect(Potion.damageBoost.getId(), 0, 1))); p.experienceLevel += 10; courage += 10; Minecraft.getMinecraft().thePlayer.sendChatMessage("Your courage has increased to: " + courage); p.inventory.getCurrentItem().stackSize = 0; } I'm not sure if I have put the code in the wrong place, or I have just used a wrong function (the lines are currently in the item's class). If someone could help me out with this, I would appreciate it! Another problem I am having is with the textures of my blocks and items. I am fairly sure I have the code right, I think I have just placed the files in the wrong location, however, I cannot figure it out (C:\<forgedirectory>\src\main\resources\assets\themod\textures\<blocks/items>). [spoiler=Block] package me.ryancp.mod; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.util.IIcon; public class BlockTest extends Block { @SideOnly(Side.CLIENT) protected IIcon blockIcon; protected IIcon blockIconTop; protected BlockTest() { super(Material.ground); this.setCreativeTab(TheMod.tabMod); } @SideOnly(Side.CLIENT) @Override public void registerBlockIcons(IIconRegister p_149651_1_) { blockIcon = p_149651_1_.registerIcon(TheMod.MODID + ":" + this.getUnlocalizedName().substring(5)); blockIconTop = p_149651_1_.registerIcon(TheMod.MODID + ":" + this.getUnlocalizedName().substring(5) + "Top"); } @SideOnly(Side.CLIENT) @Override public IIcon getIcon(int side, int metadata) { if (side == 1) { return blockIconTop; } else { return blockIcon; } } } If someone can help me with both of these problems, I would be most grateful! There's 10 types of people in this world; Those that understand binary and those that don't.
October 13, 201410 yr Author The if statement was a brain fart on my part, I meant to do a "or" statement (Idk why I made it how I did). Thank you for your help, but I am now having another problem, when I change it to e.entityPlayer I get and error under the "p.sendChatMessage(..)" line, it says to change it to addChatMessage, then when I do that it says to change it to addChatMessageComponent. Do you happen to know why this is happening? There's 10 types of people in this world; Those that understand binary and those that don't.
October 13, 201410 yr Then do that? event.entityPlayer.addChatComponentMessage(new ChatComponentText("Whatevertext")); The other method you mentioned is client side only, you'll have to cast your player to EntityClientPlayerMP. Depends on what you want. And... this.getUnlocalizedName().substring(5) will return "null" if you don't actually set the block name.
October 13, 201410 yr Author I feel really dumb... thanks . There's 10 types of people in this world; Those that understand binary and those that don't.
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.