Initial commit to GitHub of the current state of the code

This commit is contained in:
pahimar 2012-04-26 11:52:46 -04:00
parent ff5d87bb81
commit 22d41510cd
18 changed files with 758 additions and 0 deletions

View file

@ -0,0 +1,56 @@
package net.minecraft.src.ee3.client;
import java.io.File;
import net.minecraft.client.Minecraft;
import net.minecraft.src.ModLoader;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.World;
import net.minecraft.src.ee3.core.IProxy;
public class EEProxy implements IProxy {
public EEProxy() { }
@Override
public void registerRenderInformation() {
// TODO Auto-generated method stub
}
@Override
public void registerTileEntities() {
// TODO Auto-generated method stub
}
@Override
public void registerTranslations() {
// TODO Auto-generated method stub
}
@Override
public File getMinecraftDir() {
return Minecraft.getMinecraftDir();
}
@Override
public boolean isRemote() {
return ModLoader.getMinecraftInstance().theWorld.isRemote;
}
@Override
public World getCurrentWorld() {
return ModLoader.getMinecraftInstance().theWorld;
}
@Override
public String getMinecraftVersion() {
return ModLoader.getMinecraftInstance().getVersion();
}
public void handleControl(NetworkManager network, int key) { }
public void handlePedestalPacket(int x, int y, int z, int itemId, boolean activated) { }
public void handleTEPacket(int x, int y, int z, byte direction, String player) { }
}

View file

@ -0,0 +1,5 @@
package net.minecraft.src.ee3.core;
public class ConfigurationManager {
}

View file

@ -0,0 +1,20 @@
package net.minecraft.src.ee3.core;
public class GuiIds {
public static int CONDENSER = 46;
public static int COLLECTOR_1 = 47;
public static int COLLECTOR_2 = 48;
public static int COLLECTOR_3 = 49;
public static int ALCH_CHEST = 50;
public static int DM_FURNACE = 51;
public static int RM_FURNACE = 52;
public static int RELAY_1 = 53;
public static int RELAY_2 = 54;
public static int RELAY_3 = 55;
public static int ALCH_BAG = 56;
public static int TRANS_TABLE = 57;
public static int PORT_TRANS_TABLE = 58;
public static int PORT_CRAFTING = 59;
public static int PEDESTAL = 60;
public static int MERCURIAL_EYE = 61;
}

View file

@ -0,0 +1,29 @@
package net.minecraft.src.ee3.core;
import java.io.File;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.World;
public interface IProxy {
public abstract void registerRenderInformation();
public abstract void registerTileEntities();
public abstract void registerTranslations();
public abstract File getMinecraftDir();
public abstract boolean isRemote();
public abstract World getCurrentWorld();
public abstract String getMinecraftVersion();
public abstract void handleControl(NetworkManager network, int key);
public abstract void handlePedestalPacket(int x, int y, int z, int itemId, boolean activated);
public abstract void handleTEPacket(int x, int y, int z, byte direction, String player);
}

View file

