Jump to content

Recommended Posts

Posted (edited)

[Redacted]

Please ignore this post. I'm pretty sure what I was asking for is impossible, and I'll need to completely redo how I was implementing it.

Edited by IdrisQe
The whole post was nonsense
Posted
31 minutes ago, IdrisQe said:

So... basically, have I messed up horribly here, or is there a way to salvage this mess?
Sorry for my first question being so monumentally huge and completely insane in its implementation. As I said, this is my first time, and I've also not coded much of anything in the past 5 or so years, so I'm very rusty.

Cache the a list of IBlockStates on startup in either the initialization event or the postInitialization event in your @Mod class. This solves long break times, however it will take a little longer to load the game initially. On the other hand you could cache this when a block is broken so only the first block takes a while. I'd recommend the first one personally.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

While I appreciate the fast response, this isn't actually what I wanted help with. Slow block breaking is the intent of the mod, unless a block is whitelisted in the config or other conditions are met. The issue is that I want to be able to whitelist specific variants of blocks like snowy grass as an example.
so minecraft:grass with the property snowy: true
say I want to whitelist that for whatever reason so you can break snowy grass at normal speed but other variants you can't.
so in the config I have something amounting to:
String[] BreakableDataWhitelist = {"minecraft:grass{snowy=true}"}
I break that down into the block and key/value property pairs in lists so I can easily get just the key or just the value.
So it ends up something amounting to:
BreakableDataWhitelist[0] = "minecraft:grass"
BreakableData[0] = {
properties = {"snowy","true"}
}
and so I need to get the block being targeted for mining.
i get that, I pass it to isDataWhitelisted, and I need to get its properties.
so I do that, then I go to compare the key/value property pair in the properties list to the actual block's properties
so "if blockState (the block).getProperties().containsKey(properties[0])"
"if blockState.getProperties().containsValue(properties[1])"
but that doesn't work because properties[0] and properties[1] are Strings, and containsKey and containsValue need Objects as arguments, not Strings.
so I need a way to convert the String in the config file to Objects of the type [string's contents]
so i need to convert String "snowy" into Object snowy so that containsKey() can actually accept it and check if the block's properties contains the key "snowy" and String "true" into Object true so that containsValue() can actually accept it and check if the block's properties contains the value "true".

And I'm aware that brings up the issue of there being multiple "true" values in the block's properties but one issue at a time.

Posted
17 minutes ago, IdrisQe said:

And I'm aware that brings up the issue of there being multiple "true" values in the block's properties but one issue at a time.

A String is an Object. So you dont need to convert a String to an Object.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Except it wouldn't accept Strings. I tried. Just please nevermind, I'm going to redo this whole mess from the ground up to find a less completely insane way to do it.

Posted
3 hours ago, IdrisQe said:

Except it wouldn't accept Strings. I tried. Just please nevermind, I'm going to redo this whole mess from the ground up to find a less completely insane way to do it.

Can you tell us what your trying to achieve? We will probably be able to help, but you redacted your original question so no one who happens to read this (and might know an answer) will be able to help

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

I redacted it because it was terribly implemented and I redid the whole thing from the ground up. Hence why I said please ignore this post.

I don't want help on this issue anymore because I've completely scrubbed it from my code.

If I could delete the topic I would but there doesn't appear to be an option to do so.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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