// region Read - Write @Override public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); tagCompound.setFloat("X", x); tagCompound.setFloat("Y", y); tagCompound.setFloat("Z", z); tagCompound.setFloat("Size", size); tagCompound.setFloat("Mass", mass); tagCompound.setByte("Type", type); tagCompound.setInteger("Temperature", temperature); tagCompound.setInteger("Color", color); tagCompound.setInteger("Seed", seed); tagCompound.setBoolean("Generated", generated); NBTTagList planetList = new NBTTagList(); for (Planet planet : getPlanets()) { NBTTagCompound quadrantNBT = new NBTTagCompound(); planet.writeToNBT(quadrantNBT); planetList.appendTag(quadrantNBT); } tagCompound.setTag("Planets", planetList); }
@Override public void readFromNBT(NBTTagCompound tagCompound, GalaxyGenerator generator) { super.readFromNBT(tagCompound, generator); x = tagCompound.getFloat("X"); y = tagCompound.getFloat("Y"); z = tagCompound.getFloat("Z"); size = tagCompound.getFloat("Size"); mass = tagCompound.getFloat("Mass"); type = tagCompound.getByte("Type"); temperature = tagCompound.getInteger("Temperature"); color = tagCompound.getInteger("Color"); seed = tagCompound.getInteger("Seed"); generated = tagCompound.getBoolean("Generated"); NBTTagList planetList = tagCompound.getTagList("Planets", 10); for (int i = 0; i < planetList.tagCount(); i++) { Planet planet = new Planet(); planet.readFromNBT(planetList.getCompoundTagAt(i), generator); addPlanet(planet); planet.setStar(this); } generateMissing(tagCompound, generator); }
public boolean contains(SpaceBody body) { return ((Math.abs(Global.to_pixels(body.get_body().getPosition().x)) <= SPACE_BOUNDARY_X) && (Math.abs(Global.to_pixels(body.get_body().getPosition().y)) <= SPACE_BOUNDARY_Y)); }