Everything posted by HappyKiller1O1
-
[1.7.10] Trouble with stackTagCompound
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!
-
[1.7.10] Trouble with stackTagCompound
Sorry if I am becoming annoying but, could you maybe elaborate on what you just said? NBT sometimes confuses me so, yeah.
-
[1.7.10] Trouble with stackTagCompound
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.
-
[1.7.10] Trouble with stackTagCompound
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);
-
[1.7.10] Trouble with stackTagCompound
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?
-
[1.7.10] Trouble with stackTagCompound
I do do that (in my Event class) and then it returns the string I set as null.
-
[1.7.10] Trouble with stackTagCompound
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.
-
[1.7.10] Trouble with stackTagCompound
I only call it in my EventsForge class. Maybe I just need to set it on server side only.
-
[1.7.10] [SOLVED] How do i add durable items to my crafting recipes???
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; }
-
[1.7.10] Trouble with stackTagCompound
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?
-
[1.7.10] Trouble with stackTagCompound
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;
-
[1.7.10] How to check if a tool can harvest a block?
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.
-
[1.7.10] How to check if a tool can harvest a block?
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."
-
[1.7.10] How to check if a tool can harvest a block?
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.
-
[1.7.10] How to check if a tool can harvest a block?
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?
-
[1.7.10] How to make a tool break more then one block?
Well yes I know that. It's used to check the side of the block to set the variables correctly.
-
[1.7.10] How to make a tool break more then one block?
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.
-
[1.7.10] How to make a tool break more then one block?
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.
-
[1.7.10] How to make a tool break more then one block?
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); } }
-
[1.7.10] How to make a tool break more then one block?
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.
-
[1.7.10] How to make a tool break more then one block?
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!
-
[1.7.10] Need my item to get the players display name
I'm trying a method right now to update the client. Hopefully it works.
-
[1.7.10] Need my item to get the players display name
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?
-
[1.8] writing json to create an structure what library is avaliable ???
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.
-
[1.7.10] Need my item to get the players display name
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?
IPS spam blocked by CleanTalk.