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

I am working on a 1.10.2 mod and I need help. NOTICE: I am new at modding!


What I am trying to do is create an item that tests if you are looking at a grass block when you right click with it. And if you are looking at a grass block a piece of cobblestone appears. And the item only has 64 uses. I have some code for the item that I got from a tutorial on a heart that heals you. I am trying to base my code on this but I can't figure out what to do. Please help!

 

package wimpyllama.wimprimstuff.items;

import java.util.List;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import wimpyllama.wimprimstuff.Reference;
import wimpyllama.wimprimstuff.util.Utils;

public class ItemSifter extends Item{

	public ItemSifter(String unlocalizedName) {
		this.setUnlocalizedName(unlocalizedName);
		this.setRegistryName(new ResourceLocation(Reference.MODID, unlocalizedName));
	}
	
	@Override
	public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player,
			EnumHand hand) {
		if(player.getHealth() < player.getMaxHealth()) {
			player.heal(4);
			int damageToBe = player.getHeldItem(hand).getItemDamage() + 1;
			if(damageToBe > 4) {
				player.getHeldItem(hand).stackSize--;
			} else {
				player.getHeldItem(hand).setItemDamage(player.getHeldItem(hand).getItemDamage() + 1);
			}
		}
		return super.onItemRightClick(stack, world, player, hand);
	}
	
}
  • Author

As I said, I am new to modding. I don't understand what this is. And I don't want to update to 1.12.2 because most modpacks, including the one I am making, are for 1.10.2 so I just rather make it for 1.10.2 for now and maybe update it in the future.

  • Author

I don't understand what Item::rayTrace means. All I need is to create an if statement that tests if the player is looking at a grass block. if(blockAtPlayerCross == Blocks.GRASS) is what I'm trying to do but I don't know the real statement. I have looked on youtube and google and I can't find anything.

  • Author

Never mind, I figured it out by opening mcreator and making the item in there then I copied some of the code and edited it to my liking.

12 minutes ago, WimpyLlama said:

Never mind, I figured it out by opening mcreator and making the item in there then I copied some of the code and edited it to my liking.

face palm

 

DONT use that, learn java and code it properly

  • Author

I am learning java. I don't use mcreator anymore but it is useful for learning how to do things if you look at the code. I am still coding my mod by myself I just used a bit of mcreators code.

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.