All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mmb.engine.block.BlockEntityRotary Maven / Gradle / Ivy

Go to download

Dependency for the MultiMachineBuilder, a voxel game about building an industrial empire in a finite world. THIS RELEASE IS NOT PLAYABLE. To play the game, donwload from >ITCH.IO LINK HERE< or >GH releases link here<

There is a newer version: 0.6
Show newest version
/**
 * 
 */
package mmb.engine.block;

import java.awt.Graphics;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;

import mmb.NN;
import mmb.engine.rotate.RotatedImageGroup;
import mmb.engine.rotate.Rotation;

/**
 * @author oskar
 *
 */
public abstract class BlockEntityRotary extends BlockEntityData {
	@Override
	public void render(int x, int y, Graphics g, int ss) {
		getImage().get(side).draw(this, x, y, g, ss);
	}
	public abstract RotatedImageGroup getImage();
	@SuppressWarnings({ "null", "unused" })
	@Override
	public final void load(JsonNode data) {
		if(data == null) return;
		side = Rotation.valueOf(data.get("side").asText());
		if(side == null) side = Rotation.N;
		load1((ObjectNode) data);
	}
	@NN private Rotation side = Rotation.N;
	@Override
	public void setRotation(Rotation rotation) {
		side = rotation;
	}
	@Override
	public Rotation getRotation() {
		return side;
	}
	@Override
	protected final void save0(ObjectNode node) {
		node.put("side", side.toString());
		save1(node);
	}
	
	/**
	 * Additional function used to save additional data
	 * @param node node, to which data can be saved
	 */
	protected void save1(ObjectNode node) {
		//optional
	}
	/**
	 * Additional function used to save additional data
	 * @param node node, to which data can be loaded
	 */
	protected void load1(ObjectNode node) {
		//optional
	}
	
	@Override
	public boolean isRotary() {
		return true;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy