Posted December 13, 20177 yr 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); } }
December 13, 20177 yr 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.
December 13, 20177 yr Author Basically, if you could just tell me where to put the code and what it does, that would be great.
December 13, 20177 yr Author I thought you did. Whatever, just if you could help me that would be nice.
December 13, 20177 yr 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.
December 13, 20177 yr 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.
December 13, 20177 yr 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
December 13, 20177 yr 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.