@ -0,0 +1,73 @@
package net.minecraft.src.ee3.core;
public class ItemIds {
public static int PHILOSOPHER_STONE = 27270;
public static int CATALYST_STONE = 27271;
public static int BASE_RING = 27272;
public static int SOUL_STONE = 27273;
public static int EVERTIDE_AMULET = 27274;
public static int VOLCANITE_AMULET = 27275;
public static int ATTRACTION_RING = 27276;
public static int IGNITION_RING = 27277;
public static int GRIMARCH_RING = 27278;
public static int HYPERKINETIC_LENS = 27279;
public static int SWIFTWOLF_RING = 27280;
public static int HARVEST_RING = 27281;
public static int WATCH_OF_FLOWING_TIME = 27282;
public static int ALCHEMICAL_COAL = 27283;
public static int MOBIUS_FUEL = 27284;
public static int DARK_MATTER = 27285;
public static int COVALENCE_DUST = 27286;
public static int DM_PICKAXE = 27287;
public static int DM_SPADE = 27288;
public static int DM_HOE = 27289;
public static int DM_SWORD = 27290;
public static int DM_AXE = 27291;
public static int DM_SHEARS = 27292;
public static int DM_HAMMER = 27299;
public static int DM_ARMOR_CHEST = 27293;
public static int DM_ARMOR_HELMET = 27294;
public static int DM_ARMOR_LEGS = 27295;
public static int DM_ARMOR_BOOTS = 27296;
public static int GEM_OF_ETERNAL_DENSITY = 27297;
public static int REPAIR_CHARM = 27298;
public static int HYPER_CATALYST = 27300;
public static int KLEIN_STAR_1 = 27301;
public static int KLEIN_STAR_2 = 27302;
public static int KLEIN_STAR_3 = 27303;
public static int KLEIN_STAR_4 = 27304;
public static int KLEIN_STAR_5 = 27305;
public static int KLEIN_STAR_6 = 27335;
public static int ALCHEMY_BAG = 27306;
public static int RED_MATTER = 27307;
public static int RM_PICKAXE = 27308;
public static int RM_SPADE = 27309;
public static int RM_HOE = 27310;
public static int RM_SWORD = 27311;
public static int RM_AXE = 27312;
public static int RM_SHEARS = 27313;
public static int RM_HAMMER = 27314;
public static int AETERNALIS_FUEL = 27315;
public static int RM_KATAR = 27316;
public static int RM_MACE = 27317;
public static int ZERO_RING = 27318;
public static int RM_ARMOR_CHEST = 27319;
public static int RM_ARMOR_HELMET = 27320;
public static int RM_ARMOR_LEGS = 27321;
public static int RM_ARMOR_BOOTS = 27322;
public static int GEMMED_RM_ARMOR_CHEST = 27323;
public static int GEMMED_RM_ARMOR_HELMET = 27324;
public static int GEMMED_RM_ARMOR_LEGS = 27325;
public static int GEMMED_RM_ARMOR_BOOTS = 27326;
public static int MERCURIAL_EYE = 27327;
public static int ARCANE_RING = 27328;
public static int DIVINING_ROD = 27329;
public static int BODY_STONE = 27332;
public static int LIFE_STONE = 27333;
public static int MIND_STONE = 27334;
public static int TRANSMUTATION_TABLET = 27336;
public static int VOID_RING = 27337;
public static int ALCHEMY_TOME = 27338;
public static int NULL_TOME = 27339;
}

View file

@ -0,0 +1,33 @@
package net.minecraft.src.ee3.core;
public class Keys {
public static final int EXTRA = 0;
public static final int CHARGE = 1;
public static final int TOGGLE = 2;
public static final int RELEASE = 3;
public static final int LEFT_CLICK = 4;
public static final int JUMP = 5;
public static final int SNEAK = 6;
public static String toString(int key) {
switch (key) {
case Keys.CHARGE:
return "KEYS.CHARGE";
case Keys.EXTRA:
return "KEYS.EXTRA";
case Keys.TOGGLE:
return "KEYS.TOGGLE";
case Keys.RELEASE:
return "KEYS.RELEASE";
case Keys.LEFT_CLICK:
return "KEYS.LEFT_CLICK";
case Keys.JUMP:
return "KEYS.JUMP";
case Keys.SNEAK:
return "KEYS.SNEAK";
default:
return "Unknown Key";
}
}
}

View file

@ -0,0 +1,35 @@
package net.minecraft.src.ee3.core;
import net.minecraft.src.ModLoader;
import net.minecraft.src.mod_EE3;
import net.minecraft.src.forge.MinecraftForge;
public enum ServerClientProxy {
CLIENT("net.minecraft.src.ee3.client.EEProxy"),
SERVER("net.minecraft.src.ee3.server.EEProxy");
private String className;
private ServerClientProxy(String proxyClassName) {
className = proxyClassName;
}
private IProxy buildProxy() {
try {
return (IProxy)Class.forName(className).newInstance();
} catch (Exception e) {
ModLoader.getLogger().severe("[" + mod_EE3.CHANNEL_NAME + "] A fatal error has occured initializing Equivalent Exchange");
e.printStackTrace(System.err);
throw new RuntimeException(e);
}
}
public static IProxy getProxy() {
if (MinecraftForge.isClient()) {
return CLIENT.buildProxy();
}
else {
return SERVER.buildProxy();
}
}
}

