Jump to content

[1.6.4] Question on how to make a specific block mechanic


Arkoonius

Recommended Posts

Hi. I'm new to forge, and trying to make a mod of sorts that involves skills. However, I don't want the player to constantly have to explore for ores/trees if he/she doesn't want to. I would like ores to "respawn" when some time passes after the player successfully mines it (like wise with trees).

 

However, my inexperience with forge leads me having wondering how to achieve this. I've figured out that I can replace blocks via world.setBlock(), so my initial thought is I could replace the broken block with a default "empty ore" block that has an extra property which defines the block that was previously there. So, something along the lines of "emptyOreBlock.previousBlockID = Block.coalOre.blockID;". Along with that, I could have a counter variable that accumulates with a tick event of sorts. After a condition has passed, the emptyOreBlock would then revert back to the previous block by use of world.setBlock() and previousBlockID.

 

How to do this and whether or not my idea is even efficient is a bit beyond me. Could anyone provide any kind of tips/help/suggestions? Anything constructive would be appreciated.

Link to comment
Share on other sites

Alright. I'll do some research on tile entities then. Thanks.

 

What about trees though? Obviously I could do the same thing, as ores, and I should also most likely have a genTree() function of sorts to call when needed. But should I just call a bunch of world.setBlock() to spawn a tree with the coordinates relative to the stump? Or would there be a better way?

Link to comment
Share on other sites

Didn't think about looking at how saplings generate trees, lol. Sounds like a plan.

 

One more thing that just came up -- for the player's dataWatcher, I'm limited to using indexes 19-31. With due to this, I can only track the player's current experience of 13 skills. I'd like to go beyond 13, if it's possible. Any idea of a workaround?

Link to comment
Share on other sites

I have nothing against your plan for these respawning ores and trees, but just a word of caution. TileEntities that tick (which I presume these would) eventually lead to lag in larger quantities. If you don't mind a little slowdown, then press on. :)

Link to comment
Share on other sites

If you don't require your ores to regenerate at an absolutely perfect rate, you can forgo tile entities altogether by setting your block to tick randomly, return some value from tickRate(World), and handling what you need in the block's updateTick method. While this saves some on memory, it limits you to using the block's metadata as a counter, which may or may not be feasible/sufficient for your needs. Just to toss out another option xD

Link to comment
Share on other sites

If you don't require your ores to regenerate at an absolutely perfect rate, you can forgo tile entities altogether by setting your block to tick randomly, return some value from tickRate(World), and handling what you need in the block's updateTick method. While this saves some on memory, it limits you to using the block's metadata as a counter, which may or may not be feasible/sufficient for your needs. Just to toss out another option xD

 

I could do that. In fact, I'll probably do that. Store the previous block's ID as metadata within the emptyOreBlock. From there, determine a percentage that will determine whether the block respawns or not (probably just make a random number between two values). Higher tier ores will have a lower chance to respawn on tick.

 

I plan to have trees respawn similar to ores, so if using tile entities does mean taking a hit on performance, and with how common trees + ores are going to be in the world, it seems best straight from the start to make due with my plan above.

 

Think Runescape. The ore/trees of that game is what I'm trying to replicate. Well, this mod will be a Runescape mod in general. Once I figure out how to do the skills (and how to make some GUIs), I'm going to work on items, and then eventually mobs. My only issue is that I'll probably have to "combine" some skills on leave some out since the player's dataWatcher only has indexes 19-31 available.

Link to comment
Share on other sites

I meant using the metadata as a counter - there aren't enough bits in there to store a full block ID (only 4 bits of metadata storage per block). If you plan on having that many respawning blocks, you're probably going to have a huge performance hit irregardless of whether you use ticking blocks or tile entities, though slower tick rates should help ameliorate this somewhat.

 

Instead of making a new fake block for every single one of your blocks, I was more suggesting that you take your original block and only allowing it to be harvested say when metadata is zero; upon harvesting, instead of breaking, you pop out whatever drop you want and keep the block there, but set its metadata to 15. When the update tick runs, decrement the metadata at those coordinates by one. Of course you will have two different icons, one for its harvestable state, and one for its dormant state.

 

Again, this all depends on your blocks - if you are using the metadata for other things, it may not be available for you to use as a make-shift timer, but if you have at least one bitflag to determine the harvestable state, you can simply use a Random to determine if the flag gets reset during the update tick, which will effectively do the same thing if you make the chance low enough.

Link to comment
Share on other sites

I meant using the metadata as a counter - there aren't enough bits in there to store a full block ID (only 4 bits of metadata storage per block). If you plan on having that many respawning blocks, you're probably going to have a huge performance hit irregardless of whether you use ticking blocks or tile entities, though slower tick rates should help ameliorate this somewhat.

 

Instead of making a new fake block for every single one of your blocks, I was more suggesting that you take your original block and only allowing it to be harvested say when metadata is zero; upon harvesting, instead of breaking, you pop out whatever drop you want and keep the block there, but set its metadata to 15. When the update tick runs, decrement the metadata at those coordinates by one. Of course you will have two different icons, one for its harvestable state, and one for its dormant state.

 

Again, this all depends on your blocks - if you are using the metadata for other things, it may not be available for you to use as a make-shift timer, but if you have at least one bitflag to determine the harvestable state, you can simply use a Random to determine if the flag gets reset during the update tick, which will effectively do the same thing if you make the chance low enough.

 

Ok. How about this: I could use the metadata to determine whether the block can be harvested. If metadata > 0, then the block can be harvested. If the metadata is zero, then you simply can't harvest the block (cancel the BreakBlock event). From there, it's just figuring if I can dynamically switch the texture of the block so the player visually knows that the block can't be harvested. If all else, I suppose I could show a message, but that would just be annoying -- especially when it comes to the rare ores. I can also possibly use said metadata to determine how many times the block can be harvested. So, a block with a metadata of 4 can be harvested 4 times before it has to "respawn". This number would always be between 0 and 15, so it should work. Then just do whats needed if the conditions on a randomTick are met (change metadata/texture. Spawn tree if it's a tree stump, etc).

Link to comment
Share on other sites

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Realizing I was a victim of a scam was a devastating blow. My initial investment of $89,000, driven by dreams of financial success and the buzz surrounding a new cryptocurrency project, turned into a nightmare. The project promised high returns and rapid gains, attracting many eager investors like myself. However, as time passed and inconsistencies began to surface, it became evident that I had made a grave mistake by not thoroughly vetting the brokerage company handling the investment. Feeling anxious and betrayed, I desperately searched for a way to recover my funds. It was during this frantic search that I stumbled upon the Lee Ultimate Hacker tool through a Facebook post. With little left to lose, I decided to reach out to their team for help. To my relief, they were quick to respond and immediately started recovering my compromised email and regaining access to my cryptocurrency wallets. The team at Lee Ultimate Hacker was incredibly professional and transparent throughout the process. They meticulously traced the digital footprints left by the scammers, employing advanced technological methods to unravel the complex network that had ensnared my funds. Their expertise in cybersecurity and recovery strategies gradually began to turn the tide in my favor. Although the scammers had already siphoned off $30,000 worth of Bitcoin, Lee Ultimate Hacker was relentless in their pursuit. They managed to expose the fraudulent activities of the scam operators, revealing their identities and the mechanisms they used to lure investors. This exposure was crucial not only for my case but also as a warning to the wider community about the perils of unverified investment schemes. As we progressed, it became a race against time to retrieve the remaining $59,000 before the scammers could vanish completely. Each step forward was met with new challenges, as these criminals constantly shifted tactics and moved their digital assets to evade capture. Nonetheless, the determination and skill of the recovery team kept us hopeful. Throughout this ordeal, I learned the hard value of caution and due diligence in investment, especially within the volatile world of cryptocurrency. The experience has been incredibly taxing, both emotionally and financially, but the support and results provided by Lee Ultimate Hacker have been indispensable. The recovery process is ongoing, and while the final outcome remains uncertain, the progress made so far gives me hope. The battle to recover the full amount of my investment continues, and with the expertise of Lee Ultimate Hacker, I remain optimistic about the eventual recovery of my funds. Their commitment to their clients and proficiency in handling such complex cases truly sets them apart in the field of cyber recovery. LEEULTIMATEHACKER@ AOL. COM   Support @ leeultimatehacker . com.  telegram:LEEULTIMATE   wh@tsapp +1  (715) 314  -  9248     
    • Hi everyone. I’m excited to share my experience with CrackerWizard Recovery Firm. They helped me recover a substantial amount of crypto after falling victim to online scams disguised as Bitcoin investments. CrackerWizard’s exceptional service enabled me to retrieve my lost funds, despite the complex circumstances surrounding the case. With their dedicated team and advanced technology, they swiftly traced and recovered my assets. CrackerWizard is a reliable partner in the crypto world, highly recommended for anyone facing similar challenges. Contact them.
    • So I saw that mixin is shipped as a library with forge, but is it available for 1.7.10 ?  
    • So I've read the EULA, and lets be straight...     If I split my modpack(of my mods, yeah I'm nuts) into several(many) individual mods(like just one boss) with minor additions(plus not working together), then have a complete/modpack version on patreon/onlyfans having each addon work together... Would people buy my idea?
  • Topics

×
×
  • Create New...

Important Information

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