Jump to content

[1.7.2] Would this work? Some questions about modding


Recommended Posts

Posted

I'm planning on implementing some new features into my mod and for that I need more metadata per block. Only about a byte per block but I might end up using more than that for other things later.

 

I figured out a way to do it which some people would probably consider extremely hacky. I'm pretty certain it will work in singleplayer, but I don't know much about the multiplayer aspects of MC modding so I come here to ask the question... Would this work? :D

 

I have a hash table where the value is an int or byte, and the key is a tuple of 4 elements. Block coordinates x, y, z and dimension id. When I want to insert metadata at some location I create a tuple and put the relevant value at that location in the hash table. When I want to read it I can do the same. I save this hash table using the NBT.

 

Known issues:

*If a block using this metadata scheme is destroyed I must remember to erase the metadata (though this is not an important issue as only my own blocks will read from here)

*If a block is placed in some other dimension such as one created by another mod like Dimensional Doors, then when that dimension is "destroyed" I need to have the hash table erase all entries with data that is keyed to that world. Is there some way to detect when that happens and deal with it easily?

*How would this behave in practice in multiplayer? If there are any problems, how would I remedy them?

Posted
  On 3/21/2014 at 7:09 PM, KGS said:

I'm planning on implementing some new features into my mod and for that I need more metadata per block. Only about a byte per block but I might end up using more than that for other things later.

 

I have a hash table where the value is an int or byte, and the key is a tuple of 4 elements. Block coordinates x, y, z and dimension id. When I want to insert metadata at some location I create a tuple and put the relevant value at that location in the hash table. When I want to read it I can do the same. I save this hash table using the NBT.

 

I think you'll find the real issues are memory and speed.

How long does it take to generate a hash ?

How long does it take to retrieve a set of values (from the hash table) for a single block ?

How many blocks in world ?

How much memory total for the number of blocks ?

 

Even if you have a single one of your blocks visible, you need to have the data for all of them in memory.

Also where do you plan to store the data itself ?

 

Using a TileEntity is a much simpler method, especially if you need to add extra values for each block.

Posted

Make another instance of the block.

Just using up one id space more in the world save isn't much.

 

As for your issues, since you would save into the world nbt (which is organized per dimension), you wouldn't have to worry about removing it if the dimension is removed. Automatically goes with it.

Posted

Hi

 

I agree with GotoLink.  If you need a byte of storage per block, just define 16 new blocks which all inherit from the same base.  4 bits of metadata and 4 bits of block ID and you're there.  Far more robust than trying to code up something yourself.

 

Your idea sounds like it might work with a lot of effort; I think the "proper" way to do it would be to modify the chunk data storage to add an extra metadata array, and let vanilla handle the hard work of storing and reloading the chunk data.  There was a bloke asking about this on the forum a couple of weeks ago and he seemed to be pretty far advanced, perhaps he'd have some gems of wisdom.

 

Multiplayer becomes harder again because you have to synchronise the data stored on the server with the client.  It can be done but requires a fair bit of effort.

 

-TGG

 

 

Posted

I've done something similar to this, in a currently developing mod (waiting on my texturer to get back to work). It implements 2 hash-maps or "Caches" one on the client and one on the server. Syncing them however has to split the data in parts, then send the parts as they're generated. I use a ChunkDataEvent.Load to load the data into my hash maps, the save event get them from the  "server" cache, and saves them into the chunk data. Then i use the ChunkEvent.unload to mark them for removal.

Posted

Thanks for the replies people.

 

  On 3/21/2014 at 8:13 PM, fabricator77 said:

  Quote

I'm planning on implementing some new features into my mod and for that I need more metadata per block. Only about a byte per block but I might end up using more than that for other things later.

 

I have a hash table where the value is an int or byte, and the key is a tuple of 4 elements. Block coordinates x, y, z and dimension id. When I want to insert metadata at some location I create a tuple and put the relevant value at that location in the hash table. When I want to read it I can do the same. I save this hash table using the NBT.

 

