This mod is to allow players to build a ship from blocks, place a ship control block on that "ship", and have it converted to a ship they can sail around and live on.
You should note that although the files provided here "work" if you apply them to your copy of minecraft, the mod is only in a state that might be of use to other modders (source code is below too).
Anyone who read what I wrote in the S&B thread will know that I have no plans to bring this mod to a polished finish - I don't have time.
I had hoped to have basic functionality complete to the point where even players would be interested, but I have achieved less than I set out to do, and can spare no more time on this.
Currently you can build a ship, place a ship block, which will convert the blocks to a ship, and for demonstration purposes only if you rightclick the control block the ship will move (messily, atm) on a hard coded path.
I can't imagine it being of any use or enjoyment in a game in it's current state.
I can only hope that other modders with similar tastes will find my code useful.
Screenshots - don't have any pretty ones, and wouldn't show much anyway
Video - don't have one. If someone makes a brief one they think is worth watching I'll put it here.
################# To be of any use at all to players:
Detect which player is aboard which ship
Clean up movement (perhaps also updates from the controlling client to the server)
Keyboard controls
All parts of ship (not just control block) need to collide with blocks
##################### High priority
dimension limits for construction need to be implemented
slabs working correctly
stairs working correctly
drop/lift ship to correct height in water on launch (lowest block in water)
decide on ship sizes, block count limits, recipes, speeds, and accelerations
chests work (single, double, ender)
furnaces work
craft tables work
beds work
ships have owner. only owner can drive. owner can change the owner.
ents have correct collision with ALL other entities, except squid...
wooden doors and trapdoors work
ensure glass blocks work
ebnsure anchored ship doesn't move
payers who log off on a ship should respawn there on login, regardless if ship has moved
//###################### Non- urgent
minimum block limit for construction
re. my new intersection calculation: optimise it, make it efficient. eg only check blocks that can be quickly known to be close to the other ent
be able to dock ship back into world as blocks - annoying, esp. ShipRegistry
have ship adjust to changes in water height
enchant tables work (and bookshelves)
potion mixing works
anvils work
config file to change recipes
boat causes fall damage to players if they fall off mast
buttons and pressure plates
working signs
properly rendered fence
some kind of ladder fix - otherwise, consider creating spiral stair block, that allows any height stair in 2x2 area
flower pots work
let owner nominate 3 mates who can also drive (but can't change mates/owner)
allow creation of "column" entities: columns of same block type. should improve performance.
glass panes and iron bars don't render properly, fix.
//###################### Non-essential
only allow ship to dock back to world if it only replaces water or air, no other blocks
calculate correct draft , and apply it
allow below-water-level decks, and submarines
lighting works on board
redstone, pistons, rail etc
splash particles from bow
portals work??
engine and sail blocks
Permitted blocks
new IdMetaPair(5,-1), //planks
new IdMetaPair(17,-1), //wood
new IdMetaPair(20,-1), //glass
new IdMetaPair(22,-1), //lapis block
new IdMetaPair(24,-1), //sandstone
new IdMetaPair(26,-1), //bed
new IdMetaPair(35,-1), //wool
new IdMetaPair(41,-1), //gold block
new IdMetaPair(42,-1), //iron block
new IdMetaPair(43,1), //sandstone double slab
new IdMetaPair(43,2), //wood double slab
new IdMetaPair(43,7), //quartz double slab
new IdMetaPair(44,1), //sandstone slab
new IdMetaPair(44,2), //wood slab
new IdMetaPair(44,7), //quartz slab
new IdMetaPair(44,9), //upper sandstone slab?
new IdMetaPair(47,-1), //bookshelf
new IdMetaPair(49,-1), //obsidian
new IdMetaPair(50,-1), //torch
new IdMetaPair(53,-1), //oak stairs
new IdMetaPair(54,-1), //chest
new IdMetaPair(57,-1), //diamond block
new IdMetaPair(58,-1), //craft table
new IdMetaPair(61,-1), //furnace cold
new IdMetaPair(62,-1), //furnace burning
new IdMetaPair(63,-1), //sign
new IdMetaPair(64,-1), //wood door
//new IdMetaPair(65,-1), //ladder - doesn't render atm
new IdMetaPair(68,-1), //wall sign
new IdMetaPair(69,-1), //lever
new IdMetaPair(70,-1), //stone plate
new IdMetaPair(72,-1), //wood plate
new IdMetaPair(78,-1), //snow - might make excellent thin floors
new IdMetaPair(85,-1), //fence
new IdMetaPair(92,-1), //cake
new IdMetaPair(96,-1), //trapdoor
//new IdMetaPair(101,-1), //iron bars - doesn't render atm
//new IdMetaPair(102,-1), //glass pane - doesn't render atm
new IdMetaPair(113,-1), //nether fence
new IdMetaPair(116,-1), //enchant table
new IdMetaPair(117,-1), //brew stand
new IdMetaPair(118,-1), //cauldron
new IdMetaPair(125,-1), //double wood slab
new IdMetaPair(126,-1), //wood slab
new IdMetaPair(128,-1), //sandstone stairs
new IdMetaPair(130,-1), //ender chest
new IdMetaPair(133,-1), //emerald block
new IdMetaPair(134,-1), //spruce stairs
new IdMetaPair(135,-1), //birch stairs
new IdMetaPair(136,-1), //jungle stairs
//new IdMetaPair(140,-1), //flower pot - doesn't render atm
new IdMetaPair(145,-1), //anvil
new IdMetaPair(147,-1), //light plate
new IdMetaPair(148,-1), //heavy plate
new IdMetaPair(151,-1), //light sensor
new IdMetaPair(152,-1), //redstone block
new IdMetaPair(155,-1), //quartz
new IdMetaPair(156,-1) //quartz stairs
Hopefully someone will make something useful with this code.
The code:
converts Blocks to Entities.
links ships together in a parent-children relationship
minimises network traffic
Blocks are deleted and replaced with Entiys that look and feel like the block the replaced. They are rendered with net.minecraft.client.renderer.RenderBlocks.renderBlockAsItem()
Parents (ControlBlockEntity) store a list of children (BlockEntity), and the children store a reference to their parent.
To minimise network traffic:
Children do no calculate or call any of their own movement. The parent does it all.
Children are not written individually to disk. Their parent stores their vital data and recreates them when read from disk (zombie children are removed).
ControlBlockEntity is registered as normal, but BlockEntity is not registered. This means when spawned on server, a copy is NOT automatically spawned on client, so has to be (and is) done manually. This means as far as mc is concerned there is no relationship between children on the server, and children on the client, which guarantees no traffic between them. In other words the child at x,y,z on the server is technically completely independent of the child at x,y,z on the client - which is not the case usually for mc entities. It may generate other difficulties in the future though...
So for ships only a single entity is tracked (all others are relative to that, and moved by that), and only the control block sends data between client/server.
Providing the independence of the children doesn't cause a problem that can't be overcome, I am reasonably confident that my system of linking, tracking, and storing all the ship entities is good. (Until an experienced modder, or some decent testing says otherwise)
EDIT: I have just noticed that I am synching all child positions between server/client parents, AND calculating child positions on both client and server. Only one of these should be necessary, and perhaps might improve performance.
It will probably be necessary for the client who is controlling the ship to periodically send position update to the server and for the server to then update the data it has - the sailor should be the true source of location.
The movement currently demonstrated is rubbish - I don't know whether to blame lag, lack of synch, or something else, but it is messy and ugly, and needs to be cleaned up.
I have seen stationary entities suddenly drop slightly on the y axis, less than 1 block, for no apparent reason if there is air or water beneath them. Pretty sure that it's mc, not me. Have put in a crude preventative measure.
Player doesn't seem to be able to fit into a gap between entitys that is 2.0 high...2.5 is fine.
I want the source code to be used as much as possible, so included it here, heavily commented.
It is released under the GNU General Public License http://www.gnu.org/copyleft/gpl.html
This legally binding licence's most important point is this: if you use this code in your project, you must make available the source code for your entire project. No exceptions.
Note though that this doesn't stop you selling your project for profit, for example (with no obligations to me).
I don't understand at all modders writing mc mods and NOT sharing the code - after all, you aren't doing it for profit, and anyone can decompile it anyway. To hide the code you've written is a selfish and pointless act, and freeing it can cause you no harm at all.
So I encourage people to use my code, but remember the licence you must follow....
I will do my best to answer any questions about the code anyone has, but...
- although you don't need to be an expert, if you're just learning Java, or haven't ever done the tiniest bit of mc modding, you are probably biting off a bit more than you can chew at the moment
- you can pm me questions, but I'm going to answer all questions publicly, so anyone can benefit
- I am an expert on my own code but a very long way from one on the mc code, and I'm not going to trawl through any code but my own in an effort to answer questions
From a modder's point of view ships and airships are almost identical, which is why you often see them together in the same mod.
I will just be (hopefully) releasing a small demo mod that includes core functions, so I will include both ships and airships (assuming I complete keyboard control), for the purposes of showing they work.
But I'm now firmly of the opinion that ships and airships don't really belong together in a fully fledged mod (they should be separate, in their own mods) because:
1. airships essentially make ships redundant
2. a server admin should be able to choose to add either ships or airships to his server without having to accept extra stuff he doesn't really want
3. If he DOES want both he can simply install both mods.
1. To a degree but not 100%. With Ships and boats for instance. I made boats, I made submarines, I made planes, I made spaceships that were all 3. Depending on the mood and what I was going for. Also depending on what is involved in making the different types, you may want an airship but have to make do with a ship for a while. Like say the airship required something ridiculous like a netherstar or 100 ghast tears (I am not suggesting that, just first example that popped into my head). So the leet might have airships but everyone else wouldn't.
2. Agree, but wouldn't it be better and less work on the modder (i.e. you) to just make it so you can configure which parts the individual wants available or not.
At any rate, thanks for making this. Thanks even more for having the foresight to say, I don't have time to finish, but here's the source, someone else pick up the ball and run with it.
Your completely correct keep it separate as you lose nothing say for having to install two mods instead of 1. Its a win win definitely.
I can think of 3 reasons:
Duplication of code. It may be more work to setup configuration initially, but in the longrun it would be less to maintain.
Potential performance issues caused by essentially duplicate code running.
A modular framework would probably be best, where the core contains all the needed functions and then everything else is a module. That way one could make things like weapons mods that would work on ships and/or airships but not be part of either mod.
Otherwise we run into the same issue, example: SA (server admin) 1 wants ships with cannons, SA 2 wants airships with cannons, SA3 wants both but no cannons, etc, etc. Some may want modern guns, others old style cannon, yet another catapults and ballistas. Some may want all of them.
Anyway, just food for thought. If not for you, maybe the next person who picks it up.
I can think of 3 reasons:
Duplication of code. It may be more work to setup configuration initially, but in the longrun it would be less to maintain.
Perhaps, but not much. If it were me, the "more work initially" would be a much bigger problem than future maintenance.
Potential performance issues caused by essentially duplicate code running.
This would not be an issue. The code running is per instance of ship/airship, regardless of which mod they're in.
A modular framework would probably be best, where the core contains all the needed functions and then everything else is a module. That way one could make things like weapons mods that would work on ships and/or airships but not be part of either mod.
Well I guess my way of thinking is that "all the needed functions" is also something hard to agree on, so I'd just treat everything as a module.
This mod is to allow players to build a ship from blocks, place a ship control block on that "ship", and have it converted to a ship they can sail around and live on.
You should note that although the files provided here "work" if you apply them to your copy of minecraft, the mod is only in a state that might be of use to other modders (source code is below too).
Anyone who read what I wrote in the S&B thread will know that I have no plans to bring this mod to a polished finish - I don't have time.
I had hoped to have basic functionality complete to the point where even players would be interested, but I have achieved less than I set out to do, and can spare no more time on this.
Currently you can build a ship, place a ship block, which will convert the blocks to a ship, and for demonstration purposes only if you rightclick the control block the ship will move (messily, atm) on a hard coded path.
I can't imagine it being of any use or enjoyment in a game in it's current state.
I can only hope that other modders with similar tastes will find my code useful.
Screenshots - don't have any pretty ones, and wouldn't show much anyway
Video - don't have one. If someone makes a brief one they think is worth watching I'll put it here.
Download
Mod zip file: http://www.mediafire...757d7rv41hkk7d3
I was inspired by (and learnt what I could from) these mods:
Small Boats/Elegant Punt(1.4.7) - the author Awger was also very generous with his time and knowledge
Ships and Boats (1.2.5)
Zeppelin (1.2.5)
Ugocraft
Pushable Blocks
And thank you to KayatoSan for his input and enthusiasm.
More info
To do list:
################# To be of any use at all to players:
Permitted blocks
new IdMetaPair(5,-1), //planks
new IdMetaPair(17,-1), //wood
new IdMetaPair(20,-1), //glass
new IdMetaPair(22,-1), //lapis block
new IdMetaPair(24,-1), //sandstone
new IdMetaPair(26,-1), //bed
new IdMetaPair(35,-1), //wool
new IdMetaPair(41,-1), //gold block
new IdMetaPair(42,-1), //iron block
new IdMetaPair(43,1), //sandstone double slab
new IdMetaPair(43,2), //wood double slab
new IdMetaPair(43,7), //quartz double slab
new IdMetaPair(44,1), //sandstone slab
new IdMetaPair(44,2), //wood slab
new IdMetaPair(44,7), //quartz slab
new IdMetaPair(44,9), //upper sandstone slab?
new IdMetaPair(47,-1), //bookshelf
new IdMetaPair(49,-1), //obsidian
new IdMetaPair(50,-1), //torch
new IdMetaPair(53,-1), //oak stairs
new IdMetaPair(54,-1), //chest
new IdMetaPair(57,-1), //diamond block
new IdMetaPair(58,-1), //craft table
new IdMetaPair(61,-1), //furnace cold
new IdMetaPair(62,-1), //furnace burning
new IdMetaPair(63,-1), //sign
new IdMetaPair(64,-1), //wood door
//new IdMetaPair(65,-1), //ladder - doesn't render atm
new IdMetaPair(68,-1), //wall sign
new IdMetaPair(69,-1), //lever
new IdMetaPair(70,-1), //stone plate
new IdMetaPair(72,-1), //wood plate
new IdMetaPair(78,-1), //snow - might make excellent thin floors
new IdMetaPair(85,-1), //fence
new IdMetaPair(92,-1), //cake
new IdMetaPair(96,-1), //trapdoor
//new IdMetaPair(101,-1), //iron bars - doesn't render atm
//new IdMetaPair(102,-1), //glass pane - doesn't render atm
new IdMetaPair(113,-1), //nether fence
new IdMetaPair(116,-1), //enchant table
new IdMetaPair(117,-1), //brew stand
new IdMetaPair(118,-1), //cauldron
new IdMetaPair(125,-1), //double wood slab
new IdMetaPair(126,-1), //wood slab
new IdMetaPair(128,-1), //sandstone stairs
new IdMetaPair(130,-1), //ender chest
new IdMetaPair(133,-1), //emerald block
new IdMetaPair(134,-1), //spruce stairs
new IdMetaPair(135,-1), //birch stairs
new IdMetaPair(136,-1), //jungle stairs
//new IdMetaPair(140,-1), //flower pot - doesn't render atm
new IdMetaPair(145,-1), //anvil
new IdMetaPair(147,-1), //light plate
new IdMetaPair(148,-1), //heavy plate
new IdMetaPair(151,-1), //light sensor
new IdMetaPair(152,-1), //redstone block
new IdMetaPair(155,-1), //quartz
new IdMetaPair(156,-1) //quartz stairs
Notes for modders
Hopefully someone will make something useful with this code.
The code:
converts Blocks to Entities.
links ships together in a parent-children relationship
minimises network traffic
Blocks are deleted and replaced with Entiys that look and feel like the block the replaced. They are rendered with net.minecraft.client.renderer.RenderBlocks.renderBlockAsItem()
Parents (ControlBlockEntity) store a list of children (BlockEntity), and the children store a reference to their parent.
To minimise network traffic:
Children do no calculate or call any of their own movement. The parent does it all.
Children are not written individually to disk. Their parent stores their vital data and recreates them when read from disk (zombie children are removed).
ControlBlockEntity is registered as normal, but BlockEntity is not registered. This means when spawned on server, a copy is NOT automatically spawned on client, so has to be (and is) done manually. This means as far as mc is concerned there is no relationship between children on the server, and children on the client, which guarantees no traffic between them. In other words the child at x,y,z on the server is technically completely independent of the child at x,y,z on the client - which is not the case usually for mc entities. It may generate other difficulties in the future though...
So for ships only a single entity is tracked (all others are relative to that, and moved by that), and only the control block sends data between client/server.
Providing the independence of the children doesn't cause a problem that can't be overcome, I am reasonably confident that my system of linking, tracking, and storing all the ship entities is good. (Until an experienced modder, or some decent testing says otherwise)
EDIT: I have just noticed that I am synching all child positions between server/client parents, AND calculating child positions on both client and server. Only one of these should be necessary, and perhaps might improve performance.
It will probably be necessary for the client who is controlling the ship to periodically send position update to the server and for the server to then update the data it has - the sailor should be the true source of location.
The movement currently demonstrated is rubbish - I don't know whether to blame lag, lack of synch, or something else, but it is messy and ugly, and needs to be cleaned up.
I have seen stationary entities suddenly drop slightly on the y axis, less than 1 block, for no apparent reason if there is air or water beneath them. Pretty sure that it's mc, not me. Have put in a crude preventative measure.
Player doesn't seem to be able to fit into a gap between entitys that is 2.0 high...2.5 is fine.
Source code: http://www.mediafire...ya7p28pt0s1dtp3
I want the source code to be used as much as possible, so included it here, heavily commented.
It is released under the GNU General Public License
http://www.gnu.org/copyleft/gpl.html
This legally binding licence's most important point is this: if you use this code in your project, you must make available the source code for your entire project. No exceptions.
Note though that this doesn't stop you selling your project for profit, for example (with no obligations to me).
I don't understand at all modders writing mc mods and NOT sharing the code - after all, you aren't doing it for profit, and anyone can decompile it anyway. To hide the code you've written is a selfish and pointless act, and freeing it can cause you no harm at all.
So I encourage people to use my code, but remember the licence you must follow....
I will do my best to answer any questions about the code anyone has, but...
- although you don't need to be an expert, if you're just learning Java, or haven't ever done the tiniest bit of mc modding, you are probably biting off a bit more than you can chew at the moment
- you can pm me questions, but I'm going to answer all questions publicly, so anyone can benefit
- I am an expert on my own code
1. To a degree but not 100%. With Ships and boats for instance. I made boats, I made submarines, I made planes, I made spaceships that were all 3. Depending on the mood and what I was going for. Also depending on what is involved in making the different types, you may want an airship but have to make do with a ship for a while. Like say the airship required something ridiculous like a netherstar or 100 ghast tears (I am not suggesting that, just first example that popped into my head). So the leet might have airships but everyone else wouldn't.
2. Agree, but wouldn't it be better and less work on the modder (i.e. you) to just make it so you can configure which parts the individual wants available or not.
At any rate, thanks for making this. Thanks even more for having the foresight to say, I don't have time to finish, but here's the source, someone else pick up the ball and run with it.
No, no complications. I would say this thread is looking pretty terrible right now!
@Idog
This is moot, as I doubt I'll be the one releasing a fully fledged mod, but:
1. no not 100%, but close.
2. no, it is MORE work to make it configurable , not less. Easier to release two mods.
I can't think of any downside to splitting it into two separate mods...
Your completely correct keep it separate as you lose nothing say for having to install two mods instead of 1. Its a win win definitely.
He did say it will be like the Zeppelin mod. It hasn't updated for a long time, so I like this
He said it's WIP.
There is no point in raining TNT when you could have bombs.
I can think of 3 reasons:
Duplication of code. It may be more work to setup configuration initially, but in the longrun it would be less to maintain.
Potential performance issues caused by essentially duplicate code running.
A modular framework would probably be best, where the core contains all the needed functions and then everything else is a module. That way one could make things like weapons mods that would work on ships and/or airships but not be part of either mod.
Otherwise we run into the same issue, example: SA (server admin) 1 wants ships with cannons, SA 2 wants airships with cannons, SA3 wants both but no cannons, etc, etc. Some may want modern guns, others old style cannon, yet another catapults and ballistas. Some may want all of them.
Anyway, just food for thought. If not for you, maybe the next person who picks it up.
I wonder if you read the post?
Perhaps, but not much. If it were me, the "more work initially" would be a much bigger problem than future maintenance.
This would not be an issue. The code running is per instance of ship/airship, regardless of which mod they're in.
Well I guess my way of thinking is that "all the needed functions" is also something hard to agree on, so I'd just treat everything as a module.