Jump to content

Daeruin

Members
  • Posts

    424
  • Joined

  • Last visited

Everything posted by Daeruin

  1. Sigh. Learning to program via Minecraft modding sometimes makes me question my sanity. I have fixed both the problems you pointed out. I now see my GUI. Here's the new code: However, I'm still seeing the slot highlights from the original 2x2 crafting grid--they partially overlap my custom crafting grid slots. Where are they coming from? There's weird crap going on in the creative inventory, too. It seems that maybe the slot IDs are all messed up, with the little armor icons appearing in hot bar slots, and items appearing in two slots at once depending on where they are placed, etc. Possibly because it's using my custom player inventory slot IDs? How do I fix that?
  2. I'm creating a custom player inventory. I'm attempting to give the player a 3x3 crafting grid by default, instead of 2x2. However, the vanilla GUI is appearing on the screen instead of mine. It still shows the highlight slots from my GUI, and I can even put items where the slots should be. I have a few other problems, like the crafting grid not producing a crafting result—do I need a custom crafting manager? Also, the creative player inventory is screwy (armor slots appearing in hot bar). Common Proxy where I register my OpenGuiEvent and my GUI Handler: My GUI Handler: My GUI class: Event for opening GUI and attaching player inventory (no, I'm not using Capabilities for this yet - advice on how to achieve that would be welcome): My player container: My player inventory:
  3. I don't understand what you mean when you say it deletes the item in your first slot. But I did notice this line: this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 3, 30 + j * 18, 17 + i * 18)); I believe you need to change the 3 to a 4 so your crafting grid slots will have correct IDs. Maybe that will help?
  4. That's the way I was leaning. I started to get a little worried about the sheer number of files that will be in my capabilities package, considering all the capabilities I want to add in the future. But I can definitely see how it would get unwieldy to mash all the capabilities together. I don't have an API in my sights yet. If I get requests for it, I might try to learn how to do it, but things are going slowly enough that I'm not sure I'll even finish the dang mod to begin with.
  5. I wrestled with this recently, too. You have to register a color handler for your leaf block and itemblock. I did it in my client proxy. Look at the vanilla BlockColors class for examples.
  6. I am still trying to learn how to best use the new Capabilities features in Forge. I have set up two completely separate capabilities, one that adds a thirst attribute to players and one that adds a set of booleans to players to keep track of hints I give out as they play. Each of these two capabilities has their own interface, provider, and storage classes. I have a single capability handler that attaches the capabilities to the player. I think I could mash both of them together into a single Capability. But would that be wise? It seems cleaner as is. I'm not sure what the pros and cons would really be. I'm planning to add more capabilities soon, like a custom player inventory, and I want to go forward in a good way.
  7. Look at vanilla WorldGenTrees class. That first block of code in the generate method is basically scanning a section of the world in the shape of a vanilla oak tree to see if there is anything else in the way. Something along those lines might work. It would probably be harder for big trees. Or look at WorldGenAbstractTree. There are methods that define what kinds of blocks can be replaced by a tree. You might need to create your own tree generator class that extends WorldGenAbstractTree and overrides those methods.
  8. Ohhh, I see. I can get the field up front, because I know which class it's coming from. I don't even need to get the class itself, as long as I'm making sure to get the field value only when the biome being generated is of the right type. New code:
  9. Yep, that worked. I actually found an issue report you created about that snapshot mere minutes before you posted your reply. Thank you yet again. After updating, it took a few minutes to rename some fields and tweak my mcmod.info file, and the build worked. It's been over two months since I finally decided to update. It's nice to have a functioning mod again.
  10. Well, I decided to go ahead and install a newer version of Forge, but it won't compile. I updated my build.gradle file like so: minecraft { version = "1.10.2-12.18.2.2147" mappings = "snapshot_20161117" } I chose those versions because that snapshot is the latest one listed on the MCPbot site, and that version of forge was released on that day (according to the Forge downloads page). But setupDecompWorkspace gives me an error: [ant:javac] ...Primalcraft/build/tmp/recompileMc/sources/net/minecraft/inventory/ContainerPlayer.java:62: error: local variable player is accessed from within inner class; needs to be declared final [ant:javac] return stack.getItem().isValidArmor(stack, entityequipmentslot, player); [ant:javac] ^
  11. Ah. So if I go ahead and rename things to match the latest mapping, I'll need to update my Forge installation, correct? Or I could change which mapping I use in my build.gradle file to an older version that matches my installed Forge version.
  12. I finally finished converting to 1.10.2, so I thought I'd try to compile my mod. I haven't done it for months. I'm getting some errors that I don't know how to deal with. I spent a while Googling but didn't come up with anything. The most common error is a "cannot find symbol" error for "variable worldObj". Here's an example error message: And here's the relevant class: If I could fix all examples of this error, I'd cut the errors in half (I'm getting about 30 errors!).
  13. It seems to be working now. I didn't use MethodHandles, and performance seems to be OK. Thanks for posting the links to your example mod, Choonster; the examples were nice. I didn't find jabelar's info to be very helpful, but there was a link to a page that was super helpful: http://tutorials.jenkov.com/java-reflection/index.html It took me a minute to figure out how to use the MCPbot (http://mcpbot.bspk.rs/help). I discovered that there's yet another type of forest which is a subclass of BiomeForest that I had to account for. Here's the completed code from my world generator class, in case it helps anyone later. I'd be glad for feedback as well. Biome biome = world.getBiomeGenForCoords(pos); boolean rightForestType = false; if (biome instanceof BiomeForest && !(biome instanceof BiomeForestMutated)) { try { Class<?> biomeClass = biome.getClass(); Field typeField = ReflectionHelper.findField(biomeClass, "type", "field_150632_aF"); Object biomeType = typeField.get(biome); if (biomeType == BiomeForest.Type.NORMAL) rightForestType = true; } catch (IllegalAccessException x) { x.printStackTrace(); throw new ReflectionHelper.UnableToAccessFieldException(null, x); } if (rightForestType == true) { DO STUFF }
  14. That's fine. I only need to read the value to find out what kind of biome it is. I was more concerned about it being private. Edit: Now that I've done more reading, I see that it is indeed possible to access private fields with reflection.
  15. Thank you kindly, good sirs. I'll read up on all that tomorrow. Hopefully it goes well. One thing, though. I noticed that the type field in BiomeForest is private final. Seems like that will block access to the field's value. Am I right? Or will reflection let me overcome that?
  16. Thanks for your reply. I am already using instanceof to determine if the biome is a BiomeForest, so I'm good there. And yes, I looked at the BiomeForest class and saw the type field. I just didn't know how to access it. I've never used reflection, so I guess I have more reading to do. If there's a particularly good resource you can point me to online, I'd me much obliged. Unless someone has a quick explanation of how I can use it in this case.
  17. It might help if you tried explaining what you are trying to accomplish and what you've already tried. "I've tried and it does't work" doesn't give us much to go on.
  18. In my world generator class I have been using World#getBiomeGenForCoords to get the current biome and check if it's a forest biome. However, I realized I need to detect which TYPE of forest it is (NORMAL, BIRCH, FLOWER ROOFED). I can see that BiomeForest has a Type enum, but I'm not sure how to access that value given that the current biome may or may not even be of the BiomeForest type. Does that make sense?
  19. I'm a relative newbie myself, but maybe I can help a little. You have to register each model variant separately. In my mod, I have a block with variants based on an enum property, so I just iterate over the enum to register a model for each variant. I admit I didn't comb over all the code you posted, but where do you actually register the item models? I see lots of model registration methods, but I don't see any of them called for your block.
  20. OK, that makes sense. I got rid of the null pointer exception. It still wasn't working, but after a while of poking around in the BlockColors class I realized I was using the wrong colorMultiplier method. After copying the right method (which already had the null checks built in, as you pointed out), it's now working perfectly. The main difference seems to be the use of BiomeColorHelper instead of getBiomeGenForCoords, along with a backup return value in case of null arguments. I also streamlined my old methods a little. Finished code, for those who may be interested in this later:
  21. CoolAlias's tutorial has some pretty decent commentary: https://github.com/coolAlias/Forge_Tutorials/blob/master/InventoryItemTutorial.java Bedrock Miner is usually good at explaining stuff, too: https://bedrockminer.jimdo.com/modding-tutorials/#advanced Both of those are for 1.8.9 or earlier. Shadowfacts tutorials are usually good at explaining this as well and are for 1.10 and later: https://shadowfacts.net/tutorials/forge-modding-1102/
  22. I posted a question about NBT just yesterday, and Animefan8888 gave me a brief overview. You could try looking up that post. Did you create a custom chest? Containers use NBT to store their inventory.
  23. I created some custom leaves and got everything working, except the item version lacks any color. I get that I have to register an item color handler, but the code isn't working. I copied it almost directly from the vanilla ItemColors class, but I'm getting a null pointer exception. I don't understand why it works for the vanilla code but not mine. This is in init in my ClientProxy. The first part works fine and gives me nice green leaf blocks when placed in the world. The second part gives me the null pointer exception. Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(new IBlockColor() { @Override public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) { return worldIn.getBiomeGenForCoords(pos).getFoliageColorAtPos(pos); } }, PrimalBlockRegistry.leafHickory); Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemColor() { @Override public int getColorFromItemstack(ItemStack stack, int tintIndex) { @SuppressWarnings("deprecation") IBlockState iblockstate = ((ItemBlock) stack.getItem()).getBlock().getStateFromMeta(stack.getMetadata()); return Minecraft.getMinecraft().getBlockColors().colorMultiplier(iblockstate, (IBlockAccess)null, (BlockPos)null, tintIndex); } }, PrimalBlockRegistry.leafHickory); The error (lines 45 and 54 are the two return statements in the above code): Any advice you can give is greatly appreciated. Thanks in advance.
  24. Thank you, that was very helpful! I put my set of boolean values in an array, then in my capability's storage class I iterated through the array to save each value using NBTTagCompound#setBoolean. Very slick, once I figured it out. It took me a bit longer to figure out how to get the values out. I was trying it with a single boolean value at first, and apparently there is no getBoolean method available from NBTBase or NBTPrimitive. Once I put everything into the compound, I was able to use NBTTagCompound#getBoolean. For those reading this later, I found this reference helpful: http://www.cs.cornell.edu/courses/cs2110/2014fa/L04-Hierarchy_static/mcp_doc/net/minecraft/src/NBTTagCompound.html
  25. Oh, right... I remember seeing that somewhere before. Can anyone point me to some good examples? Or explain how it's done? I have yet to find a decent tutorial on NBT tags. The few things I have that use NBT were created by looking at examples, but that never gives the whole picture.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.