FountainMC / FountainAPI

A 'simple but beautiful' Minecraft Server Plugin API
https://fountainmc.org/
MIT License
5 stars 5 forks source link

Represent health as a float #24

Closed jamierocks closed 8 years ago

jamierocks commented 8 years ago

This is what Minecraft uses - I see no reason why the API shouldn't

Techcable commented 8 years ago

👎 doubles are future-proof, and are more common

jamierocks commented 8 years ago

More common, but not what Minecraft uses.

Techcable commented 8 years ago

It's a simple cast, and we won't have to break plugins if minecraft ever changes (like back when it changed from int to float).

wgaylord commented 8 years ago

True. But if they change it there will be a version bump so people should update anyways.

Techcable commented 8 years ago

@chibill We want to maximize compatibility across versions, and make it easier for plugins. Doubles do both.

PizzaCrust commented 8 years ago

:+1: doesn't floats use less memory than doubles?

sgdc3 commented 8 years ago

@PizzaCrust yeah but nothing relevant

Techcable commented 8 years ago

@PizzaCrust Fun-fact: on 64 bit machines, floats sometimes take as much memory as a double because of word alignment. if you have a float and then a pointer in memory, the float will actually be padded with 4 more bytes to ensure the pointer is word-alligned (IE: memory address is a multiple of 4 bytes). Additionally, when the memory is in a register on a 64 bit machine, they will take up the same amount of memory, since its stupid to stuff two values in a register.

So like @sgdc3 said, the overhead is negligable and in fact, in this case, its non-existent, since the double will only be there for a little bit until its cast to a float, and will take the same amount of space in a register as a float.