Revert "Merge"

This reverts commit 5a1e2fe6ff.
This commit is contained in:
Aidan Brady 2013-08-25 11:01:40 -04:00
parent 5a1e2fe6ff
commit 2d592b57eb
7 changed files with 115 additions and 35 deletions

View file

@ -0,0 +1,45 @@
package ic2.api.keyboard;
import net.minecraft.entity.player.EntityPlayer;
public class Keys {
public static boolean isModeKeyPressed(EntityPlayer aPlayer) {
return getKeyPressed(aPlayer, "isModeSwitchKeyDown");
}
public static boolean isAltKeyPressed(EntityPlayer aPlayer) {
return getKeyPressed(aPlayer, "isAltKeyDown");
}
public static boolean isHudModeKeyPressed(EntityPlayer aPlayer) {
return getKeyPressed(aPlayer, "isHudModeKeyDown");
}
public static boolean isBoostKeyPressed(EntityPlayer aPlayer) {
return getKeyPressed(aPlayer, "isBoostKeyDown");
}
public static boolean isForwardKeyPressed(EntityPlayer aPlayer) {
return getKeyPressed(aPlayer, "isForwardKeyDown");
}
public static boolean isJumpKeyPressed(EntityPlayer aPlayer) {
return getKeyPressed(aPlayer, "isJumpKeyDown");
}
public static boolean isSideInventoryKeyPressed(EntityPlayer aPlayer) {
return getKeyPressed(aPlayer, "isSideinventoryKeyDown");
}
public static boolean isSneakKeyPressed(EntityPlayer aPlayer) {
return getKeyPressed(aPlayer, "isSneakKeyDown");
}
public static boolean getKeyPressed(EntityPlayer aPlayer, String aKeyName) {
Object tObject = ic2.api.util.ReflectionHelper.callMethod(ic2.api.util.ReflectionHelper.getField(ic2.api.info.Info.ic2ModInstance, "keyboard", false, true), "isModeSwitchKeyDown", false, false, true, aPlayer);
if (tObject != null && tObject instanceof Boolean) {
return (Boolean)tObject;
}
return false;
}
}

View file

