coolAlias Posted March 25, 2014 Posted March 25, 2014 What are your opinions on setting out a separate class file for the detection of when my mod items damage entities they store NBT data. That way each of my tools doesn't need 20+ lines of code. It just refers to the separate class file? Yeah, sorry, as sequituri pointed out, what you stated there is a terrible idea, which I failed to mention in my post. Glad that's all cleared up. Quote http://i.imgur.com/NdrFdld.png[/img]
Deadlyapples Posted March 25, 2014 Author Posted March 25, 2014 I actually slept on it and thought maybe 20 lines for each item isnt a big deal. The other thing I was thinking of is potentially storing all the items data within the nbt of that one item. Sooo. Sword kills mob. + 1 Kill onto the sword. -1 Durability to the sword. When sword reaches 100 kills - Do something! When durability reaches 1 - Sword texture changes to (Blah blah:swordtexture2) - Weapon durability disabled. - Weapon damage set to 1. ( So it does as much damage as punching) - If item.texture = swordtexture2 - Don't gain kills when mob killed. This way when the tool reaches 1 durability and then no longer functions as a normal tool, the texture is also switched out and it no longer gains kills etc. Any thoughts on that? Quote
coolAlias Posted March 25, 2014 Posted March 25, 2014 You may as well just switch to a different item at that point. Is there any reason that you need to keep it the exact same Item or ItemStack? Will you keep the NBT data intact? You can do that by transferring the NBT to a new stack with a different item. You could do it all in one class, but it's cleaner (and easier) to have a separate item if that many traits will be different. Quote http://i.imgur.com/NdrFdld.png[/img]
Deadlyapples Posted March 25, 2014 Author Posted March 25, 2014 Ok. My idea is tools that change but keep their data. So a Pick, upgrades with a speed upgrade but then might level up to another pick, so it needs to keep the speed upgrade. And because each tool might have a variety of different upgrades, the only way I can think of it working is if the item stays the same and the same ID but the texture changes and its stats change while other stats remain. Do you understand where I am coming from? Quote
coolAlias Posted March 25, 2014 Posted March 25, 2014 Gotcha. You can still do it either way, though. For your idea, you will need to override lots of methods, making sure each one has an ItemStack parameter so you can access the NBT and return an appropriate value based on that, rather than the Item's base values. Any method that you need that does not have an ItemStack-parameter version will require a new Item to handle, but you can still copy the NBT over to the new item when you set the player's held item, retaining all the important data. Quote http://i.imgur.com/NdrFdld.png[/img]
Deadlyapples Posted March 25, 2014 Author Posted March 25, 2014 I both understand and am completely confused at the same time. Haha! I will just have to get used to all this stuff. But I am enjoying it greatly. I understand doing all this overriding of stats. Also are you saying that storing durability, damage, kills, upgrades, breakable/or not, speed is all stored as NBT data and the weapons damage is derived or extracted from the NBT data? That way as the NBT data changes so does the weapons damage, speed, durability etc? Quote
coolAlias Posted March 25, 2014 Posted March 25, 2014 Also are you saying that storing durability, damage, kills, upgrades, breakable/or not, speed is all stored as NBT data and the weapons damage is derived or extracted from the NBT data? That way as the NBT data changes so does the weapons damage, speed, durability etc? Oops, wrong button No, I'm saying that YOU will have to make it rely on NBT for that stuff, which is not going to be a walk in the park. Weapon damage is based on the multimap data, which does not have an ItemStack parameter, meaning your best bet for changing that is to create a new Item, though that can be worked around it's a lot easier to do it that way. Quote http://i.imgur.com/NdrFdld.png[/img]
Deadlyapples Posted March 25, 2014 Author Posted March 25, 2014 Could I not declare and set up the nbt prior to the weapons damage and other stats then this.setDamage() equals NBTDamage ? I am still learning so trial and error works for me as it always does hehe The other thing is that because I am still learning and new to this I am probably going to make so e messy code for the most part. But if I can get some of the functionality to work as I understand at the moment then I can develop my knowledge of programming with minecraft and make the code more efficient. Quote
coolAlias Posted March 25, 2014 Posted March 25, 2014 That's not how NBT works. You need an ItemStack to have access to NBT, and you won't have one when you are assigning damage, but you could get the MultiMap when your item is changing / breaking or whatever and set a new value from there, in which case you should have an ItemStack handy. Quote http://i.imgur.com/NdrFdld.png[/img]
Deadlyapples Posted March 25, 2014 Author Posted March 25, 2014 Oooh. Herp a derp on my part. So I could set base stats for the tools (Like you normally do for a weapon / tool) and from then on i can have their stats change based on if statments, mob damage, block breaking and other things, and have it also save that data as NBT data or change stats by checking the NBT data? But what your saying is you cannot have the damage changed by the nbt data at initialization because the tool really doesn't exist then? I appreciate all the fast replies btw. You are really helping me learn more as I make this mod! Quote
coolAlias Posted March 25, 2014 Posted March 25, 2014 You can't use NBT during initialization because you don't have any NBT and you don't have any way to get valid NBT. The whole point of NBT is that it is attached to a specific ItemStack, it's not magic that stores data anywhere At this point you should just start coding and see if you can get it to work. Start with something simple first, and add things one at a time, making sure each one works before moving on to the next. If you try to do it all at once with no prior experience, you're just asking for trouble. Quote http://i.imgur.com/NdrFdld.png[/img]
Deadlyapples Posted March 25, 2014 Author Posted March 25, 2014 So you are telling me that Minecraft and java programming is not magic? Well I am truly disappointed! My dreams are scattered! Oh wait I forgot to ask. Is there any way of displayed the stored NBT data on the actual tool? You know how you can see this weapon as 6 Damage or what ever on the tool. Can you display as simple text or color text some of the information? Like I could show that the tool has 21 out of 100 kills on it or something like that? Quote
coolAlias Posted March 25, 2014 Posted March 25, 2014 Item#addInformation is what you're looking for. Quote http://i.imgur.com/NdrFdld.png[/img]
Deadlyapples Posted March 25, 2014 Author Posted March 25, 2014 "These are not the methods you are looking for.." *waves hand about like a Jedi* Quote
coolAlias Posted March 25, 2014 Posted March 25, 2014 "These are not the methods you are looking for.." *waves hand about like a Jedi* Exactly Quote http://i.imgur.com/NdrFdld.png[/img]
Deadlyapples Posted March 25, 2014 Author Posted March 25, 2014 Btw is there a way of disabling an items ability to take damage? I know there is a .isDamageable() but is it possible to set that to false so that it isn't damageable ? Quote
SanAndreaP Posted March 25, 2014 Posted March 25, 2014 setMaxDamage(0); Quote Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
Deadlyapples Posted March 25, 2014 Author Posted March 25, 2014 Aaaaand. Another questions. How does one change a tools efficiency / speed of harvesting? I see there is the ability to .getDigSpeed() but not a way to set it? Quote
SanAndreaP Posted March 25, 2014 Posted March 25, 2014 Aaaaand. Another questions. How does one change a tools efficiency / speed of harvesting? I see there is the ability to .getDigSpeed() but not a way to set it? override getStrVsBlock(...) Look at the ItemTool class on how it did it (read the javadoc above the method). Quote Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
Deadlyapples Posted March 25, 2014 Author Posted March 25, 2014 I dunno if this is a bug on my part or whether things have changed but with 1.7 all I am seeing in the class file editor for ItemTool.class us Source file not found. Then all the code underneath is hideous to look at. No comments as well. Or Javadocs etc. Quote
coolAlias Posted March 25, 2014 Posted March 25, 2014 Run "gradlew setupDecompWorkspace" Quote http://i.imgur.com/NdrFdld.png[/img]
Deadlyapples Posted March 25, 2014 Author Posted March 25, 2014 All I get at the end is build failed. Then when I open the class file it still says Source not found. I have had this issue on every computer I have tried. My Java I am sure is set up correctly, but that gradlew setupDecompWorkspace doesn't work. Any thoughts? Quote
Deadlyapples Posted March 25, 2014 Author Posted March 25, 2014 setupDecompWorkspace yields this mess! **************************** Powered By MCP: http://mcp.ocean-labs.de/ Searge, ProfMobius, Fesh0r, R4wk, ZeuX, IngisKahn MCP Data version : unknown **************************** :extractUserDev :getAssetsIndex :getAssets :copyAssets :extractNatives :genSrgs UP-TO-DATE :downloadMcpTools UP-TO-DATE :downloadClient SKIPPED :downloadServer SKIPPED :mergeJars SKIPPED :deobfuscateJar Applying SpecialSource... Applying Exceptor... Injecting source info... :decompile :doFmlPatchesPatching failed: net/minecraft/client/gui/GuiIngame.java Cannot find hunk target 2: Cannot find hunk target @ 0 1/2 failed Rejects written to C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\expandedArchives\fmlpatches.zip_bjh7akumkkh12c91hrqumojdr\net\minecraft\client\gui\GuiIngame.java.patch.rej Patching failed: net/minecraft/entity/player/EntityPlayer.java Cannot find hunk target 4: Cannot find hunk target @ 0 1/4 failed Rejects written to C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\expandedArchives\fmlpatches.zip_bjh7akumkkh12c91hrqumojdr\net\minecraft\entity\player\EntityPlayer.java.patch.rej :addFmlSources :remapJar :doForgePatchesPatching failed: net/minecraft/client/gui/achievement/GuiAchievements.java Cannot find hunk target 6: Cannot find hunk target @ 0 7: Cannot find hunk target @ 0 2/7 failed Rejects written to C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\expandedArchives\forgepatches.zip_6vp0dsutg5p1795v38lpgl539p\net\minecraft\client\gui\achievement\GuiAchievements.java.patch.rej Patching failed: net/minecraft/client/renderer/ItemRenderer.java Cannot find hunk target 5: Cannot find hunk target @ 0 7: Cannot find hunk target @ 0 2/7 failed Rejects written to C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\expandedArchives\forgepatches.zip_6vp0dsutg5p1795v38lpgl539p\net\minecraft\client\renderer\ItemRenderer.java.patch.rej Patching failed: net/minecraft/client/renderer/RenderBlocks.java Cannot find hunk target 5: Cannot find hunk target @ 0 1/11 failed Rejects written to C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\expandedArchives\forgepatches.zip_6vp0dsutg5p1795v38lpgl539p\net\minecraft\client\renderer\RenderBlocks.java.patch.rej Patching failed: net/minecraft/client/renderer/RenderGlobal.java Cannot find hunk target 4: Cannot find hunk target @ 0 1/10 failed Rejects written to C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\expandedArchives\forgepatches.zip_6vp0dsutg5p1795v38lpgl539p\net\minecraft\client\renderer\RenderGlobal.java.patch.rej Patching failed: net/minecraft/client/renderer/entity/RenderItem.java Cannot find hunk target 4: Cannot find hunk target @ 0 14: Cannot find hunk target @ 0 2/18 failed Rejects written to C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\expandedArchives\forgepatches.zip_6vp0dsutg5p1795v38lpgl539p\net\minecraft\client\renderer\entity\RenderItem.java.patch.rej Patching failed: net/minecraft/entity/player/EntityPlayer.java Cannot find hunk target 37: Cannot find hunk target @ 0 1/37 failed Rejects written to C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\expandedArchives\forgepatches.zip_6vp0dsutg5p1795v38lpgl539p\net\minecraft\entity\player\EntityPlayer.java.patch.rej Patching failed: net/minecraft/inventory/ContainerBrewingStand.java Cannot find hunk target 3: Cannot find hunk target @ 0 1/3 failed Rejects written to C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\expandedArchives\forgepatches.zip_6vp0dsutg5p1795v38lpgl539p\net\minecraft\inventory\ContainerBrewingStand.java.patch.rej Patching failed: net/minecraft/world/gen/feature/WorldGenDungeons.java Cannot find hunk target 2: Cannot find hunk target @ 0 1/3 failed Rejects written to C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\expandedArchives\forgepatches.zip_6vp0dsutg5p1795v38lpgl539p\net\minecraft\world\gen\feature\WorldGenDungeons.java.patch.rej Patching failed: net/minecraft/world/gen/feature/WorldGenSwamp.java Cannot find hunk target 3: Cannot find hunk target @ 0 1/7 failed Rejects written to C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\expandedArchives\forgepatches.zip_6vp0dsutg5p1795v38lpgl539p\net\minecraft\world\gen\feature\WorldGenSwamp.java.patch.rej Patching failed: net/minecraft/world/gen/structure/StructureVillagePieces.java Cannot find hunk target 7: Cannot find hunk target @ 0 8: Cannot find hunk target @ 0 9: Cannot find hunk target @ 0 3/9 failed Rejects written to C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\expandedArchives\forgepatches.zip_6vp0dsutg5p1795v38lpgl539p\net\minecraft\world\gen\structure\StructureVillagePieces.java.patch.rej :addForgeJavadoc :extractForgeSrc :recompForgewarning: [options] bootstrap class path not set in conjunction with -source 1.6 C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\entity\player\EntityPlayer.java:208: error: cannot find symbol this.eyeHeight = this.getDefaultEyeHeight(); ^ symbol: variable eyeHeight C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\entity\player\EntityPlayer.java:208: error: cannot find symbol this.eyeHeight = this.getDefaultEyeHeight(); ^ symbol: method getDefaultEyeHeight() C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\entity\player\EntityPlayer.java:1116: error: cannot find symbol return eyeHeight; ^ symbol: variable eyeHeight location: class EntityPlayer C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\entity\player\EntityPlayer.java:1806: error: method getBedLocation in class EntityPlayer cannot be applied to given types; return getBedLocation(this.dimension); ^ required: no arguments found: int reason: actual and formal argument lists differ in length C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\entity\player\EntityPlayer.java:1812: error: method isSpawnForced in class EntityPlayer cannot be applied to given types; return isSpawnForced(this.dimension); ^ required: no arguments found: int reason: actual and formal argument lists differ in length C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\entity\player\EntityPlayer.java:1822: error: method setSpawnChunk in class EntityPlayer cannot be applied to given types; setSpawnChunk(par1ChunkCoordinates, par2, this.dimension); ^ required: ChunkCoordinates,boolean found: ChunkCoordinates,boolean,int reason: actual and formal argument lists differ in length C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\entity\player\EntityPlayer.java:2442: error: cannot find symbol ChatComponentText chatcomponenttext = new ChatComponentText(ScorePlayerTeam.formatPlayerName(this.getTeam(), this.getDisplayName())); ^ symbol: method getDisplayName() C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\item\Item.java:790: error: cannot find symbol double d1 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)f + (double)(par1World.isRemote ? par2EntityPlayer.getEyeHeight() - par2EntityPlayer.getDefaultEyeHeight() : par2EntityPlayer.getEyeHeight()); // isRemote check to revert changes to ray trace position due to adding the eye height clientside and player yOffset differences ^ symbol: method getDefaultEyeHeight() location: variable par2EntityPlayer of type EntityPlayer C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\world\gen\structure\StructureVillagePieces.java:1942: error: cannot find symbol BiomeEvent.GetVillageBlockID event = new BiomeEvent.GetVillageBlockID(startPiece == null ? null : startPiece.biome, p_151558_1_, p_151558_2_); ^ symbol: variable biome location: variable startPiece of type Start C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\world\gen\structure\StructureVillagePieces.java:1983: error: cannot find symbol BiomeEvent.GetVillageBlockMeta event = new BiomeEvent.GetVillageBlockMeta(startPiece == null ? null : startPiece.biome, p_151557_1_, p_151557_2_); ^ symbol: variable biome location: variable startPiece of type Start C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\server\management\ServerConfigurationManager.java:435: error: method getBedLocation in class EntityPlayer cannot be applied to given types; ChunkCoordinates chunkcoordinates = par1EntityPlayerMP.getBedLocation(par2); ^ required: no arguments found: int reason: actual and formal argument lists differ in length C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\server\management\ServerConfigurationManager.java:436: error: method isSpawnForced in class EntityPlayer cannot be applied to given types; boolean flag1 = par1EntityPlayerMP.isSpawnForced(par2); ^ required: no arguments found: int reason: actual and formal argument lists differ in length C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\entity\player\EntityPlayerMP.java:1176: error: method does not override or implement a method from a supertype @Override ^ C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\cpw\mods\fml\common\network\internal\OpenGuiHandler.java:16: error: cannot find symbol player.openGui(msg.modId, msg.modGuiId, player.worldObj, msg.x, msg.y, msg.z); ^ symbol: method openGui(String,int,World,int,int,int) location: variable player of type EntityPlayer C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraft\client\entity\EntityOtherPlayerMP.java:174: error: method does not override or implement a method from a supertype @Override ^ C:\Users\Studio Apples\Desktop\Minecraft Mod\build\tmp\recompSrc\net\minecraftforge\common\util\FakePlayer.java:33: error: method does not override or implement a method from a supertype @Override public void openGui(Object mod, int modGuiId, World world, int x, int y, int z){} ^ Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 16 errors 1 warning FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':recompForge'. > Compilation failed; see the compiler error output for details. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 2 mins 34.937 secs Quote
Deadlyapples Posted March 25, 2014 Author Posted March 25, 2014 coolAlias I am trying to trigger something if (evometer.getInteger("evolutionMeter") >= 30) { this.setTextureName("evolvinggearmod:FleshBoundPick"); this.setUnlocalizedName(toolNameFlesh); } } return When the evolution meter reaches 30 + changed item texture and name but not swap the actual item. Just change the way it looks and its name. But when I do this the texture doesn't change and the name becomes weird. Like name.FleshBoundPickaxe.## etc Any thoughts? The issue I think I am having is with that current code I am effectivly changing the entire item types name and texture. When what I want to be doing is just changing the texture and name and stats of the currently held item as its own thing. I just don't know how to work that out. Would I be able to do something with NBT data? Quote
Recommended Posts
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.