I think you'll find the real issues are memory and speed.

How long does it take to generate a hash ?

How long does it take to retrieve a set of values (from the hash table) for a single block ?

How many blocks in world ?

How much memory total for the number of blocks ?

 

Even if you have a single one of your blocks visible, you need to have the data for all of them in memory.

Also where do you plan to store the data itself ?

 

Using a TileEntity is a much simpler method, especially if you need to add extra values for each block.

 

Afaik hashing 4 ints should be trivial.

 

I expect at most 30-40 blocks of special metadata. Maybe 100 in extreme situations.

 

I do not want to use a TileEntity because I might want to store more than just bits. Also the problem in general is interesting. I am aware of using multiple blocks to store metadata. It, however, is not as interesting as what I'm trying to get at here.

 

This also relates to another problem I'm working on for my mod.

 

I have a block that when it is placed in a chunk makes sure that no mobs can spawn in that chunk. It does so by adding a listener to events which checks if a spawned living event is triggered from inside a chunk with this particular block. Blocks are stored in a hash table which is a WorldSavedData using x, y, z, w tuples as keys and integers as values (the integer representing the number of these blocks in a particular chunk). What i want to know is how the server/client aspect might interfere with this.

 

This works fine in single player, but I don't actually know if it works in multiplayer as I have been unable to test it.

Posted

Hi

 

  On 3/22/2014 at 1:16 AM, KGS said:

I do not want to use a TileEntity because I might want to store more than just bits.

I don't understand what you mean.  You can store anything you like in a TileEntity.  You write the NBT serialisation code yourself and can put whatever you need into it.  TileEntities are specifically designed for exactly what it sounds like you're trying to do.

 

  Quote

Also the problem in general is interesting. I am aware of using multiple blocks to store metadata. It, however, is not as interesting as what I'm trying to get at here.

Fair enough :-)

 

  Quote

This also relates to another problem I'm working on for my mod.

 

I have a block that when it is placed in a chunk makes sure that no mobs can spawn in that chunk. It does so by adding a listener to events which checks if a spawned living event is triggered from inside a chunk with this particular block. Blocks are stored in a hash table which is a WorldSavedData using x, y, z, w tuples as keys and integers as values (the integer representing the number of these blocks in a particular chunk). What i want to know is how the server/client aspect might interfere with this.

 

This works fine in single player, but I don't actually know if it works in multiplayer as I have been unable to test it.

Actually this is probably pretty easy since you only need to prevent spawning on the server, which is also the place you record your block placements.  So the client doesn't need to know about your hash table at all.

 

Just a comment - you are using the inbuilt Java hash tables, yeah?  (HashMap, HashSet)

 

  Quote

This works fine in single player, but I don't actually know if it works in multiplayer as I have been unable to test it.

Why haven't you been able to test it? (i.e. what's stopping you?)

 

-TGG

Posted

I concur with what TGG said, there are better ways to go about inventing the wheel that is already on cars, trucks, wagons, and moon rovers. Why not use what's already in Minecraft rather than risk killing servers, clients, breaking savegames, and many other hazards?

Posted
  On 3/22/2014 at 1:41 AM, TheGreyGhost said:

Hi

 

  Quote

I do not want to use a TileEntity because I might want to store more than just bits.

I don't understand what you mean.  You can store anything you like in a TileEntity.  You write the NBT serialisation code yourself and can put whatever you need into it.  TileEntities are specifically designed for exactly what it sounds like you're trying to do.

 

Oh that's interesting. I haven't actually dealt with tile entities yet but now that I think about it's obvious they can store anything, seeing that they store inventory data for containers and such.

 

I will look into using tile entities.

 

  Quote

  Quote

Also the problem in general is interesting. I am aware of using multiple blocks to store metadata. It, however, is not as interesting as what I'm trying to get at here.

Fair enough :-)

 

:D

 

  Quote

  Quote

This also relates to another problem I'm working on for my mod.

 

