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

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.

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

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.

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

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.