Posted December 17, 20177 yr Hey guy im working on adding items to my mod and i while doing so i had difficulty get a few things right and maybe you can point me in the right direction. first off i couldnt find a clear guide on how to save data to an item, right now it changes the global value for the item rather then just the stack used, below is the code for the wrench im making and i want the user to be able to switch modes but switching the mode changes it for all wrenches rather then just the one used how so i make it so that it only affects the one wrench? public class ItemRobotWrench extends Item { EntityRobot selectedBot; private String[] modes = new String[]{"insert", "extract", "fuel"}; private int mode = 0; public ItemRobotWrench() { setRegistryName("robotwrench"); setUnlocalizedName(Reference.MOD_ID + ":robotwrench"); setCreativeTab(ModItems.SteampunkItemsTab); this.selectedBot = null; } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { Entity target= Minecraft.getMinecraft().objectMouseOver.entityHit; if (target != null && target instanceof EntityRobot) { if (this.selectedBot != null) { this.selectedBot.setGlowing(false); } this.selectedBot = (EntityRobot) target; } else { if (! playerIn.isSneaking()) { nextMode(); } } return super.onItemRightClick(worldIn, playerIn, handIn); } @Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { if (worldIn.isAirBlock(pos)) { nextMode(); } else { if (player.isSneaking()) { if (this.selectedBot != null) { PacketHandler.INSTANCE.sendToServer(new PacketSetAccessPoint(pos,facing.ordinal(),this.selectedBot.getEntityId(),this.mode)); } } } } return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ); } private void nextMode () { this.mode++; if (this.mode >= this.modes.length) { this.mode = 0; } } @Override public String getItemStackDisplayName(ItemStack stack) { if (this.selectedBot != null) { return super.getItemStackDisplayName(stack) + ":" + this.modes[this.mode] + ":" + this.selectedBot.getName(); } return super.getItemStackDisplayName(stack) + ":" + this.modes[this.mode]; } @Override public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if (this.selectedBot != null) { if (isSelected) { this.selectedBot.setGlowing(true); } else { this.selectedBot.setGlowing(false); } } super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected); } } in another item i have trouble getting the texture loaded, i found a post that said i had to insert the .json for the item in the blockstates, which i think should be the right way since thermal foundation does it the same way, but i cant get it to load the file i have attached an image with what it looks like in game the place where it most likely goes wrong is in the .json file because thats what im most unfamiliar with { "forge_marker": 1, "defaults": { "model": "item/generated", "textures": { "layer0": "blocks/dirt" }, }, "variants": { "inventory": [{}], "normal": [{}], "type": { "ingotcopper": { "textures": { "layer0": "steampunkrevolution:items/material/ingotcopper" } }, "ingottin": { "textures": { "layer0": "steampunkrevolution:items/material/ingotcopper" } } } } } tin and copper currently use the same texture but neither of them load i get an java.io.FileNotFoundException: steampunkrevolution:models/item/material.json error because the file is under models/block/material.json
December 17, 20177 yr Quote i get an java.io.FileNotFoundException: steampunkrevolution:models/item/material.json error because the file is under models/block/material.json Then...move it. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
December 17, 20177 yr Author 33 minutes ago, Draco18s said: Then...move it. when i had it in the other folder originally i ended up with invisible items, so that didnt work either. but ill try again. any idea what might have caused items being invisible? Edit: back to invisible items again, added image Edited December 17, 20177 yr by ghostwolf_ added image
December 17, 20177 yr Author 48 minutes ago, William5553 said: Is your image a png? yes sir. also i fixed the name swapped names, and the path "steampunkrevolution:items/material/copperingot " Edited December 17, 20177 yr by ghostwolf_ added extra info
December 18, 20177 yr Show how you register your item model. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.