I have a block that when it is placed in a chunk makes sure that no mobs can spawn in that chunk. It does so by adding a listener to events which checks if a spawned living event is triggered from inside a chunk with this particular block. Blocks are stored in a hash table which is a WorldSavedData using x, y, z, w tuples as keys and integers as values (the integer representing the number of these blocks in a particular chunk). What i want to know is how the server/client aspect might interfere with this.

 

This works fine in single player, but I don't actually know if it works in multiplayer as I have been unable to test it.

Actually this is probably pretty easy since you only need to prevent spawning on the server, which is also the place you record your block placements.  So the client doesn't need to know about your hash table at all.

 

Yes that's what I was thinking too. My worry was that I would have to do some kind of syncing manually between clients, but I guess minecraft automatically synchs clients with whatever is on the server. The reverse, though, to make sure the server is updated when some local changes are made on clients is when you need to be careful... (?)

 

  Quote
Just a comment - you are using the inbuilt Java hash tables, yeah?  (HashMap, HashSet)

 

Yeah. I'm not going to write my own hash tables. THAT would be reinventing the wheel :P

 

  Quote

  Quote

This works fine in single player, but I don't actually know if it works in multiplayer as I have been unable to test it.

Why haven't you been able to test it? (i.e. what's stopping you?)

 

