Thread: Minecraft
View Single Post
Old May 5 2011, 02:50 PM   #830
Robert Maxwell
Not Your Toy
 
Robert Maxwell's Avatar
 
Location: A broken roof
View Robert Maxwell's Twitter Profile Send a message via ICQ to Robert Maxwell Send a message via AIM to Robert Maxwell Send a message via Windows Live Messenger to Robert Maxwell Send a message via Yahoo to Robert Maxwell
Re: Minecraft

Jadzia wrote: View Post
Robert Maxwell wrote: View Post
We already know blocks can move due to gravity, and the Piston Mod takes it a bit further. What I think we haven't seen is a large collection of blocks moving in tandem, which is what would be needed to make it work. You are probably right that there are technical reasons why this wouldn't work well. The game never has a lot of blocks moving at once, and in fact if you quickly destroy a lot of blocks (such as with TNT) game performance drops dramatically. Given the number of constant chunk updates that would be required, it is probably not feasible. Ah well.
I expect moving blocks have been implemented by having a location property, and a target location property, and the block moves in a straight line from one to the other over time.

When a block moves, it will add surrounding blocks to a queue, so that you get a cascade effect for the gravel or lava, or whatever.

Having a large object moving would mean turning it into a sprite, rather than terrain, as it has to be capable of rotating and moving independent of the terrain grid.

Boats could also be made in funny shapes, and funny shaped things are hard for collision detection. Imagine if you made lots of boats that were tangled/knotted together. How would you handle that? Too may collision tests would cripple the engine.
Well, this is why it wouldn't work. A block is a block is a block. There is no distinction between "terrain" and "not terrain" blocks. The game world is divided into 16x16x128 "chunks," and if you destroy/place/move a block within a chunk, that's a "chunk update." I could see moving collections of blocks becoming exponentially less efficient due to the number of chunk updates that would be required. Say you had a boat that was 5x5x5 and it moves at a rate of 1 block per second. That's 125 chunk updates per second. Of course, that's not very big at all. More realistically, you might have a boat that's 40 blocks long by 15 blocks wide by 20 blocks tall. If it moves at the same rate, you are updating 12,000 blocks per second.

Other than blocks affected by gravity (which have relatively simple gravity physics which are only activated in proximity/on a chunk update, not all the time), the only things that can move are entities: mobs, vehicles, inventory items. And that works because an entity just has a single x,y,z coordinate, so it's pretty trivial to update the position/direction/speed.

The only alternative I can think of is maybe turning your custom vehicle into an entity, which would eliminate all of its block properties. So, you build a ship, define its boundaries, turn it into an entity--and then you cannot destroy any of its blocks or place blocks in it. It could use very dumb bounding box collision detection which would be sufficient for most purposes. Unfortunately, the "entity" method would rule out having a mobile crafting/storage platform, as nothing in it would be considered a block anymore.

If Notch ever releases the source code (which he says he will) I would love to get down into the guts and see if it's possible to do any of this.
__________________
It's all false love and affection
I has a blag.
Robert Maxwell is offline   Reply With Quote