

1SDAN
Members-
Content count
24 -
Joined
-
Last visited
Community Reputation
0 NeutralAbout 1SDAN
-
Rank
Tree Puncher
-
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.
-
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.
-
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.
-
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?
-
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.
-
Oh it works with arrays? That helps a lot then. Thank you.
-
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.
-
Understood. I would normally have used int[] but animefan advised using Float or Integer so I was misled to thinking it'd be better.
-
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.
-
I just noticed I typed String instead of Integer. (Short/String/Long instead of Short/Integer/Long)... *faceplam*
-
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?
-
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.
-
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?
-
Am I correct in that this means I will have to create a 3D array in order to store per-block values?
-
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.