Jump to content

1SDAN

Members
  • Posts

    24
  • Joined

  • Last visited

1SDAN's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. So if I give this a Block class it will give me the String (ie minecraft:oak_log) and vice versa? EDIT: Apparently not. Is the block to string one block.getRegistryName().toString()? EDIT2: I couldn't figure out how to convert a string to a resource location, but I've found Block.getBlockFromName(string). I'm going to do a couple tests to see what these two lines output and go from there.
  2. I'm working on a config file where players can set custom behaviors for blocks of vanilla and my and other mods and am having trouble finding a method of turning a string to a block and back. I know it exists, but all of the results I found via google that might answer my question seem to be outdated.
  3. Even in cases like changing block hardness where the game would still run fine even if it wasn't changed? NOTE: Block hardness is just an example, this is for the whole Block Health thing.
  4. That seems a bit clunky. Wouldn't it be better to send a client side chat message to the player once they log in/when the mod loads, use ConfigChangedEvent.OnConfigChangedEvent to detect a change in the .cfg filess and reload them using ConfigManager.sync(TestMod3.MODID, Config.Type.INSTANCE) so players don't have to reload the game every time they make a mistake?
  5. What would be the best method of notifying players of a null pointer exception caused by an improperly edited .cfg file without closing the game? I'm currently using a try catch expression to avoid crashes, but I'm unsure of what method is standard practice for notifying users.
  6. Oh it works with arrays? That helps a lot then. Thank you.
  7. I'm looking at the config annotation documentation but am still having trouble. What I'd prefer is if there was a region in the .cfg file where players can enter the name of a block and couple of health-related values, which the mod would use to fill an array of values. I'm completely clueless as to how I would go about this. It seems the config annotation requires you to define the individual variables ahead of time, unless I'm misunderstanding this.
  8. Understood. I would normally have used int[] but animefan advised using Float or Integer so I was misled to thinking it'd be better.
  9. Funny enough, this is the exact implementation I went with. Since starting this thread I've moved from Short, Integer maps to Short, Integer[] maps, does fastutil support something like this? I'm looking at the shorts package and can't find anything of the like.
  10. I just noticed I typed String instead of Integer. (Short/String/Long instead of Short/Integer/Long)... *faceplam*
  11. Your comment is a bit vague, are you saying I should use a Map<Short,Int> or a series of Longs/Strings/Shorts that when combined contain 16x256x16 X digit integers?
  12. I'm having trouble finding a method of iterating through an NBTTagCompound. It seems like I'm finding this a lot more difficult than it should be. I'm trying to use it in the following code: public static class QubHealthStorage implements Capability.IStorage<IQubHealth> { @Nullable @Override public NBTBase writeNBT(Capability<IQubHealth> capability, IQubHealth instance, EnumFacing side) { return new NBTTagInt(instance.get()); } @Override public void readNBT(Capability<IQubHealth> capability, IQubHealth instance, EnumFacing side, NBTBase nbt) { if (nbt instanceof NBTTagInt) { // The state is being loaded and not updated. We set the value silently to avoid unnecessary dirty chunks instance.set(((NBTTagInt) nbt).getInt(), false); } } } That's the int implementation. This is what I have in my current Map implementation public static class QubHealthStorage implements Capability.IStorage<IQubHealth> { @Nullable @Override public NBTBase writeNBT(Capability<IQubHealth> capability, IQubHealth instance, EnumFacing side) { NBTTagCompound compound = new NBTTagCompound(); for (Entry<BlockPos, Integer> entry : instance.get().entrySet()) { compound.setInteger(entry.getKey().toString(), entry.getValue()); } return compound; } @Override public void readNBT(Capability<IQubHealth> capability, IQubHealth instance, EnumFacing side, NBTBase nbt) { if (nbt instanceof NBTTagCompound) { //iterate through compound and set values } } } Seems like it'll end up being a lot less hassle, thanks.
  13. If my understanding of Chunk Capabilities (based on the example mod) is correct, I need an IStorage, which requires the use of an NBT tag matching the type of the variable. However there's no NBTTagMap class. Did I do something wrong? Must I make my own?
  14. Am I correct in that this means I will have to create a 3D array in order to store per-block values?
  15. As I said in the OP, BreakEvent seems to occur when you first click on a block, not when you break it. EDIT: Seems like I was wrong. My original implementation is working now, strange.
×
×
  • Create New...

Important Information

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