View file

@ -0,0 +1,62 @@
package net.minecraft.src.ee3.core;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import net.minecraft.src.ModLoader;
import net.minecraft.src.mod_EE3;
public class Version {
public static final int MAJOR = 1;
public static final int MINOR = 0;
public static final int REVISION = 0;
public static final int BUILD = 0;
public static final int REQ_FORGE_MAJOR = 3;
public static final int REQ_FORGE_MINOR = 1;
public static final int REQ_FORGE_REVISION = 2;
private static final String REMOTE_VERSION_FILE = "http://dl.dropbox.com/u/25591134/EE2/version.txt";
public static final byte CURRENT = 0;
public static final byte OUTDATED = 1;
public static final byte CONNECTION_ERROR = 2;
public static byte currentVersion = 0;
public static String getVersion() {
return String.format("%d.%d.%d.%d", MAJOR, MINOR, REVISION, BUILD);
}
public static void versionCheck() {
try {
URL url = new URL(REMOTE_VERSION_FILE);
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line = null;
while ((line = reader.readLine()) != null) {
if (line.startsWith(mod_EE3.proxy.getMinecraftVersion())) {
if (line.contains(mod_EE3.CHANNEL_NAME)) {
if (line.endsWith(getVersion())) {
ModLoader.getLogger().info("[" + mod_EE3.CHANNEL_NAME + "] Version Check: Using the latest version");
currentVersion = CURRENT;
return;
}
}
}
}
ModLoader.getLogger().info("[" + mod_EE3.CHANNEL_NAME + "] Version Check: Using outdated version");
currentVersion = OUTDATED;
} catch (Exception e) {
ModLoader.getLogger().warning("[" + mod_EE3.CHANNEL_NAME + "] Version Check: Unable to read from remote version authority");
currentVersion = CONNECTION_ERROR;
}
}
}

View file

@ -0,0 +1,21 @@
package net.minecraft.src.ee3.gui;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.World;
import net.minecraft.src.ee3.core.GuiIds;
import net.minecraft.src.forge.IGuiHandler;
public class GuiHandler implements IGuiHandler {
@Override
public Object getGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
/*
* Returns true of the GuiId id is for a item and not a Block/TE in the world
*/
private static boolean isItemGui(int id) {
return ((id == GuiIds.PORT_CRAFTING) || (id == GuiIds.MERCURIAL_EYE) || (id == GuiIds.PORT_TRANS_TABLE) || (id == GuiIds.ALCH_BAG));
}
}

View file

@ -0,0 +1,53 @@
package net.minecraft.src.ee3.network;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.forge.packets.ForgePacket;
public class EEPacket {
protected PacketTypeHandler packetType;
protected boolean isChunkDataPacket;
public EEPacket(PacketTypeHandler type, boolean isChunkDataPacket) {
this.packetType = type;
this.isChunkDataPacket = isChunkDataPacket;
}
public byte[] populate() {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
try {
dos.writeByte(packetType.ordinal());
this.writeData(dos);
} catch (IOException e) {
e.printStackTrace();
}
return bos.toByteArray();
}
public void readPopulate(DataInputStream data) {
try {
this.readData(data);
} catch (IOException e) {
e.printStackTrace();
}
}
public void execute(NetworkManager network) { }
public void writeData(DataOutputStream data) throws IOException { }
public void readData(DataInputStream data) throws IOException { }
public void setKey(int key) { }
public void setCoords(int x, int y, int z) { }
public void setOrientation(byte direction) { }
public void setPlayerName(String player) { }
public void setItem(int itemId) { }
public void setState(boolean activated) { }
}

View file

@ -0,0 +1,35 @@
package net.minecraft.src.ee3.network;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.mod_EE3;
public class KeyPressedPacket extends EEPacket {
public int key;
public KeyPressedPacket() {
super(PacketTypeHandler.KEY, false);
}
@Override
public void writeData(DataOutputStream data) throws IOException {
data.writeInt(key);
}
public void readData(DataInputStream data) throws IOException {
this.key = data.readInt();
}
public void setKey(int key) {
this.key = key;
}
// Stub
public void execute(NetworkManager network) {
mod_EE3.proxy.handleControl(network, key);
}
}

View file

@ -0,0 +1,50 @@
package net.minecraft.src.ee3.network;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.Packet;
import net.minecraft.src.Packet1Login;
import net.minecraft.src.mod_EE3;
import net.minecraft.src.forge.IConnectionHandler;
import net.minecraft.src.forge.IPacketHandler;
import net.minecraft.src.forge.MessageManager;
public class PacketHandler implements IPacketHandler, IConnectionHandler {
@Override
public void onConnect(NetworkManager network) {
}
@Override
//Called when a connection is established
public void onLogin(NetworkManager network, Packet1Login login) {
MessageManager.getInstance().registerChannel(network, this, mod_EE3.CHANNEL_NAME);
}
@Override
//Called when a connection drops
public void onDisconnect(NetworkManager network, String message, Object[] args) {
MessageManager.getInstance().removeConnection(network);
}
@Override
// Called when a Packet is received
public void onPacketData(NetworkManager network, String channel, byte[] data) {
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(data));
EEPacket packet = PacketTypeHandler.buildPacket(data);
packet.execute(network);
}
// Called when a Packet is requested to be sent
public static Packet getPacketForSending(EEPacket packet) {
return PacketTypeHandler.populatePacket(packet);
}
public static EEPacket getPacket(PacketTypeHandler type) {
EEPacket pkt = PacketTypeHandler.buildPacket(type);
return pkt;
}
}

View file

@ -0,0 +1,7 @@
package net.minecraft.src.ee3.network;
public class PacketIds {
public static final int KEYPRESS_EVENT = 0;
public static final int TILE_UPDATE = 1;
public static final int PEDESTAL_UPDATE = 2;
}

View file

@ -0,0 +1,59 @@
package net.minecraft.src.ee3.network;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import net.minecraft.src.Packet;
import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.mod_EE3;
public enum PacketTypeHandler {
KEY(KeyPressedPacket.class),
TILE(TileEntityPacket.class),
PEDESTAL(PedestalPacket.class);
private Class<? extends EEPacket> clazz;
PacketTypeHandler(Class<? extends EEPacket> clazz) {
this.clazz=clazz;
}
// Called from PacketHandler.onPacketData
public static EEPacket buildPacket(byte[] data) {
ByteArrayInputStream bis = new ByteArrayInputStream(data);
int selector = bis.read();
DataInputStream dis = new DataInputStream(bis);
EEPacket pkt = null;
try {
pkt = values()[selector].clazz.newInstance();
} catch (Exception e) {
e.printStackTrace();
}
pkt.readPopulate(dis);
return pkt;
}
// Called from code to get a packet of a specific type
public static EEPacket buildPacket(PacketTypeHandler type) {
EEPacket pkt = null;
try {
pkt = values()[type.ordinal()].clazz.newInstance();
} catch (Exception e) {
e.printStackTrace();
}
return pkt;
}
public static Packet populatePacket(EEPacket packet) {
byte[] data = packet.populate();
Packet250CustomPayload pkt = new Packet250CustomPayload();
pkt.channel = mod_EE3.CHANNEL_NAME;
pkt.data = data;
pkt.length = data.length;
pkt.isChunkDataPacket = packet.isChunkDataPacket;
return pkt;
}
}

View file

@ -0,0 +1,53 @@
package net.minecraft.src.ee3.network;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.mod_EE3;
public class PedestalPacket extends EEPacket {
int x, y, z;
public int itemId;
public boolean activated;
public PedestalPacket() {
super(PacketTypeHandler.PEDESTAL, true);
}
public void setCoords(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public void setItem(int itemId) {
this.itemId = itemId;
}
public void setState(boolean activated) {
this.activated = activated;
}
@Override
public void writeData(DataOutputStream data) throws IOException {
data.writeInt(x);
data.writeInt(y);
data.writeInt(z);
data.writeInt(itemId);
data.writeBoolean(activated);
}
public void readData(DataInputStream data) throws IOException {
this.x = data.readInt();
this.y = data.readInt();
this.z = data.readInt();
this.itemId = data.readInt();
this.activated = data.readBoolean();
}
public void execute(NetworkManager network) {
mod_EE3.proxy.handlePedestalPacket(x, y, z, itemId, activated);
}
}

View file

@ -0,0 +1,55 @@
package net.minecraft.src.ee3.network;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import net.minecraft.src.mod_EE3;
import net.minecraft.src.NetworkManager;
public class TileEntityPacket extends EEPacket {
public int x, y, z;
public byte direction;
String player;
public TileEntityPacket() {
super(PacketTypeHandler.TILE, true);
}
public void setCoords(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public void setOrientation(byte direction) {
this.direction = direction;
}
public void setPlayerName(String player) {
this.player = player;
}
@Override
public void writeData(DataOutputStream data) throws IOException {
data.writeInt(x);
data.writeInt(y);
data.writeInt(z);
data.writeByte(direction);
data.writeUTF(player);
}
public void readData(DataInputStream data) throws IOException {
this.x = data.readInt();
this.y = data.readInt();
this.z = data.readInt();
this.direction = data.readByte();
this.player = data.readUTF();
}
public void execute(NetworkManager network) {
mod_EE3.proxy.handleTEPacket(x, y, z, direction, player);
}
}

View file

@ -0,0 +1,57 @@
package net.minecraft.src;
import net.minecraft.src.ModLoader;
import net.minecraft.src.ee3.core.IProxy;
import net.minecraft.src.ee3.core.ServerClientProxy;
import net.minecraft.src.ee3.core.Version;
import net.minecraft.src.ee3.gui.GuiHandler;
import net.minecraft.src.ee3.network.PacketHandler;
import net.minecraft.src.forge.MinecraftForge;
import net.minecraft.src.forge.NetworkMod;
public class mod_EE3 extends NetworkMod {
public static mod_EE3 instance;
public static IProxy proxy;
public static final String CHANNEL_NAME = "EE3";
public mod_EE3() {
instance = this;
proxy = ServerClientProxy.getProxy();
// Forge version check
MinecraftForge.versionDetect("Equivalent Exchange 3", Version.REQ_FORGE_MAJOR, Version.REQ_FORGE_MINOR, Version.REQ_FORGE_REVISION);
// Register the mod with ModLoader
ModLoader.setInGameHook(this, true, true);
// Check this version of EE against the remote version authority
Version.versionCheck();
// Bind Packet Handler
MinecraftForge.registerConnectionHandler(new PacketHandler());
// Bind GUI Handler
MinecraftForge.setGuiHandler(this, new GuiHandler());
}
@Override
public String getVersion() {
return Version.getVersion();
}
@Override
public boolean clientSideRequired() {
return true;
}
@Override
public boolean serverSideRequired() {
return false;
}
@Override
public void load() { }
}

View file

@ -0,0 +1,55 @@
package net.minecraft.src.ee3.server;
import java.io.File;
import net.minecraft.src.ModLoader;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.World;
import net.minecraft.src.ee3.core.IProxy;
public class EEProxy implements IProxy {
public EEProxy() { }
@Override
public void registerRenderInformation() {
// TODO Auto-generated method stub
}
@Override
public void registerTileEntities() {
// TODO Auto-generated method stub
}
@Override
public void registerTranslations() {
// TODO Auto-generated method stub
}
@Override
public File getMinecraftDir() {
return new File(".");
}
@Override
public boolean isRemote() {
return false;
}
@Override
public World getCurrentWorld() {
return null;
}
@Override
public String getMinecraftVersion() {
return ModLoader.getMinecraftServerInstance().getVersion();
}
public void handleControl(NetworkManager network, int key) { }
public void handlePedestalPacket(int x, int y, int z, int itemId, boolean activated) { }
public void handleTEPacket(int x, int y, int z, byte direction, String player) { }
}