Some mucking about
This commit is contained in:
parent
3be12ee169
commit
2ca30f4845
|
@ -15,7 +15,7 @@ import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes;
|
|||
import com.pahimar.ee3.lib.Reference;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import com.pahimar.ee3.network.PacketHandler;
|
||||
import com.pahimar.ee3.proxy.CommonProxy;
|
||||
import com.pahimar.ee3.proxy.IProxy;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
|
@ -48,7 +48,7 @@ public class EquivalentExchange3
|
|||
public static EquivalentExchange3 instance;
|
||||
|
||||
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
|
||||
public static CommonProxy proxy;
|
||||
public static IProxy proxy;
|
||||
|
||||
public static CreativeTabs tabsEE3 = new CreativeTabEE3(CreativeTabs.getNextID(), Reference.MOD_ID);
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class EquivalentExchange3
|
|||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
// Register the GUI Handler
|
||||
NetworkRegistry.instance().registerGuiHandler(instance, proxy);
|
||||
NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler());
|
||||
|
||||
// Register the PlayerDestroyItem Handler
|
||||
MinecraftForge.EVENT_BUS.register(new PlayerDestroyItemHandler());
|
||||
|
@ -131,10 +131,12 @@ public class EquivalentExchange3
|
|||
|
||||
MinecraftForge.EVENT_BUS.register(new WorldTransmutationHandler());
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new ItemTooltipEventHandler());
|
||||
|
||||
// Register the hook to initialize the EmcRegistry
|
||||
MinecraftForge.EVENT_BUS.register(new WorldEventHandler());
|
||||
|
||||
// Register the ItemTooltipEvent Handler
|
||||
proxy.registerItemTooltipHandler();
|
||||
|
||||
// Register the DrawBlockHighlight Handler
|
||||
proxy.registerDrawBlockHighlightHandler();
|
||||
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
package com.pahimar.ee3.handler;
|
||||
package com.pahimar.ee3.client.handler;
|
||||
|
||||
import com.pahimar.ee3.api.OreStack;
|
||||
import com.pahimar.ee3.api.WrappedStack;
|
||||
import com.pahimar.ee3.emc.EmcRegistry;
|
||||
import com.pahimar.ee3.emc.EmcType;
|
||||
import com.pahimar.ee3.emc.EmcValue;
|
||||
import com.pahimar.ee3.item.crafting.RecipeRegistry;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
* <p/>
|
||||
|
@ -17,37 +18,25 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
|||
*
|
||||
* @author pahimar
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ItemTooltipEventHandler
|
||||
{
|
||||
|
||||
private static boolean debug = true;
|
||||
private static DecimalFormat emcDecimalFormat = new DecimalFormat("#.###");
|
||||
|
||||
@ForgeSubscribe
|
||||
public void handleItemTooltipEvent(ItemTooltipEvent event)
|
||||
{
|
||||
|
||||
WrappedStack stack = new WrappedStack(event.itemStack);
|
||||
if (debug)
|
||||
{
|
||||
event.toolTip.add(EnumChatFormatting.AQUA + "ID: " + event.itemStack.itemID + ", Meta: " + event.itemStack.getItemDamage());
|
||||
if (stack.getWrappedStack() instanceof OreStack)
|
||||
{
|
||||
event.toolTip.add(EnumChatFormatting.AQUA + "OreDictionary Item");
|
||||
}
|
||||
if (RecipeRegistry.getInstance().getRecipeMappings().containsKey(stack))
|
||||
{
|
||||
event.toolTip.add(EnumChatFormatting.AQUA + "Made from a recipe");
|
||||
}
|
||||
}
|
||||
|
||||
if (EmcRegistry.hasEmcValue(stack))
|
||||
if (EmcRegistry.getInstance().hasEmcValue(stack))
|
||||
{
|
||||
EmcValue emcValue = EmcRegistry.getEmcValue(stack);
|
||||
EmcValue emcValue = EmcRegistry.getInstance().getEmcValue(stack);
|
||||
|
||||
event.toolTip.add("");
|
||||
if (emcValue != null)
|
||||
{
|
||||
event.toolTip.add("EMC: " + String.format("%.3f", stack.getStackSize() * emcValue.getValue()));
|
||||
event.toolTip.add("EMC: " + String.format("%s", emcDecimalFormat.format(stack.getStackSize() * emcValue.getValue())));
|
||||
|
||||
if (debug)
|
||||
{
|
||||
|
@ -55,7 +44,7 @@ public class ItemTooltipEventHandler
|
|||
{
|
||||
if (emcValue.components[emcType.ordinal()] > 0)
|
||||
{
|
||||
event.toolTip.add(" * " + emcType + ": " + String.format("%.3f", stack.getStackSize() * emcValue.components[emcType.ordinal()]));
|
||||
event.toolTip.add(" * " + emcType + ": " + String.format("%s", emcDecimalFormat.format(stack.getStackSize() * emcValue.components[emcType.ordinal()])));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,8 +10,6 @@ import net.minecraftforge.oredict.OreDictionary;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
import static com.pahimar.ee3.item.crafting.RecipeRegistry.getInstance;
|
||||
|
||||
public class EmcRegistry
|
||||
{
|
||||
private static EmcRegistry emcRegistry = null;
|
||||
|
@ -19,20 +17,23 @@ public class EmcRegistry
|
|||
private ImmutableSortedMap<WrappedStack, EmcValue> stackMappings;
|
||||
private ImmutableSortedMap<EmcValue, List<WrappedStack>> valueMappings;
|
||||
|
||||
// TODO Change this into a proper registry
|
||||
public static void lazyInit()
|
||||
private EmcRegistry()
|
||||
{
|
||||
}
|
||||
|
||||
public static EmcRegistry getInstance()
|
||||
{
|
||||
if (emcRegistry == null)
|
||||
{
|
||||
emcRegistry = new EmcRegistry();
|
||||
emcRegistry.init();
|
||||
}
|
||||
|
||||
return emcRegistry;
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
|
||||
HashMap<WrappedStack, EmcValue> stackValueMap = new HashMap<WrappedStack, EmcValue>();
|
||||
|
||||
/*
|
||||
|
@ -153,13 +154,13 @@ public class EmcRegistry
|
|||
valueMappings = ImmutableSortedMap.copyOf(tempValueMappings);
|
||||
}
|
||||
|
||||
private static Map<WrappedStack, EmcValue> computeStackMappings()
|
||||
private Map<WrappedStack, EmcValue> computeStackMappings()
|
||||
{
|
||||
Map<WrappedStack, EmcValue> computedStackMap = new HashMap<WrappedStack, EmcValue>();
|
||||
|
||||
for (WrappedStack recipeOutput : getInstance().getRecipeMappings().keySet())
|
||||
for (WrappedStack recipeOutput : RecipeRegistry.getInstance().getRecipeMappings().keySet())
|
||||
{
|
||||
if (!hasEmcValue(recipeOutput.getWrappedStack(), false) && !computedStackMap.containsKey(recipeOutput.getWrappedStack()))
|
||||
if (!hasEmcValue(recipeOutput.getWrappedStack(), false) && !computedStackMap.containsKey(recipeOutput))
|
||||
{
|
||||
EmcValue lowestValue = null;
|
||||
|
||||
|
@ -187,10 +188,8 @@ public class EmcRegistry
|
|||
return computedStackMap;
|
||||
}
|
||||
|
||||
public static boolean hasEmcValue(Object object, boolean strict)
|
||||
public boolean hasEmcValue(Object object, boolean strict)
|
||||
{
|
||||
lazyInit();
|
||||
|
||||
if (WrappedStack.canBeWrapped(object))
|
||||
{
|
||||
WrappedStack stack = new WrappedStack(object);
|
||||
|
@ -253,15 +252,13 @@ public class EmcRegistry
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasEmcValue(Object object)
|
||||
public boolean hasEmcValue(Object object)
|
||||
{
|
||||
return hasEmcValue(object, false);
|
||||
}
|
||||
|
||||
public static EmcValue getEmcValue(Object object, boolean strict)
|
||||
public EmcValue getEmcValue(Object object, boolean strict)
|
||||
{
|
||||
lazyInit();
|
||||
|
||||
if (hasEmcValue(object, strict))
|
||||
{
|
||||
WrappedStack stack = new WrappedStack(object);
|
||||
|
@ -339,25 +336,24 @@ public class EmcRegistry
|
|||
return null;
|
||||
}
|
||||
|
||||
public static EmcValue getEmcValue(Object object)
|
||||
public EmcValue getEmcValue(Object object)
|
||||
{
|
||||
return getEmcValue(object, false);
|
||||
}
|
||||
|
||||
public static List<WrappedStack> getStacksInRange(int start, int finish)
|
||||
@SuppressWarnings("unused")
|
||||
public List<WrappedStack> getStacksInRange(int start, int finish)
|
||||
{
|
||||
return getStacksInRange(new EmcValue(start), new EmcValue(finish));
|
||||
}
|
||||
|
||||
public static List<WrappedStack> getStacksInRange(float start, float finish)
|
||||
public List<WrappedStack> getStacksInRange(float start, float finish)
|
||||
{
|
||||
return getStacksInRange(new EmcValue(start), new EmcValue(finish));
|
||||
}
|
||||
|
||||
public static List<WrappedStack> getStacksInRange(EmcValue start, EmcValue finish)
|
||||
public List<WrappedStack> getStacksInRange(EmcValue start, EmcValue finish)
|
||||
{
|
||||
lazyInit();
|
||||
|
||||
List<WrappedStack> stacksInRange = new ArrayList<WrappedStack>();
|
||||
|
||||
SortedMap<EmcValue, List<WrappedStack>> tailMap = emcRegistry.valueMappings.tailMap(start);
|
||||
|
@ -391,4 +387,14 @@ public class EmcRegistry
|
|||
|
||||
return stacksInRange;
|
||||
}
|
||||
|
||||
public ImmutableSortedMap<WrappedStack, EmcValue> getStackToEmcValueMap()
|
||||
{
|
||||
return stackMappings;
|
||||
}
|
||||
|
||||
public ImmutableSortedMap<EmcValue, List<WrappedStack>> getEmcValueToStackMap()
|
||||
{
|
||||
return valueMappings;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.pahimar.ee3.lib.Compare;
|
|||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -20,6 +21,7 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
|
|||
{
|
||||
// Gson serializer for serializing to/deserializing from json
|
||||
private static final Gson gsonSerializer = (new GsonBuilder()).registerTypeAdapter(EmcValue.class, new EmcValue()).create();
|
||||
private static final int PRECISION = 100;
|
||||
|
||||
public final float[] components;
|
||||
|
||||
|
@ -50,24 +52,33 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
|
|||
|
||||
public EmcValue(float value, EmcType emcType)
|
||||
{
|
||||
this.components = new float[EmcType.TYPES.length];
|
||||
this.components[emcType.ordinal()] = value;
|
||||
this(value, Arrays.asList(new EmcComponent(emcType)));
|
||||
}
|
||||
|
||||
public EmcValue(float[] components)
|
||||
{
|
||||
this.components = components;
|
||||
if (components.length == EmcType.TYPES.length)
|
||||
{
|
||||
this.components = new float[EmcType.TYPES.length];
|
||||
for (int i = 0; i < components.length; i++)
|
||||
{
|
||||
//this.components[i] = (float) Math.round(components[i]) * PRECISION / PRECISION;
|
||||
this.components[i] = components[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.components = null;
|
||||
}
|
||||
}
|
||||
|
||||
public EmcValue(int value, List<EmcComponent> componentList)
|
||||
{
|
||||
|
||||
this((float) value, componentList);
|
||||
}
|
||||
|
||||
public EmcValue(float value, List<EmcComponent> componentList)
|
||||
{
|
||||
|
||||
this.components = new float[EmcType.TYPES.length];
|
||||
|
||||
List<EmcComponent> collatedComponents = collateComponents(componentList);
|
||||
|
@ -96,11 +107,15 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
|
|||
{
|
||||
this.components[EmcType.DEFAULT.ordinal()] = value;
|
||||
}
|
||||
|
||||
// for (int i = 0; i < this.components.length; i++)
|
||||
// {
|
||||
// this.components[i] = (float) Math.round(this.components[i]) * PRECISION / PRECISION;
|
||||
// }
|
||||
}
|
||||
|
||||
public float getValue()
|
||||
{
|
||||
|
||||
float sumSubValues = 0;
|
||||
|
||||
for (float subValue : this.components)
|
||||
|
@ -144,7 +159,6 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
|
|||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
|
||||
int hashCode = 1;
|
||||
|
||||
hashCode = 37 * hashCode + Float.floatToIntBits(getValue());
|
||||
|
|
|
@ -1,89 +1,18 @@
|
|||
package com.pahimar.ee3.proxy;
|
||||
package com.pahimar.ee3.handler;
|
||||
|
||||
import com.pahimar.ee3.client.gui.inventory.*;
|
||||
import com.pahimar.ee3.inventory.*;
|
||||
import com.pahimar.ee3.lib.GuiIds;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
|
||||
import com.pahimar.ee3.tileentity.TileAludel;
|
||||
import com.pahimar.ee3.tileentity.TileCalcinator;
|
||||
import com.pahimar.ee3.tileentity.TileGlassBell;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
* <p/>
|
||||
* CommonProxy
|
||||
*
|
||||
* @author pahimar
|
||||
*/
|
||||
public class CommonProxy implements IGuiHandler
|
||||
public class GuiHandler implements IGuiHandler
|
||||
{
|
||||
|
||||
public void registerKeyBindingHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void registerRenderTickHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void registerDrawBlockHighlightHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setKeyBinding(String name, int value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void registerSoundHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void initRenderingAndTextures()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void registerTileEntities()
|
||||
{
|
||||
|
||||
GameRegistry.registerTileEntity(TileCalcinator.class, Strings.TE_CALCINATOR_NAME);
|
||||
GameRegistry.registerTileEntity(TileAludel.class, Strings.TE_ALUDEL_NAME);
|
||||
GameRegistry.registerTileEntity(TileAlchemicalChest.class, Strings.TE_ALCHEMICAL_CHEST_NAME);
|
||||
GameRegistry.registerTileEntity(TileGlassBell.class, Strings.TE_GLASS_BELL_NAME);
|
||||
}
|
||||
|
||||
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void sendRequestEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void handleTileEntityPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
|
@ -24,24 +24,20 @@ import java.util.EnumSet;
|
|||
*/
|
||||
public class KeyBindingHandler extends KeyBindingRegistry.KeyHandler
|
||||
{
|
||||
|
||||
public KeyBindingHandler()
|
||||
{
|
||||
|
||||
super(KeyBindingHelper.gatherKeyBindings(), KeyBindingHelper.gatherIsRepeating());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel()
|
||||
{
|
||||
|
||||
return Reference.MOD_NAME + ": " + this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat)
|
||||
{
|
||||
|
||||
// Only operate at the end of the tick
|
||||
if (tickEnd)
|
||||
{
|
||||
|
@ -81,7 +77,6 @@ public class KeyBindingHandler extends KeyBindingRegistry.KeyHandler
|
|||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
|
||||
return EnumSet.of(TickType.CLIENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,9 @@ import net.minecraftforge.event.world.WorldEvent;
|
|||
|
||||
public class WorldEventHandler
|
||||
{
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onWorldLoaded(WorldEvent.Load event)
|
||||
{
|
||||
EmcRegistry.lazyInit();
|
||||
EmcRegistry.getInstance();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class DebugHelper
|
|||
|
||||
for (String oreName : oreNames)
|
||||
{
|
||||
if (!EmcRegistry.hasEmcValue(new OreStack(oreName)))
|
||||
if (!EmcRegistry.getInstance().hasEmcValue(new OreStack(oreName)))
|
||||
{
|
||||
LogHelper.debug(String.format("OreStack '%s' requires an EmcValue", oreName));
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class DebugHelper
|
|||
{
|
||||
for (WrappedStack wrappedStack : RecipeRegistry.getInstance().getDiscoveredStacks())
|
||||
{
|
||||
if (!EmcRegistry.hasEmcValue(wrappedStack))
|
||||
if (!EmcRegistry.getInstance().hasEmcValue(wrappedStack))
|
||||
{
|
||||
if (wrappedStack.getWrappedStack() instanceof ItemStack)
|
||||
{
|
||||
|
@ -91,4 +91,12 @@ public class DebugHelper
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void printStackToEmcValueMappings()
|
||||
{
|
||||
for (WrappedStack wrappedStack : EmcRegistry.getInstance().getStackToEmcValueMap().keySet())
|
||||
{
|
||||
LogHelper.debug(String.format("EmcValue for stack '%s': %s", wrappedStack, EmcRegistry.getInstance().getStackToEmcValueMap().get(wrappedStack)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ public class EmcHelper
|
|||
|
||||
for (WrappedStack stack : unfilteredStacks)
|
||||
{
|
||||
if (EmcRegistry.hasEmcValue(stack))
|
||||
if (EmcRegistry.getInstance().hasEmcValue(stack))
|
||||
{
|
||||
EmcValue value = EmcRegistry.getEmcValue(stack);
|
||||
EmcValue value = EmcRegistry.getInstance().getEmcValue(stack);
|
||||
boolean satisfiesFilter = true;
|
||||
float[] valueSubValues = value.components;
|
||||
float[] filterValueSubValues = filterValue.components;
|
||||
|
@ -47,7 +47,7 @@ public class EmcHelper
|
|||
@SuppressWarnings("unused")
|
||||
public static List<WrappedStack> filterStacksByEmcAndRange(float start, float end, EmcValue filterValue)
|
||||
{
|
||||
return filterStacksByEmc(EmcRegistry.getStacksInRange(start, end), filterValue);
|
||||
return filterStacksByEmc(EmcRegistry.getInstance().getStacksInRange(start, end), filterValue);
|
||||
}
|
||||
|
||||
public static EmcValue computeEmcValueFromList(List<WrappedStack> wrappedStacks)
|
||||
|
@ -68,11 +68,11 @@ public class EmcHelper
|
|||
if (itemStack.getItem().getContainerItemStack(itemStack) != null)
|
||||
{
|
||||
stackSize = FluidContainerRegistry.getFluidForFilledItem(itemStack).amount;
|
||||
wrappedStackValue = EmcRegistry.getEmcValue(FluidContainerRegistry.getFluidForFilledItem(itemStack));
|
||||
wrappedStackValue = EmcRegistry.getInstance().getEmcValue(FluidContainerRegistry.getFluidForFilledItem(itemStack));
|
||||
}
|
||||
else
|
||||
{
|
||||
wrappedStackValue = EmcRegistry.getEmcValue(wrappedStack);
|
||||
wrappedStackValue = EmcRegistry.getInstance().getEmcValue(wrappedStack);
|
||||
}
|
||||
}
|
||||
// If we are dealing with a "tool" (container item), assume it's value is 0 (since it won't be used up in the recipe)
|
||||
|
@ -82,12 +82,12 @@ public class EmcHelper
|
|||
}
|
||||
else
|
||||
{
|
||||
wrappedStackValue = EmcRegistry.getEmcValue(wrappedStack);
|
||||
wrappedStackValue = EmcRegistry.getInstance().getEmcValue(wrappedStack);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wrappedStackValue = EmcRegistry.getEmcValue(wrappedStack);
|
||||
wrappedStackValue = EmcRegistry.getInstance().getEmcValue(wrappedStack);
|
||||
}
|
||||
|
||||
if (wrappedStackValue != null)
|
||||
|
|
|
@ -159,7 +159,7 @@ public class InterModCommsHandler implements ITickHandler, IScheduledTickHandler
|
|||
EquivalentExchange3.instance,
|
||||
imcMessage.getSender(),
|
||||
InterModCommsOperations.EMC_RETURN_HAS_VALUE,
|
||||
String.format("%s==%s", imcMessage.getStringValue(), String.valueOf(EmcRegistry.hasEmcValue(wrappedStack))));
|
||||
String.format("%s==%s", imcMessage.getStringValue(), String.valueOf(EmcRegistry.getInstance().hasEmcValue(wrappedStack))));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -177,7 +177,7 @@ public class InterModCommsHandler implements ITickHandler, IScheduledTickHandler
|
|||
EquivalentExchange3.instance,
|
||||
imcMessage.getSender(),
|
||||
InterModCommsOperations.EMC_RETURN_HAS_VALUE,
|
||||
String.format("%s==%s", gson.toJson(itemStack), String.valueOf(EmcRegistry.hasEmcValue(itemStack))));
|
||||
String.format("%s==%s", gson.toJson(itemStack), String.valueOf(EmcRegistry.getInstance().hasEmcValue(itemStack))));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ public class InterModCommsHandler implements ITickHandler, IScheduledTickHandler
|
|||
EquivalentExchange3.instance,
|
||||
imcMessage.getSender(),
|
||||
InterModCommsOperations.EMC_RETURN_GET_VALUE,
|
||||
String.format("%s==%s", imcMessage.getStringValue(), EmcRegistry.getEmcValue(wrappedStack).toJson()));
|
||||
String.format("%s==%s", imcMessage.getStringValue(), EmcRegistry.getInstance().getEmcValue(wrappedStack).toJson()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -223,7 +223,7 @@ public class InterModCommsHandler implements ITickHandler, IScheduledTickHandler
|
|||
EquivalentExchange3.instance,
|
||||
imcMessage.getSender(),
|
||||
InterModCommsOperations.EMC_RETURN_GET_VALUE,
|
||||
String.format("%s==%s", gson.toJson(itemStack), EmcRegistry.getEmcValue(itemStack).toJson()));
|
||||
String.format("%s==%s", gson.toJson(itemStack), EmcRegistry.getInstance().getEmcValue(itemStack).toJson()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ public class Reference
|
|||
public static final String FINGERPRINT = "@FINGERPRINT@";
|
||||
public static final int SECOND_IN_TICKS = 20;
|
||||
public static final int SHIFTED_ID_RANGE_CORRECTION = 256;
|
||||
public static final String SERVER_PROXY_CLASS = "com.pahimar.ee3.proxy.CommonProxy";
|
||||
public static final String SERVER_PROXY_CLASS = "com.pahimar.ee3.proxy.ServerProxy";
|
||||
public static final String CLIENT_PROXY_CLASS = "com.pahimar.ee3.proxy.ClientProxy";
|
||||
public static final int VERSION_CHECK_ATTEMPTS = 3;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.pahimar.ee3.proxy;
|
|||
|
||||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
import com.pahimar.ee3.client.audio.SoundHandler;
|
||||
import com.pahimar.ee3.client.handler.ItemTooltipEventHandler;
|
||||
import com.pahimar.ee3.client.renderer.item.ItemAlchemicalChestRenderer;
|
||||
import com.pahimar.ee3.client.renderer.item.ItemAludelRenderer;
|
||||
import com.pahimar.ee3.client.renderer.item.ItemCalcinatorRenderer;
|
||||
|
@ -17,10 +18,7 @@ import com.pahimar.ee3.helper.ItemHelper;
|
|||
import com.pahimar.ee3.helper.KeyBindingHelper;
|
||||
import com.pahimar.ee3.helper.TransmutationHelper;
|
||||
import com.pahimar.ee3.item.IChargeable;
|
||||
import com.pahimar.ee3.lib.ActionTypes;
|
||||
import com.pahimar.ee3.lib.BlockIds;
|
||||
import com.pahimar.ee3.lib.Colours;
|
||||
import com.pahimar.ee3.lib.RenderIds;
|
||||
import com.pahimar.ee3.lib.*;
|
||||
import com.pahimar.ee3.network.PacketTypeHandler;
|
||||
import com.pahimar.ee3.network.packet.PacketRequestEvent;
|
||||
import com.pahimar.ee3.tileentity.*;
|
||||
|
@ -29,8 +27,10 @@ import cpw.mods.fml.client.registry.ClientRegistry;
|
|||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -46,34 +46,30 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
*
|
||||
* @author pahimar
|
||||
*/
|
||||
public class ClientProxy extends CommonProxy
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ClientProxy implements IProxy
|
||||
{
|
||||
|
||||
@Override
|
||||
public void registerKeyBindingHandler()
|
||||
{
|
||||
|
||||
KeyBindingRegistry.registerKeyBinding(new KeyBindingHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRenderTickHandler()
|
||||
{
|
||||
|
||||
TickRegistry.registerTickHandler(new TransmutationTargetOverlayHandler(), Side.CLIENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerDrawBlockHighlightHandler()
|
||||
{
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new DrawBlockHighlightHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeyBinding(String name, int value)
|
||||
{
|
||||
|
||||
KeyBindingHelper.addKeyBinding(name, value);
|
||||
KeyBindingHelper.addIsRepeating(false);
|
||||
}
|
||||
|
@ -81,14 +77,12 @@ public class ClientProxy extends CommonProxy
|
|||
@Override
|
||||
public void registerSoundHandler()
|
||||
{
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new SoundHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initRenderingAndTextures()
|
||||
{
|
||||
|
||||
RenderIds.calcinatorRender = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderIds.aludelRender = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderIds.alchemicalChestRender = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
@ -98,13 +92,6 @@ public class ClientProxy extends CommonProxy
|
|||
MinecraftForgeClient.registerItemRenderer(BlockIds.ALUDEL_BASE, new ItemAludelRenderer());
|
||||
MinecraftForgeClient.registerItemRenderer(BlockIds.ALCHEMICAL_CHEST, new ItemAlchemicalChestRenderer());
|
||||
MinecraftForgeClient.registerItemRenderer(BlockIds.GLASS_BELL, new ItemGlassBellRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTileEntities()
|
||||
{
|
||||
|
||||
super.registerTileEntities();
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileCalcinator.class, new TileEntityCalcinatorRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileAludel.class, new TileEntityAludelRenderer());
|
||||
|
@ -112,17 +99,30 @@ public class ClientProxy extends CommonProxy
|
|||
ClientRegistry.bindTileEntitySpecialRenderer(TileGlassBell.class, new TileEntityGlassBellRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTileEntities()
|
||||
{
|
||||
GameRegistry.registerTileEntity(TileCalcinator.class, Strings.TE_CALCINATOR_NAME);
|
||||
GameRegistry.registerTileEntity(TileAludel.class, Strings.TE_ALUDEL_NAME);
|
||||
GameRegistry.registerTileEntity(TileAlchemicalChest.class, Strings.TE_ALCHEMICAL_CHEST_NAME);
|
||||
GameRegistry.registerTileEntity(TileGlassBell.class, Strings.TE_GLASS_BELL_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemTooltipHandler()
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register(new ItemTooltipEventHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequestEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data)
|
||||
{
|
||||
|
||||
PacketDispatcher.sendPacketToServer(PacketTypeHandler.populatePacket(new PacketRequestEvent(eventType, originX, originY, originZ, sideHit, rangeX, rangeY, rangeZ, data)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTileEntityPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName)
|
||||
{
|
||||
|
||||
TileEntity tileEntity = FMLClientHandler.instance().getClient().theWorld.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null)
|
||||
|
@ -139,7 +139,6 @@ public class ClientProxy extends CommonProxy
|
|||
@Override
|
||||
public void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color)
|
||||
{
|
||||
|
||||
World world = FMLClientHandler.instance().getClient().theWorld;
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
|
@ -177,7 +176,6 @@ public class ClientProxy extends CommonProxy
|
|||
@Override
|
||||
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit)
|
||||
{
|
||||
|
||||
if (TransmutationHelper.targetBlockStack != null)
|
||||
{
|
||||
if (itemStack != null)
|
||||
|
|
33
src/main/java/com/pahimar/ee3/proxy/IProxy.java
Normal file
33
src/main/java/com/pahimar/ee3/proxy/IProxy.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package com.pahimar.ee3.proxy;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public interface IProxy
|
||||
{
|
||||
public abstract void registerKeyBindingHandler();
|
||||
|
||||
public abstract void registerRenderTickHandler();
|
||||
|
||||
public abstract void registerDrawBlockHighlightHandler();
|
||||
|
||||
public abstract void setKeyBinding(String name, int value);
|
||||
|
||||
public abstract void registerSoundHandler();
|
||||
|
||||
public abstract void initRenderingAndTextures();
|
||||
|
||||
public abstract void registerTileEntities();
|
||||
|
||||
public abstract void registerItemTooltipHandler();
|
||||
|
||||
public abstract void sendRequestEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data);
|
||||
|
||||
public abstract void handleTileEntityPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName);
|
||||
|
||||
public abstract void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color);
|
||||
|
||||
public abstract void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit);
|
||||
}
|
86
src/main/java/com/pahimar/ee3/proxy/ServerProxy.java
Normal file
86
src/main/java/com/pahimar/ee3/proxy/ServerProxy.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.pahimar.ee3.proxy;
|
||||
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
|
||||
import com.pahimar.ee3.tileentity.TileAludel;
|
||||
import com.pahimar.ee3.tileentity.TileCalcinator;
|
||||
import com.pahimar.ee3.tileentity.TileGlassBell;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
* <p/>
|
||||
* ServerProxy
|
||||
*
|
||||
* @author pahimar
|
||||
*/
|
||||
public class ServerProxy implements IProxy
|
||||
{
|
||||
public void registerKeyBindingHandler()
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public void registerRenderTickHandler()
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public void registerDrawBlockHighlightHandler()
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public void setKeyBinding(String name, int value)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public void registerSoundHandler()
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public void initRenderingAndTextures()
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public void registerTileEntities()
|
||||
{
|
||||
GameRegistry.registerTileEntity(TileCalcinator.class, Strings.TE_CALCINATOR_NAME);
|
||||
GameRegistry.registerTileEntity(TileAludel.class, Strings.TE_ALUDEL_NAME);
|
||||
GameRegistry.registerTileEntity(TileAlchemicalChest.class, Strings.TE_ALCHEMICAL_CHEST_NAME);
|
||||
GameRegistry.registerTileEntity(TileGlassBell.class, Strings.TE_GLASS_BELL_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItemTooltipHandler()
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public void sendRequestEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public void handleTileEntityPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
}
|
|
@ -2,13 +2,12 @@ package com.pahimar.ee3.recipe;
|
|||
|
||||
import com.pahimar.ee3.emc.EmcRegistry;
|
||||
import com.pahimar.ee3.emc.EmcValue;
|
||||
import com.pahimar.ee3.helper.ItemHelper;
|
||||
import com.pahimar.ee3.helper.LogHelper;
|
||||
import com.pahimar.ee3.item.ModItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
|
@ -19,19 +18,86 @@ import java.util.List;
|
|||
*/
|
||||
public class CalcinationManager
|
||||
{
|
||||
// Helper stacks
|
||||
private static ItemStack ASH_DUST_STACK = new ItemStack(ModItems.alchemicalDust.itemID, 1, 0);
|
||||
private static ItemStack MINIUM_DUST_STACK = new ItemStack(ModItems.alchemicalDust.itemID, 1, 1);
|
||||
private static ItemStack VERDANT_DUST_STACK = new ItemStack(ModItems.alchemicalDust.itemID, 1, 2);
|
||||
private static ItemStack AZURE_DUST_STACK = new ItemStack(ModItems.alchemicalDust.itemID, 1, 3);
|
||||
private static ItemStack AMARANTHINE_DUST_STACK = new ItemStack(ModItems.alchemicalDust.itemID, 1, 4);
|
||||
private static ItemStack IRIDESCENT_DUST_STACK = new ItemStack(ModItems.alchemicalDust.itemID, 1, 5);
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
public static List<ItemStack> getCalcinationResult(ItemStack itemStack)
|
||||
{
|
||||
ItemStack stack = itemStack.copy();
|
||||
List<ItemStack> calcinationResults = new ArrayList<ItemStack>();
|
||||
|
||||
EmcValue emcValue = EmcRegistry.getEmcValue(itemStack);
|
||||
EmcValue emcValue = EmcRegistry.getInstance().getEmcValue(itemStack);
|
||||
|
||||
if (emcValue != null)
|
||||
{
|
||||
// TODO Get EmcValue of itemStack, add it list of EmcValues of the different dusts, sort it, determine position, and determine result from that
|
||||
for (ItemStack alchemicalDustStack : ModItems.alchemicalDust.getSubTypes())
|
||||
{
|
||||
LogHelper.debug(ItemHelper.toString(alchemicalDustStack));
|
||||
}
|
||||
// // ASH
|
||||
// if (Float.compare(emcValue.getValue(), EmcRegistry.getEmcValue(ASH_DUST_STACK).getValue()) == Compare.LESSER_THAN)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// else if (Float.compare(emcValue.getValue(), EmcRegistry.getEmcValue(ASH_DUST_STACK).getValue()) == Compare.EQUALS)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// // MINIUM
|
||||
// else if (Float.compare(emcValue.getValue(), EmcRegistry.getEmcValue(MINIUM_DUST_STACK).getValue()) == Compare.LESSER_THAN)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// else if (Float.compare(emcValue.getValue(), EmcRegistry.getEmcValue(MINIUM_DUST_STACK).getValue()) == Compare.EQUALS)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// // VERDANT
|
||||
// else if (Float.compare(emcValue.getValue(), EmcRegistry.getEmcValue(VERDANT_DUST_STACK).getValue()) == Compare.LESSER_THAN)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// else if (Float.compare(emcValue.getValue(), EmcRegistry.getEmcValue(VERDANT_DUST_STACK).getValue()) == Compare.EQUALS)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// // AZURE
|
||||
// else if (Float.compare(emcValue.getValue(), EmcRegistry.getEmcValue(AZURE_DUST_STACK).getValue()) == Compare.LESSER_THAN)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// else if (Float.compare(emcValue.getValue(), EmcRegistry.getEmcValue(AZURE_DUST_STACK).getValue()) == Compare.EQUALS)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// // AMARATHINE
|
||||
// else if (Float.compare(emcValue.getValue(), EmcRegistry.getEmcValue(AMARANTHINE_DUST_STACK).getValue()) == Compare.LESSER_THAN)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// else if (Float.compare(emcValue.getValue(), EmcRegistry.getEmcValue(AMARANTHINE_DUST_STACK).getValue()) == Compare.EQUALS)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// // IRIDESCENT
|
||||
// else if (Float.compare(emcValue.getValue(), EmcRegistry.getEmcValue(IRIDESCENT_DUST_STACK).getValue()) == Compare.LESSER_THAN)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// else if (Float.compare(emcValue.getValue(), EmcRegistry.getEmcValue(IRIDESCENT_DUST_STACK).getValue()) == Compare.LESSER_THAN)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// else if (Float.compare(emcValue.getValue(), EmcRegistry.getEmcValue(IRIDESCENT_DUST_STACK).getValue()) == Compare.GREATER_THAN)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
calcinationResults.add(ASH_DUST_STACK.copy());
|
||||
}
|
||||
|
||||
return calcinationResults;
|
||||
|
|
Loading…
Reference in a new issue