@ -13,9 +13,9 @@ public class Recipes {
public static IMachineRecipeManager compressor;
public static IMachineRecipeManager centrifuge;
public static IMachineRecipeManager recycler;
public static IMachineRecipeManager metalformerExtruding;
public static IMachineRecipeManager metalformerCutting;
public static IMachineRecipeManager metalformerRolling;
public static IMachineRecipeManager metalformerextruding;
public static IMachineRecipeManager metalformercutting;
public static IMachineRecipeManager metalformerrolling;
public static IMachineRecipeManager orewasching;
/**

View file

@ -1,14 +0,0 @@
package ic2.api.util;
import net.minecraft.entity.player.EntityPlayer;
public interface IKeyboard {
boolean isAltKeyDown(EntityPlayer player);
boolean isBoostKeyDown(EntityPlayer player);
boolean isForwardKeyDown(EntityPlayer player);
boolean isJumpKeyDown(EntityPlayer player);
boolean isModeSwitchKeyDown(EntityPlayer player);
boolean isSideinventoryKeyDown(EntityPlayer player);
boolean isHudModeKeyDown(EntityPlayer player);
boolean isSneakKeyDown(EntityPlayer player);
}

View file

@ -1,6 +0,0 @@
package ic2.api.util;
public class Keys {
public static IKeyboard instance;
}

View file

@ -0,0 +1,55 @@
package ic2.api.util;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class ReflectionHelper {
public static Object callMethod(Object aObject, String aMethod, boolean aPrivate, boolean aUseUpperCasedDataTypes, boolean aLogErrors, Object... aParameters) {
try {
Class<?>[] tParameterTypes = new Class<?>[aParameters.length];
for (byte i = 0; i < aParameters.length; i++) {
if (aParameters[i] instanceof Class) {
tParameterTypes[i] = (Class)aParameters[i];
aParameters[i] = null;
} else {
tParameterTypes[i] = aParameters[i].getClass();
}
if (!aUseUpperCasedDataTypes) {
if (tParameterTypes[i] == Boolean.class ) tParameterTypes[i] = boolean.class;
if (tParameterTypes[i] == Byte.class ) tParameterTypes[i] = byte.class;
if (tParameterTypes[i] == Short.class ) tParameterTypes[i] = short.class;
if (tParameterTypes[i] == Integer.class ) tParameterTypes[i] = int.class;
if (tParameterTypes[i] == Long.class ) tParameterTypes[i] = long.class;
if (tParameterTypes[i] == Float.class ) tParameterTypes[i] = float.class;
if (tParameterTypes[i] == Double.class ) tParameterTypes[i] = double.class;
}
}
Method tMethod = (aObject instanceof Class)?((Class)aObject).getMethod(aMethod, tParameterTypes):aObject.getClass().getMethod(aMethod, tParameterTypes);
if (aPrivate) tMethod.setAccessible(true);
return tMethod.invoke(aObject, aParameters);
} catch (Throwable e) {
if (aLogErrors) e.printStackTrace();
}
return null;
}
public static Object callConstructor(String aClass, int aConstructorIndex, Object aReplacementObject, boolean aLogErrors, Object... aParameters) {
try {
return Class.forName(aClass).getConstructors()[aConstructorIndex].newInstance(aParameters);
} catch (Throwable e) {
if (aLogErrors) e.printStackTrace();
}
return aReplacementObject;
}
public static Object getField(Object aObject, String aField, boolean aPrivate, boolean aLogErrors) {
try {
Field tField = (aObject instanceof Class)?((Class)aObject).getDeclaredField(aField):aObject.getClass().getDeclaredField(aField);
if (aPrivate) tField.setAccessible(true);
return tField.get(aObject);
} catch (Throwable e) {
if (aLogErrors) e.printStackTrace();
}
return null;
}
}

View file

@ -9,11 +9,11 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatMessageComponent;
import net.minecraft.world.World;
public class ItemNetworkMeter extends ItemEnergized
public class ItemEnergyMeter extends ItemEnergized
{
public static double ENERGY_PER_USE = 400;
public ItemNetworkMeter(int id)
public ItemEnergyMeter(int id)
{
super(id, 60000, 120);
}
@ -31,13 +31,13 @@ public class ItemNetworkMeter extends ItemEnergized
{
setEnergy(stack, getEnergy(stack)-ENERGY_PER_USE);
ITransmitter transmitter = (ITransmitter)tileEntity;
ITransmitter cable = (ITransmitter)tileEntity;
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------"));
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Transmitters: " + EnumColor.DARK_GREY + transmitter.getNetworkSize()));
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + transmitter.getNetworkAcceptorSize()));
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Needed: " + EnumColor.DARK_GREY + transmitter.getNetworkNeeded()));
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Power: " + EnumColor.DARK_GREY + transmitter.getNetworkFlow()));
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Cables: " + EnumColor.DARK_GREY + cable.getNetworkSize()));
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + cable.getNetworkAcceptorSize()));
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Needed energy: " + EnumColor.DARK_GREY + cable.getNetworkNeeded()));
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + " *Power: " + EnumColor.DARK_GREY + cable.getNetworkFlow() ));
player.sendChatToPlayer(ChatMessageComponent.func_111066_d(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------"));
}
}

View file

@ -156,7 +156,7 @@ public class Mekanism
public static Item PortableTeleporter;
public static Item TeleportationCore;
public static Item Configurator;
public static Item NetworkMeter;
public static Item EnergyMeter;
//Blocks
public static Block BasicBlock;
@ -374,7 +374,7 @@ public class Mekanism
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(Robit.getUnchargedItem(), new Object[] {
" S ", "ECE", "OIO", Character.valueOf('S'), "ingotSteel", Character.valueOf('E'), EnergyTablet.getUnchargedItem(), Character.valueOf('C'), AtomicCore, Character.valueOf('O'), "ingotRefinedObsidian", Character.valueOf('I'), new ItemStack(MachineBlock, 1, 13)
}));
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(NetworkMeter), new Object[] {
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(EnergyMeter), new Object[] {
" G ", "AEA", " I ", Character.valueOf('G'), Block.glass, Character.valueOf('A'), EnrichedAlloy, Character.valueOf('E'), EnergyTablet.getUnchargedItem(), Character.valueOf('I'), "ingotSteel"
}));
@ -493,7 +493,7 @@ public class Mekanism
LanguageRegistry.addName(PortableTeleporter, "Portable Teleporter");
LanguageRegistry.addName(TeleportationCore, "Teleportation Core");
LanguageRegistry.addName(Configurator, "Configurator");
LanguageRegistry.addName(NetworkMeter, "NetworkMeter");
LanguageRegistry.addName(EnergyMeter, "EnergyMeter");
//Localization for BasicBlock
LanguageRegistry.instance().addStringLocalization("tile.BasicBlock.OsmiumBlock.name", "Osmium Block");
@ -613,7 +613,7 @@ public class Mekanism
Clump = new ItemClump(configuration.getItem("Clump", 11219).getInt()-256);
DirtyDust = new ItemDirtyDust(configuration.getItem("DirtyDust", 11220).getInt()-256);
Configurator = new ItemConfigurator(configuration.getItem("Configurator", 11221).getInt()).setUnlocalizedName("Configurator");
NetworkMeter = new ItemNetworkMeter(configuration.getItem("NetworkMeter", 11222).getInt()).setUnlocalizedName("NetworkMeter");
EnergyMeter = new ItemEnergyMeter(configuration.getItem("EnergyMeter", 11222).getInt()).setUnlocalizedName("EnergyMeter");
configuration.save();
//Registrations
@ -643,7 +643,7 @@ public class Mekanism
GameRegistry.registerItem(Clump, "Clump");
GameRegistry.registerItem(DirtyDust, "DirtyDust");
GameRegistry.registerItem(Configurator, "Configurator");
GameRegistry.registerItem(NetworkMeter, "NetworkMeter");
GameRegistry.registerItem(EnergyMeter, "EnergyMeter");
}
/**