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. Thank you for this. Where would I create this though? Considering it is static, would it go in the Item class? And also, you tell the game if it doesn't contain the key "MiningArea" to set the string? I'm guessing that was a typo? EDIT: Nevermind! Forgot hasKey is used for anything set to NBT. Sorry!
  2. Sorry if I am becoming annoying but, could you maybe elaborate on what you just said? NBT sometimes confuses me so, yeah.
  3. Well see, the string is set from a gui so it would be quite difficult to set it in the event class and item class. And that was me testing if I got the itemstack incorrect so ignore that.
  4. So, I tried that and it still won't get the string. Here's what I did: ItemStack hammer = new ItemStack(player.inventory.getCurrentItem().getItem()); //System.out.println("ITEM IN HAND IS CREW HAMMER"); Block block = event.block; World world = event.world; int x = event.x; int y = event.y; int z = event.z; NBTTagCompound cmp = hammer.stackTagCompound; if(cmp == null) { System.out.println("onBlockBreak HAMMER NBT WAS NULL"); hammer.stackTagCompound = new NBTTagCompound(); cmp = hammer.stackTagCompound; } //if(event.isCanceled()) //return; String miningArea = null; if(cmp != null) { miningArea = cmp.getString("MiningSize"); System.out.println("CMP WAS NOT NULL"); } hammer.stackTagCompound = cmp; System.out.println(miningArea); this.breakBlock(world, player, hammer, x, y, z, direction, miningArea);
  5. I'll try that but, may I ask why you set the stackCompound to a new one and set the tag you made to it but then, after doing everything; set the stackCompound to the tag?
  6. I do do that (in my Event class) and then it returns the string I set as null.
  7. Ok so, it's still returning null. Is it somehow because I can't get the stackTagCompound from the item in the player's hand? I just don't know what's wrong.
  8. I only call it in my EventsForge class. Maybe I just need to set it on server side only.
  9. You put this in your item class to override it from Item.java: public ItemStack getContainerItem(ItemStack stack) { ItemStack newStack = stack.copy(); newStack.setItemDamage(newStack.getItemDamage() + 1); stack.stackSize = 1; return newStack; }
  10. I do craft it and it registers it in the console with my printout. It does seem to call the onCreated method four times (twice for server and twice for client) is that a problem?
  11. Ok so, my item when crafted sets it's stackTagCompound to a new NBTTagCompound. After that, I set a string. Then, in my event class I get the item in the players hand and, if it's the hammer I am creating; sets an itemstack to it and then gets it's stackTagCompound. What's my problem you may ask? Well, it's always null. I have pondered this for hours and have no clue what I am doing wrong. I have tried setting tags, resetting the stackTagCompound to a another NBTTagCompound, making sure my item is only stackable to 1 etc. I need help because I am about to rip my hair out. Here's the code as it is now. Creation method in my item: public void onCreated(ItemStack stack, World world, EntityPlayer player) { System.out.println("NBT TAG SET"); stack.stackTagCompound = new NBTTagCompound(); stack.stackTagCompound.setString("MiningSize", "3x3"); } Event method to get it (this is using the BlockBreak event): if(event.world != null && player != null) { if(player.inventory.getCurrentItem() != null) { if(player.inventory.getCurrentItem().getItem().equals(CrewMod.crewHammer)) { int direction = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; ItemStack hammer = player.inventory.getCurrentItem(); //System.out.println("ITEM IN HAND IS CREW HAMMER"); Block block = event.block; World world = event.world; int x = event.x; int y = event.y; int z = event.z; NBTTagCompound cmp = hammer.stackTagCompound;
  12. Let me explain a bit, my tool (when created) sets its stackTagCompound to not be null. With that, I set a string that is either "3x3", "5x5" or, "7x7". These are how many blocks it will mine. Basically my tag is returning null now. I fixed it but it did piss me off. Sorry about the vagueness in my previous posts.
  13. See, I would think that would work and would love to test it but the game is like "Oh you want to set an NBT tag on you item? Nah don't feel like it."
  14. I am creating a tool that breaks a 3x3 area and need to check if the blocks it is trying to break around the block that the player is breaking can be broken by the tool. So like, if you break stone it won't break the dirt around it.
  15. So, I just need to compare if the item the player is holding has the right toolset and harvest level for the block being broken. I really have no idea how to go about this. Any suggestions?
  16. Well yes I know that. It's used to check the side of the block to set the variables correctly.
  17. I believe they solved a way to break the block beside the one actually broken by comparing the hardness. I need to make sure that the extra blocks are for one, able to broken by the tool set (pickaxe) and two, the hardness doesn't exceed a certain amount like, breaking stone breaks obsidian around it.
  18. Thank you for that, elix. But, when looking at their code it slightly confuses me. They created a bunch of classes that re-handle block events, onBlockStartBreaking and, a few rayTrace methods. I feel like there is a cleaner way of doing things but can't seem to find a good place to start.
  19. So, the break block method in World seemed to work but, when I place things like obsidian or bedrock around the area to break it also breaks the bedrock. I'm sure you can see my problem here. Would love some help on how to prevent this? Here's my code for breaking it (slightly messy. ): @SubscribeEvent public void onBlockBreak(BreakEvent event) { EntityPlayer player = event.getPlayer(); if(event.world != null && player != null) { if(player.inventory.getCurrentItem().getItem() != null) { if(player.inventory.getCurrentItem().getItem().equals(CrewMod.crewHammer)) { int direction = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; ItemStack hammer = player.inventory.getCurrentItem(); //System.out.println("ITEM IN HAND IS CREW HAMMER"); Block block = event.block; World world = event.world; int x = event.x; int y = event.y; int z = event.z; NBTTagCompound cmp = hammer.stackTagCompound; if(cmp != null) { //System.out.println("CMP IS NOT NULL"); if(cmp.getString("MiningSize") != null) { System.out.println("MININGSIZE IS NOT NULL"); if(cmp.getString("MiningSize").equals("1x1")) { System.out.println("1x1"); return; }else if(cmp.getString("MiningSize").equals("3x3")) { //System.out.println("3x3"); this.breakThreeByThree(world, x, y, z, direction); }else if(cmp.getString("MiningSize").equals("5x5")) { }else if(cmp.getString("MiningSize").equals("7x7")) { } } } } } } } public void breakThreeByThree(World world, int x, int y, int z, int playerFacing) { if(playerFacing == 0 || playerFacing == 2) { //SOUTH world.func_147480_a(x, y + 1, z, true); world.func_147480_a(x - 1, y + 1, z, true); world.func_147480_a(x + 1, y + 1, z, true); world.func_147480_a(x, y - 1, z, true); world.func_147480_a(x - 1, y - 1, z, true); world.func_147480_a(x + 1, y - 1, z, true); world.func_147480_a(x - 1, y, z, true); world.func_147480_a(x + 1, y, z, true); }else { world.func_147480_a(x, y + 1, z, true); world.func_147480_a(x, y + 1, z - 1, true); world.func_147480_a(x, y + 1, z + 1, true); world.func_147480_a(x, y - 1, z, true); world.func_147480_a(x, y - 1, z - 1, true); world.func_147480_a(x, y - 1, z + 1, true); world.func_147480_a(x, y, z - 1, true); world.func_147480_a(x, y, z + 1, true); } }
  20. Aren't those only for classes that extend Block? I found World#func_147480_a() destroys the block and can add drops if you set the boolean to true. I'm gonna try it in my BreakEvent.
  21. So, I need my tool (hammer if you're wondering) to break a 3x3, 5x5, or, 7x7 set of blocks for what ever it is set to. Basically, you shift + right-click the hammer to open the GUI and select the size of area you want to destroy etc. But, that's not my problem; my problem is how to go about destroying the blocks! I was thinking about using the BreakEvent but, still not sure if that will work. Any input would be great!
  22. I'm trying a method right now to update the client. Hopefully it works.
  23. So, I am guessing that maybe no nbt tag is set on the client side? I seem to only be setting the stack.stackTagCompound and it's strings to the server and not the client. Would there be a way to send a packet to update the clients nbt tag?
  24. I don't want to be a dick here but, could you maybe write your sentences a bit clearer? Kinda hard to understand what you want with a thousand words combined into an incomplete sentence.
  25. So, when attempting to enchant it: it shows the glim on the item of it being enchanted but doesn't display it has Unbreaking 3 on the tooltip. What am I doing wrong?

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.