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.

HappyKiller1O1

Members
  • Joined

  • Last visited

Everything posted by HappyKiller1O1

  1. What's... reflection? Excuse my ignorance I have seriously never heard that term before.
  2. So I have this to check if the item is in use: if(player.getItemInUse() != stack) { LogHelper.logInfo(player.getItemInUse()); int autoRepairDelay = stack.stackTagCompound.getInteger("RepairBase"); if(autoRepairDelay < stack.stackTagCompound.getInteger("RepairDelay")) { autoRepairDelay++; stack.stackTagCompound.setInteger("RepairBase", autoRepairDelay); } LogHelper.logInfo("Delay: " + autoRepairDelay); //TODO WORK ON AUTO REPAIR if(autoRepairDelay == stack.stackTagCompound.getInteger("RepairDelay")) { stack.damageItem(-1, player); stack.stackTagCompound.setInteger("RepairBase", 0); } } But, the Item in use is CONSTANTLY null. How does Minecraft determine if the Item is in use?
  3. How exactly would I check if the tool is in use? Is there a method for it in ItemStack?
  4. This is so weird, I am using NBT as a timer and basically while I set it for the hammer I can't mine blocks. It keeps canceling. Here is how I use it: public void onUpdate(ItemStack stack, World world, Entity entity, int i, boolean flag) { //3600 = 3 minutes fixNBT(stack); if(!world.isRemote) { if(stack.stackTagCompound.getBoolean("AutoRepair")) { if(stack.isItemDamaged()) { int autoRepairDelay = stack.stackTagCompound.getInteger("RepairBase"); if(autoRepairDelay < stack.stackTagCompound.getInteger("RepairDelay")) { autoRepairDelay++; stack.stackTagCompound.setInteger("RepairBase", autoRepairDelay); } LogHelper.logInfo("Delay: " + autoRepairDelay); //TODO WORK ON AUTO REPAIR if(autoRepairDelay == stack.stackTagCompound.getInteger("RepairDelay")) { stack.damageItem(-1, (EntityPlayer)entity); stack.stackTagCompound.setInteger("RepairBase", 0); } } } } } All I can say is it cancels while it sets NBT. Pretty weird so any help is appreciated.
  5. Thanks for attempting to help but, like Ernio said: declaring a field in the item class would be for every one of those Items. That would mean that, for one: the tick count would be shared between all of that Item. And secondly, you could not repair two of the item in your inventory.
  6. Hm, see I understand that but, in changing it to go up and down like a timer; wouldn't I have to constantly save and load from NBT?
  7. Anyone got any ideas? I honestly am not sure how to use NBT to fix this.
  8. That was my problem for that. In 1.6.4 I made a timer just fine but I can't remember how I did.
  9. Honestly, I know I gotta be doing something wrong. public void onUpdate(ItemStack stack, World world, Entity entity, int i, boolean flag) { //3600 = 3 minutes fixNBT(stack); if(stack.stackTagCompound.getBoolean("AutoRepair")) { if(stack.isItemDamaged()) { int autoRepairDelay = stack.stackTagCompound.getInteger("RepairDelay"); if(autoRepairDelay < 3600) autoRepairDelay++; LogHelper.logInfo("Delay: " + autoRepairDelay); //TODO WORK ON AUTO REPAIR if(autoRepairDelay == 3600) { stack.damageItem(-1, (EntityPlayer)entity); autoRepairDelay = stack.stackTagCompound.getInteger("RepairDelay"); } } } } public static void fixNBT(ItemStack stack){ if(stack.stackTagCompound == null) { LogHelper.logWarn("[CrewHammer] " + "The ItemStack NBTTagCompound was null. Attempting fix..."); stack.stackTagCompound = new NBTTagCompound(); } /*if(!stack.stackTagCompound.hasKey("HammerTag")) { stack.stackTagCompound.setTag("HammerTag", new NBTTagCompound()); LogHelper.logWarn("[CrewHammer] " + "The ItemStack did not contain the key 'HammerTag'. Attempting fix..."); }*/ if(!stack.stackTagCompound.hasKey("RepairDelay")) { LogHelper.logWarn("[CrewHammer] " + "The ItemStack did not contain the key 'RepairDelay'. Attempting fix..."); stack.stackTagCompound.setInteger("RepairDelay", 0); } if(!stack.stackTagCompound.hasKey("MiningSize")) { LogHelper.logWarn("[CrewHammer] " + "The ItemStack did not contain the key 'MiningSize'. Attempting fix..."); stack.stackTagCompound.setString("MiningSize", "3x3"); } if(!stack.stackTagCompound.hasKey("AutoSmelt")) { LogHelper.logWarn("[CrewHammer] " + "The ItemStack did not contain the key 'AutoSmelt'. Attempting fix..."); stack.stackTagCompound.setBoolean("AutoSmelt", false); } if(!stack.stackTagCompound.hasKey("AutoRepair")) { LogHelper.logWarn("[CrewHammer] " + "The ItemStack did not contain the key 'AutoRepair'. Attempting fix..."); stack.stackTagCompound.setBoolean("AutoRepair", false); } if(!stack.stackTagCompound.hasKey("Has3x3")) { LogHelper.logWarn("[CrewHammer] " + "The ItemStack did not contain the key 'Has3x3'. Attempting fix..."); stack.stackTagCompound.setBoolean("Has3x3", false); } if(!stack.stackTagCompound.hasKey("Has5x5")) { LogHelper.logWarn("[CrewHammer] " + "The ItemStack did not contain the key 'Has5x5'. Attempting fix..."); stack.stackTagCompound.setBoolean("Has5x5", false); } if(!stack.stackTagCompound.hasKey("Has7x7")) { LogHelper.logWarn("[CrewHammer] " + "The ItemStack did not contain the key 'Has7x7'. Attempting fix..."); stack.stackTagCompound.setBoolean("Has7x7", false); } } It's set in fixNBT and read in onUpdate. I was thinking about setting a variable to my class and setting it equal to the saved Integer? Not sure if that would work though.
  10. Yes, I get that. My problem still is I need to make a timer. Even if I set my Integer to a Integer set in the stack's NBT it still gets reset every time. Am I suppose to just use that number and constantly save and load the nbt to raise the number?
  11. You do know I have not added any number to NBT yet, right?
  12. My problem is not setting and reading from NBT, even if it is set to NBT it will still be constantly set to that number.
  13. Hey so, I am trying to set a timer for my auto repair and, I really wish it would work. I am using ticks and basically, the int constantly is set back to zero. Here is my code: public void onUpdate(ItemStack stack, World world, Entity entity, int i, boolean flag) { //3600 = 3 minutes fixNBT(stack); if(stack.stackTagCompound.getBoolean("AutoRepair")) { if(stack.isItemDamaged()) { int autoRepairDelay = 0; if(autoRepairDelay < 3600) autoRepairDelay++; LogHelper.logInfo("Delay: " + autoRepairDelay); if(autoRepairDelay == 3600) { stack.damageItem(-1, (EntityPlayer)entity); autoRepairDelay = 0; } } } } The autoRepairDelay NEEDS to be initialized before I can edit it but, if I set it to zero it will constantly be reset to zero and my number gets stuck going back and forth from one to zero. If I make the int declared in my class it works but, when you have two of the item in your inventory to repair it screws up. Any way to do this?
  14. Fixed! I didn't realize I never defined the metadata in the ItemStack. Silly happy.
  15. If you extend GuiScreen you get a ready-to-use instance of Minecraft. Just thought I'd point it out.
  16. To accomplish this, you'll need to check where the mouse is on the screen then, draw the tooltip. Considering this took me hours of research to figure out a few months back; here's some code to help you out. public void drawToolTips(int mouseX, int mouseY) { int boxX = (this.width - this.xSize) / 2; //These are just like the center of the screen. int boxY = (this.height - this.ySize) / 2;//You make these in order to get a starting point on where to check (With these, it would be the top left of your GUI) int defaultX = 16; //These are like the boxes of the area to check. int defaultY = 16; //So, if you're rendering an Item to hover over, it would be 16x16. //This checks if the mouse is in the correct position on screen. You can add and subtract from boxX and Y to determine where to be. if(mouseX > boxX && mouseX < boxX + defaultX && mouseY > boxY && mouseY < boxY + defaultY) { List list = new ArrayList(); //Just the list of text to be added. It is just like the addInformation method now. list.add("SOMETHING") //Each time you add something, it's gonna be a new line in the tooltip. this.drawHoveringText(list, mouseX, mouseY, fontRenderer); } } Then you just add that method in your drawScreen AFTER calling super.drawScreen(). If you add it before, you will get some pretty weird rendering errors. The first two params of drawScreen are the mouseX and mouseY so use those. Hope it helped!
  17. Does the method not exist because it is a client to server error or it doesn't exist in general?
  18. Have you tried not declaring the Object array? I don't use Object arrays in my crafting recipes and I can use ItemStacks for input just fine.
  19. Check out the Portal block for the nether portal. I'm pretty sure they edit the collision bounding boxes.
  20. What are you talking about? I use ItemStacks to get metadata with crafting recipes all the time.
  21. So, I am trying to add autosmelt block drops (which I do fine. ) but, in doing so, blocks such as lapis ore drops ink sacks instead of lapis. I know this is because I can't seem to change the metadata. Here is what I am doing to add the item to a custom drop list I created: ret.add(new ItemStack(block.getItemDropped(block.damageDropped(blockMeta), world.rand, fortune))); The block and blockMeta are gotten correctly (checked through console print outs). So , what could be wrong?
  22. I think I fixed it. I changed my code a bit to make it neater and copied the smelting result. Here's it finished: public ArrayList<ItemStack> getFurnaceDrops(World world, int x, int y, int z, int meta, int fortune, int quantity, Block block, int blockMeta, EntityPlayer player) { ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); ArrayList<ItemStack> originalDrops = block.getDrops(world, x, y, z, blockMeta, fortune); int count = quantity; for(int i = 0; i < count; i++) { for(ItemStack stack : originalDrops) { if(FurnaceRecipes.smelting().getSmeltingResult(stack) != null) { ItemStack furnaceStack = FurnaceRecipes.smelting().getSmeltingResult(stack).copy(); int itemMeta = furnaceStack.getItemDamage(); //float xpToDrop = FurnaceRecipes.smelting().getSmeltingResult(stack).getItem().getSmeltingExperience(FurnaceRecipes.smelting().getSmeltingResult(stack)); float xpToDrop = FurnaceRecipes.smelting().func_151398_b(furnaceStack); LogHelper.logInfo("Block: " + new ItemStack(block, 1, blockMeta)); LogHelper.logInfo("XP: " + xpToDrop); Item item = furnaceStack.getItem(); LogHelper.logInfo("Item Meta: " + itemMeta); if (item != null) { ret.add(new ItemStack(item, 1, itemMeta)); } }else { if(block.canSilkHarvest(world, player, x, y, z, meta)) ret.add(new ItemStack(block, 1, meta)); else ret.add(new ItemStack(block.getItemDropped(blockMeta, world.rand, fortune))); } } } return ret; } Seems my problem was not copying the ItemStack. Honestly pretty weird.
  23. The block is oreBlock and the metadata makes it goldOre. I also printed the ItemStack I was using and got the same result.
  24. Still returning -1 It says that it is used to get the smelting experience of an item when it is pulled out (as a smelting result) yet, no items seem to use it (like gold ingots etc.)

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.