package com.hbm.saveddata.satellites; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import com.hbm.items.ModItems; import com.hbm.saveddata.SatelliteSavedData; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public abstract class Satellite { public static List satellites = new ArrayList(); public static HashMap itemToClass = new HashMap(); public static enum InterfaceActions { HAS_MAP, //lets the interface display loaded chunks CAN_CLICK, //enables onClick events SHOW_COORDS, //enables coordinates as a mouse tooltip HAS_RADAR, //lets the interface display loaded entities HAS_ORES //like HAS_MAP but only shows ores } public static enum CoordActions { HAS_Y //enables the Y-coord field which is disabled by default } public static enum Interfaces { NONE, //does not interact with any sat interface (i.e. asteroid miners) SAT_PANEL, //allows to interact with the sat interface panel (for graphical applications) SAT_COORD //allows to interact with the sat coord remote (for teleportation or other coord related actions) } public List ifaceAcs = new ArrayList(); public List coordAcs = new ArrayList(); public Interfaces satIface = Interfaces.NONE; public static void register() { registerSatellite(SatelliteMapper.class, ModItems.sat_mapper); registerSatellite(SatelliteScanner.class, ModItems.sat_scanner); registerSatellite(SatelliteRadar.class, ModItems.sat_radar); registerSatellite(SatelliteLaser.class, ModItems.sat_laser); registerSatellite(SatelliteResonator.class, ModItems.sat_resonator); registerSatellite(SatelliteRelay.class, ModItems.sat_foeq); registerSatellite(SatelliteMiner.class, ModItems.sat_miner); registerSatellite(SatelliteHorizons.class, ModItems.sat_gerald); } private static void registerSatellite(Class sat, Item item) { satellites.add(sat); itemToClass.put(item, sat); } public static void orbit(World world, int id, int freq, double x, double y, double z) { Satellite sat = create(id); if(sat != null && !world.isRemote) { SatelliteSavedData data = SatelliteSavedData.getData(world); data.sats.put(freq, sat); sat.onOrbit(world, x, y, z); data.markDirty(); } } public static Satellite create(int id) { Satellite sat = null; try { Class c = satellites.get(id); sat = (Satellite) c.newInstance(); } catch(Exception ex) { } return sat; } public static int getIDFromItem(Item item) { Class sat = itemToClass.get(item); int i = satellites.indexOf(sat); return i; } public int getID() { return satellites.indexOf(this.getClass()); } public void writeToNBT(NBTTagCompound nbt) { } public void readFromNBT(NBTTagCompound nbt) { } /** * Called when the satellite reaches space, used to trigger achievements and other funny stuff. * @param x posX of the rocket * @param y ditto * @param z ditto */ public void onOrbit(World world, double x, double y, double z) { } /** * Called by the sat interface when clicking on the screen * @param x the x-coordinate translated from the on-screen coords to actual world coordinates * @param z ditto */ public void onClick(World world, int x, int z) { } /** * Called by the coord sat interface * @param x the specified x-coordinate * @param y ditto * @param z ditto */ public void onCoordAction(World world, EntityPlayer player, int x, int y, int z) { } }