Everything posted by HappyKiller1O1
-
[1.7.10] [SOLVED] How do i add durable items to my crafting recipes???
Sorry about the wrong code; I didn't have my IDE open and I remembered using it from 1.6.4. I'll re-make it myself to see how to do what he wants to accomplish. But diesieben, the way you addressed me did come off quite rude. You could of just said it was incorrect in a less condescending format.
-
[1.7.10] Why does a stack's NBTTagCompound return null?
Um, ok I might sound a little bit uneducated but, how would I use those? EDIT: Scratch that, I looked it up. So, it seems to be called two times in the SlotCrafting class on line 70 and 62 but, I'm not sure why. It is also called through the onCrafting method in ItemStack. Maybe if I override the onCrafting method in ItemStack it would not run twice?
-
[1.7.10] Why does a stack's NBTTagCompound return null?
I added at the start of the onCreated method "System.out.println(Thread.getCurrentThread().getName())" and this is what I got: [21:32:04] [Client thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:38]: Client thread [21:32:04] [Client thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:38]: Client thread [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:38]: Server thread [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:41]: THE STACK: 0xitem.CrewHammer@0 [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:45]: THE TAG: null [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:48]: NEW TAG [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:56]: {MiningSize:"3x3",} [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:57]: {MiningSize:"3x3",} [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:38]: Server thread [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:41]: THE STACK: 0xitem.CrewHammer@0 [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:45]: THE TAG: {MiningSize:"3x3",} [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:56]: {MiningSize:"3x3",} [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:57]: {MiningSize:"3x3",} When the method is first called, it displays two client threads and, one server thread. Then, on the second pass, just one server thread. Does this mean something? I'm not sure if this is what you meant to do. I'm not really sure how to see what calls my method and why. onCreated is abstract so, do you want me to find every place it is used?
-
I would like to make a mod but...
When I looked, I didn't find any.
-
[1.7.10] Why does a stack's NBTTagCompound return null?
Now see, I did that and all I can get is that somehow, the server thread is called with the client thread then recalled for when the client thread is not needed.
-
[1.7.10] onCreated method for Item called twice for server?
So, I decided to add a "System.out.println(Thread.getCurrentThread().getName())" at the start of the onCreated method and got this: [21:32:04] [Client thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:38]: Client thread [21:32:04] [Client thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:38]: Client thread [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:38]: Server thread [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:41]: THE STACK: 0xitem.CrewHammer@0 [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:45]: THE TAG: null [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:48]: NEW TAG [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:56]: {MiningSize:"3x3",} [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:57]: {MiningSize:"3x3",} [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:38]: Server thread [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:41]: THE STACK: 0xitem.CrewHammer@0 [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:45]: THE TAG: {MiningSize:"3x3",} [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:56]: {MiningSize:"3x3",} [21:32:04] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:57]: {MiningSize:"3x3",} When the method is first called, it displays two client threads and, one server thread. Then, on the second pass, just one server thread. Does this mean something?
-
[1.7.10] onCreated method for Item called twice for server?
Is there anything else that could be causing this?
-
I would like to make a mod but...
What one do you need to download? I could add it to my mediafire for ya. But, why can't you change the settings of OpenDNS on your router?
-
[1.7.10] onCreated method for Item called twice for server?
Um, no I have not done anything like that.
-
[1.7.10] onCreated method for Item called twice for server?
It is an Item but, it extends ItemPickaxe so it can mine blocks and also, has a ToolMaterial. I only registered one item with that class. And what do you mean by the last question?
-
[1.7.10] onCreated method for Item called twice for server?
Ok so, when using some prints to debug my code, I noticed that the onCreated method is called twice on the server. I do not understand how this is possible considering it should only be called once and, if it is called twice it should be on for server then one for client right? I do check if it is the server world and, when I don't, it is called twice for server and client. I really need some help here; here's my code: public void onCreated(ItemStack stack, World world, EntityPlayer player) { if(!world.isRemote) { System.out.println("THE STACK: " + stack); NBTTagCompound cmp = stack.getTagCompound(); System.out.println("THE TAG: " + cmp); if(cmp == null) { System.out.println("NEW TAG"); cmp = new NBTTagCompound(); cmp.setString("MiningSize", "3x3"); stack.setTagCompound(cmp); } System.out.println(cmp); System.out.println(stack.getTagCompound()); } }
-
[1.7.10] Why does a stack's NBTTagCompound return null?
I'm not sure what's happening. It sets it two times on the server for me when it obviously is only suppose to set it once. All I do is override the onCreated method. Am I suppose to call a super?
-
[1.7.10] Why does a stack's NBTTagCompound return null?
See, put your code in there to test it and again, it is null with the onBlockDestroyed method. I have noticed though, the onCreated method gets called two times for server. Is this natural?
-
[1.7.10] Why does a stack's NBTTagCompound return null?
Well see, did you try calling it with an onBlockDestroyed method to see if it is still set? Because, although this is nearly the same as what I coded; it seems like it doesn't not fix my problem.
-
[1.7.10] Why does a stack's NBTTagCompound return null?
Ok so, I set my itemstack's stackTagCompound to a new NBTTagCompound and, need to retrieve the String I set in it for handling in another method inside the same class. Pretty simple right? Wrong. When I try to retrieve the string, the stackTagCompound is null even after setting it. Here are my methods: //Where it is set (yes I craft a new one every time) public void onCreated(ItemStack stack, World world, EntityPlayer player) { if(world.isRemote) return; NBTTagCompound cmp = stack.stackTagCompound; if(cmp == null) { System.out.println("NBT TAG SET"); cmp = new NBTTagCompound(); stack.stackTagCompound = cmp; } System.out.println(stack.stackTagCompound); cmp.setString("MiningSize", "3x3"); } //Where I try to retrieve it public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { EntityPlayer player = (EntityPlayer)entity; System.out.println("CALLED"); if(world != null && player != null) { System.out.println("WORLD WAS NOT NULL NOR WAS PLAYER"); 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 = stack; //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(event.isCanceled()) //return; String miningArea = null; if(cmp != null) { miningArea = cmp.getString("MiningSize"); //System.out.println("CMP WAS NOT NULL"); } System.out.println(miningArea); this.breakBlock(world, player, hammer, x, y, z, direction, miningArea); }else { super.onBlockDestroyed(stack, world, block, x, y, z, entity); } }else { super.onBlockDestroyed(stack, world, block, x, y, z, entity); } } return true; } And, when retrieving it although, the ItemStack parameter is suppose to contain the item and all of it's info; it does not. I know I must be doing something incorrectly and would love some knowledge on the subject.
-
[1.8] Allocate more ram to mc
Every game uses the CPU, GPU and RAM to perform tasks. Ram is like a train station holding information for the train which would be the game to call for it. The GPU renders all the graphic components on the client and, the CPU handles server type input such as block placement, entities and the sorts.
-
[1.7.10] Trouble with stackTagCompound
So, I did what you said but still the same problem. I moved my code under the "onBlockDestroyed" method in my item class yet, the NBT of the stack still returns null. Am I not setting it correctly? Ignore the GUI stuff. public void onCreated(ItemStack stack, World world, EntityPlayer player) { if(world.isRemote) return; NBTTagCompound cmp = stack.stackTagCompound; if(cmp == null) { System.out.println("NBT TAG SET"); cmp = new NBTTagCompound(); stack.stackTagCompound = cmp; } this.fixNBT(stack); System.out.println(stack.stackTagCompound); cmp.setString("MiningSize", "3x3"); } public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean flag) { list.add(EnumChatFormatting.RED + "Use SHIFT + Right-Click to"); list.add(EnumChatFormatting.RED + "open the modification menu."); list.add(""); list.add(EnumChatFormatting.GREEN + "Hit Left-ALT to open the"); list.add(EnumChatFormatting.GREEN + "quick change menu."); } public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if(player.isSneaking()) { FMLNetworkHandler.openGui(player, CrewMod.instance, GuiId.guiCrewHammerID, world, (int)player.posX, (int)player.posY, (int)player.posZ); } return stack; } public static void fixNBT(ItemStack hammer){ NBTTagCompound cmp = hammer.stackTagCompound; if(cmp == null) { System.out.println("CMP WAS NULL, FIXING..."); hammer.stackTagCompound = new NBTTagCompound(); cmp = hammer.stackTagCompound; } if(!cmp.hasKey("MiningSize")){ System.out.println("MiningSize WAS NULL, FIXING..."); cmp.setString("MiningSize", "1x1"); } hammer.stackTagCompound = cmp; } public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entity) { EntityPlayer player = (EntityPlayer)entity; System.out.println("CALLED"); if(world != null && player != null) { System.out.println("WORLD WAS NOT NULL NOR WAS PLAYER"); 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 = stack; //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; CrewHammer.fixNBT(hammer); 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"); } System.out.println(miningArea); this.breakBlock(world, player, hammer, x, y, z, direction, miningArea); }else { super.onBlockDestroyed(stack, world, block, x, y, z, entity); } }else { super.onBlockDestroyed(stack, world, block, x, y, z, entity); } } return true; }
-
[1.7.10] Trouble with stackTagCompound
What do you mean by the same tool? And there would be no final code as of yet considering my problem is not solved.
-
[1.7.10] Trouble with stackTagCompound
Even when I do that, it would still require me to be able to set and update the nbt for the item from the GUI class.
-
[1.7.10] Trouble with stackTagCompound
I do check if it is the server: if(world.isRemote) return; And when it printed out it said this: [01:38:47] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:46]: {MiningSize:"1x1",} [01:38:47] [server thread/INFO] [sTDOUT]: [com.happykiller.crewmod.items.tools.CrewHammer:onCreated:46]: {MiningSize:"3x3",} The fixNBT sets it to 1x1 and then I set it to 3x3. Both of those are called by doing: System.out.println(stack.stackTagCompound);
-
[1.7.10] Trouble with stackTagCompound
It prints out two times in the console saying it set.
-
[1.7.10]adding effects to an arrow
Check out the Bow class and EntityArrow class in the vanilla code. I believe the arrow just checks if the bow has an enchantment then edits the "onEntityCollided" method to add the effects like lighting someone on fire.
-
[1.7.10] Trouble with stackTagCompound
No that is what I mean but, it seems to always default my info. Like see here where it is called in my Item class and event class (I removed the String variable): //In Item Class public void onCreated(ItemStack stack, World world, EntityPlayer player) { if(world.isRemote) return; System.out.println("NBT TAG SET"); NBTTagCompound cmp = stack.stackTagCompound; if(cmp == null) { cmp = new NBTTagCompound(); stack.stackTagCompound = cmp; } this.fixNBT(stack); cmp.setString("MiningSize", "3x3"); } //Event Class public void onBlockBreak(BreakEvent event) { EntityPlayer player = event.getPlayer(); 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; CrewHammer.fixNBT(hammer); 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"); } System.out.println(miningArea); this.breakBlock(world, player, hammer, x, y, z, direction, miningArea); } } } } When called in the event class, the information is defaulted because the stackTagCompound returns null although I set it in the onCreated (Yes I craft a new hammer every time I go to test it)
-
[1.7.10] Trouble with stackTagCompound
Now see, the stackTagCompound will be null in any class besides the Item class (as it is now). By calling this method it would fix the nbt but, I'd have to fix it again in the gui class which wouldn't update it for the event class. This is a problem considering the nbt needs to be set from the gui to be used in the event class for handling.
-
[1.7.10] Trouble with stackTagCompound
It does seem to work. I added a String variable so I can set the string to something I want. So, in a GUI class I could call the fix NBT to set it correctly? Or am I missing something?
IPS spam blocked by CleanTalk.