Well I guess I could run a server locally and test with myself only...

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

    • C:\Users\bruiser\curseforge\minecraft\Instances\Fazbear Remnants\essential\loader\stage1\launchwrapper\stage2.forge_1.12.2.jar: The process cannot access the file because it is being used by another process. Restart your system and test it again If there is no change, delete the mentioned essential folder or remove the mod essential
    • Does it work with newer versions? For 1.16.5 also make a test with Embeddium + Oculus as Optifine replacement
    • Looking for the best Temu coupon code $100 off? You’re in the right place! We’ve got the ultimate deal that helps you save big on your favorite items. Our exclusive ACS670886 Temu coupon code is perfect for shoppers in the USA, Canada, and Europe. Whether you're a new or existing customer, this code ensures you get maximum benefits. By using the Temu coupon $100 off, you can unlock exciting savings on Temu’s vast collection. Don’t miss this chance to claim your Temu 100 off coupon code today! What Is The Coupon Code For Temu $100 Off? Both new and existing customers can enjoy incredible benefits with our Temu coupon $100 off on the Temu app and website. This $100 off Temu coupon ensures huge savings for everyone! ACS670886 – Get a flat $100 off on selected purchases. ACS670886 – Unlock a $100 coupon pack for multiple uses. ACS670886 – Enjoy a $100 flat discount if you're a new customer. ACS670886 – Existing customers can claim an extra $100 promo code. ACS670886 – This $100 coupon is valid for shoppers in the USA and Canada. Temu Coupon Code $100 Off For New Users In 2025 New users can maximize their savings by applying our Temu coupon $100 off on the Temu app. This Temu coupon code $100 off unlocks amazing deals for first-time shoppers. ACS670886 – Get a flat $100 discount for new users. ACS670886 – Receive a $100 coupon bundle as a welcome offer. ACS670886 – Unlock up to $100 in coupons for multiple uses. ACS670886 – Enjoy free shipping to 68 countries. ACS670886 – Get an extra 30% off on any purchase as a first-time user. How To Redeem The Temu Coupon $100 Off For New Customers? Using the Temu $100 coupon is easy! Follow these steps to redeem your Temu $100 off coupon code for new users: Sign up on the Temu app or website. Browse and add your favorite items to the cart. Enter ACS670886 at checkout. See the $100 discount applied instantly. Complete your purchase and enjoy your savings! Temu Coupon $100 Off For Existing Customers Existing customers can also benefit from our exclusive Temu $100 coupon codes for existing users. Use this Temu coupon $100 off for existing customers free shipping deal and save more! ACS670886 – Get an extra $100 discount for existing users. ACS670886 – Enjoy a $100 coupon bundle for multiple purchases. ACS670886 – Receive a free gift with express shipping across the USA/Canada. ACS670886 – Grab an extra 30% off on top of existing discounts. ACS670886 – Avail free shipping to 68 countries. How To Use The Temu Coupon Code $100 Off For Existing Customers? Redeeming your Temu coupon code $100 off as an existing user is simple. Just follow these steps: Log in to your Temu account. Select your desired products and add them to your cart. Apply ACS670886 at checkout. Your Temu coupon $100 off code will be applied automatically. Confirm your order and enjoy massive savings! Latest Temu Coupon $100 Off First Order First-time buyers get the best deals with our Temu coupon code $100 off first order. This Temu coupon code first order ensures maximum savings. ACS670886 – Flat $100 discount for the first order. ACS670886 – Special $100 Temu coupon code for new customers. ACS670886 – Get up to $100 in coupons for multiple uses. ACS670886 – Free shipping to 68 countries. ACS670886 – Extra 30% off on any first-time purchase. How To Find The Temu Coupon Code $100 Off? Finding a Temu coupon $100 off is easy! Check out the Temu coupon $100 off Reddit section or follow these tips: Subscribe to the Temu newsletter for exclusive deals. Follow Temu’s official social media pages for the latest updates. Visit trusted coupon sites for verified and working codes. Is Temu $100 Off Coupon Legit? Yes, our Temu $100 Off Coupon Legit and verified! Wondering if the Temu 100 off coupon legit? Here’s why: The ACS670886 code is officially tested and confirmed. Valid for all customers in the USA, Canada, and Europe. No expiration date—use it anytime! How Does Temu $100 Off Coupon Work? The Temu coupon code $100 off first-time user works instantly upon applying at checkout. Simply enter the Temu coupon codes 100 off, and the discount is automatically deducted. How To Earn Temu $100 Coupons As A New Customer? To earn a Temu coupon code $100 off, sign up on Temu, make your first purchase, and refer friends. This 100 off Temu coupon code can be unlocked through special promotions. What Are The Advantages Of Using The Temu Coupon $100 Off? $100 discount on the first order $100 coupon bundle for multiple uses 70% discount on popular items Extra 30% off for existing customers Up to 90% off on selected products Free gifts for new users Free delivery to 68 countries Temu $100 Discount Code And Free Gift For New And Existing Customers Enjoy the Temu $100 off coupon code and get amazing benefits! Our $100 off Temu coupon code ensures huge savings. ACS670886 – $100 discount for the first order. ACS670886 – Extra 30% off on any item. ACS670886 – Free gift for new Temu users. ACS670886 – Up to 70% discount on all Temu items. ACS670886 – Free shipping in 68 countries including the USA and UK. Final Note: Use The Latest Temu Coupon Code $100 Off Using the Temu coupon code $100 off is the smartest way to save on Temu! Don’t wait—grab your discount now. Our Temu coupon $100 off is available for all customers, ensuring maximum savings. Get yours today! FAQs Of Temu $100 Off Coupon Q: How can I get the Temu $100 off coupon? A: Use code ACS670886 at checkout to claim your $100 discount. Q: Is the Temu $100 coupon valid for existing customers? A: Yes! Existing users can also apply ACS670886 and enjoy savings. Q: Does the Temu $100 off coupon have an expiration date? A: No, ACS670886 is valid indefinitely. Q: Can I use the Temu coupon on multiple orders? A: Yes! ACS670886 allows multiple redemptions. Q: Is the Temu $100 coupon applicable worldwide? A: Yes, it’s valid in the USA, Canada, Europe, and 68 other countries.
    • I tried both Vanilla and Optfine like you said, and both gave the same result. So I believe the issue is most likely with Minecraft in general and not Forge
    • https://pastebin.com/xWy0mWXA Like I said Modded Java Edition 1.12.2 using Forge Version 14.23.5.2859 Oh yeah and Exit Code: 1  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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