Don't be scared - it's easier to start from the bottom. There's also still the MC 1.6.4 branch :)
This commit is contained in:
parent
059d9614c1
commit
4410c25bd6
|
@ -1,18 +1,13 @@
|
||||||
package com.pahimar.ee3;
|
package com.pahimar.ee3;
|
||||||
|
|
||||||
import com.pahimar.ee3.addon.AddonHandler;
|
|
||||||
import com.pahimar.ee3.block.ModBlocks;
|
import com.pahimar.ee3.block.ModBlocks;
|
||||||
import com.pahimar.ee3.command.CommandHandler;
|
import com.pahimar.ee3.handler.CraftingHandler;
|
||||||
import com.pahimar.ee3.configuration.ConfigurationHandler;
|
import com.pahimar.ee3.handler.GuiHandler;
|
||||||
import com.pahimar.ee3.handler.*;
|
|
||||||
import com.pahimar.ee3.helper.FluidHelper;
|
|
||||||
import com.pahimar.ee3.helper.LogHelper;
|
|
||||||
import com.pahimar.ee3.helper.VersionHelper;
|
|
||||||
import com.pahimar.ee3.imc.InterModCommsHandler;
|
|
||||||
import com.pahimar.ee3.item.ModItems;
|
import com.pahimar.ee3.item.ModItems;
|
||||||
import com.pahimar.ee3.lib.Reference;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.proxy.IProxy;
|
import com.pahimar.ee3.proxy.IProxy;
|
||||||
|
import com.pahimar.ee3.reference.EventHandlers;
|
||||||
|
import com.pahimar.ee3.reference.Reference;
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.common.Mod;
|
import cpw.mods.fml.common.Mod;
|
||||||
import cpw.mods.fml.common.Mod.EventHandler;
|
import cpw.mods.fml.common.Mod.EventHandler;
|
||||||
import cpw.mods.fml.common.Mod.Instance;
|
import cpw.mods.fml.common.Mod.Instance;
|
||||||
|
@ -20,80 +15,32 @@ import cpw.mods.fml.common.SidedProxy;
|
||||||
import cpw.mods.fml.common.event.*;
|
import cpw.mods.fml.common.event.*;
|
||||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
import java.io.File;
|
@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, certificateFingerprint = Reference.FINGERPRINT, version = "0.2")
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* EquivalentExchange3
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, certificateFingerprint = Reference.FINGERPRINT)
|
|
||||||
public class EquivalentExchange3
|
public class EquivalentExchange3
|
||||||
{
|
{
|
||||||
@Instance(Reference.MOD_ID)
|
@Instance
|
||||||
public static EquivalentExchange3 instance;
|
public static EquivalentExchange3 instance;
|
||||||
|
|
||||||
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
|
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
|
||||||
public static IProxy proxy;
|
public static IProxy proxy;
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public void invalidFingerprint(FMLFingerprintViolationEvent event)
|
public void invalidFingerprint(FMLFingerprintViolationEvent event)
|
||||||
{
|
{
|
||||||
// Report (log) to the user that the version of Equivalent Exchange 3
|
|
||||||
// they are using has been changed/tampered with
|
|
||||||
if (Reference.FINGERPRINT.equals("@FINGERPRINT@"))
|
|
||||||
{
|
|
||||||
LogHelper.warn(Strings.NO_FINGERPRINT_MESSAGE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogHelper.error(Strings.INVALID_FINGERPRINT_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public void serverStarting(FMLServerStartingEvent event)
|
public void serverStarting(FMLServerStartingEvent event)
|
||||||
{
|
{
|
||||||
// Initialize the custom commands
|
|
||||||
CommandHandler.initCommands(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public void preInit(FMLPreInitializationEvent event)
|
public void preInit(FMLPreInitializationEvent event)
|
||||||
{
|
{
|
||||||
// set version number
|
|
||||||
event.getModMetadata().version = Reference.VERSION_NUMBER;
|
|
||||||
|
|
||||||
// Initialize the configuration
|
|
||||||
ConfigurationHandler.init(event.getModConfigurationDirectory().getAbsolutePath() + File.separator + Reference.CHANNEL_NAME.toLowerCase() + File.separator);
|
|
||||||
|
|
||||||
// Conduct the version check and log the result
|
|
||||||
VersionHelper.execute();
|
|
||||||
|
|
||||||
// Initialize the Version Check Tick Handler (Client only)
|
|
||||||
TickRegistry.registerTickHandler(new VersionCheckTickHandler(), Side.CLIENT);
|
|
||||||
|
|
||||||
// Initialize the InterModCommunications Tick Handler (Server only)
|
|
||||||
TickRegistry.registerScheduledTickHandler(new InterModCommsHandler(), Side.SERVER);
|
|
||||||
|
|
||||||
// Initialize the Render Tick Handler (Client only)
|
|
||||||
proxy.registerRenderTickHandler();
|
|
||||||
|
|
||||||
// Register the KeyBinding Handler (Client only)
|
|
||||||
proxy.registerKeyBindingHandler();
|
|
||||||
|
|
||||||
// Register the Sound Handler (Client only)
|
|
||||||
proxy.registerSoundHandler();
|
|
||||||
|
|
||||||
// Initialize mod blocks
|
// Initialize mod blocks
|
||||||
ModBlocks.init();
|
ModBlocks.init();
|
||||||
|
|
||||||
|
@ -102,58 +49,27 @@ public class EquivalentExchange3
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@SuppressWarnings("unchecked, unused")
|
|
||||||
public void init(FMLInitializationEvent event)
|
public void init(FMLInitializationEvent event)
|
||||||
{
|
{
|
||||||
// Register the GUI Handler
|
// Register the GUI Handler
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||||
|
|
||||||
// Register the Item Pickup Handler
|
// Register the Items Event Handler
|
||||||
MinecraftForge.EVENT_BUS.register(new ItemEventHandler());
|
FMLCommonHandler.instance().bus().register(EventHandlers.itemEventHandler);
|
||||||
|
MinecraftForge.EVENT_BUS.register(EventHandlers.itemEventHandler);
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(new ActionRequestHandler());
|
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(new WorldTransmutationHandler());
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
|
|
||||||
// Initialize custom rendering and pre-load textures (Client only)
|
|
||||||
proxy.initRenderingAndTextures();
|
|
||||||
|
|
||||||
// Initialize our Crafting Handler
|
|
||||||
CraftingHandler.init();
|
CraftingHandler.init();
|
||||||
|
|
||||||
// Handle fluid registration
|
|
||||||
FluidHelper.registerFluids();
|
|
||||||
|
|
||||||
// Initialize mod tile entities
|
|
||||||
proxy.registerTileEntities();
|
|
||||||
|
|
||||||
// Register our fuels
|
|
||||||
GameRegistry.registerFuelHandler(new FuelHandler());
|
|
||||||
|
|
||||||
// Initialize addons (which work with IMC, and must be used in Init)
|
|
||||||
AddonHandler.init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public void postInit(FMLPostInitializationEvent event)
|
public void postInit(FMLPostInitializationEvent event)
|
||||||
{
|
{
|
||||||
// NOOP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public void handleIMCMessages(IMCEvent event)
|
public void handleIMCMessages(IMCEvent event)
|
||||||
{
|
{
|
||||||
InterModCommsHandler.processIMCMessages(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
package com.pahimar.ee3.addon;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.block.ModBlocks;
|
|
||||||
import com.pahimar.ee3.item.ModItems;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
public class AddonEquivalentExchange3
|
|
||||||
{
|
|
||||||
public static void init()
|
|
||||||
{
|
|
||||||
addRecipes();
|
|
||||||
addPreAssignmentEmcValues();
|
|
||||||
addPostAssignmentEmcValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addRecipes()
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Chalk
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new ItemStack(ModItems.chalk, 4), new ItemStack(ModBlocks.chalk));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addPreAssignmentEmcValues()
|
|
||||||
{
|
|
||||||
// NOOP
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addPostAssignmentEmcValues()
|
|
||||||
{
|
|
||||||
// NOOP
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
package com.pahimar.ee3.addon;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.api.RecipeMapping;
|
|
||||||
import com.pahimar.ee3.api.StackValueMapping;
|
|
||||||
import com.pahimar.ee3.emc.EmcValue;
|
|
||||||
import com.pahimar.ee3.imc.InterModCommsOperations;
|
|
||||||
import com.pahimar.ee3.lib.Reference;
|
|
||||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* AddonHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class AddonHandler
|
|
||||||
{
|
|
||||||
public static void init()
|
|
||||||
{
|
|
||||||
AddonEquivalentExchange3.init();
|
|
||||||
AddonIndustrialCraft2.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendAddRecipe(Object outputObject, Object... inputObjects)
|
|
||||||
{
|
|
||||||
List<?> inputObjectsList = Arrays.asList(inputObjects);
|
|
||||||
FMLInterModComms.sendMessage(Reference.MOD_ID, InterModCommsOperations.RECIPE_ADD, new RecipeMapping(outputObject, inputObjectsList).toJson());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendPreValueAssignment(Object object, EmcValue emcValue)
|
|
||||||
{
|
|
||||||
sendPreValueAssignment(new StackValueMapping(object, emcValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendPreValueAssignment(StackValueMapping stackValueMapping)
|
|
||||||
{
|
|
||||||
if (stackValueMapping != null)
|
|
||||||
{
|
|
||||||
FMLInterModComms.sendMessage(Reference.MOD_ID, InterModCommsOperations.EMC_ASSIGN_VALUE_PRE, stackValueMapping.toJson());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendPostValueAssignment(Object object, EmcValue emcValue)
|
|
||||||
{
|
|
||||||
sendPostValueAssignment(new StackValueMapping(object, emcValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendPostValueAssignment(StackValueMapping stackValueMapping)
|
|
||||||
{
|
|
||||||
if (stackValueMapping != null)
|
|
||||||
{
|
|
||||||
FMLInterModComms.sendMessage(Reference.MOD_ID, InterModCommsOperations.EMC_ASSIGN_VALUE_POST, stackValueMapping.toJson());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,233 +0,0 @@
|
||||||
package com.pahimar.ee3.addon;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.api.OreStack;
|
|
||||||
import com.pahimar.ee3.api.WrappedStack;
|
|
||||||
import com.pahimar.ee3.emc.EmcValue;
|
|
||||||
import com.pahimar.ee3.helper.LogHelper;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* AddonIndustrialCraft2
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class AddonIndustrialCraft2
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* EmcValues for various IC2 things
|
|
||||||
*/
|
|
||||||
private static final EmcValue COPPER_EMC_VALUE = new EmcValue(72);
|
|
||||||
private static final EmcValue TIN_EMC_VALUE = new EmcValue(256);
|
|
||||||
private static final EmcValue LEAD_EMC_VALUE = new EmcValue(512);
|
|
||||||
private static final EmcValue SILVER_EMC_VALUE = new EmcValue(1024);
|
|
||||||
private static final EmcValue URANIUM_EMC_VALUE = new EmcValue(4096);
|
|
||||||
private static final EmcValue SULFUR_EMC_VALUE = new EmcValue(512);
|
|
||||||
private static final EmcValue LITHIUM_EMC_VALUE = new EmcValue(512);
|
|
||||||
private static final EmcValue SILICON_DIOXIDE_EMC_VALUE = new EmcValue(256);
|
|
||||||
private static final EmcValue RUBBER_WOOD_EMC_VALUE = new EmcValue(24);
|
|
||||||
|
|
||||||
public static void init()
|
|
||||||
{
|
|
||||||
addRecipes();
|
|
||||||
addPreAssignmentEmcValues();
|
|
||||||
addPostAssignmentEmcValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addRecipes()
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Bronze
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustBronze"), new OreStack("dustTin"), new OreStack("dustCopper", 3));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("ingotBronze"), new OreStack("dustBronze"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateBronze"), new OreStack("ingotBronze"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("blockBronze"), new OreStack("ingotBronze", 9));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateDenseBronze"), new OreStack("ingotBronze", 9));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clay
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustClay", 2), Block.blockClay);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Coal
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustCoal"), new ItemStack(Item.coal, 1));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustHydratedCoal"), new OreStack("dustCoal"), new WrappedStack(FluidRegistry.WATER));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copper
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustCopper"), new OreStack("oreCopper"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustTinyCopper", 9), new OreStack("dustCopper"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedCopper"), new OreStack("dustCopper"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedPurifiedCopper"), new OreStack("crushedCopper"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("ingotCopper"), new OreStack("dustCopper"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateCopper"), new OreStack("ingotCopper"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("blockCopper"), new OreStack("ingotCopper", 9));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateDenseCopper"), new OreStack("ingotCopper", 9));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Diamond
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustDiamond"), Item.diamond);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gold
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedGold"), Block.oreGold);
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedPurifiedGold"), new OreStack("crushedGold"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustGold"), new OreStack("crushedPurifiedGold"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustTinyGold", 9), Block.oreGold);
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateGold"), Item.ingotGold);
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateDenseGold"), new ItemStack(Item.ingotGold, 9));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Industrial Diamond
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("gemDiamond"), Item.diamond);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Iron
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedIron"), Block.oreIron);
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedPurifiedIron"), new OreStack("crushedIron"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustIron"), new OreStack("crushedPurifiedIron"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustTinyIron", 9), Block.oreIron);
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("ingotRefinedIron"), Item.ingotIron);
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateIron"), Item.ingotIron);
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateRefinedIron"), new OreStack("ingotRefinedIron"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateDenseIron"), new ItemStack(Item.ingotIron, 9));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lapis
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustLapis"), new ItemStack(Item.dyePowder, 1, 4));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateLapis"), new OreStack("dustLapis"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateDenseLapis"), new OreStack("plateLapis", 9));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lead
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedLead"), new OreStack("oreLead"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedPurifiedLead"), new OreStack("crushedLead"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustLead"), new OreStack("crushedPurifiedLead"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustTinyLead", 9), new OreStack("dustLead"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("ingotLead"), new OreStack("dustLead"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateLead"), new OreStack("ingotLead"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateDenseLead"), new OreStack("ingotLead", 9));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("blockLead"), new OreStack("ingotLead", 9));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lithium
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustTinyLithium", 9), new OreStack("dustLithium"));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obsidian
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustObsidian", 4), Block.obsidian);
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateObsidian"), new OreStack("dustObsidian"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateDenseObsidian"), new OreStack("plateObsidian", 9));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Silver
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedSilver"), new OreStack("oreSilver"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedPurifiedSilver"), new OreStack("crushedSilver"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustSilver"), new OreStack("crushedPurifiedSilver"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustTinySilver", 9), new OreStack("dustSilver"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("ingotSilver"), new OreStack("dustSilver"));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sulfur
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustTinySulfur", 9), new OreStack("dustSulfur"));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tin
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustTin"), new OreStack("oreTin"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("dustTinyTin", 9), new OreStack("dustTin"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedTin"), new OreStack("dustTin"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedPurifiedTin"), new OreStack("crushedTin"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("ingotTin"), new OreStack("dustTin"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateTin"), new OreStack("ingotTin"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("blockTin"), new OreStack("ingotTin", 9));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("plateDenseTin"), new OreStack("ingotTin", 9));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Uranium
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedUranium"), new OreStack("oreUranium"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("crushedPurifiedUranium"), new OreStack("crushedUranium"));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("blockUranium"), new OreStack("oreUranium", 9));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tools
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("craftingToolForgeHammer"), new ItemStack(Item.ingotIron, 5), new OreStack("stickWood", 2));
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("craftingToolWireCutter"), new ItemStack(Item.ingotIron, 2), new OreStack("plateIron", 3));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Items
|
|
||||||
*/
|
|
||||||
AddonHandler.sendAddRecipe(new OreStack("itemRubber"), new OreStack("woodRubber"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addPreAssignmentEmcValues()
|
|
||||||
{
|
|
||||||
AddonHandler.sendPreValueAssignment(new OreStack("oreCopper"), COPPER_EMC_VALUE);
|
|
||||||
AddonHandler.sendPreValueAssignment(new OreStack("oreTin"), TIN_EMC_VALUE);
|
|
||||||
AddonHandler.sendPreValueAssignment(new OreStack("oreLead"), LEAD_EMC_VALUE);
|
|
||||||
AddonHandler.sendPreValueAssignment(new OreStack("oreSilver"), SILVER_EMC_VALUE);
|
|
||||||
AddonHandler.sendPreValueAssignment(new OreStack("oreUranium"), URANIUM_EMC_VALUE);
|
|
||||||
AddonHandler.sendPreValueAssignment(new OreStack("dustSulfur"), SULFUR_EMC_VALUE);
|
|
||||||
AddonHandler.sendPreValueAssignment(new OreStack("dustLithium"), LITHIUM_EMC_VALUE);
|
|
||||||
AddonHandler.sendPreValueAssignment(new OreStack("dustSiliconDioxide"), SILICON_DIOXIDE_EMC_VALUE);
|
|
||||||
AddonHandler.sendPreValueAssignment(new OreStack("woodRubber"), RUBBER_WOOD_EMC_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addPostAssignmentEmcValues()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Item grabIC2ItemByName(String name)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Object object = Class.forName("ic2.api.item.Items").getDeclaredMethod("getItem", String.class).invoke(null, name);
|
|
||||||
LogHelper.debug(object);
|
|
||||||
}
|
|
||||||
catch (NoSuchMethodException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (InvocationTargetException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch (IllegalAccessException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***
|
|
||||||
* TODO Investigate ways to scope out IC2 recipes and auto-add them
|
|
||||||
*/
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
package com.pahimar.ee3.api;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Compare;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
public class EnergyStack implements Comparable<EnergyStack>
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final String VANILLA_SMELTING_ENERGY_NAME = "vanillaFuelValueUnits";
|
|
||||||
public static final int VANILLA_SMELTING_ENERGY_THRESHOLD = 200;
|
|
||||||
|
|
||||||
public String energyName;
|
|
||||||
public int stackSize;
|
|
||||||
|
|
||||||
public EnergyStack(String energyName, int stackSize)
|
|
||||||
{
|
|
||||||
this.energyName = energyName;
|
|
||||||
this.stackSize = stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EnergyStack(String energyName)
|
|
||||||
{
|
|
||||||
this(energyName, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return String.format("%dxenergyStack.%s", stackSize, energyName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object object)
|
|
||||||
{
|
|
||||||
return object instanceof EnergyStack && (this.compareTo((EnergyStack) object) == Compare.EQUALS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean compareEnergyNames(EnergyStack energyStack1, EnergyStack energyStack2)
|
|
||||||
{
|
|
||||||
if (energyStack1 != null && energyStack2 != null)
|
|
||||||
{
|
|
||||||
if ((energyStack1.energyName != null) && (energyStack2.energyName != null))
|
|
||||||
{
|
|
||||||
return energyStack1.energyName.equalsIgnoreCase(energyStack2.energyName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(EnergyStack energyStack)
|
|
||||||
{
|
|
||||||
return comparator.compare(this, energyStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int compare(EnergyStack energyStack1, EnergyStack energyStack2)
|
|
||||||
{
|
|
||||||
return comparator.compare(energyStack1, energyStack2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Comparator<EnergyStack> comparator = new Comparator<EnergyStack>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int compare(EnergyStack energyStack1, EnergyStack energyStack2)
|
|
||||||
{
|
|
||||||
if (energyStack1 != null)
|
|
||||||
{
|
|
||||||
if (energyStack2 != null)
|
|
||||||
{
|
|
||||||
if (energyStack1.energyName.equalsIgnoreCase(energyStack2.energyName))
|
|
||||||
{
|
|
||||||
return energyStack1.stackSize - energyStack2.stackSize;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return energyStack1.energyName.compareToIgnoreCase(energyStack2.energyName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.LESSER_THAN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (energyStack2 != null)
|
|
||||||
{
|
|
||||||
return Compare.GREATER_THAN;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.EQUALS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package com.pahimar.ee3.api;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.emc.EmcValue;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
public interface ICustomEmcValueProvider
|
|
||||||
{
|
|
||||||
public abstract EmcValue getEmcValue(ItemStack itemStack);
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package com.pahimar.ee3.api;
|
|
||||||
|
|
||||||
public class JsonItemStack
|
|
||||||
{
|
|
||||||
public int stackSize;
|
|
||||||
public int itemID;
|
|
||||||
public byte[] compressedStackTagCompound;
|
|
||||||
public int itemDamage;
|
|
||||||
}
|
|
|
@ -1,175 +0,0 @@
|
||||||
package com.pahimar.ee3.api;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.google.gson.JsonSyntaxException;
|
|
||||||
import com.pahimar.ee3.helper.LogHelper;
|
|
||||||
import com.pahimar.ee3.lib.Compare;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class OreStack implements Comparable<OreStack>
|
|
||||||
{
|
|
||||||
// Gson serializer for serializing to/deserializing from json
|
|
||||||
private static final Gson gsonSerializer = new Gson();
|
|
||||||
|
|
||||||
private static final int ORE_DICTIONARY_NOT_FOUND = -1;
|
|
||||||
|
|
||||||
public String oreName;
|
|
||||||
public int stackSize;
|
|
||||||
public static Comparator<OreStack> comparator = new Comparator<OreStack>()
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(OreStack oreStack1, OreStack oreStack2)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (oreStack1 != null)
|
|
||||||
{
|
|
||||||
if (oreStack2 != null)
|
|
||||||
{
|
|
||||||
if (oreStack1.oreName.equalsIgnoreCase(oreStack2.oreName))
|
|
||||||
{
|
|
||||||
return oreStack1.stackSize - oreStack2.stackSize;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return oreStack1.oreName.compareToIgnoreCase(oreStack2.oreName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.LESSER_THAN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (oreStack2 != null)
|
|
||||||
{
|
|
||||||
return Compare.GREATER_THAN;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.EQUALS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public OreStack(String oreName, int stackSize)
|
|
||||||
{
|
|
||||||
this.oreName = oreName;
|
|
||||||
this.stackSize = stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OreStack(String oreName)
|
|
||||||
{
|
|
||||||
this(oreName, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OreStack(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
this(OreDictionary.getOreName(OreDictionary.getOreID(itemStack)), itemStack.stackSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean compareOreNames(OreStack oreStack1, OreStack oreStack2)
|
|
||||||
{
|
|
||||||
if (oreStack1 != null && oreStack2 != null)
|
|
||||||
{
|
|
||||||
if ((oreStack1.oreName != null) && (oreStack2.oreName != null))
|
|
||||||
{
|
|
||||||
return oreStack1.oreName.equalsIgnoreCase(oreStack2.oreName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializes a OreStack object from the given serialized json String
|
|
||||||
*
|
|
||||||
* @param jsonOreStack
|
|
||||||
* Json encoded String representing a OreStack object
|
|
||||||
*
|
|
||||||
* @return The OreStack that was encoded as json, or null if a valid OreStack could not be decoded from given String
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public static OreStack createFromJson(String jsonOreStack)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return gsonSerializer.fromJson(jsonOreStack, OreStack.class);
|
|
||||||
}
|
|
||||||
catch (JsonSyntaxException exception)
|
|
||||||
{
|
|
||||||
LogHelper.error(exception.getMessage());
|
|
||||||
}
|
|
||||||
catch (JsonParseException exception)
|
|
||||||
{
|
|
||||||
LogHelper.error(exception.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OreStack getOreStackFromList(Object... objects)
|
|
||||||
{
|
|
||||||
return getOreStackFromList(Arrays.asList(objects));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OreStack getOreStackFromList(List<?> objectList)
|
|
||||||
{
|
|
||||||
for (Object listElement : objectList)
|
|
||||||
{
|
|
||||||
if (listElement instanceof ItemStack)
|
|
||||||
{
|
|
||||||
ItemStack stack = (ItemStack) listElement;
|
|
||||||
|
|
||||||
if (OreDictionary.getOreID(stack) != ORE_DICTIONARY_NOT_FOUND)
|
|
||||||
{
|
|
||||||
return new OreStack(stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int compare(OreStack oreStack1, OreStack oreStack2)
|
|
||||||
{
|
|
||||||
return comparator.compare(oreStack1, oreStack2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return String.format("%sxoreStack.%s", stackSize, oreName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object object)
|
|
||||||
{
|
|
||||||
return object instanceof OreStack && (comparator.compare(this, (OreStack) object) == Compare.EQUALS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(OreStack oreStack)
|
|
||||||
{
|
|
||||||
return comparator.compare(this, oreStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns this OreStack as a json serialized String
|
|
||||||
*
|
|
||||||
* @return Json serialized String of this OreStack
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public String toJson()
|
|
||||||
{
|
|
||||||
return gsonSerializer.toJson(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,126 +0,0 @@
|
||||||
package com.pahimar.ee3.api;
|
|
||||||
|
|
||||||
import com.google.gson.*;
|
|
||||||
import com.pahimar.ee3.helper.LogHelper;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class RecipeMapping implements JsonSerializer<RecipeMapping>, JsonDeserializer<RecipeMapping>
|
|
||||||
{
|
|
||||||
private static final Gson gsonSerializer = (new GsonBuilder()).registerTypeAdapter(RecipeMapping.class, new RecipeMapping()).create();
|
|
||||||
|
|
||||||
public final WrappedStack outputWrappedStack;
|
|
||||||
public final List<WrappedStack> inputWrappedStacks;
|
|
||||||
|
|
||||||
private RecipeMapping()
|
|
||||||
{
|
|
||||||
outputWrappedStack = null;
|
|
||||||
inputWrappedStacks = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RecipeMapping(Object outputStack, List<?> inputStacks)
|
|
||||||
{
|
|
||||||
this.outputWrappedStack = new WrappedStack(outputStack);
|
|
||||||
|
|
||||||
List<WrappedStack> wrappedStacks = new ArrayList<WrappedStack>();
|
|
||||||
for (Object object : inputStacks)
|
|
||||||
{
|
|
||||||
|
|
||||||
WrappedStack wrappedStack = new WrappedStack(object);
|
|
||||||
|
|
||||||
if (wrappedStack.getWrappedStack() != null)
|
|
||||||
{
|
|
||||||
wrappedStacks.add(wrappedStack);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogHelper.warn(String.format("RecipeMapping with output: %s is containing a null WrappedStack " +
|
|
||||||
"input that will not be added to the input list.", outputWrappedStack.toString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.inputWrappedStacks = wrappedStacks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RecipeMapping createFromJson(String jsonRecipeMapping)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return gsonSerializer.fromJson(jsonRecipeMapping, RecipeMapping.class);
|
|
||||||
}
|
|
||||||
catch (JsonSyntaxException exception)
|
|
||||||
{
|
|
||||||
LogHelper.error(exception.getMessage());
|
|
||||||
}
|
|
||||||
catch (JsonParseException exception)
|
|
||||||
{
|
|
||||||
LogHelper.error(exception.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toJson()
|
|
||||||
{
|
|
||||||
return gsonSerializer.toJson(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RecipeMapping deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException
|
|
||||||
{
|
|
||||||
if (!jsonElement.isJsonPrimitive())
|
|
||||||
{
|
|
||||||
JsonObject jsonRecipeMapping = (JsonObject) jsonElement;
|
|
||||||
|
|
||||||
WrappedStack outputStack = null;
|
|
||||||
List<WrappedStack> inputStacks = new ArrayList<WrappedStack>();
|
|
||||||
|
|
||||||
if (jsonRecipeMapping.get("outputWrappedStack") != null)
|
|
||||||
{
|
|
||||||
outputStack = new WrappedStack().deserialize(jsonRecipeMapping.get("outputWrappedStack").getAsJsonObject(), WrappedStack.class, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonRecipeMapping.get("inputWrappedStacks") != null)
|
|
||||||
{
|
|
||||||
JsonArray jsonInputStacks = jsonRecipeMapping.get("inputWrappedStacks").getAsJsonArray();
|
|
||||||
|
|
||||||
for (int i = 0; i < jsonInputStacks.size(); i++)
|
|
||||||
{
|
|
||||||
WrappedStack inputStack = new WrappedStack().deserialize(jsonInputStacks.get(i).getAsJsonObject(), WrappedStack.class, context);
|
|
||||||
inputStacks.add(inputStack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new RecipeMapping(outputStack, inputStacks);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonElement serialize(RecipeMapping recipeMapping, Type type, JsonSerializationContext context)
|
|
||||||
{
|
|
||||||
JsonObject jsonRecipeMapping = new JsonObject();
|
|
||||||
|
|
||||||
Gson gsonWrappedStack = new Gson();
|
|
||||||
|
|
||||||
JsonArray jsonArray = new JsonArray();
|
|
||||||
for (WrappedStack inputStack : recipeMapping.inputWrappedStacks)
|
|
||||||
{
|
|
||||||
jsonArray.add(gsonWrappedStack.toJsonTree(inputStack, WrappedStack.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonRecipeMapping.add("outputWrappedStack", gsonWrappedStack.toJsonTree(recipeMapping.outputWrappedStack, WrappedStack.class));
|
|
||||||
jsonRecipeMapping.add("inputWrappedStacks", jsonArray);
|
|
||||||
|
|
||||||
return jsonRecipeMapping;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return String.format("RecipeMapping[Output: %s, Input: %s]", outputWrappedStack, inputWrappedStacks);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,108 +0,0 @@
|
||||||
package com.pahimar.ee3.api;
|
|
||||||
|
|
||||||
import com.google.gson.*;
|
|
||||||
import com.pahimar.ee3.emc.EmcValue;
|
|
||||||
import com.pahimar.ee3.helper.LogHelper;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
|
|
||||||
public class StackValueMapping implements JsonSerializer<StackValueMapping>, JsonDeserializer<StackValueMapping>
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final Gson gsonSerializer = (new GsonBuilder()).registerTypeAdapter(StackValueMapping.class, new StackValueMapping()).create();
|
|
||||||
|
|
||||||
public final WrappedStack wrappedStack;
|
|
||||||
public final EmcValue emcValue;
|
|
||||||
|
|
||||||
public StackValueMapping()
|
|
||||||
{
|
|
||||||
wrappedStack = null;
|
|
||||||
emcValue = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StackValueMapping(Object object, EmcValue emcValue)
|
|
||||||
{
|
|
||||||
this.wrappedStack = new WrappedStack(object);
|
|
||||||
this.emcValue = emcValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static StackValueMapping createFromJson(String jsonStackValueMapping)
|
|
||||||
{
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return gsonSerializer.fromJson(jsonStackValueMapping, StackValueMapping.class);
|
|
||||||
}
|
|
||||||
catch (JsonSyntaxException exception)
|
|
||||||
{
|
|
||||||
LogHelper.error(exception.getMessage());
|
|
||||||
}
|
|
||||||
catch (JsonParseException exception)
|
|
||||||
{
|
|
||||||
LogHelper.error(exception.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toJson()
|
|
||||||
{
|
|
||||||
return gsonSerializer.toJson(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see com.google.gson.JsonSerializer#serialize(java.lang.Object, java.lang.reflect.Type, com.google.gson.JsonSerializationContext)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public JsonElement serialize(StackValueMapping stackValueMapping, Type type, JsonSerializationContext context)
|
|
||||||
{
|
|
||||||
|
|
||||||
JsonObject jsonStackValueMapping = new JsonObject();
|
|
||||||
|
|
||||||
Gson gsonWrappedStack = (new GsonBuilder()).registerTypeAdapter(WrappedStack.class, new WrappedStack()).create();
|
|
||||||
Gson gsonEmcValue = (new GsonBuilder()).registerTypeAdapter(EmcValue.class, new EmcValue()).create();
|
|
||||||
|
|
||||||
jsonStackValueMapping.add("wrappedStack", gsonWrappedStack.toJsonTree(stackValueMapping.wrappedStack));
|
|
||||||
jsonStackValueMapping.add("emcValue", gsonEmcValue.toJsonTree(stackValueMapping.emcValue));
|
|
||||||
|
|
||||||
return jsonStackValueMapping;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see com.google.gson.JsonDeserializer#deserialize(com.google.gson.JsonElement, java.lang.reflect.Type, com.google.gson.JsonDeserializationContext)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public StackValueMapping deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!jsonElement.isJsonPrimitive())
|
|
||||||
{
|
|
||||||
|
|
||||||
JsonObject jsonStackValueMapping = (JsonObject) jsonElement;
|
|
||||||
|
|
||||||
WrappedStack wrappedStack = null;
|
|
||||||
EmcValue emcValue = null;
|
|
||||||
|
|
||||||
if (jsonStackValueMapping.get("wrappedStack") != null)
|
|
||||||
{
|
|
||||||
wrappedStack = new WrappedStack().deserialize(jsonStackValueMapping.get("wrappedStack").getAsJsonObject(), type, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonStackValueMapping.get("emcValue") != null)
|
|
||||||
{
|
|
||||||
emcValue = new EmcValue().deserialize(jsonStackValueMapping.get("emcValue").getAsJsonObject(), type, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wrappedStack != null && emcValue != null)
|
|
||||||
{
|
|
||||||
return new StackValueMapping(wrappedStack, emcValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,766 +0,0 @@
|
||||||
package com.pahimar.ee3.api;
|
|
||||||
|
|
||||||
import com.google.gson.*;
|
|
||||||
import com.pahimar.ee3.helper.FluidHelper;
|
|
||||||
import com.pahimar.ee3.helper.ItemHelper;
|
|
||||||
import com.pahimar.ee3.helper.LogHelper;
|
|
||||||
import com.pahimar.ee3.lib.Compare;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompressedStreamTools;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<WrappedStack>, JsonSerializer<WrappedStack>
|
|
||||||
{
|
|
||||||
private static final Gson gsonSerializer = (new GsonBuilder()).registerTypeAdapter(WrappedStack.class, new WrappedStack()).create();
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private final String className;
|
|
||||||
|
|
||||||
private int stackSize;
|
|
||||||
private final Object wrappedStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public WrappedStack()
|
|
||||||
{
|
|
||||||
className = null;
|
|
||||||
stackSize = -1;
|
|
||||||
wrappedStack = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WrappedStack(Object object)
|
|
||||||
{
|
|
||||||
if (object instanceof Item)
|
|
||||||
{
|
|
||||||
object = new ItemStack((Item) object);
|
|
||||||
}
|
|
||||||
else if (object instanceof Block)
|
|
||||||
{
|
|
||||||
object = new ItemStack((Block) object);
|
|
||||||
}
|
|
||||||
else if (object instanceof Fluid)
|
|
||||||
{
|
|
||||||
object = new FluidStack((Fluid) object, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (object instanceof ItemStack)
|
|
||||||
{
|
|
||||||
ItemStack itemStack = ((ItemStack) object).copy();
|
|
||||||
|
|
||||||
className = ItemStack.class.getSimpleName();
|
|
||||||
stackSize = itemStack.stackSize;
|
|
||||||
itemStack.stackSize = 1;
|
|
||||||
wrappedStack = itemStack;
|
|
||||||
}
|
|
||||||
else if (object instanceof OreStack)
|
|
||||||
{
|
|
||||||
OreStack oreStack = (OreStack) object;
|
|
||||||
|
|
||||||
className = OreStack.class.getSimpleName();
|
|
||||||
stackSize = oreStack.stackSize;
|
|
||||||
oreStack.stackSize = 1;
|
|
||||||
wrappedStack = oreStack;
|
|
||||||
}
|
|
||||||
else if (object instanceof ArrayList)
|
|
||||||
{
|
|
||||||
ArrayList<?> objectList = (ArrayList<?>) object;
|
|
||||||
|
|
||||||
OreStack possibleOreStack = OreStack.getOreStackFromList(objectList);
|
|
||||||
|
|
||||||
if (possibleOreStack != null)
|
|
||||||
{
|
|
||||||
className = OreStack.class.getSimpleName();
|
|
||||||
stackSize = possibleOreStack.stackSize;
|
|
||||||
possibleOreStack.stackSize = 1;
|
|
||||||
wrappedStack = possibleOreStack;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stackSize = -1;
|
|
||||||
className = null;
|
|
||||||
wrappedStack = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (object instanceof EnergyStack)
|
|
||||||
{
|
|
||||||
EnergyStack energyStack = (EnergyStack) object;
|
|
||||||
|
|
||||||
className = EnergyStack.class.getSimpleName();
|
|
||||||
stackSize = energyStack.stackSize;
|
|
||||||
energyStack.stackSize = 1;
|
|
||||||
wrappedStack = energyStack;
|
|
||||||
}
|
|
||||||
else if (object instanceof FluidStack)
|
|
||||||
{
|
|
||||||
FluidStack fluidStack = ((FluidStack) object).copy();
|
|
||||||
|
|
||||||
className = FluidStack.class.getSimpleName();
|
|
||||||
stackSize = fluidStack.amount;
|
|
||||||
fluidStack.amount = 1;
|
|
||||||
wrappedStack = fluidStack;
|
|
||||||
}
|
|
||||||
else if (object instanceof WrappedStack)
|
|
||||||
{
|
|
||||||
WrappedStack wrappedStackObject = (WrappedStack) object;
|
|
||||||
|
|
||||||
if (wrappedStackObject.getWrappedStack() != null)
|
|
||||||
{
|
|
||||||
className = wrappedStackObject.wrappedStack.getClass().getSimpleName();
|
|
||||||
this.stackSize = wrappedStackObject.stackSize;
|
|
||||||
this.wrappedStack = wrappedStackObject.wrappedStack;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
className = null;
|
|
||||||
stackSize = -1;
|
|
||||||
wrappedStack = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (object instanceof String)
|
|
||||||
{
|
|
||||||
WrappedStack wrappedStack = createFromJson((String) object);
|
|
||||||
|
|
||||||
if (wrappedStack != null && wrappedStack.getWrappedStack() != null)
|
|
||||||
{
|
|
||||||
className = wrappedStack.getWrappedStack().getClass().getSimpleName();
|
|
||||||
stackSize = wrappedStack.stackSize;
|
|
||||||
this.wrappedStack = wrappedStack.wrappedStack;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
className = null;
|
|
||||||
stackSize = -1;
|
|
||||||
this.wrappedStack = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
className = null;
|
|
||||||
stackSize = -1;
|
|
||||||
wrappedStack = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public WrappedStack(Object object, int stackSize)
|
|
||||||
{
|
|
||||||
if (object instanceof Item)
|
|
||||||
{
|
|
||||||
object = new ItemStack((Item) object);
|
|
||||||
}
|
|
||||||
else if (object instanceof Block)
|
|
||||||
{
|
|
||||||
object = new ItemStack((Block) object);
|
|
||||||
}
|
|
||||||
else if (object instanceof Fluid)
|
|
||||||
{
|
|
||||||
object = new FluidStack((Fluid) object, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (object instanceof ItemStack)
|
|
||||||
{
|
|
||||||
ItemStack itemStack = ((ItemStack) object).copy();
|
|
||||||
|
|
||||||
className = ItemStack.class.getSimpleName();
|
|
||||||
this.stackSize = stackSize;
|
|
||||||
itemStack.stackSize = 1;
|
|
||||||
wrappedStack = itemStack;
|
|
||||||
}
|
|
||||||
else if (object instanceof OreStack)
|
|
||||||
{
|
|
||||||
OreStack oreStack = (OreStack) object;
|
|
||||||
|
|
||||||
className = OreStack.class.getSimpleName();
|
|
||||||
this.stackSize = stackSize;
|
|
||||||
oreStack.stackSize = 1;
|
|
||||||
wrappedStack = oreStack;
|
|
||||||
}
|
|
||||||
else if (object instanceof ArrayList)
|
|
||||||
{
|
|
||||||
ArrayList<?> objectList = (ArrayList<?>) object;
|
|
||||||
|
|
||||||
OreStack possibleOreStack = OreStack.getOreStackFromList(objectList);
|
|
||||||
|
|
||||||
if (possibleOreStack != null)
|
|
||||||
{
|
|
||||||
className = OreStack.class.getSimpleName();
|
|
||||||
this.stackSize = stackSize;
|
|
||||||
possibleOreStack.stackSize = 1;
|
|
||||||
wrappedStack = possibleOreStack;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.stackSize = -1;
|
|
||||||
className = null;
|
|
||||||
wrappedStack = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (object instanceof EnergyStack)
|
|
||||||
{
|
|
||||||
EnergyStack energyStack = (EnergyStack) object;
|
|
||||||
|
|
||||||
className = EnergyStack.class.getSimpleName();
|
|
||||||
this.stackSize = stackSize;
|
|
||||||
energyStack.stackSize = 1;
|
|
||||||
wrappedStack = energyStack;
|
|
||||||
}
|
|
||||||
else if (object instanceof FluidStack)
|
|
||||||
{
|
|
||||||
FluidStack fluidStack = (FluidStack) object;
|
|
||||||
|
|
||||||
className = FluidStack.class.getSimpleName();
|
|
||||||
this.stackSize = stackSize;
|
|
||||||
fluidStack.amount = 1;
|
|
||||||
wrappedStack = fluidStack;
|
|
||||||
}
|
|
||||||
else if (object instanceof WrappedStack)
|
|
||||||
{
|
|
||||||
WrappedStack wrappedStackObject = (WrappedStack) object;
|
|
||||||
|
|
||||||
if (wrappedStackObject.getWrappedStack() != null)
|
|
||||||
{
|
|
||||||
className = wrappedStackObject.wrappedStack.getClass().getSimpleName();
|
|
||||||
this.stackSize = stackSize;
|
|
||||||
this.wrappedStack = wrappedStackObject.wrappedStack;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
className = null;
|
|
||||||
this.stackSize = -1;
|
|
||||||
wrappedStack = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (object instanceof String)
|
|
||||||
{
|
|
||||||
WrappedStack wrappedStack = createFromJson((String) object);
|
|
||||||
|
|
||||||
if (wrappedStack != null && wrappedStack.getWrappedStack() != null)
|
|
||||||
{
|
|
||||||
className = wrappedStack.wrappedStack.getClass().getSimpleName();
|
|
||||||
this.stackSize = stackSize;
|
|
||||||
this.wrappedStack = wrappedStack.wrappedStack;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
className = null;
|
|
||||||
this.stackSize = -1;
|
|
||||||
this.wrappedStack = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
className = null;
|
|
||||||
this.stackSize = -1;
|
|
||||||
wrappedStack = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStackSize()
|
|
||||||
{
|
|
||||||
|
|
||||||
return stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStackSize(int stackSize)
|
|
||||||
{
|
|
||||||
|
|
||||||
this.stackSize = stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getWrappedStack()
|
|
||||||
{
|
|
||||||
|
|
||||||
return wrappedStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WrappedStack createFromJson(String jsonWrappedObject) throws JsonParseException
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return gsonSerializer.fromJson(jsonWrappedObject, WrappedStack.class);
|
|
||||||
}
|
|
||||||
catch (JsonSyntaxException exception)
|
|
||||||
{
|
|
||||||
LogHelper.error(exception.getMessage());
|
|
||||||
}
|
|
||||||
catch (JsonParseException exception)
|
|
||||||
{
|
|
||||||
LogHelper.error(exception.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public String toJson()
|
|
||||||
{
|
|
||||||
return gsonSerializer.toJson(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sort order (class-wise) goes ItemStack, OreStack, EnergyStack,
|
|
||||||
* FluidStack, null
|
|
||||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int compareTo(WrappedStack wrappedStack)
|
|
||||||
{
|
|
||||||
return comparator.compare(this, wrappedStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
int hashCode = 1;
|
|
||||||
hashCode = (37 * hashCode) + stackSize;
|
|
||||||
|
|
||||||
if (wrappedStack instanceof ItemStack)
|
|
||||||
{
|
|
||||||
hashCode = (37 * hashCode) + ((ItemStack) wrappedStack).itemID;
|
|
||||||
hashCode = (37 * hashCode) + ((ItemStack) wrappedStack).getItemDamage();
|
|
||||||
|
|
||||||
if (((ItemStack) wrappedStack).getTagCompound() != null)
|
|
||||||
{
|
|
||||||
hashCode = (37 * hashCode) + ((ItemStack) wrappedStack).getTagCompound().hashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (wrappedStack instanceof OreStack)
|
|
||||||
{
|
|
||||||
if (((OreStack) wrappedStack).oreName != null)
|
|
||||||
{
|
|
||||||
hashCode = (37 * hashCode) + ((OreStack) wrappedStack).oreName.hashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (wrappedStack instanceof EnergyStack)
|
|
||||||
{
|
|
||||||
if (((EnergyStack) wrappedStack).energyName != null)
|
|
||||||
{
|
|
||||||
hashCode = (37 * hashCode) + ((EnergyStack) wrappedStack).energyName.hashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (wrappedStack instanceof FluidStack)
|
|
||||||
{
|
|
||||||
hashCode = (37 * hashCode) + wrappedStack.hashCode();
|
|
||||||
|
|
||||||
if (((FluidStack) wrappedStack).tag != null)
|
|
||||||
{
|
|
||||||
hashCode = (37 * hashCode) + ((FluidStack) wrappedStack).tag.hashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return hashCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object object)
|
|
||||||
{
|
|
||||||
return object instanceof WrappedStack && (this.compareTo((WrappedStack) object) == Compare.EQUALS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a string representation of the object.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
|
|
||||||
if (wrappedStack instanceof ItemStack)
|
|
||||||
{
|
|
||||||
ItemStack itemStack = (ItemStack) wrappedStack;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
stringBuilder.append(String.format("%sxitemStack[%s:%s:%s:%s]", stackSize, itemStack.itemID, itemStack.getItemDamage(), itemStack.getUnlocalizedName(), itemStack.getItem().getClass().getCanonicalName()));
|
|
||||||
}
|
|
||||||
catch (ArrayIndexOutOfBoundsException e)
|
|
||||||
{
|
|
||||||
// NOOP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (wrappedStack instanceof OreStack)
|
|
||||||
{
|
|
||||||
OreStack oreStack = (OreStack) wrappedStack;
|
|
||||||
stringBuilder.append(String.format("%sxoreStack.%s", stackSize, oreStack.oreName));
|
|
||||||
}
|
|
||||||
else if (wrappedStack instanceof EnergyStack)
|
|
||||||
{
|
|
||||||
EnergyStack energyStack = (EnergyStack) wrappedStack;
|
|
||||||
stringBuilder.append(String.format("%sxenergyStack.%s", stackSize, energyStack.energyName));
|
|
||||||
}
|
|
||||||
else if (wrappedStack instanceof FluidStack)
|
|
||||||
{
|
|
||||||
FluidStack fluidStack = (FluidStack) wrappedStack;
|
|
||||||
stringBuilder.append(String.format("%sxfluidStack.%s", stackSize, fluidStack.getFluid().getName()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stringBuilder.append("null");
|
|
||||||
}
|
|
||||||
|
|
||||||
return stringBuilder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canBeWrapped(Object object)
|
|
||||||
{
|
|
||||||
if (object instanceof WrappedStack)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (object instanceof Item || object instanceof Block || object instanceof ItemStack)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (object instanceof OreStack)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (object instanceof List)
|
|
||||||
{
|
|
||||||
if (OreStack.getOreStackFromList((List<?>) object) != null)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (object instanceof EnergyStack)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (object instanceof Fluid || object instanceof FluidStack)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonElement serialize(WrappedStack wrappedStack, Type type, JsonSerializationContext context)
|
|
||||||
{
|
|
||||||
JsonObject jsonWrappedStack = new JsonObject();
|
|
||||||
|
|
||||||
Gson gsonWrappedStack = new Gson();
|
|
||||||
|
|
||||||
jsonWrappedStack.addProperty("className", wrappedStack.className);
|
|
||||||
jsonWrappedStack.addProperty("stackSize", wrappedStack.stackSize);
|
|
||||||
|
|
||||||
if (wrappedStack.wrappedStack instanceof ItemStack)
|
|
||||||
{
|
|
||||||
JsonItemStack jsonItemStack = new JsonItemStack();
|
|
||||||
jsonItemStack.itemID = ((ItemStack) wrappedStack.wrappedStack).itemID;
|
|
||||||
jsonItemStack.itemDamage = ((ItemStack) wrappedStack.wrappedStack).getItemDamage();
|
|
||||||
jsonItemStack.stackSize = ((ItemStack) wrappedStack.wrappedStack).stackSize;
|
|
||||||
if (((ItemStack) wrappedStack.wrappedStack).stackTagCompound != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
jsonItemStack.compressedStackTagCompound = CompressedStreamTools.compress(((ItemStack) wrappedStack.wrappedStack).stackTagCompound);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jsonWrappedStack.add("wrappedStack", gsonWrappedStack.toJsonTree(jsonItemStack, JsonItemStack.class));
|
|
||||||
}
|
|
||||||
else if (wrappedStack.wrappedStack instanceof OreStack)
|
|
||||||
{
|
|
||||||
jsonWrappedStack.add("wrappedStack", gsonWrappedStack.toJsonTree(wrappedStack.wrappedStack, OreStack.class));
|
|
||||||
}
|
|
||||||
else if (wrappedStack.wrappedStack instanceof EnergyStack)
|
|
||||||
{
|
|
||||||
jsonWrappedStack.add("wrappedStack", gsonWrappedStack.toJsonTree(wrappedStack.wrappedStack, EnergyStack.class));
|
|
||||||
}
|
|
||||||
else if (wrappedStack.wrappedStack instanceof FluidStack)
|
|
||||||
{
|
|
||||||
jsonWrappedStack.add("wrappedStack", gsonWrappedStack.toJsonTree(wrappedStack.wrappedStack, FluidStack.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
return jsonWrappedStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public WrappedStack deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException
|
|
||||||
{
|
|
||||||
if (!jsonElement.isJsonPrimitive())
|
|
||||||
{
|
|
||||||
JsonObject jsonWrappedStack = (JsonObject) jsonElement;
|
|
||||||
|
|
||||||
int stackSize = -1;
|
|
||||||
String className = null;
|
|
||||||
Object stackObject = null;
|
|
||||||
|
|
||||||
if (jsonWrappedStack.get("className") != null)
|
|
||||||
{
|
|
||||||
className = jsonWrappedStack.get("className").getAsString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonWrappedStack.get("stackSize") != null)
|
|
||||||
{
|
|
||||||
stackSize = jsonWrappedStack.get("stackSize").getAsInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonWrappedStack.get("wrappedStack") != null && !jsonWrappedStack.get("wrappedStack").isJsonPrimitive())
|
|
||||||
{
|
|
||||||
if (className != null)
|
|
||||||
{
|
|
||||||
if (className.equalsIgnoreCase(ItemStack.class.getSimpleName()))
|
|
||||||
{
|
|
||||||
JsonItemStack jsonItemStack = gsonSerializer.fromJson(jsonWrappedStack.get("wrappedStack"), JsonItemStack.class);
|
|
||||||
ItemStack itemStack = null;
|
|
||||||
if (stackSize > 0)
|
|
||||||
{
|
|
||||||
itemStack = new ItemStack(jsonItemStack.itemID, stackSize, jsonItemStack.itemDamage);
|
|
||||||
if (jsonItemStack.compressedStackTagCompound != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
itemStack.stackTagCompound = CompressedStreamTools.decompress(jsonItemStack.compressedStackTagCompound);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stackObject = itemStack;
|
|
||||||
}
|
|
||||||
else if (className.equalsIgnoreCase(OreStack.class.getSimpleName()))
|
|
||||||
{
|
|
||||||
OreStack oreStack = gsonSerializer.fromJson(jsonWrappedStack.get("wrappedStack"), OreStack.class);
|
|
||||||
|
|
||||||
if (stackSize > 0)
|
|
||||||
{
|
|
||||||
oreStack.stackSize = stackSize;
|
|
||||||
}
|
|
||||||
stackObject = oreStack;
|
|
||||||
}
|
|
||||||
else if (className.equalsIgnoreCase(EnergyStack.class.getSimpleName()))
|
|
||||||
{
|
|
||||||
EnergyStack energyStack = gsonSerializer.fromJson(jsonWrappedStack.get("wrappedStack"), EnergyStack.class);
|
|
||||||
|
|
||||||
if (stackSize > 0)
|
|
||||||
{
|
|
||||||
energyStack.stackSize = stackSize;
|
|
||||||
}
|
|
||||||
stackObject = energyStack;
|
|
||||||
}
|
|
||||||
else if (className.equalsIgnoreCase(FluidStack.class.getSimpleName()))
|
|
||||||
{
|
|
||||||
FluidStack fluidStack = gsonSerializer.fromJson(jsonWrappedStack.get("wrappedStack"), FluidStack.class);
|
|
||||||
|
|
||||||
if (stackSize > 0)
|
|
||||||
{
|
|
||||||
fluidStack.amount = stackSize;
|
|
||||||
}
|
|
||||||
stackObject = fluidStack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stackObject != null)
|
|
||||||
{
|
|
||||||
return new WrappedStack(stackObject);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new JsonParseException(String.format("Unable to parse a wrappable stack object from the provided json: %s", jsonElement.toString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new JsonParseException(String.format("Unable to parse a wrappable stack object from the provided json: %s", jsonElement.toString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public WrappedStack deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException
|
|
||||||
{
|
|
||||||
if (!jsonElement.isJsonPrimitive())
|
|
||||||
{
|
|
||||||
JsonObject jsonWrappedStack = (JsonObject) jsonElement;
|
|
||||||
|
|
||||||
int stackSize = -1;
|
|
||||||
String className = null;
|
|
||||||
Object stackObject = null;
|
|
||||||
|
|
||||||
if (jsonWrappedStack.get("className") != null)
|
|
||||||
{
|
|
||||||
className = jsonWrappedStack.get("className").getAsString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonWrappedStack.get("stackSize") != null)
|
|
||||||
{
|
|
||||||
stackSize = jsonWrappedStack.get("stackSize").getAsInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (jsonWrappedStack.get("wrappedStack") != null && !jsonWrappedStack.get("wrappedStack").isJsonPrimitive())
|
|
||||||
{
|
|
||||||
if (className != null)
|
|
||||||
{
|
|
||||||
if (className.equalsIgnoreCase(ItemStack.class.getSimpleName()))
|
|
||||||
{
|
|
||||||
JsonItemStack jsonItemStack = gsonSerializer.fromJson(jsonWrappedStack.get("wrappedStack"), JsonItemStack.class);
|
|
||||||
ItemStack itemStack = null;
|
|
||||||
if (stackSize > 0)
|
|
||||||
{
|
|
||||||
itemStack = new ItemStack(jsonItemStack.itemID, stackSize, jsonItemStack.itemDamage);
|
|
||||||
if (jsonItemStack.compressedStackTagCompound != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
itemStack.stackTagCompound = CompressedStreamTools.decompress(jsonItemStack.compressedStackTagCompound);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stackObject = itemStack;
|
|
||||||
}
|
|
||||||
else if (className.equalsIgnoreCase(OreStack.class.getSimpleName()))
|
|
||||||
{
|
|
||||||
OreStack oreStack = gsonSerializer.fromJson(jsonWrappedStack.get("wrappedStack"), OreStack.class);
|
|
||||||
|
|
||||||
if (stackSize > 0)
|
|
||||||
{
|
|
||||||
oreStack.stackSize = stackSize;
|
|
||||||
}
|
|
||||||
stackObject = oreStack;
|
|
||||||
}
|
|
||||||
else if (className.equalsIgnoreCase(EnergyStack.class.getSimpleName()))
|
|
||||||
{
|
|
||||||
EnergyStack energyStack = gsonSerializer.fromJson(jsonWrappedStack.get("wrappedStack"), EnergyStack.class);
|
|
||||||
|
|
||||||
if (stackSize > 0)
|
|
||||||
{
|
|
||||||
energyStack.stackSize = stackSize;
|
|
||||||
}
|
|
||||||
stackObject = energyStack;
|
|
||||||
}
|
|
||||||
else if (className.equalsIgnoreCase(FluidStack.class.getSimpleName()))
|
|
||||||
{
|
|
||||||
FluidStack fluidStack = gsonSerializer.fromJson(jsonWrappedStack.get("wrappedStack"), FluidStack.class);
|
|
||||||
|
|
||||||
if (stackSize > 0)
|
|
||||||
{
|
|
||||||
fluidStack.amount = stackSize;
|
|
||||||
}
|
|
||||||
stackObject = fluidStack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stackObject != null)
|
|
||||||
{
|
|
||||||
return new WrappedStack(stackObject);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new JsonParseException(String.format("Unable to parse a wrappable stack object from the provided json: %s", jsonElement.toString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new JsonParseException(String.format("Unable to parse a wrappable stack object from the provided json: %s", jsonElement.toString()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Comparator<WrappedStack> comparator = new Comparator<WrappedStack>()
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(WrappedStack wrappedStack1, WrappedStack wrappedStack2)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (wrappedStack1.wrappedStack instanceof ItemStack)
|
|
||||||
{
|
|
||||||
if (wrappedStack2.wrappedStack instanceof ItemStack)
|
|
||||||
{
|
|
||||||
return ItemHelper.compare((ItemStack) wrappedStack1.wrappedStack, (ItemStack) wrappedStack2.wrappedStack);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.GREATER_THAN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (wrappedStack1.wrappedStack instanceof OreStack)
|
|
||||||
{
|
|
||||||
if (wrappedStack2.wrappedStack instanceof ItemStack)
|
|
||||||
{
|
|
||||||
return Compare.LESSER_THAN;
|
|
||||||
}
|
|
||||||
else if (wrappedStack2.wrappedStack instanceof OreStack)
|
|
||||||
{
|
|
||||||
return OreStack.compare((OreStack) wrappedStack1.wrappedStack, (OreStack) wrappedStack2.wrappedStack);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.GREATER_THAN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (wrappedStack1.wrappedStack instanceof EnergyStack)
|
|
||||||
{
|
|
||||||
if (wrappedStack2.wrappedStack instanceof ItemStack || wrappedStack2.wrappedStack instanceof OreStack)
|
|
||||||
{
|
|
||||||
return Compare.LESSER_THAN;
|
|
||||||
}
|
|
||||||
else if (wrappedStack2.wrappedStack instanceof EnergyStack)
|
|
||||||
{
|
|
||||||
return EnergyStack.compare((EnergyStack) wrappedStack1.wrappedStack, (EnergyStack) wrappedStack2.wrappedStack);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.GREATER_THAN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (wrappedStack1.wrappedStack instanceof FluidStack)
|
|
||||||
{
|
|
||||||
if (wrappedStack2.wrappedStack instanceof ItemStack || wrappedStack2.wrappedStack instanceof OreStack || wrappedStack2.wrappedStack instanceof EnergyStack)
|
|
||||||
{
|
|
||||||
return Compare.LESSER_THAN;
|
|
||||||
}
|
|
||||||
else if (wrappedStack2.wrappedStack instanceof FluidStack)
|
|
||||||
{
|
|
||||||
return FluidHelper.compare((FluidStack) wrappedStack1.wrappedStack, (FluidStack) wrappedStack2.wrappedStack);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.GREATER_THAN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (wrappedStack1.wrappedStack == null)
|
|
||||||
{
|
|
||||||
if (wrappedStack2.wrappedStack != null)
|
|
||||||
{
|
|
||||||
return Compare.LESSER_THAN;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.EQUALS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Compare.EQUALS;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,117 +0,0 @@
|
||||||
package com.pahimar.ee3.block;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.EquivalentExchange3;
|
|
||||||
import com.pahimar.ee3.lib.GuiIds;
|
|
||||||
import com.pahimar.ee3.lib.RenderIds;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
|
|
||||||
import com.pahimar.ee3.tileentity.TileAlchemicalChestLarge;
|
|
||||||
import com.pahimar.ee3.tileentity.TileAlchemicalChestMedium;
|
|
||||||
import com.pahimar.ee3.tileentity.TileAlchemicalChestSmall;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* BlockAlchemicalChest
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class BlockAlchemicalChest extends BlockEE implements ITileEntityProvider
|
|
||||||
{
|
|
||||||
public BlockAlchemicalChest(int id)
|
|
||||||
{
|
|
||||||
super(id, Material.wood);
|
|
||||||
this.setHardness(2.5F);
|
|
||||||
this.setUnlocalizedName(Strings.ALCHEMICAL_CHEST_NAME);
|
|
||||||
this.setCreativeTab(EquivalentExchange3.tabsEE3);
|
|
||||||
this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createTileEntity(World world, int metaData)
|
|
||||||
{
|
|
||||||
if (metaData == 0)
|
|
||||||
{
|
|
||||||
return new TileAlchemicalChestSmall();
|
|
||||||
}
|
|
||||||
else if (metaData == 1)
|
|
||||||
{
|
|
||||||
return new TileAlchemicalChestMedium();
|
|
||||||
}
|
|
||||||
else if (metaData == 2)
|
|
||||||
{
|
|
||||||
return new TileAlchemicalChestLarge();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void getSubBlocks(int id, CreativeTabs creativeTabs, List list)
|
|
||||||
{
|
|
||||||
for (int meta = 0; meta < 3; meta++)
|
|
||||||
{
|
|
||||||
list.add(new ItemStack(id, 1, meta));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int damageDropped(int metaData)
|
|
||||||
{
|
|
||||||
return metaData;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderAsNormalBlock()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRenderType()
|
|
||||||
{
|
|
||||||
|
|
||||||
return RenderIds.alchemicalChestRender;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
|
||||||
{
|
|
||||||
if (player.isSneaking() || world.isBlockSolidOnSide(x, y + 1, z, ForgeDirection.DOWN))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!world.isRemote && world.getBlockTileEntity(x, y, z) instanceof TileAlchemicalChest)
|
|
||||||
{
|
|
||||||
player.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_CHEST, world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
package com.pahimar.ee3.block;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.EquivalentExchange3;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class BlockAlchemicalFuel extends BlockEE
|
|
||||||
{
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private Icon[] blockTop, blockSide;
|
|
||||||
|
|
||||||
public BlockAlchemicalFuel(int id)
|
|
||||||
{
|
|
||||||
super(id);
|
|
||||||
this.setUnlocalizedName(Strings.ALCHEMICAL_FUEL_BLOCK_NAME);
|
|
||||||
this.setCreativeTab(EquivalentExchange3.tabsEE3);
|
|
||||||
this.setHardness(5.0F);
|
|
||||||
this.setResistance(10.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void getSubBlocks(int id, CreativeTabs creativeTabs, List list)
|
|
||||||
{
|
|
||||||
for (int meta = 0; meta < Strings.ALCHEMICAL_FUEL_SUBTYPE_NAMES.length; meta++)
|
|
||||||
{
|
|
||||||
list.add(new ItemStack(id, 1, meta));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int damageDropped(int metaData)
|
|
||||||
{
|
|
||||||
return metaData;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IconRegister iconRegister)
|
|
||||||
{
|
|
||||||
this.blockTop = new Icon[Strings.ALCHEMICAL_FUEL_SUBTYPE_NAMES.length];
|
|
||||||
this.blockSide = new Icon[Strings.ALCHEMICAL_FUEL_SUBTYPE_NAMES.length];
|
|
||||||
|
|
||||||
for (int i = 0; i < Strings.ALCHEMICAL_FUEL_SUBTYPE_NAMES.length; i++)
|
|
||||||
{
|
|
||||||
blockTop[i] = iconRegister.registerIcon(String.format("%s.%s_top", getUnwrappedUnlocalizedName(this.getUnlocalizedName()), Strings.ALCHEMICAL_FUEL_SUBTYPE_NAMES[i]));
|
|
||||||
blockSide[i] = iconRegister.registerIcon(String.format("%s.%s_side", getUnwrappedUnlocalizedName(this.getUnlocalizedName()), Strings.ALCHEMICAL_FUEL_SUBTYPE_NAMES[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon getIcon(int side, int metaData)
|
|
||||||
{
|
|
||||||
metaData = MathHelper.clamp_int(metaData, 0, Strings.ALCHEMICAL_FUEL_SUBTYPE_NAMES.length - 1);
|
|
||||||
|
|
||||||
if (ForgeDirection.getOrientation(side) == ForgeDirection.UP || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN)
|
|
||||||
{
|
|
||||||
return blockTop[metaData];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return blockSide[metaData];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package com.pahimar.ee3.block;
|
|
||||||
|
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
public class BlockAlchemySquare extends BlockEE implements ITileEntityProvider
|
|
||||||
{
|
|
||||||
public BlockAlchemySquare(int id)
|
|
||||||
{
|
|
||||||
super(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
return createTileEntity(world, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createTileEntity(World world, int metadata)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,193 +0,0 @@
|
||||||
package com.pahimar.ee3.block;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.EquivalentExchange3;
|
|
||||||
import com.pahimar.ee3.lib.GuiIds;
|
|
||||||
import com.pahimar.ee3.lib.Particles;
|
|
||||||
import com.pahimar.ee3.lib.RenderIds;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.tileentity.TileAludel;
|
|
||||||
import com.pahimar.ee3.tileentity.TileGlassBell;
|
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* BlockAludel
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class BlockAludelBase extends BlockEE implements ITileEntityProvider
|
|
||||||
{
|
|
||||||
public BlockAludelBase(int id)
|
|
||||||
{
|
|
||||||
super(id, Material.anvil);
|
|
||||||
this.setUnlocalizedName(Strings.ALUDEL_NAME);
|
|
||||||
this.setCreativeTab(EquivalentExchange3.tabsEE3);
|
|
||||||
this.setBlockBounds(0.10F, 0.0F, 0.10F, 0.90F, 1.0F, 0.90F);
|
|
||||||
this.setHardness(5F);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
return new TileAludel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderAsNormalBlock()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRenderType()
|
|
||||||
{
|
|
||||||
|
|
||||||
return RenderIds.aludelRender;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6)
|
|
||||||
{
|
|
||||||
super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
|
|
||||||
TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4);
|
|
||||||
return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void breakBlock(World world, int x, int y, int z, int id, int meta)
|
|
||||||
{
|
|
||||||
if (world.getBlockTileEntity(x, y + 1, z) instanceof TileGlassBell)
|
|
||||||
{
|
|
||||||
world.markBlockForUpdate(x, y + 1, z);
|
|
||||||
world.updateAllLightTypes(x, y + 1, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.breakBlock(world, x, y, z, id, meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int faceHit, float par7, float par8, float par9)
|
|
||||||
{
|
|
||||||
if (player.isSneaking())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!world.isRemote)
|
|
||||||
{
|
|
||||||
if (world.getBlockTileEntity(x, y, z) instanceof TileAludel && world.getBlockTileEntity(x, y + 1, z) instanceof TileGlassBell)
|
|
||||||
{
|
|
||||||
player.openGui(EquivalentExchange3.instance, GuiIds.ALUDEL, world, x, y, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world.getBlockTileEntity(x, y, z) instanceof TileAludel && ModBlocks.glassBell.canPlaceBlockAt(world, x, y + 1, z) && faceHit == ForgeDirection.UP.ordinal())
|
|
||||||
{
|
|
||||||
if (player.getHeldItem() != null && player.getHeldItem().itemID == ModBlocks.glassBell.blockID)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack)
|
|
||||||
{
|
|
||||||
super.onBlockPlacedBy(world, x, y, z, entityLiving, itemStack);
|
|
||||||
|
|
||||||
if (world.getBlockTileEntity(x, y + 1, z) instanceof TileGlassBell)
|
|
||||||
{
|
|
||||||
TileGlassBell tileGlassBell = (TileGlassBell) world.getBlockTileEntity(x, y + 1, z);
|
|
||||||
|
|
||||||
tileGlassBell.setOrientation(ForgeDirection.UP);
|
|
||||||
|
|
||||||
if (world.getBlockTileEntity(x, y, z) instanceof TileAludel)
|
|
||||||
{
|
|
||||||
TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
ItemStack itemStackGlassBell = tileGlassBell.getStackInSlot(TileGlassBell.DISPLAY_SLOT_INVENTORY_INDEX);
|
|
||||||
|
|
||||||
tileGlassBell.setInventorySlotContents(TileGlassBell.DISPLAY_SLOT_INVENTORY_INDEX, null);
|
|
||||||
|
|
||||||
tileAludel.setInventorySlotContents(TileAludel.INPUT_INVENTORY_INDEX, itemStackGlassBell);
|
|
||||||
|
|
||||||
tileAludel.hasGlassBell = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
|
|
||||||
{
|
|
||||||
TileAludel aludel = (TileAludel) world.getBlockTileEntity(x, y, z);
|
|
||||||
aludel.hasGlassBell = world.getBlockTileEntity(x, y + 1, z) instanceof TileGlassBell;
|
|
||||||
|
|
||||||
super.onNeighborBlockChange(world, x, y, z, blockID);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
if (world.getBlockTileEntity(x, y, z) instanceof TileAludel)
|
|
||||||
{
|
|
||||||
if (((TileAludel) world.getBlockTileEntity(x, y, z)).getState() == 1)
|
|
||||||
{
|
|
||||||
return 15;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getLightValue(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void randomDisplayTick(World world, int x, int y, int z, Random random)
|
|
||||||
{
|
|
||||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
|
||||||
if (tile instanceof TileAludel)
|
|
||||||
{
|
|
||||||
if (((TileAludel) tile).getState() == 1)
|
|
||||||
{
|
|
||||||
switch (((TileAludel) tile).getOrientation())
|
|
||||||
{
|
|
||||||
case NORTH:
|
|
||||||
world.spawnParticle(Particles.FLAME, (double) x + 0.5F, (double) y + 0.33F, (double) z + 0.175F, 0.0D, 0.0D, 0.0D);
|
|
||||||
break;
|
|
||||||
case SOUTH:
|
|
||||||
world.spawnParticle(Particles.FLAME, (double) x + 0.5F, (double) y + 0.33F, (double) z + 0.825F, 0.0D, 0.0D, 0.0D);
|
|
||||||
break;
|
|
||||||
case WEST:
|
|
||||||
world.spawnParticle(Particles.FLAME, (double) x + 0.175F, (double) y + 0.33F, (double) z + 0.5F, 0.0D, 0.0D, 0.0D);
|
|
||||||
break;
|
|
||||||
case EAST:
|
|
||||||
world.spawnParticle(Particles.FLAME, (double) x + 0.825F, (double) y + 0.33F, (double) z + 0.5F, 0.0D, 0.0D, 0.0D);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 0.5F, (double) y + 0.7F, (double) z + 0.0F, 0.0D, 0.05D, 0.0D);
|
|
||||||
world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 0.5F, (double) y + 0.7F, (double) z + 1.0F, 0.0D, 0.05D, 0.0D);
|
|
||||||
world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 0.0F, (double) y + 0.7F, (double) z + 0.5F, 0.0D, 0.05D, 0.0D);
|
|
||||||
world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 1.0F, (double) y + 0.7F, (double) z + 0.5F, 0.0D, 0.05D, 0.0D);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,117 +0,0 @@
|
||||||
package com.pahimar.ee3.block;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.EquivalentExchange3;
|
|
||||||
import com.pahimar.ee3.lib.GuiIds;
|
|
||||||
import com.pahimar.ee3.lib.Particles;
|
|
||||||
import com.pahimar.ee3.lib.RenderIds;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.tileentity.TileCalcinator;
|
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* BlockCalcinator
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class BlockCalcinator extends BlockEE implements ITileEntityProvider
|
|
||||||
{
|
|
||||||
public BlockCalcinator(int id)
|
|
||||||
{
|
|
||||||
super(id, Material.rock);
|
|
||||||
this.setUnlocalizedName(Strings.CALCINATOR_NAME);
|
|
||||||
this.setCreativeTab(EquivalentExchange3.tabsEE3);
|
|
||||||
this.setHardness(2.0F);
|
|
||||||
this.setBlockBounds(0.1F, 0.0F, 0.1F, 0.9F, 1.0F, 0.9F);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
return new TileCalcinator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderAsNormalBlock()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
if (world.getBlockTileEntity(x, y, z) instanceof TileCalcinator)
|
|
||||||
{
|
|
||||||
if (((TileCalcinator) world.getBlockTileEntity(x, y, z)).getState() == 1)
|
|
||||||
{
|
|
||||||
return 15;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getLightValue(world, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRenderType()
|
|
||||||
{
|
|
||||||
|
|
||||||
return RenderIds.calcinatorRender;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6)
|
|
||||||
{
|
|
||||||
super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
|
|
||||||
TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4);
|
|
||||||
return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
|
||||||
{
|
|
||||||
if (player.isSneaking())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!world.isRemote)
|
|
||||||
{
|
|
||||||
if (world.getBlockTileEntity(x, y, z) instanceof TileCalcinator)
|
|
||||||
{
|
|
||||||
player.openGui(EquivalentExchange3.instance, GuiIds.CALCINATOR, world, x, y, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void randomDisplayTick(World world, int x, int y, int z, Random random)
|
|
||||||
{
|
|
||||||
if (world.getBlockTileEntity(x, y, z) instanceof TileCalcinator)
|
|
||||||
{
|
|
||||||
if (((TileCalcinator) world.getBlockTileEntity(x, y, z)).getState() == 1)
|
|
||||||
{
|
|
||||||
// Fire pot particles
|
|
||||||
world.spawnParticle(Particles.NORMAL_SMOKE, (double) x + 0.5F, (double) y + 0.4F, (double) ((z + 0.5F) + (random.nextFloat() * 0.5F - 0.3F)), 0.0D, 0.0D, 0.0D);
|
|
||||||
world.spawnParticle(Particles.FLAME, (double) x + 0.5F, (double) y + 0.4F, (double) z + 0.5F, 0.0D, 0.0D, 0.0D);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package com.pahimar.ee3.block;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.EquivalentExchange3;
|
|
||||||
import com.pahimar.ee3.item.ModItems;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class BlockChalk extends BlockEE
|
|
||||||
{
|
|
||||||
public BlockChalk(int id)
|
|
||||||
{
|
|
||||||
super(id, Material.clay);
|
|
||||||
this.setHardness(0.6F);
|
|
||||||
this.setUnlocalizedName(Strings.CHALK_NAME);
|
|
||||||
this.setCreativeTab(EquivalentExchange3.tabsEE3);
|
|
||||||
this.setStepSound(soundStoneFootstep);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int idDropped(int par1, Random random, int par2)
|
|
||||||
{
|
|
||||||
return ModItems.chalk.itemID;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int quantityDropped(Random random)
|
|
||||||
{
|
|
||||||
return (random.nextInt(4) + 1);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,132 +0,0 @@
|
||||||
package com.pahimar.ee3.block;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.tileentity.TileEE;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class BlockEE extends Block
|
|
||||||
{
|
|
||||||
public BlockEE(int id)
|
|
||||||
{
|
|
||||||
this(id, Material.rock);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockEE(int id, Material material)
|
|
||||||
{
|
|
||||||
super(id, material);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUnlocalizedName()
|
|
||||||
{
|
|
||||||
return String.format("tile.%s%s", Strings.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IconRegister iconRegister)
|
|
||||||
{
|
|
||||||
blockIcon = iconRegister.registerIcon(String.format("%s", getUnwrappedUnlocalizedName(this.getUnlocalizedName())));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getUnwrappedUnlocalizedName(String unlocalizedName)
|
|
||||||
{
|
|
||||||
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void breakBlock(World world, int x, int y, int z, int id, int meta)
|
|
||||||
{
|
|
||||||
dropInventory(world, x, y, z);
|
|
||||||
super.breakBlock(world, x, y, z, id, meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack)
|
|
||||||
{
|
|
||||||
if (world.getBlockTileEntity(x, y, z) instanceof TileEE)
|
|
||||||
{
|
|
||||||
int direction = 0;
|
|
||||||
int facing = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
|
||||||
|
|
||||||
if (facing == 0)
|
|
||||||
{
|
|
||||||
direction = ForgeDirection.NORTH.ordinal();
|
|
||||||
}
|
|
||||||
else if (facing == 1)
|
|
||||||
{
|
|
||||||
direction = ForgeDirection.EAST.ordinal();
|
|
||||||
}
|
|
||||||
else if (facing == 2)
|
|
||||||
{
|
|
||||||
direction = ForgeDirection.SOUTH.ordinal();
|
|
||||||
}
|
|
||||||
else if (facing == 3)
|
|
||||||
{
|
|
||||||
direction = ForgeDirection.WEST.ordinal();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemStack.hasDisplayName())
|
|
||||||
{
|
|
||||||
((TileEE) world.getBlockTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
((TileEE) world.getBlockTileEntity(x, y, z)).setOrientation(direction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void dropInventory(World world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (!(tileEntity instanceof IInventory))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IInventory inventory = (IInventory) tileEntity;
|
|
||||||
|
|
||||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
ItemStack itemStack = inventory.getStackInSlot(i);
|
|
||||||
|
|
||||||
if (itemStack != null && itemStack.stackSize > 0)
|
|
||||||
{
|
|
||||||
Random rand = new Random();
|
|
||||||
|
|
||||||
float dX = rand.nextFloat() * 0.8F + 0.1F;
|
|
||||||
float dY = rand.nextFloat() * 0.8F + 0.1F;
|
|
||||||
float dZ = rand.nextFloat() * 0.8F + 0.1F;
|
|
||||||
|
|
||||||
EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, new ItemStack(itemStack.itemID, itemStack.stackSize, itemStack.getItemDamage()));
|
|
||||||
|
|
||||||
if (itemStack.hasTagCompound())
|
|
||||||
{
|
|
||||||
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
float factor = 0.05F;
|
|
||||||
entityItem.motionX = rand.nextGaussian() * factor;
|
|
||||||
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
|
|
||||||
entityItem.motionZ = rand.nextGaussian() * factor;
|
|
||||||
world.spawnEntityInWorld(entityItem);
|
|
||||||
itemStack.stackSize = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,202 +0,0 @@
|
||||||
package com.pahimar.ee3.block;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.EquivalentExchange3;
|
|
||||||
import com.pahimar.ee3.lib.GuiIds;
|
|
||||||
import com.pahimar.ee3.lib.RenderIds;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.tileentity.TileAludel;
|
|
||||||
import com.pahimar.ee3.tileentity.TileEE;
|
|
||||||
import com.pahimar.ee3.tileentity.TileGlassBell;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
|
||||||
import net.minecraft.util.Vec3;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
public class BlockGlassBell extends BlockEE implements ITileEntityProvider
|
|
||||||
{
|
|
||||||
public BlockGlassBell(int id)
|
|
||||||
{
|
|
||||||
super(id, Material.glass);
|
|
||||||
this.setUnlocalizedName(Strings.GLASS_BELL_NAME);
|
|
||||||
this.setCreativeTab(EquivalentExchange3.tabsEE3);
|
|
||||||
this.setHardness(1.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
return new TileGlassBell();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderAsNormalBlock()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRenderType()
|
|
||||||
{
|
|
||||||
|
|
||||||
return RenderIds.glassBell;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void breakBlock(World world, int x, int y, int z, int id, int meta)
|
|
||||||
{
|
|
||||||
dropInventory(world, x, y, z);
|
|
||||||
super.breakBlock(world, x, y, z, id, meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
|
|
||||||
{
|
|
||||||
if (player.isSneaking())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!world.isRemote)
|
|
||||||
{
|
|
||||||
if (world.getBlockTileEntity(x, y, z) instanceof TileGlassBell)
|
|
||||||
{
|
|
||||||
if (world.getBlockTileEntity(x, y - 1, z) instanceof TileAludel)
|
|
||||||
{
|
|
||||||
player.openGui(EquivalentExchange3.instance, GuiIds.ALUDEL, world, x, y - 1, z);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.openGui(EquivalentExchange3.instance, GuiIds.GLASS_BELL, world, x, y, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack)
|
|
||||||
{
|
|
||||||
if (itemStack.hasDisplayName())
|
|
||||||
{
|
|
||||||
((TileEE) world.getBlockTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world.getBlockTileEntity(x, y - 1, z) != null && world.getBlockTileEntity(x, y - 1, z) instanceof TileAludel)
|
|
||||||
{
|
|
||||||
((TileEE) world.getBlockTileEntity(x, y, z)).setOrientation(ForgeDirection.UP);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
((TileEE) world.getBlockTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, 0, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData)
|
|
||||||
{
|
|
||||||
return sideHit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world,
|
|
||||||
* x, y, z, startVec, endVec
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec)
|
|
||||||
{
|
|
||||||
if (world.getBlockTileEntity(x, y, z) instanceof TileGlassBell)
|
|
||||||
{
|
|
||||||
TileGlassBell tileGlassBell = (TileGlassBell) world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
switch (tileGlassBell.getOrientation())
|
|
||||||
{
|
|
||||||
case DOWN:
|
|
||||||
{
|
|
||||||
this.setBlockBounds(0.125F, 0.33F, 0.125F, 0.875F, 1.0F, 0.875F);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case UP:
|
|
||||||
{
|
|
||||||
this.setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.66F, 0.875F);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case NORTH:
|
|
||||||
{
|
|
||||||
this.setBlockBounds(0.125F, 0.125F, 0.33F, 0.875F, 0.875F, 1.0F);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SOUTH:
|
|
||||||
{
|
|
||||||
this.setBlockBounds(0.125F, 0.125F, 0.0F, 0.875F, 0.875F, 0.66F);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EAST:
|
|
||||||
{
|
|
||||||
this.setBlockBounds(0.0F, 0.125F, 0.125F, 0.66F, 0.875F, 0.875F);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case WEST:
|
|
||||||
{
|
|
||||||
this.setBlockBounds(0.33F, 0.125F, 0.125F, 1.0F, 0.875F, 0.875F);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case UNKNOWN:
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.collisionRayTrace(world, x, y, z, startVec, endVec);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
ItemStack itemStack;
|
|
||||||
|
|
||||||
if (world.getBlockTileEntity(x, y, z) instanceof TileGlassBell)
|
|
||||||
{
|
|
||||||
TileGlassBell tileGlassBell = (TileGlassBell) world.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (world.getBlockTileEntity(x, y - 1, z) instanceof TileAludel)
|
|
||||||
{
|
|
||||||
TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y - 1, z);
|
|
||||||
|
|
||||||
itemStack = tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX);
|
|
||||||
|
|
||||||
if (itemStack != null && itemStack.itemID < 4096)
|
|
||||||
{
|
|
||||||
return Block.lightValue[itemStack.itemID];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
itemStack = tileGlassBell.getStackInSlot(TileGlassBell.DISPLAY_SLOT_INVENTORY_INDEX);
|
|
||||||
|
|
||||||
if (itemStack != null && itemStack.itemID < 4096)
|
|
||||||
{
|
|
||||||
return Block.lightValue[itemStack.itemID];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,91 +0,0 @@
|
||||||
package com.pahimar.ee3.block;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.EquivalentExchange3;
|
|
||||||
import com.pahimar.ee3.lib.Colours;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class BlockInfusedCloth extends BlockEE
|
|
||||||
{
|
|
||||||
public BlockInfusedCloth(int id)
|
|
||||||
{
|
|
||||||
super(id, Material.cloth);
|
|
||||||
this.setUnlocalizedName(Strings.INFUSED_CLOTH_NAME);
|
|
||||||
this.setCreativeTab(EquivalentExchange3.tabsEE3);
|
|
||||||
this.setStepSound(soundClothFootstep);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IconRegister iconRegister)
|
|
||||||
{
|
|
||||||
blockIcon = iconRegister.registerIcon("wool_colored_white");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int damageDropped(int metaData)
|
|
||||||
{
|
|
||||||
return metaData;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z)
|
|
||||||
{
|
|
||||||
int metaData = blockAccess.getBlockMetadata(x, y, z);
|
|
||||||
|
|
||||||
if (metaData == 0)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_CLOTH_VERDANT, 16);
|
|
||||||
}
|
|
||||||
else if (metaData == 1)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_CLOTH_AZURE, 16);
|
|
||||||
}
|
|
||||||
else if (metaData == 2)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_CLOTH_MINIUM, 16);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.PURE_WHITE, 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public int getRenderColor(int metaData)
|
|
||||||
{
|
|
||||||
if (metaData == 0)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_CLOTH_VERDANT, 16);
|
|
||||||
}
|
|
||||||
else if (metaData == 1)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_CLOTH_AZURE, 16);
|
|
||||||
}
|
|
||||||
else if (metaData == 2)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_CLOTH_MINIUM, 16);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.PURE_WHITE, 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void getSubBlocks(int id, CreativeTabs creativeTab, List list)
|
|
||||||
{
|
|
||||||
for (int meta = 0; meta < 3; ++meta)
|
|
||||||
{
|
|
||||||
list.add(new ItemStack(id, 1, meta));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,91 +0,0 @@
|
||||||
package com.pahimar.ee3.block;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.EquivalentExchange3;
|
|
||||||
import com.pahimar.ee3.lib.Colours;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class BlockInfusedPlanks extends BlockEE
|
|
||||||
{
|
|
||||||
public BlockInfusedPlanks(int id)
|
|
||||||
{
|
|
||||||
super(id, Material.wood);
|
|
||||||
this.setUnlocalizedName(Strings.INFUSED_PLANKS_NAME);
|
|
||||||
this.setCreativeTab(EquivalentExchange3.tabsEE3);
|
|
||||||
this.setStepSound(soundWoodFootstep);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IconRegister iconRegister)
|
|
||||||
{
|
|
||||||
blockIcon = iconRegister.registerIcon("planks_oak");
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z)
|
|
||||||
{
|
|
||||||
int metaData = blockAccess.getBlockMetadata(x, y, z);
|
|
||||||
|
|
||||||
if (metaData == 0)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_PLANKS_VERDANT, 16);
|
|
||||||
}
|
|
||||||
else if (metaData == 1)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_PLANKS_AZURE, 16);
|
|
||||||
}
|
|
||||||
else if (metaData == 2)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_PLANKS_MINIUM, 16);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.PURE_WHITE, 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int damageDropped(int metaData)
|
|
||||||
{
|
|
||||||
return metaData;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public int getRenderColor(int metaData)
|
|
||||||
{
|
|
||||||
if (metaData == 0)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_PLANKS_VERDANT, 16);
|
|
||||||
}
|
|
||||||
else if (metaData == 1)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_PLANKS_AZURE, 16);
|
|
||||||
}
|
|
||||||
else if (metaData == 2)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_PLANKS_MINIUM, 16);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.PURE_WHITE, 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void getSubBlocks(int id, CreativeTabs creativeTab, List list)
|
|
||||||
{
|
|
||||||
for (int meta = 0; meta < 3; ++meta)
|
|
||||||
{
|
|
||||||
list.add(new ItemStack(id, 1, meta));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,166 +0,0 @@
|
||||||
package com.pahimar.ee3.block;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.EquivalentExchange3;
|
|
||||||
import com.pahimar.ee3.lib.Colours;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class BlockInfusedWood extends BlockEE
|
|
||||||
{
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
private Icon logEnd, logSide;
|
|
||||||
|
|
||||||
public BlockInfusedWood(int id)
|
|
||||||
{
|
|
||||||
super(id, Material.wood);
|
|
||||||
this.setUnlocalizedName(Strings.INFUSED_WOOD_NAME);
|
|
||||||
this.setCreativeTab(EquivalentExchange3.tabsEE3);
|
|
||||||
this.setStepSound(soundWoodFootstep);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IconRegister iconRegister)
|
|
||||||
{
|
|
||||||
logEnd = iconRegister.registerIcon("log_oak_top");
|
|
||||||
logSide = iconRegister.registerIcon("log_oak");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int damageDropped(int metaData)
|
|
||||||
{
|
|
||||||
return metaData & 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon getIcon(int side, int metaData)
|
|
||||||
{
|
|
||||||
if (ForgeDirection.getOrientation(side) == ForgeDirection.UP || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN)
|
|
||||||
{
|
|
||||||
if (metaData >> 2 == 0)
|
|
||||||
{
|
|
||||||
return logEnd;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return logSide;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (ForgeDirection.getOrientation(side) == ForgeDirection.NORTH || ForgeDirection.getOrientation(side) == ForgeDirection.SOUTH)
|
|
||||||
{
|
|
||||||
if (metaData >> 2 == 2)
|
|
||||||
{
|
|
||||||
return logEnd;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return logSide;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (metaData >> 2 == 1)
|
|
||||||
{
|
|
||||||
return logEnd;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return logSide;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metaData)
|
|
||||||
{
|
|
||||||
int logType = metaData & 3;
|
|
||||||
byte rotation = 0;
|
|
||||||
|
|
||||||
switch (side)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
rotation = 0;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
rotation = 8;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
rotation = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
int newMetaData = logType | rotation;
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, newMetaData, 3);
|
|
||||||
return newMetaData;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z)
|
|
||||||
{
|
|
||||||
int metaData = blockAccess.getBlockMetadata(x, y, z) & 3;
|
|
||||||
|
|
||||||
if (metaData == 0)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_WOOD_VERDANT, 16);
|
|
||||||
}
|
|
||||||
else if (metaData == 1)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_WOOD_AZURE, 16);
|
|
||||||
}
|
|
||||||
else if (metaData == 2)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_WOOD_MINIUM, 16);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.PURE_WHITE, 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public int getRenderColor(int metaData)
|
|
||||||
{
|
|
||||||
int adjustedMetaData = metaData & 3;
|
|
||||||
if (adjustedMetaData == 0)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_WOOD_VERDANT, 16);
|
|
||||||
}
|
|
||||||
else if (adjustedMetaData == 1)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_WOOD_AZURE, 16);
|
|
||||||
}
|
|
||||||
else if (adjustedMetaData == 2)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.INFUSED_WOOD_MINIUM, 16);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.PURE_WHITE, 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void getSubBlocks(int id, CreativeTabs creativeTab, List list)
|
|
||||||
{
|
|
||||||
for (int meta = 0; meta < 3; ++meta)
|
|
||||||
{
|
|
||||||
list.add(new ItemStack(id, 1, meta));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
package com.pahimar.ee3.block;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.EquivalentExchange3;
|
|
||||||
import com.pahimar.ee3.lib.RenderIds;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.tileentity.TileResearchStation;
|
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
public class BlockResearchStation extends BlockEE implements ITileEntityProvider
|
|
||||||
{
|
|
||||||
public BlockResearchStation(int id)
|
|
||||||
{
|
|
||||||
super(id);
|
|
||||||
this.setUnlocalizedName(Strings.RESEARCH_STATION_NAME);
|
|
||||||
this.setCreativeTab(EquivalentExchange3.tabsEE3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createNewTileEntity(World world)
|
|
||||||
{
|
|
||||||
return new TileResearchStation();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean renderAsNormalBlock()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRenderType()
|
|
||||||
{
|
|
||||||
|
|
||||||
return RenderIds.calcinatorRender;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,55 +1,9 @@
|
||||||
package com.pahimar.ee3.block;
|
package com.pahimar.ee3.block;
|
||||||
|
|
||||||
import com.pahimar.ee3.item.*;
|
|
||||||
import com.pahimar.ee3.lib.BlockIds;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ModBlocks
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class ModBlocks
|
public class ModBlocks
|
||||||
{
|
{
|
||||||
public static BlockEE alchemicalChest;
|
|
||||||
public static BlockEE alchemicalFuel;
|
|
||||||
public static BlockEE alchemySquare;
|
|
||||||
public static BlockEE aludelBase;
|
|
||||||
public static BlockEE calcinator;
|
|
||||||
public static BlockEE chalk;
|
|
||||||
public static BlockEE glassBell;
|
|
||||||
public static BlockEE researchStation;
|
|
||||||
public static BlockEE infusedCloth;
|
|
||||||
public static BlockEE infusedWood;
|
|
||||||
public static BlockEE infusedPlanks;
|
|
||||||
|
|
||||||
public static void init()
|
public static void init()
|
||||||
{
|
{
|
||||||
alchemicalChest = new BlockAlchemicalChest(BlockIds.ALCHEMICAL_CHEST);
|
|
||||||
alchemicalFuel = new BlockAlchemicalFuel(BlockIds.ALCHEMICAL_FUEL);
|
|
||||||
alchemySquare = new BlockAlchemySquare(BlockIds.ALCHEMY_SQUARE);
|
|
||||||
aludelBase = new BlockAludelBase(BlockIds.ALUDEL_BASE);
|
|
||||||
calcinator = new BlockCalcinator(BlockIds.CALCINATOR);
|
|
||||||
chalk = new BlockChalk(BlockIds.CHALK);
|
|
||||||
glassBell = new BlockGlassBell(BlockIds.GLASS_BELL);
|
|
||||||
researchStation = new BlockResearchStation((BlockIds.RESEARCH_STATION));
|
|
||||||
infusedWood = new BlockInfusedWood(BlockIds.INFUSED_WOOD);
|
|
||||||
infusedCloth = new BlockInfusedCloth(BlockIds.INFUSED_CLOTH);
|
|
||||||
infusedPlanks = new BlockInfusedPlanks(BlockIds.INFUSED_PLANKS);
|
|
||||||
|
|
||||||
GameRegistry.registerBlock(alchemicalChest, ItemBlockAlchemicalChest.class, "block." + Strings.ALCHEMICAL_CHEST_NAME);
|
|
||||||
GameRegistry.registerBlock(alchemicalFuel, ItemBlockAlchemicalFuel.class, "block." + Strings.ALCHEMICAL_FUEL_NAME);
|
|
||||||
GameRegistry.registerBlock(alchemySquare, "block." + Strings.ALCHEMY_SQUARE_NAME);
|
|
||||||
GameRegistry.registerBlock(aludelBase, "block." + Strings.ALUDEL_NAME);
|
|
||||||
GameRegistry.registerBlock(calcinator, "block." + Strings.CALCINATOR_NAME);
|
|
||||||
GameRegistry.registerBlock(chalk, "block." + Strings.CHALK_NAME);
|
|
||||||
GameRegistry.registerBlock(glassBell, "block." + Strings.GLASS_BELL_NAME);
|
|
||||||
GameRegistry.registerBlock(researchStation, "block." + Strings.RESEARCH_STATION_NAME);
|
|
||||||
GameRegistry.registerBlock(infusedCloth, ItemBlockInfusedCloth.class, "block." + Strings.INFUSED_CLOTH_NAME);
|
|
||||||
GameRegistry.registerBlock(infusedWood, ItemBlockInfusedWood.class, "block." + Strings.INFUSED_WOOD_NAME);
|
|
||||||
GameRegistry.registerBlock(infusedPlanks, ItemBlockInfusedPlanks.class, "block." + Strings.INFUSED_PLANKS_NAME);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
package com.pahimar.ee3.client.audio;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.helper.LogHelper;
|
|
||||||
import com.pahimar.ee3.lib.Sounds;
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* SoundHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class SoundHandler
|
|
||||||
{
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onSoundLoad(SoundLoadEvent event)
|
|
||||||
{
|
|
||||||
// FIXME Load custom sounds into Minecraft
|
|
||||||
// For each custom sound file we have defined in Sounds
|
|
||||||
// for (String soundFile : Sounds.soundFiles)
|
|
||||||
// {
|
|
||||||
// // Try to add the custom sound file to the pool of sounds
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// event.manager.addSound(soundFile);
|
|
||||||
// }
|
|
||||||
// // If we cannot add the custom sound file to the pool, log the exception
|
|
||||||
// catch (Exception e)
|
|
||||||
// {
|
|
||||||
// LogHelper.warn("Failed loading sound file: " + soundFile);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,105 +0,0 @@
|
||||||
package com.pahimar.ee3.client.gui.inventory;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.helper.ItemStackNBTHelper;
|
|
||||||
import com.pahimar.ee3.inventory.ContainerAlchemicalBag;
|
|
||||||
import com.pahimar.ee3.inventory.InventoryAlchemicalBag;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.StatCollector;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* GuiAlchemicalBag
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class GuiAlchemicalBag extends GuiContainer
|
|
||||||
{
|
|
||||||
private final ItemStack parentItemStack;
|
|
||||||
private final InventoryAlchemicalBag inventoryAlchemicalBag;
|
|
||||||
|
|
||||||
public GuiAlchemicalBag(EntityPlayer entityPlayer, InventoryAlchemicalBag inventoryAlchemicalBag)
|
|
||||||
{
|
|
||||||
super(new ContainerAlchemicalBag(entityPlayer, inventoryAlchemicalBag));
|
|
||||||
|
|
||||||
this.parentItemStack = inventoryAlchemicalBag.parentItemStack;
|
|
||||||
this.inventoryAlchemicalBag = inventoryAlchemicalBag;
|
|
||||||
|
|
||||||
if (this.parentItemStack.getItemDamage() == 0)
|
|
||||||
{
|
|
||||||
xSize = 230;
|
|
||||||
ySize = 186;
|
|
||||||
}
|
|
||||||
else if (this.parentItemStack.getItemDamage() == 1)
|
|
||||||
{
|
|
||||||
xSize = 230;
|
|
||||||
ySize = 240;
|
|
||||||
}
|
|
||||||
else if (this.parentItemStack.getItemDamage() == 2)
|
|
||||||
{
|
|
||||||
xSize = 248;
|
|
||||||
ySize = 256;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
|
||||||
{
|
|
||||||
if (this.parentItemStack.getItemDamage() == 0 || this.parentItemStack.getItemDamage() == 1)
|
|
||||||
{
|
|
||||||
fontRenderer.drawString(StatCollector.translateToLocal(inventoryAlchemicalBag.getInvName()), 8, 6, 4210752);
|
|
||||||
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 35, ySize - 95 + 2, 4210752);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y)
|
|
||||||
{
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
if (this.parentItemStack.getItemDamage() == 0)
|
|
||||||
{
|
|
||||||
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_BAG_SMALL);
|
|
||||||
}
|
|
||||||
else if (this.parentItemStack.getItemDamage() == 1)
|
|
||||||
{
|
|
||||||
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_BAG_MEDIUM);
|
|
||||||
}
|
|
||||||
else if (this.parentItemStack.getItemDamage() == 2)
|
|
||||||
{
|
|
||||||
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_BAG_LARGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
int xStart = (width - xSize) / 2;
|
|
||||||
int yStart = (height - ySize) / 2;
|
|
||||||
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGuiClosed()
|
|
||||||
{
|
|
||||||
super.onGuiClosed();
|
|
||||||
|
|
||||||
if (mc.thePlayer != null)
|
|
||||||
{
|
|
||||||
for (ItemStack itemStack : mc.thePlayer.inventory.mainInventory)
|
|
||||||
{
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN))
|
|
||||||
{
|
|
||||||
ItemStackNBTHelper.removeTag(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
package com.pahimar.ee3.client.gui.inventory;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.inventory.ContainerAlchemicalChest;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
|
||||||
import net.minecraft.util.StatCollector;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* GuiAlchemicalChest
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class GuiAlchemicalChest extends GuiContainer
|
|
||||||
{
|
|
||||||
private TileAlchemicalChest tileAlchemicalChest;
|
|
||||||
|
|
||||||
public GuiAlchemicalChest(InventoryPlayer inventoryPlayer, TileAlchemicalChest alchemicalChest)
|
|
||||||
{
|
|
||||||
super(new ContainerAlchemicalChest(inventoryPlayer, alchemicalChest));
|
|
||||||
tileAlchemicalChest = alchemicalChest;
|
|
||||||
|
|
||||||
if (this.tileAlchemicalChest.getState() == 0)
|
|
||||||
{
|
|
||||||
xSize = 230;
|
|
||||||
ySize = 186;
|
|
||||||
}
|
|
||||||
else if (this.tileAlchemicalChest.getState() == 1)
|
|
||||||
{
|
|
||||||
xSize = 230;
|
|
||||||
ySize = 240;
|
|
||||||
}
|
|
||||||
else if (this.tileAlchemicalChest.getState() == 2)
|
|
||||||
{
|
|
||||||
xSize = 248;
|
|
||||||
ySize = 256;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
|
||||||
{
|
|
||||||
if (tileAlchemicalChest.getState() == 0 || tileAlchemicalChest.getState() == 1)
|
|
||||||
{
|
|
||||||
fontRenderer.drawString(tileAlchemicalChest.isInvNameLocalized() ? tileAlchemicalChest.getInventoryname() : StatCollector.translateToLocal(tileAlchemicalChest.getInventoryname()), 8, 6, 4210752);
|
|
||||||
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 35, ySize - 95 + 2, 4210752);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y)
|
|
||||||
{
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
if (tileAlchemicalChest.getState() == 0)
|
|
||||||
{
|
|
||||||
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_CHEST_SMALL);
|
|
||||||
}
|
|
||||||
else if (tileAlchemicalChest.getState() == 1)
|
|
||||||
{
|
|
||||||
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_CHEST_MEDIUM);
|
|
||||||
}
|
|
||||||
else if (tileAlchemicalChest.getState() == 2)
|
|
||||||
{
|
|
||||||
this.mc.getTextureManager().bindTexture(Textures.GUI_ALCHEMICAL_CHEST_LARGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
int xStart = (width - xSize) / 2;
|
|
||||||
int yStart = (height - ySize) / 2;
|
|
||||||
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
package com.pahimar.ee3.client.gui.inventory;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.inventory.ContainerAludel;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import com.pahimar.ee3.tileentity.TileAludel;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
|
||||||
import net.minecraft.util.StatCollector;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* GuiAludel
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class GuiAludel extends GuiContainer
|
|
||||||
{
|
|
||||||
private TileAludel tileAludel;
|
|
||||||
|
|
||||||
public GuiAludel(InventoryPlayer inventoryPlayer, TileAludel tileAludel)
|
|
||||||
{
|
|
||||||
super(new ContainerAludel(inventoryPlayer, tileAludel));
|
|
||||||
this.tileAludel = tileAludel;
|
|
||||||
xSize = 176;
|
|
||||||
ySize = 187;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
|
||||||
{
|
|
||||||
String containerName = tileAludel.isInvNameLocalized() ? tileAludel.getInvName() : StatCollector.translateToLocal(tileAludel.getInvName());
|
|
||||||
fontRenderer.drawString(containerName, xSize / 2 - fontRenderer.getStringWidth(containerName) / 2, 6, 4210752);
|
|
||||||
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 8, ySize - 93, 4210752);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3)
|
|
||||||
{
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
this.mc.getTextureManager().bindTexture(Textures.GUI_ALUDEL);
|
|
||||||
|
|
||||||
int xStart = (width - xSize) / 2;
|
|
||||||
int yStart = (height - ySize) / 2;
|
|
||||||
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
|
|
||||||
int scaleAdjustment;
|
|
||||||
|
|
||||||
if (this.tileAludel.getState() == 1)
|
|
||||||
{
|
|
||||||
scaleAdjustment = this.tileAludel.getBurnTimeRemainingScaled(12);
|
|
||||||
this.drawTexturedModalRect(xStart + 45, yStart + 36 + 34 - scaleAdjustment, 176, 12 - scaleAdjustment, 14, scaleAdjustment + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
scaleAdjustment = this.tileAludel.getCookProgressScaled(24);
|
|
||||||
this.drawTexturedModalRect(xStart + 76, yStart + 39, 176, 14, scaleAdjustment + 1, 16);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
package com.pahimar.ee3.client.gui.inventory;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.inventory.ContainerCalcinator;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import com.pahimar.ee3.tileentity.TileCalcinator;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
|
||||||
import net.minecraft.util.StatCollector;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* GuiCalcinator
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class GuiCalcinator extends GuiContainer
|
|
||||||
{
|
|
||||||
private TileCalcinator tileCalcinator;
|
|
||||||
|
|
||||||
public GuiCalcinator(InventoryPlayer player, TileCalcinator tileCalcinator)
|
|
||||||
{
|
|
||||||
super(new ContainerCalcinator(player, tileCalcinator));
|
|
||||||
ySize = 176;
|
|
||||||
this.tileCalcinator = tileCalcinator;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
|
||||||
{
|
|
||||||
String containerName = tileCalcinator.isInvNameLocalized() ? tileCalcinator.getInvName() : StatCollector.translateToLocal(tileCalcinator.getInvName());
|
|
||||||
fontRenderer.drawString(containerName, xSize / 2 - fontRenderer.getStringWidth(containerName) / 2, 6, 4210752);
|
|
||||||
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 8, ySize - 96 + 2, 4210752);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y)
|
|
||||||
{
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
|
|
||||||
this.mc.getTextureManager().bindTexture(Textures.GUI_CALCINATOR);
|
|
||||||
|
|
||||||
int xStart = (width - xSize) / 2;
|
|
||||||
int yStart = (height - ySize) / 2;
|
|
||||||
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
|
|
||||||
int scaleAdjustment;
|
|
||||||
|
|
||||||
if (this.tileCalcinator.getState() == 1)
|
|
||||||
{
|
|
||||||
scaleAdjustment = this.tileCalcinator.getBurnTimeRemainingScaled(12);
|
|
||||||
this.drawTexturedModalRect(xStart + 57, yStart + 36 + 23 - scaleAdjustment, 176, 12 - scaleAdjustment, 14, scaleAdjustment + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
scaleAdjustment = this.tileCalcinator.getCookProgressScaled(24);
|
|
||||||
this.drawTexturedModalRect(xStart + 83, yStart + 34, 176, 14, scaleAdjustment + 1, 16);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
package com.pahimar.ee3.client.gui.inventory;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.inventory.ContainerGlassBell;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import com.pahimar.ee3.tileentity.TileGlassBell;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
|
||||||
import net.minecraft.util.StatCollector;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* GuiGlassBell
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class GuiGlassBell extends GuiContainer
|
|
||||||
{
|
|
||||||
|
|
||||||
private TileGlassBell tileGlassBell;
|
|
||||||
|
|
||||||
public GuiGlassBell(InventoryPlayer inventoryPlayer, TileGlassBell tileGlassBell)
|
|
||||||
{
|
|
||||||
|
|
||||||
super(new ContainerGlassBell(inventoryPlayer, tileGlassBell));
|
|
||||||
this.tileGlassBell = tileGlassBell;
|
|
||||||
xSize = 176;
|
|
||||||
ySize = 140;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
|
||||||
{
|
|
||||||
|
|
||||||
String containerName = tileGlassBell.isInvNameLocalized() ? tileGlassBell.getInvName() : StatCollector.translateToLocal(tileGlassBell.getInvName());
|
|
||||||
fontRenderer.drawString(containerName, xSize / 2 - fontRenderer.getStringWidth(containerName) / 2, 6, 4210752);
|
|
||||||
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 8, ySize - 93, 4210752);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3)
|
|
||||||
{
|
|
||||||
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
this.mc.getTextureManager().bindTexture(Textures.GUI_GLASS_BELL);
|
|
||||||
int xStart = (width - xSize) / 2;
|
|
||||||
int yStart = (height - ySize) / 2;
|
|
||||||
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,78 +0,0 @@
|
||||||
package com.pahimar.ee3.client.gui.inventory;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.helper.ItemStackNBTHelper;
|
|
||||||
import com.pahimar.ee3.inventory.ContainerPortableCrafting;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.StatCollector;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* GuiPortableCrafting
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class GuiPortableCrafting extends GuiContainer
|
|
||||||
{
|
|
||||||
|
|
||||||
public GuiPortableCrafting(EntityPlayer player, World world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
|
|
||||||
super(new ContainerPortableCrafting(player.inventory, world, x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
|
||||||
{
|
|
||||||
|
|
||||||
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_PORTABLE_CRAFTING), 28, 6, 4210752);
|
|
||||||
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 8, ySize - 96 + 2, 4210752);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Draw the background layer for the GuiContainer (everything behind the items)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
|
||||||
{
|
|
||||||
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
this.mc.getTextureManager().bindTexture(Textures.GUI_PORTABLE_CRAFTING);
|
|
||||||
int var5 = (width - xSize) / 2;
|
|
||||||
int var6 = (height - ySize) / 2;
|
|
||||||
this.drawTexturedModalRect(var5, var6, 0, 0, xSize, ySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGuiClosed()
|
|
||||||
{
|
|
||||||
|
|
||||||
super.onGuiClosed();
|
|
||||||
|
|
||||||
if (mc.thePlayer != null)
|
|
||||||
{
|
|
||||||
for (ItemStack itemStack : mc.thePlayer.inventory.mainInventory)
|
|
||||||
{
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_CRAFTING_GUI_OPEN))
|
|
||||||
{
|
|
||||||
ItemStackNBTHelper.removeTag(itemStack, Strings.NBT_ITEM_CRAFTING_GUI_OPEN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,213 +0,0 @@
|
||||||
package com.pahimar.ee3.client.handler;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.item.IChargeable;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.lwjgl.opengl.GL12;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* DrawBlockHighlightHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class DrawBlockHighlightHandler
|
|
||||||
{
|
|
||||||
private static int pulse = 0;
|
|
||||||
private static boolean doInc = true;
|
|
||||||
|
|
||||||
public static void renderPulsingQuad(ResourceLocation texture, float maxTransparency)
|
|
||||||
{
|
|
||||||
|
|
||||||
float pulseTransparency = getPulseValue() * maxTransparency / 3000f;
|
|
||||||
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture);
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
|
||||||
|
|
||||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
|
||||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
GL11.glColor4f(1, 1, 1, pulseTransparency);
|
|
||||||
|
|
||||||
tessellator.startDrawingQuads();
|
|
||||||
tessellator.setColorRGBA_F(1, 1, 1, pulseTransparency);
|
|
||||||
|
|
||||||
tessellator.addVertexWithUV(-0.5D, 0.5D, 0F, 0, 1);
|
|
||||||
tessellator.addVertexWithUV(0.5D, 0.5D, 0F, 1, 1);
|
|
||||||
tessellator.addVertexWithUV(0.5D, -0.5D, 0F, 1, 0);
|
|
||||||
tessellator.addVertexWithUV(-0.5D, -0.5D, 0F, 0, 0);
|
|
||||||
|
|
||||||
tessellator.draw();
|
|
||||||
GL11.glDisable(GL11.GL_BLEND);
|
|
||||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getPulseValue()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (doInc)
|
|
||||||
{
|
|
||||||
pulse += 8;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pulse -= 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pulse == 3000)
|
|
||||||
{
|
|
||||||
doInc = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pulse == 0)
|
|
||||||
{
|
|
||||||
doInc = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pulse;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Disabling this until transmutation is done, since it's useless at the moment
|
|
||||||
|
|
||||||
Minecraft minecraft = FMLClientHandler.instance().getClient();
|
|
||||||
|
|
||||||
if (event.currentItem != null)
|
|
||||||
{
|
|
||||||
if (event.currentItem.getItem() instanceof ITransmutationStone)
|
|
||||||
{
|
|
||||||
if (event.target.typeOfHit == EnumMovingObjectType.TILE)
|
|
||||||
{
|
|
||||||
TransmutationHelper.updateTargetBlock(event.player.worldObj, event.target.blockX, event.target.blockY, event.target.blockZ);
|
|
||||||
|
|
||||||
if (Minecraft.isGuiEnabled() && minecraft.inGameHasFocus)
|
|
||||||
{
|
|
||||||
if (ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION)
|
|
||||||
{
|
|
||||||
drawInWorldTransmutationOverlay(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawInWorldTransmutationOverlay(DrawBlockHighlightEvent event)
|
|
||||||
{
|
|
||||||
|
|
||||||
double x = event.target.blockX + 0.5F;
|
|
||||||
double y = event.target.blockY + 0.5F;
|
|
||||||
double z = event.target.blockZ + 0.5F;
|
|
||||||
double iPX = event.player.prevPosX + (event.player.posX - event.player.prevPosX) * event.partialTicks;
|
|
||||||
double iPY = event.player.prevPosY + (event.player.posY - event.player.prevPosY) * event.partialTicks;
|
|
||||||
double iPZ = event.player.prevPosZ + (event.player.posZ - event.player.prevPosZ) * event.partialTicks;
|
|
||||||
|
|
||||||
float xScale = 1;
|
|
||||||
float yScale = 1;
|
|
||||||
float zScale = 1;
|
|
||||||
float xShift = 0.1F;
|
|
||||||
float yShift = 0.1F;
|
|
||||||
float zShift = 0.1F;
|
|
||||||
int chargeLevel;
|
|
||||||
int itemChargeLevel = 0;
|
|
||||||
|
|
||||||
if (event.currentItem.getItem() instanceof IChargeable)
|
|
||||||
{
|
|
||||||
itemChargeLevel = ((IChargeable) event.currentItem.getItem()).getCharge(event.currentItem);
|
|
||||||
}
|
|
||||||
chargeLevel = 1 + itemChargeLevel * 2;
|
|
||||||
|
|
||||||
ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit);
|
|
||||||
|
|
||||||
switch (sideHit)
|
|
||||||
{
|
|
||||||
case UP:
|
|
||||||
{
|
|
||||||
xScale = chargeLevel + 0.1F;
|
|
||||||
zScale = chargeLevel + 0.1F;
|
|
||||||
xShift = 0;
|
|
||||||
zShift = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DOWN:
|
|
||||||
{
|
|
||||||
xScale = chargeLevel + 0.1F;
|
|
||||||
zScale = chargeLevel + 0.1F;
|
|
||||||
xShift = 0;
|
|
||||||
yShift = -yShift;
|
|
||||||
zShift = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case NORTH:
|
|
||||||
{
|
|
||||||
xScale = chargeLevel + 0.1F;
|
|
||||||
yScale = chargeLevel + 0.1F;
|
|
||||||
xShift = 0;
|
|
||||||
yShift = 0;
|
|
||||||
zShift = -zShift;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SOUTH:
|
|
||||||
{
|
|
||||||
xScale = chargeLevel + 0.1F;
|
|
||||||
yScale = chargeLevel + 0.1F;
|
|
||||||
xShift = 0;
|
|
||||||
yShift = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EAST:
|
|
||||||
{
|
|
||||||
yScale = chargeLevel + 0.1F;
|
|
||||||
zScale = chargeLevel + 0.1F;
|
|
||||||
yShift = 0;
|
|
||||||
zShift = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case WEST:
|
|
||||||
{
|
|
||||||
yScale = chargeLevel + 0.1F;
|
|
||||||
zScale = chargeLevel + 0.1F;
|
|
||||||
xShift = -xShift;
|
|
||||||
yShift = 0;
|
|
||||||
zShift = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glDepthMask(false);
|
|
||||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
ForgeDirection forgeDir = ForgeDirection.getOrientation(i);
|
|
||||||
int zCorrection = i == 2 ? -1 : 1;
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift);
|
|
||||||
GL11.glScalef(1F * xScale, 1F * yScale, 1F * zScale);
|
|
||||||
GL11.glRotatef(90, forgeDir.offsetX, forgeDir.offsetY, forgeDir.offsetZ);
|
|
||||||
GL11.glTranslated(0, 0, 0.5f * zCorrection);
|
|
||||||
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
|
|
||||||
renderPulsingQuad(Textures.EFFECT_WORLD_TRANSMUTATION, 0.75F);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
|
||||||
GL11.glDepthMask(true);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package com.pahimar.ee3.client.handler;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.api.WrappedStack;
|
|
||||||
import com.pahimar.ee3.emc.EmcRegistry;
|
|
||||||
import com.pahimar.ee3.emc.EmcValue;
|
|
||||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ItemTooltipEventHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class ItemTooltipEventHandler
|
|
||||||
{
|
|
||||||
private static DecimalFormat emcDecimalFormat = new DecimalFormat("###,###,###,###,###.###");
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
|
||||||
public void handleItemTooltipEvent(ItemTooltipEvent event)
|
|
||||||
{
|
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
|
|
||||||
{
|
|
||||||
WrappedStack stack = new WrappedStack(event.itemStack);
|
|
||||||
|
|
||||||
if (EmcRegistry.getInstance().hasEmcValue(stack))
|
|
||||||
{
|
|
||||||
EmcValue emcValue = EmcRegistry.getInstance().getEmcValue(stack);
|
|
||||||
if (stack.getStackSize() > 1)
|
|
||||||
{
|
|
||||||
event.toolTip.add("EMC (Item): " + String.format("%s", emcDecimalFormat.format(emcValue.getValue())));
|
|
||||||
event.toolTip.add("EMC (Stack): " + String.format("%s", emcDecimalFormat.format(stack.getStackSize() * emcValue.getValue())));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
event.toolTip.add("EMC: " + String.format("%s", emcDecimalFormat.format(stack.getStackSize() * emcValue.getValue())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
event.toolTip.add("No EMC value");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
package com.pahimar.ee3.client.handler;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.client.helper.KeyBindingHelper;
|
|
||||||
import com.pahimar.ee3.item.IKeyBound;
|
|
||||||
import com.pahimar.ee3.lib.Reference;
|
|
||||||
import com.pahimar.ee3.network.PacketTypeHandler;
|
|
||||||
import com.pahimar.ee3.network.packet.PacketKeyPressed;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* KeyBindingHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
// If we are not in a GUI of any kind, continue execution
|
|
||||||
if (FMLClientHandler.instance().getClient().inGameHasFocus)
|
|
||||||
{
|
|
||||||
EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
ItemStack currentItem = FMLClientHandler.instance().getClient().thePlayer.getCurrentEquippedItem();
|
|
||||||
|
|
||||||
if (currentItem != null)
|
|
||||||
{
|
|
||||||
if (currentItem.getItem() instanceof IKeyBound)
|
|
||||||
{
|
|
||||||
if (player.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
PacketDispatcher.sendPacketToServer(PacketTypeHandler.populatePacket(new PacketKeyPressed(kb.keyDescription)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
((IKeyBound) currentItem.getItem()).doKeyBindingAction(player, currentItem, kb.keyDescription);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumSet<TickType> ticks()
|
|
||||||
{
|
|
||||||
return EnumSet.of(TickType.CLIENT);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,158 +0,0 @@
|
||||||
package com.pahimar.ee3.client.handler;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.client.helper.RenderUtils;
|
|
||||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
|
||||||
import com.pahimar.ee3.helper.TransmutationHelper;
|
|
||||||
import com.pahimar.ee3.item.ITransmutationStone;
|
|
||||||
import com.pahimar.ee3.lib.Reference;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.ScaledResolution;
|
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.lwjgl.opengl.GL12;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* TransmutationTargetOverlayHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class TransmutationTargetOverlayHandler implements ITickHandler
|
|
||||||
{
|
|
||||||
|
|
||||||
private static void renderStoneHUD(Minecraft minecraft, EntityPlayer player, ItemStack stack, float partialTicks)
|
|
||||||
{
|
|
||||||
|
|
||||||
float overlayScale = ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE;
|
|
||||||
float blockScale = overlayScale / 2;
|
|
||||||
float overlayOpacity = ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY;
|
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
ScaledResolution sr = new ScaledResolution(minecraft.gameSettings, minecraft.displayWidth, minecraft.displayHeight);
|
|
||||||
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
|
|
||||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
|
||||||
GL11.glLoadIdentity();
|
|
||||||
GL11.glOrtho(0.0D, sr.getScaledWidth_double(), sr.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
|
|
||||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
|
||||||
GL11.glLoadIdentity();
|
|
||||||
GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
|
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
RenderHelper.enableGUIStandardItemLighting();
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
|
||||||
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
|
|
||||||
int hudOverlayX = 0;
|
|
||||||
int hudOverlayY = 0;
|
|
||||||
int hudBlockX = 0;
|
|
||||||
int hudBlockY = 0;
|
|
||||||
|
|
||||||
switch (ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
hudOverlayX = 0;
|
|
||||||
hudBlockX = (int) (16 * overlayScale / 2 - 8);
|
|
||||||
hudOverlayY = 0;
|
|
||||||
hudBlockY = (int) (16 * overlayScale / 2 - 8);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
hudOverlayX = (int) (sr.getScaledWidth() - 16 * overlayScale);
|
|
||||||
hudBlockX = (int) (sr.getScaledWidth() - 16 * overlayScale / 2 - 8);
|
|
||||||
hudOverlayY = 0;
|
|
||||||
hudBlockY = (int) (16 * overlayScale / 2 - 8);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
hudOverlayX = 0;
|
|
||||||
hudBlockX = (int) (16 * overlayScale / 2 - 8);
|
|
||||||
hudOverlayY = (int) (sr.getScaledHeight() - 16 * overlayScale);
|
|
||||||
hudBlockY = (int) (sr.getScaledHeight() - 16 * overlayScale / 2 - 8);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 3:
|
|
||||||
{
|
|
||||||
hudOverlayX = (int) (sr.getScaledWidth() - 16 * overlayScale);
|
|
||||||
hudBlockX = (int) (sr.getScaledWidth() - 16 * overlayScale / 2 - 8);
|
|
||||||
hudOverlayY = (int) (sr.getScaledHeight() - 16 * overlayScale);
|
|
||||||
hudBlockY = (int) (sr.getScaledHeight() - 16 * overlayScale / 2 - 8);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderUtils.renderItemIntoGUI(minecraft.fontRenderer, stack, hudOverlayX, hudOverlayY, overlayOpacity, overlayScale);
|
|
||||||
|
|
||||||
if (TransmutationHelper.targetBlockStack != null && TransmutationHelper.targetBlockStack.getItem() instanceof ItemBlock)
|
|
||||||
{
|
|
||||||
RenderUtils.renderRotatingBlockIntoGUI(minecraft.fontRenderer, TransmutationHelper.targetBlockStack, hudBlockX, hudBlockY, -90, blockScale);
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
|
||||||
{
|
|
||||||
|
|
||||||
Minecraft minecraft = FMLClientHandler.instance().getClient();
|
|
||||||
EntityPlayer player = minecraft.thePlayer;
|
|
||||||
ItemStack currentItemStack;
|
|
||||||
|
|
||||||
if (type.contains(TickType.RENDER))
|
|
||||||
{
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
currentItemStack = player.inventory.getCurrentItem();
|
|
||||||
|
|
||||||
if (Minecraft.isGuiEnabled() && minecraft.inGameHasFocus)
|
|
||||||
{
|
|
||||||
if (currentItemStack != null && currentItemStack.getItem() instanceof ITransmutationStone && ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION)
|
|
||||||
{
|
|
||||||
renderStoneHUD(minecraft, player, currentItemStack, (Float) tickData[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumSet<TickType> ticks()
|
|
||||||
{
|
|
||||||
|
|
||||||
return EnumSet.of(TickType.CLIENT, TickType.RENDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLabel()
|
|
||||||
{
|
|
||||||
|
|
||||||
return Reference.MOD_NAME + ": " + this.getClass().getSimpleName();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,89 +0,0 @@
|
||||||
package com.pahimar.ee3.client.helper;
|
|
||||||
|
|
||||||
public class ColourUtils
|
|
||||||
{
|
|
||||||
public static byte[] convertIntColourToByteArray(int intColour)
|
|
||||||
{
|
|
||||||
byte[] colourByteArray = new byte[3];
|
|
||||||
|
|
||||||
colourByteArray[0] = (byte) (intColour >> 16 & 255);
|
|
||||||
colourByteArray[1] = (byte) (intColour >> 8 & 255);
|
|
||||||
colourByteArray[2] = (byte) (intColour & 255);
|
|
||||||
|
|
||||||
return colourByteArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float[] convertIntColourToFloatArray(int intColour)
|
|
||||||
{
|
|
||||||
float[] colourFloatArray = new float[3];
|
|
||||||
|
|
||||||
colourFloatArray[0] = ((intColour >> 16 & 0xFF) / 255F);
|
|
||||||
colourFloatArray[1] = ((intColour >> 8 & 0xFF) / 255F);
|
|
||||||
colourFloatArray[2] = ((intColour & 0xFF) / 255F);
|
|
||||||
|
|
||||||
return colourFloatArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[][] getByteBlendedColours(byte[] firstColour, byte[] secondColour, int steps)
|
|
||||||
{
|
|
||||||
if (firstColour.length == 3 && secondColour.length == 3 && steps > 0)
|
|
||||||
{
|
|
||||||
byte[][] blendedColours = new byte[steps + 2][3];
|
|
||||||
|
|
||||||
byte redDifference = (byte) (((secondColour[0] & 0xFF) - (firstColour[0] & 0xFF)) / steps);
|
|
||||||
byte greenDifference = (byte) (((secondColour[1] & 0xFF) - (firstColour[1] & 0xFF)) / steps);
|
|
||||||
byte blueDifference = (byte) (((secondColour[2] & 0xFF) - (firstColour[2] & 0xFF)) / steps);
|
|
||||||
|
|
||||||
blendedColours[0] = firstColour;
|
|
||||||
for (int i = 1; i < blendedColours.length - 1; i++)
|
|
||||||
{
|
|
||||||
blendedColours[i][0] = (byte) (firstColour[0] + i * redDifference);
|
|
||||||
blendedColours[i][1] = (byte) (firstColour[1] + i * greenDifference);
|
|
||||||
blendedColours[i][2] = (byte) (firstColour[2] + i * blueDifference);
|
|
||||||
}
|
|
||||||
blendedColours[blendedColours.length - 1] = secondColour;
|
|
||||||
|
|
||||||
return blendedColours;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float[][] getFloatBlendedColours(byte[] firstColour, byte[] secondColour, int steps)
|
|
||||||
{
|
|
||||||
byte[][] byteBlendedColours = getByteBlendedColours(firstColour, secondColour, steps);
|
|
||||||
|
|
||||||
if (byteBlendedColours != null)
|
|
||||||
{
|
|
||||||
float[][] floatBlendedColours = new float[byteBlendedColours.length][3];
|
|
||||||
|
|
||||||
for (int i = 0; i < byteBlendedColours.length; i++)
|
|
||||||
{
|
|
||||||
floatBlendedColours[i][0] = (byteBlendedColours[i][0] & 0xFF) / 255F;
|
|
||||||
floatBlendedColours[i][1] = (byteBlendedColours[i][1] & 0xFF) / 255F;
|
|
||||||
floatBlendedColours[i][2] = (byteBlendedColours[i][2] & 0xFF) / 255F;
|
|
||||||
}
|
|
||||||
|
|
||||||
return floatBlendedColours;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float[][] getFloatBlendedColours(int firstColour, int secondColour, int steps)
|
|
||||||
{
|
|
||||||
byte[] firstColourByteArray = convertIntColourToByteArray(firstColour);
|
|
||||||
byte[] secondColourByteArray = convertIntColourToByteArray(secondColour);
|
|
||||||
|
|
||||||
if (firstColourByteArray != null && secondColourByteArray != null)
|
|
||||||
{
|
|
||||||
return getFloatBlendedColours(firstColourByteArray, secondColourByteArray, steps);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
package com.pahimar.ee3.client.helper;
|
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* KeyBindingHelper
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class KeyBindingHelper
|
|
||||||
{
|
|
||||||
private static ArrayList<KeyBinding> keyBindingsList;
|
|
||||||
private static ArrayList<Boolean> isRepeatingList;
|
|
||||||
|
|
||||||
public static void addKeyBinding(String name, int value)
|
|
||||||
{
|
|
||||||
if (keyBindingsList == null)
|
|
||||||
{
|
|
||||||
keyBindingsList = new ArrayList<KeyBinding>();
|
|
||||||
}
|
|
||||||
|
|
||||||
keyBindingsList.add(new KeyBinding(name, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addIsRepeating(boolean value)
|
|
||||||
{
|
|
||||||
if (isRepeatingList == null)
|
|
||||||
{
|
|
||||||
isRepeatingList = new ArrayList<Boolean>();
|
|
||||||
}
|
|
||||||
|
|
||||||
isRepeatingList.add(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static KeyBinding[] gatherKeyBindings()
|
|
||||||
{
|
|
||||||
return keyBindingsList.toArray(new KeyBinding[keyBindingsList.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean[] gatherIsRepeating()
|
|
||||||
{
|
|
||||||
boolean[] isRepeating = new boolean[isRepeatingList.size()];
|
|
||||||
|
|
||||||
for (int x = 0; x < isRepeating.length; x++)
|
|
||||||
{
|
|
||||||
isRepeating[x] = isRepeatingList.get(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
return isRepeating;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,78 +0,0 @@
|
||||||
package com.pahimar.ee3.client.helper;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* RenderUtils
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
//@SideOnly(Side.CLIENT)
|
|
||||||
public class RenderUtils
|
|
||||||
{
|
|
||||||
private static int rotationAngle = 0;
|
|
||||||
|
|
||||||
public static void renderRotatingBlockIntoGUI(FontRenderer fontRenderer, ItemStack stack, int x, int y, float zLevel, float scale)
|
|
||||||
{
|
|
||||||
RenderBlocks renderBlocks = new RenderBlocks();
|
|
||||||
|
|
||||||
Block block = Block.blocksList[stack.itemID];
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.VANILLA_BLOCK_TEXTURE_SHEET);
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslatef(x - 2, y + 3, -3.0F + zLevel);
|
|
||||||
GL11.glScalef(10.0F, 10.0F, 10.0F);
|
|
||||||
GL11.glTranslatef(1.0F, 0.5F, 1.0F);
|
|
||||||
GL11.glScalef(1.0F * scale, 1.0F * scale, -1.0F);
|
|
||||||
GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F);
|
|
||||||
GL11.glRotatef(0F + rotationAngle, 0.0F, 1.0F, 0.0F);
|
|
||||||
rotationAngle = (rotationAngle + 1) % 360;
|
|
||||||
|
|
||||||
int var10 = Item.itemsList[stack.itemID].getColorFromItemStack(stack, 0);
|
|
||||||
float var16 = (var10 >> 16 & 255) / 255.0F;
|
|
||||||
float var12 = (var10 >> 8 & 255) / 255.0F;
|
|
||||||
float var13 = (var10 & 255) / 255.0F;
|
|
||||||
|
|
||||||
GL11.glColor4f(var16, var12, var13, 1.0F);
|
|
||||||
|
|
||||||
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
|
|
||||||
renderBlocks.useInventoryTint = true;
|
|
||||||
renderBlocks.renderBlockAsItem(block, stack.getItemDamage(), 1.0F);
|
|
||||||
renderBlocks.useInventoryTint = true;
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void renderItemIntoGUI(FontRenderer fontRenderer, ItemStack itemStack, int x, int y, float opacity, float scale)
|
|
||||||
{
|
|
||||||
Icon icon = itemStack.getIconIndex();
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.VANILLA_ITEM_TEXTURE_SHEET);
|
|
||||||
int overlayColour = itemStack.getItem().getColorFromItemStack(itemStack, 0);
|
|
||||||
float red = (overlayColour >> 16 & 255) / 255.0F;
|
|
||||||
float green = (overlayColour >> 8 & 255) / 255.0F;
|
|
||||||
float blue = (overlayColour & 255) / 255.0F;
|
|
||||||
GL11.glColor4f(red, green, blue, opacity);
|
|
||||||
drawTexturedQuad(x, y, icon, 16 * scale, 16 * scale, -90);
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void drawTexturedQuad(int x, int y, Icon icon, float width, float height, double zLevel)
|
|
||||||
{
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
|
||||||
tessellator.startDrawingQuads();
|
|
||||||
tessellator.addVertexWithUV(x, y + height, zLevel, icon.getMinU(), icon.getMaxV());
|
|
||||||
tessellator.addVertexWithUV(x + width, y + height, zLevel, icon.getMaxU(), icon.getMaxV());
|
|
||||||
tessellator.addVertexWithUV(x + width, y, zLevel, icon.getMaxU(), icon.getMinV());
|
|
||||||
tessellator.addVertexWithUV(x, y, zLevel, icon.getMinU(), icon.getMinV());
|
|
||||||
tessellator.draw();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package com.pahimar.ee3.client.model;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Models;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
|
||||||
import net.minecraftforge.client.model.IModelCustom;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ModelAludel
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class ModelAludel
|
|
||||||
{
|
|
||||||
private IModelCustom modelAludel;
|
|
||||||
|
|
||||||
public ModelAludel()
|
|
||||||
{
|
|
||||||
modelAludel = AdvancedModelLoader.loadModel(Models.ALUDEL);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render()
|
|
||||||
{
|
|
||||||
modelAludel.renderPart("Base");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package com.pahimar.ee3.client.model;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Models;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
|
||||||
import net.minecraftforge.client.model.IModelCustom;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ModelCalcinator
|
|
||||||
* <p/>
|
|
||||||
* Model for the Calcinator
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class ModelCalcinator
|
|
||||||
{
|
|
||||||
private IModelCustom modelCalcinator;
|
|
||||||
|
|
||||||
public ModelCalcinator()
|
|
||||||
{
|
|
||||||
modelCalcinator = AdvancedModelLoader.loadModel(Models.CALCINATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render()
|
|
||||||
{
|
|
||||||
modelCalcinator.renderAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void renderPart(String partName)
|
|
||||||
{
|
|
||||||
modelCalcinator.renderPart(partName);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package com.pahimar.ee3.client.model;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Models;
|
|
||||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
|
||||||
import net.minecraftforge.client.model.IModelCustom;
|
|
||||||
|
|
||||||
public class ModelGlassBell
|
|
||||||
{
|
|
||||||
private IModelCustom modelGlassBell;
|
|
||||||
|
|
||||||
public ModelGlassBell()
|
|
||||||
{
|
|
||||||
modelGlassBell = AdvancedModelLoader.loadModel(Models.GLASS_BELL);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render()
|
|
||||||
{
|
|
||||||
modelGlassBell.renderPart("Bell");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package com.pahimar.ee3.client.model;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Models;
|
|
||||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
|
||||||
import net.minecraftforge.client.model.IModelCustom;
|
|
||||||
|
|
||||||
public class ModelResearchStation
|
|
||||||
{
|
|
||||||
private IModelCustom modelResearchStation;
|
|
||||||
|
|
||||||
public ModelResearchStation()
|
|
||||||
{
|
|
||||||
modelResearchStation = AdvancedModelLoader.loadModel(Models.RESEARCH_STATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render()
|
|
||||||
{
|
|
||||||
modelResearchStation.renderAll();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,93 +0,0 @@
|
||||||
package com.pahimar.ee3.client.renderer.item;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.model.ModelChest;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.client.IItemRenderer;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ItemAlchemicalChestRenderer
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class ItemAlchemicalChestRenderer implements IItemRenderer
|
|
||||||
{
|
|
||||||
private final ModelChest modelChest;
|
|
||||||
|
|
||||||
public ItemAlchemicalChestRenderer()
|
|
||||||
{
|
|
||||||
modelChest = new ModelChest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case ENTITY:
|
|
||||||
{
|
|
||||||
renderAlchemicalChest(0.5F, 0.5F, 0.5F, item.getItemDamage());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EQUIPPED:
|
|
||||||
{
|
|
||||||
renderAlchemicalChest(1.0F, 1.0F, 1.0F, item.getItemDamage());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EQUIPPED_FIRST_PERSON:
|
|
||||||
{
|
|
||||||
renderAlchemicalChest(1.0F, 1.0F, 1.0F, item.getItemDamage());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case INVENTORY:
|
|
||||||
{
|
|
||||||
renderAlchemicalChest(0.0F, 0.075F, 0.0F, item.getItemDamage());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderAlchemicalChest(float x, float y, float z, int metaData)
|
|
||||||
{
|
|
||||||
if (metaData == 0)
|
|
||||||
{
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ALCHEMICAL_CHEST_SMALL);
|
|
||||||
}
|
|
||||||
else if (metaData == 1)
|
|
||||||
{
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ALCHEMICAL_CHEST_MEDIUM);
|
|
||||||
}
|
|
||||||
else if (metaData == 2)
|
|
||||||
{
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ALCHEMICAL_CHEST_LARGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glPushMatrix(); //start
|
|
||||||
GL11.glTranslatef(x, y, z); //size
|
|
||||||
GL11.glRotatef(180, 1, 0, 0);
|
|
||||||
GL11.glRotatef(-90, 0, 1, 0);
|
|
||||||
modelChest.renderAll();
|
|
||||||
GL11.glPopMatrix(); //end
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,89 +0,0 @@
|
||||||
package com.pahimar.ee3.client.renderer.item;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.client.model.ModelAludel;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.client.IItemRenderer;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ItemAludelRenderer
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class ItemAludelRenderer implements IItemRenderer
|
|
||||||
{
|
|
||||||
private final ModelAludel modelAludel;
|
|
||||||
|
|
||||||
public ItemAludelRenderer()
|
|
||||||
{
|
|
||||||
modelAludel = new ModelAludel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case ENTITY:
|
|
||||||
{
|
|
||||||
renderAludel(-0.5F, -0.38F, 0.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case EQUIPPED:
|
|
||||||
{
|
|
||||||
renderAludel(0.0F, 0.0F, 1.0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case EQUIPPED_FIRST_PERSON:
|
|
||||||
{
|
|
||||||
renderAludel(0.0F, 0.0F, 1.0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case INVENTORY:
|
|
||||||
{
|
|
||||||
renderAludel(-1.0F, -0.9F, 0.0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderAludel(float x, float y, float z)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
|
|
||||||
// Scale, Translate, Rotate
|
|
||||||
GL11.glScalef(1F, 1F, 1F);
|
|
||||||
GL11.glTranslatef(x, y, z);
|
|
||||||
GL11.glRotatef(-90F, 1F, 0, 0);
|
|
||||||
|
|
||||||
// Bind texture
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ALUDEL);
|
|
||||||
|
|
||||||
// Render
|
|
||||||
modelAludel.render();
|
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,91 +0,0 @@
|
||||||
package com.pahimar.ee3.client.renderer.item;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.client.model.ModelCalcinator;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.client.IItemRenderer;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ItemCalcinatorRenderer
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class ItemCalcinatorRenderer implements IItemRenderer
|
|
||||||
{
|
|
||||||
private final ModelCalcinator modelCalcinator;
|
|
||||||
|
|
||||||
public ItemCalcinatorRenderer()
|
|
||||||
{
|
|
||||||
modelCalcinator = new ModelCalcinator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case ENTITY:
|
|
||||||
{
|
|
||||||
renderCalcinator(-0.5F, 0.0F, 0.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case EQUIPPED:
|
|
||||||
{
|
|
||||||
renderCalcinator(0.0F, 0.0F, 1.0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case EQUIPPED_FIRST_PERSON:
|
|
||||||
{
|
|
||||||
renderCalcinator(0.0F, 0.0F, 1.0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case INVENTORY:
|
|
||||||
{
|
|
||||||
renderCalcinator(0.0F, -0.1F, 1.0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderCalcinator(float x, float y, float z)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
|
|
||||||
// Scale, Translate, Rotate
|
|
||||||
GL11.glScalef(1F, 1F, 1F);
|
|
||||||
GL11.glTranslatef(x, y, z);
|
|
||||||
GL11.glRotatef(-90F, 1F, 0, 0);
|
|
||||||
|
|
||||||
// Bind texture
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_CALCINATOR_IDLE);
|
|
||||||
|
|
||||||
// Render
|
|
||||||
modelCalcinator.renderPart("Calcinator");
|
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,91 +0,0 @@
|
||||||
package com.pahimar.ee3.client.renderer.item;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.client.model.ModelGlassBell;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.client.IItemRenderer;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ItemGlassBellRenderer
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class ItemGlassBellRenderer implements IItemRenderer
|
|
||||||
{
|
|
||||||
private final ModelGlassBell modelGlassBell;
|
|
||||||
|
|
||||||
public ItemGlassBellRenderer()
|
|
||||||
{
|
|
||||||
modelGlassBell = new ModelGlassBell();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case ENTITY:
|
|
||||||
{
|
|
||||||
renderGlassBell(-0.5F, -1.2F, 0.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case EQUIPPED:
|
|
||||||
{
|
|
||||||
renderGlassBell(-0.2F, -0.85F, 0.8F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case EQUIPPED_FIRST_PERSON:
|
|
||||||
{
|
|
||||||
renderGlassBell(-0.2F, -0.85F, 0.8F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case INVENTORY:
|
|
||||||
{
|
|
||||||
renderGlassBell(-1.0F, -1.675F, 0.0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderGlassBell(float x, float y, float z)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
|
|
||||||
// Scale, Translate, Rotate
|
|
||||||
GL11.glScalef(1.4F, 1.4F, 1.4F);
|
|
||||||
GL11.glTranslatef(x, y, z);
|
|
||||||
GL11.glRotatef(-90F, 1F, 0, 0);
|
|
||||||
|
|
||||||
// Bind texture
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_GLASS_BELL);
|
|
||||||
|
|
||||||
// Render
|
|
||||||
modelGlassBell.render();
|
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
package com.pahimar.ee3.client.renderer.item;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.client.model.ModelResearchStation;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.client.IItemRenderer;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class ItemResearchStationRenderer implements IItemRenderer
|
|
||||||
{
|
|
||||||
private final ModelResearchStation modelResearchStation;
|
|
||||||
|
|
||||||
public ItemResearchStationRenderer()
|
|
||||||
{
|
|
||||||
modelResearchStation = new ModelResearchStation();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case ENTITY:
|
|
||||||
{
|
|
||||||
renderCalcinator(-0.5F, 0.0F, 0.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case EQUIPPED:
|
|
||||||
{
|
|
||||||
renderCalcinator(0.0F, 0.0F, 1.0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case EQUIPPED_FIRST_PERSON:
|
|
||||||
{
|
|
||||||
renderCalcinator(0.0F, 0.0F, 1.0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case INVENTORY:
|
|
||||||
{
|
|
||||||
renderCalcinator(0.0F, -0.1F, 1.0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderCalcinator(float x, float y, float z)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
|
|
||||||
// Scale, Translate, Rotate
|
|
||||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glTranslatef(x, y, z);
|
|
||||||
|
|
||||||
// Bind texture
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_RESEARCH_STATION);
|
|
||||||
|
|
||||||
// Render
|
|
||||||
modelResearchStation.render();
|
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,92 +0,0 @@
|
||||||
package com.pahimar.ee3.client.renderer.tileentity;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.model.ModelChest;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.lwjgl.opengl.GL12;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* TileEntityAlchemicalChestRenderer
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class TileEntityAlchemicalChestRenderer extends TileEntitySpecialRenderer
|
|
||||||
{
|
|
||||||
private final ModelChest modelChest = new ModelChest();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
|
|
||||||
{
|
|
||||||
if (tileEntity instanceof TileAlchemicalChest)
|
|
||||||
{
|
|
||||||
TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) tileEntity;
|
|
||||||
ForgeDirection direction = null;
|
|
||||||
|
|
||||||
if (tileAlchemicalChest.getWorldObj() != null)
|
|
||||||
{
|
|
||||||
direction = tileAlchemicalChest.getOrientation();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tileAlchemicalChest.getState() == 0)
|
|
||||||
{
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ALCHEMICAL_CHEST_SMALL);
|
|
||||||
}
|
|
||||||
else if (tileAlchemicalChest.getState() == 1)
|
|
||||||
{
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ALCHEMICAL_CHEST_MEDIUM);
|
|
||||||
}
|
|
||||||
else if (tileAlchemicalChest.getState() == 2)
|
|
||||||
{
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ALCHEMICAL_CHEST_LARGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
|
|
||||||
GL11.glScalef(1.0F, -1.0F, -1.0F);
|
|
||||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
|
||||||
short angle = 0;
|
|
||||||
|
|
||||||
if (direction != null)
|
|
||||||
{
|
|
||||||
if (direction == ForgeDirection.NORTH)
|
|
||||||
{
|
|
||||||
angle = 180;
|
|
||||||
}
|
|
||||||
else if (direction == ForgeDirection.SOUTH)
|
|
||||||
{
|
|
||||||
angle = 0;
|
|
||||||
}
|
|
||||||
else if (direction == ForgeDirection.WEST)
|
|
||||||
{
|
|
||||||
angle = 90;
|
|
||||||
}
|
|
||||||
else if (direction == ForgeDirection.EAST)
|
|
||||||
{
|
|
||||||
angle = -90;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F);
|
|
||||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
|
||||||
float adjustedLidAngle = tileAlchemicalChest.prevLidAngle + (tileAlchemicalChest.lidAngle - tileAlchemicalChest.prevLidAngle) * tick;
|
|
||||||
adjustedLidAngle = 1.0F - adjustedLidAngle;
|
|
||||||
adjustedLidAngle = 1.0F - adjustedLidAngle * adjustedLidAngle * adjustedLidAngle;
|
|
||||||
modelChest.chestLid.rotateAngleX = -(adjustedLidAngle * (float) Math.PI / 2.0F);
|
|
||||||
modelChest.renderAll();
|
|
||||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,172 +0,0 @@
|
||||||
package com.pahimar.ee3.client.renderer.tileentity;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.client.model.ModelAludel;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import com.pahimar.ee3.tileentity.TileAludel;
|
|
||||||
import com.pahimar.ee3.tileentity.TileGlassBell;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderItem;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* TileEntityAludelRenderer
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class TileEntityAludelRenderer extends TileEntitySpecialRenderer
|
|
||||||
{
|
|
||||||
private final ModelAludel modelAludel = new ModelAludel();
|
|
||||||
private final RenderItem customRenderItem;
|
|
||||||
|
|
||||||
public TileEntityAludelRenderer()
|
|
||||||
{
|
|
||||||
customRenderItem = new RenderItem()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean shouldBob()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
customRenderItem.setRenderManager(RenderManager.instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
|
|
||||||
{
|
|
||||||
if (tileEntity instanceof TileAludel)
|
|
||||||
{
|
|
||||||
TileAludel tileAludel = (TileAludel) tileEntity;
|
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
|
|
||||||
// Scale, Translate, Rotate
|
|
||||||
scaleTranslateRotate(x, y, z, tileAludel.getOrientation());
|
|
||||||
|
|
||||||
// Bind texture
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ALUDEL);
|
|
||||||
|
|
||||||
// Render
|
|
||||||
modelAludel.render();
|
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render the ghost item inside of the Aludel, slowly spinning
|
|
||||||
*/
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
|
|
||||||
TileEntity tileGlassBell = tileAludel.getWorldObj().getTileEntity(tileAludel.xCoord, tileAludel.yCoord + 1, tileAludel.zCoord);
|
|
||||||
|
|
||||||
if (tileGlassBell instanceof TileGlassBell)
|
|
||||||
{
|
|
||||||
if (tileAludel.outputItemStack != null)
|
|
||||||
{
|
|
||||||
float scaleFactor = getGhostItemScaleFactor(tileAludel.outputItemStack);
|
|
||||||
float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
|
|
||||||
|
|
||||||
EntityItem ghostEntityItem = new EntityItem(tileAludel.getWorldObj());
|
|
||||||
ghostEntityItem.hoverStart = 0.0F;
|
|
||||||
ghostEntityItem.setEntityItemStack(tileAludel.outputItemStack);
|
|
||||||
|
|
||||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.25F, (float) z + 0.5F);
|
|
||||||
GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
|
|
||||||
GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F);
|
|
||||||
|
|
||||||
customRenderItem.doRenderItem(ghostEntityItem, 0, 0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scaleTranslateRotate(double x, double y, double z, ForgeDirection orientation)
|
|
||||||
{
|
|
||||||
if (orientation == ForgeDirection.NORTH)
|
|
||||||
{
|
|
||||||
GL11.glTranslated(x + 1, y, z);
|
|
||||||
GL11.glRotatef(180F, 0F, 1F, 0F);
|
|
||||||
GL11.glRotatef(-90F, 1F, 0F, 0F);
|
|
||||||
}
|
|
||||||
else if (orientation == ForgeDirection.EAST)
|
|
||||||
{
|
|
||||||
GL11.glTranslated(x + 1, y, z + 1);
|
|
||||||
GL11.glRotatef(90F, 0F, 1F, 0F);
|
|
||||||
GL11.glRotatef(-90F, 1F, 0F, 0F);
|
|
||||||
}
|
|
||||||
else if (orientation == ForgeDirection.SOUTH)
|
|
||||||
{
|
|
||||||
GL11.glTranslated(x, y, z + 1);
|
|
||||||
GL11.glRotatef(0F, 0F, 1F, 0F);
|
|
||||||
GL11.glRotatef(-90F, 1F, 0F, 0F);
|
|
||||||
}
|
|
||||||
else if (orientation == ForgeDirection.WEST)
|
|
||||||
{
|
|
||||||
GL11.glTranslated(x, y, z);
|
|
||||||
GL11.glRotatef(-90F, 0F, 1F, 0F);
|
|
||||||
GL11.glRotatef(-90F, 1F, 0F, 0F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getGhostItemScaleFactor(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
float scaleFactor = 1.0F;
|
|
||||||
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
if (itemStack.getItem() instanceof ItemBlock)
|
|
||||||
{
|
|
||||||
switch (customRenderItem.getMiniBlockCount(itemStack))
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return 0.90F;
|
|
||||||
case 2:
|
|
||||||
return 0.90F;
|
|
||||||
case 3:
|
|
||||||
return 0.90F;
|
|
||||||
case 4:
|
|
||||||
return 0.90F;
|
|
||||||
case 5:
|
|
||||||
return 0.80F;
|
|
||||||
default:
|
|
||||||
return 0.90F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (customRenderItem.getMiniItemCount(itemStack))
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return 0.65F;
|
|
||||||
case 2:
|
|
||||||
return 0.65F;
|
|
||||||
case 3:
|
|
||||||
return 0.65F;
|
|
||||||
case 4:
|
|
||||||
return 0.65F;
|
|
||||||
default:
|
|
||||||
return 0.65F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return scaleFactor;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,125 +0,0 @@
|
||||||
package com.pahimar.ee3.client.renderer.tileentity;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.client.helper.ColourUtils;
|
|
||||||
import com.pahimar.ee3.client.model.ModelCalcinator;
|
|
||||||
import com.pahimar.ee3.lib.Colours;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import com.pahimar.ee3.tileentity.TileCalcinator;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* TileEntityCalcinatorRenderer
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class TileEntityCalcinatorRenderer extends TileEntitySpecialRenderer
|
|
||||||
{
|
|
||||||
private final ModelCalcinator modelCalcinator = new ModelCalcinator();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
|
|
||||||
{
|
|
||||||
if (tileEntity instanceof TileCalcinator)
|
|
||||||
{
|
|
||||||
TileCalcinator tileCalcinator = (TileCalcinator) tileEntity;
|
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
|
|
||||||
// Scale, Translate, Rotate
|
|
||||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.0F, (float) z + 1.2F);
|
|
||||||
GL11.glRotatef(45F, 0F, 1F, 0F);
|
|
||||||
GL11.glRotatef(-90F, 1F, 0F, 0F);
|
|
||||||
|
|
||||||
// Bind texture
|
|
||||||
if (tileCalcinator.getState() == 1)
|
|
||||||
{
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_CALCINATOR_ACTIVE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_CALCINATOR_IDLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render
|
|
||||||
modelCalcinator.renderPart("Calcinator");
|
|
||||||
|
|
||||||
int dustStackSize = tileCalcinator.leftStackSize + tileCalcinator.rightStackSize;
|
|
||||||
|
|
||||||
if (dustStackSize > 0)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
|
|
||||||
// Reverse previous rotation to get back into a workable frame of reference
|
|
||||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
|
||||||
GL11.glRotatef(-45F, 0F, 1F, 0F);
|
|
||||||
|
|
||||||
float[] dustColour = getBlendedDustColour(tileCalcinator.leftStackSize, tileCalcinator.leftStackMeta, tileCalcinator.rightStackSize, tileCalcinator.rightStackMeta);
|
|
||||||
|
|
||||||
GL11.glColor4f(dustColour[0], dustColour[1], dustColour[2], 1F);
|
|
||||||
|
|
||||||
if (dustStackSize <= 32)
|
|
||||||
{
|
|
||||||
GL11.glScalef(0.25F, 0.25F, 0.25F);
|
|
||||||
GL11.glTranslatef(0.0F, 2.20F, -2.1125F);
|
|
||||||
}
|
|
||||||
else if (dustStackSize <= 64)
|
|
||||||
{
|
|
||||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
|
||||||
GL11.glTranslatef(-0.0125F, 0.75F, -0.7125F);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reapply previous rotation to get it back to a viewable state
|
|
||||||
GL11.glRotatef(45F, 0F, 1F, 0F);
|
|
||||||
GL11.glRotatef(-90F, 1F, 0F, 0F);
|
|
||||||
|
|
||||||
// Render the dust in the Calcinator bowl
|
|
||||||
modelCalcinator.renderPart("Dust");
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static float[] getBlendedDustColour(int leftStackSize, int leftStackMeta, int rightStackSize, int rightStackMeta)
|
|
||||||
{
|
|
||||||
int totalDustStacksSize = leftStackSize + rightStackSize;
|
|
||||||
|
|
||||||
if (totalDustStacksSize > 0)
|
|
||||||
{
|
|
||||||
int leftStackColour = Integer.parseInt(Colours.DUST_COLOURS[MathHelper.clamp_int(leftStackMeta, 0, Colours.DUST_COLOURS.length)], 16);
|
|
||||||
int rightStackColour = Integer.parseInt(Colours.DUST_COLOURS[MathHelper.clamp_int(rightStackMeta, 0, Colours.DUST_COLOURS.length)], 16);
|
|
||||||
|
|
||||||
float leftStackRatio = leftStackSize * 1f / totalDustStacksSize;
|
|
||||||
float rightStackRatio = rightStackSize * 1f / totalDustStacksSize;
|
|
||||||
|
|
||||||
float[][] blendedColours = ColourUtils.getFloatBlendedColours(leftStackColour, rightStackColour, 32);
|
|
||||||
|
|
||||||
if (blendedColours.length > 0)
|
|
||||||
{
|
|
||||||
if (Float.compare(leftStackRatio, rightStackRatio) > 0)
|
|
||||||
{
|
|
||||||
return blendedColours[Math.round((1 - leftStackRatio) * (blendedColours.length - 1))];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return blendedColours[Math.round(rightStackRatio * (blendedColours.length - 1))];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new float[]{1F, 1F, 1F};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,294 +0,0 @@
|
||||||
package com.pahimar.ee3.client.renderer.tileentity;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.client.model.ModelGlassBell;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import com.pahimar.ee3.tileentity.TileGlassBell;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderItem;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* TileEntityGlassBellRenderer
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer
|
|
||||||
{
|
|
||||||
private final ModelGlassBell modelGlassBell = new ModelGlassBell();
|
|
||||||
private final RenderItem customRenderItem;
|
|
||||||
|
|
||||||
public TileEntityGlassBellRenderer()
|
|
||||||
{
|
|
||||||
customRenderItem = new RenderItem()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean shouldBob()
|
|
||||||
{
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
customRenderItem.setRenderManager(RenderManager.instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
|
|
||||||
{
|
|
||||||
if (tileEntity instanceof TileGlassBell)
|
|
||||||
{
|
|
||||||
TileGlassBell tileGlassBell = (TileGlassBell) tileEntity;
|
|
||||||
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render the Glass Bell
|
|
||||||
*/
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
|
|
||||||
// Scale, Translate, Rotate
|
|
||||||
renderGlassBellByOrientation(x, y, z, tileGlassBell.getOrientation());
|
|
||||||
|
|
||||||
// Bind texture
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_GLASS_BELL);
|
|
||||||
|
|
||||||
modelGlassBell.render();
|
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render the ghost item inside of the Glass Bell, slowly spinning
|
|
||||||
*/
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
|
|
||||||
if (tileGlassBell.outputItemStack != null)
|
|
||||||
{
|
|
||||||
float scaleFactor = getGhostItemScaleFactor(tileGlassBell.outputItemStack);
|
|
||||||
float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
|
|
||||||
|
|
||||||
EntityItem ghostEntityItem = new EntityItem(tileGlassBell.getWorldObj());
|
|
||||||
ghostEntityItem.hoverStart = 0.0F;
|
|
||||||
ghostEntityItem.setEntityItemStack(tileGlassBell.outputItemStack);
|
|
||||||
|
|
||||||
translateGhostItemByOrientation(ghostEntityItem.getEntityItem(), x, y, z, tileGlassBell.getOrientation());
|
|
||||||
GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
|
|
||||||
GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F);
|
|
||||||
|
|
||||||
customRenderItem.doRenderItem(ghostEntityItem, 0, 0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderGlassBellByOrientation(double x, double y, double z, ForgeDirection forgeDirection)
|
|
||||||
{
|
|
||||||
switch (forgeDirection)
|
|
||||||
{
|
|
||||||
case DOWN:
|
|
||||||
{
|
|
||||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glTranslatef((float) x + 0.0F, (float) y + 2.0F, (float) z + 0.0F);
|
|
||||||
GL11.glRotatef(90F, 1F, 0F, 0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case UP:
|
|
||||||
{
|
|
||||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glTranslatef((float) x + 0.0F, (float) y + -1.0F, (float) z + 1.0F);
|
|
||||||
GL11.glRotatef(-90F, 1F, 0F, 0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case NORTH:
|
|
||||||
{
|
|
||||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glTranslatef((float) x + 1.0F, (float) y + 0.0F, (float) z + 2.0F);
|
|
||||||
GL11.glRotatef(180F, 0F, 1F, 0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case SOUTH:
|
|
||||||
{
|
|
||||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glTranslatef((float) x + 0.0F, (float) y + 0.0F, (float) z + -1.0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case EAST:
|
|
||||||
{
|
|
||||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glTranslatef((float) x + -1.0F, (float) y + 1.0F, (float) z + 1.0F);
|
|
||||||
GL11.glRotatef(-90F, 0F, 0F, 1F);
|
|
||||||
GL11.glRotatef(-90F, 1F, 0F, 0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case WEST:
|
|
||||||
{
|
|
||||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glTranslatef((float) x + 2.0F, (float) y + 0.0F, (float) z + 1.0F);
|
|
||||||
GL11.glRotatef(90F, 0F, 0F, 1F);
|
|
||||||
GL11.glRotatef(-90F, 1F, 0F, 0F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case UNKNOWN:
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void translateGhostItemByOrientation(ItemStack ghostItemStack, double x, double y, double z, ForgeDirection forgeDirection)
|
|
||||||
{
|
|
||||||
if (ghostItemStack != null)
|
|
||||||
{
|
|
||||||
if (ghostItemStack.getItem() instanceof ItemBlock)
|
|
||||||
{
|
|
||||||
switch (forgeDirection)
|
|
||||||
{
|
|
||||||
case DOWN:
|
|
||||||
{
|
|
||||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.7F, (float) z + 0.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case UP:
|
|
||||||
{
|
|
||||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.25F, (float) z + 0.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case NORTH:
|
|
||||||
{
|
|
||||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.7F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case SOUTH:
|
|
||||||
{
|
|
||||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.3F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case EAST:
|
|
||||||
{
|
|
||||||
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.5F, (float) z + 0.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case WEST:
|
|
||||||
{
|
|
||||||
GL11.glTranslatef((float) x + 0.70F, (float) y + 0.5F, (float) z + 0.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case UNKNOWN:
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (forgeDirection)
|
|
||||||
{
|
|
||||||
case DOWN:
|
|
||||||
{
|
|
||||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.6F, (float) z + 0.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case UP:
|
|
||||||
{
|
|
||||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.20F, (float) z + 0.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case NORTH:
|
|
||||||
{
|
|
||||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.7F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case SOUTH:
|
|
||||||
{
|
|
||||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.3F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case EAST:
|
|
||||||
{
|
|
||||||
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.4F, (float) z + 0.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case WEST:
|
|
||||||
{
|
|
||||||
GL11.glTranslatef((float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case UNKNOWN:
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getGhostItemScaleFactor(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
float scaleFactor = 1.0F;
|
|
||||||
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
if (itemStack.getItem() instanceof ItemBlock)
|
|
||||||
{
|
|
||||||
switch (customRenderItem.getMiniBlockCount(itemStack))
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return 0.90F;
|
|
||||||
case 2:
|
|
||||||
return 0.90F;
|
|
||||||
case 3:
|
|
||||||
return 0.90F;
|
|
||||||
case 4:
|
|
||||||
return 0.90F;
|
|
||||||
case 5:
|
|
||||||
return 0.80F;
|
|
||||||
default:
|
|
||||||
return 0.90F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (customRenderItem.getMiniItemCount(itemStack))
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
return 0.65F;
|
|
||||||
case 2:
|
|
||||||
return 0.65F;
|
|
||||||
case 3:
|
|
||||||
return 0.65F;
|
|
||||||
case 4:
|
|
||||||
return 0.65F;
|
|
||||||
default:
|
|
||||||
return 0.65F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return scaleFactor;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package com.pahimar.ee3.client.renderer.tileentity;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.client.model.ModelResearchStation;
|
|
||||||
import com.pahimar.ee3.lib.Textures;
|
|
||||||
import com.pahimar.ee3.tileentity.TileResearchStation;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class TileEntityResearchStationRenderer extends TileEntitySpecialRenderer
|
|
||||||
{
|
|
||||||
private final ModelResearchStation modelResearchStation = new ModelResearchStation();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
|
|
||||||
{
|
|
||||||
if (tileEntity instanceof TileResearchStation)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
|
|
||||||
// Scale, Translate, Rotate
|
|
||||||
GL11.glScalef(1.0F, 1.0F, 1.0F);
|
|
||||||
GL11.glTranslatef((float) x + 0.0F, (float) y + 0.0F, (float) z + 1.0F);
|
|
||||||
|
|
||||||
// Bind texture
|
|
||||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_RESEARCH_STATION);
|
|
||||||
|
|
||||||
// Render
|
|
||||||
modelResearchStation.render();
|
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package com.pahimar.ee3.client.settings;
|
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class Keybindings
|
|
||||||
{
|
|
||||||
public KeyBinding keyBindCharge = new KeyBinding("key.charge", 47, "key.categories.ee3");
|
|
||||||
public KeyBinding keyBindExtra = new KeyBinding("key.extra", 46, "key.categories.ee3");
|
|
||||||
public KeyBinding keyBindRelease = new KeyBinding("key.release", 19, "key.categories.ee3");
|
|
||||||
public KeyBinding keyBindToggle = new KeyBinding("key.toggle", 34, "key.categories.ee3");
|
|
||||||
}
|
|
|
@ -1,151 +0,0 @@
|
||||||
package com.pahimar.ee3.command;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Commands;
|
|
||||||
import net.minecraft.command.CommandBase;
|
|
||||||
import net.minecraft.command.ICommand;
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.command.WrongUsageException;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* CommandEE
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class CommandEE extends CommandBase
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName()
|
|
||||||
{
|
|
||||||
|
|
||||||
return Commands.COMMAND_EE3;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canCommandSenderUseCommand(ICommandSender commandSender)
|
|
||||||
{
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public List addTabCompletionOptions(ICommandSender commandSender, String[] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
switch (args.length)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
return getListOfStringsMatchingLastWord(args, Commands.COMMAND_OVERLAY, Commands.COMMAND_PARTICLES, Commands.COMMAND_SOUNDS, Commands.COMMAND_VERSION);
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
if (args[0].equalsIgnoreCase(Commands.COMMAND_OVERLAY))
|
|
||||||
{
|
|
||||||
return getListOfStringsMatchingLastWord(args, Commands.COMMAND_ON, Commands.COMMAND_OFF, Commands.COMMAND_POSITION, Commands.COMMAND_SCALE, Commands.COMMAND_OPACITY);
|
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase(Commands.COMMAND_PARTICLES))
|
|
||||||
{
|
|
||||||
return getListOfStringsMatchingLastWord(args, Commands.COMMAND_ON, Commands.COMMAND_OFF);
|
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase(Commands.COMMAND_SOUNDS))
|
|
||||||
{
|
|
||||||
return getListOfStringsMatchingLastWord(args, Commands.COMMAND_ALL, Commands.COMMAND_SELF, Commands.COMMAND_OFF);
|
|
||||||
}
|
|
||||||
else if (args[0].equalsIgnoreCase(Commands.COMMAND_VERSION))
|
|
||||||
{
|
|
||||||
return getListOfStringsMatchingLastWord(args, Commands.COMMAND_CHANGELOG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 3:
|
|
||||||
{
|
|
||||||
if (args[0].equalsIgnoreCase(Commands.COMMAND_OVERLAY))
|
|
||||||
{
|
|
||||||
if (args[1].equalsIgnoreCase(Commands.COMMAND_POSITION))
|
|
||||||
{
|
|
||||||
return getListOfStringsMatchingLastWord(args, Commands.COMMAND_TOP, Commands.COMMAND_BOTTOM);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 4:
|
|
||||||
{
|
|
||||||
if (args[0].equalsIgnoreCase(Commands.COMMAND_OVERLAY))
|
|
||||||
{
|
|
||||||
if (args[1].equalsIgnoreCase(Commands.COMMAND_POSITION))
|
|
||||||
{
|
|
||||||
if (args[2].equalsIgnoreCase(Commands.COMMAND_TOP) || args[2].equalsIgnoreCase(Commands.COMMAND_BOTTOM))
|
|
||||||
{
|
|
||||||
return getListOfStringsMatchingLastWord(args, Commands.COMMAND_LEFT, Commands.COMMAND_RIGHT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void processCommand(ICommandSender commandSender, String[] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (args.length > 0)
|
|
||||||
{
|
|
||||||
String commandName = args[0];
|
|
||||||
System.arraycopy(args, 1, args, 0, args.length - 1);
|
|
||||||
|
|
||||||
if (commandName.equalsIgnoreCase(Commands.COMMAND_OVERLAY))
|
|
||||||
{
|
|
||||||
CommandOverlay.processCommand(commandSender, args);
|
|
||||||
}
|
|
||||||
else if (commandName.equalsIgnoreCase(Commands.COMMAND_PARTICLES))
|
|
||||||
{
|
|
||||||
CommandParticles.processCommand(commandSender, args);
|
|
||||||
}
|
|
||||||
else if (commandName.equalsIgnoreCase(Commands.COMMAND_SOUNDS))
|
|
||||||
{
|
|
||||||
CommandSounds.processCommand(commandSender, args);
|
|
||||||
}
|
|
||||||
else if (commandName.equalsIgnoreCase(Commands.COMMAND_VERSION))
|
|
||||||
{
|
|
||||||
CommandVersion.processCommand(commandSender, args);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_EE3_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_EE3_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandUsage(ICommandSender icommandsender)
|
|
||||||
{
|
|
||||||
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(Object obj)
|
|
||||||
{
|
|
||||||
if (obj instanceof ICommand)
|
|
||||||
{
|
|
||||||
return this.compareTo((ICommand) obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package com.pahimar.ee3.command;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* CommandHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class CommandHandler
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void initCommands(FMLServerStartingEvent event)
|
|
||||||
{
|
|
||||||
|
|
||||||
event.registerServerCommand(new CommandEE());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,179 +0,0 @@
|
||||||
package com.pahimar.ee3.command;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
|
||||||
import com.pahimar.ee3.configuration.GeneralConfiguration;
|
|
||||||
import com.pahimar.ee3.lib.Commands;
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.command.WrongUsageException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* CommandOverlay
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class CommandOverlay
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void processCommand(ICommandSender commandSender, String[] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (args.length > 0)
|
|
||||||
{
|
|
||||||
String subCommand = args[0];
|
|
||||||
|
|
||||||
if (subCommand.equalsIgnoreCase(Commands.COMMAND_ON))
|
|
||||||
{
|
|
||||||
processOnCommand(commandSender);
|
|
||||||
}
|
|
||||||
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_OFF))
|
|
||||||
{
|
|
||||||
processOffCommand(commandSender);
|
|
||||||
}
|
|
||||||
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_OPACITY))
|
|
||||||
{
|
|
||||||
processOpacityCommand(commandSender, args);
|
|
||||||
}
|
|
||||||
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_SCALE))
|
|
||||||
{
|
|
||||||
processScaleCommand(commandSender, args);
|
|
||||||
}
|
|
||||||
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_POSITION))
|
|
||||||
{
|
|
||||||
processPositionCommand(commandSender, args);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processOnCommand(ICommandSender commandSender)
|
|
||||||
{
|
|
||||||
|
|
||||||
ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION = true;
|
|
||||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME, "true");
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_TURNED_ON));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processOffCommand(ICommandSender commandSender)
|
|
||||||
{
|
|
||||||
|
|
||||||
ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION = false;
|
|
||||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME, "false");
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_TURNED_OFF));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processScaleCommand(ICommandSender commandSender, String[] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (args.length > 2 && args.length < 4)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
float scale = Float.parseFloat(args[1]);
|
|
||||||
|
|
||||||
if (scale <= 0F)
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_SCALE_USAGE_ADDITIONAL_TEXT, Commands.COMMAND_OVERLAY_SCALE_USAGE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE = scale;
|
|
||||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE_CONFIGNAME, args[1]);
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_SCALE_UPDATED));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_SCALE_USAGE_ADDITIONAL_TEXT, Commands.COMMAND_OVERLAY_SCALE_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_SCALE_USAGE_ADDITIONAL_TEXT, Commands.COMMAND_OVERLAY_SCALE_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processOpacityCommand(ICommandSender commandSender, String[] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (args.length > 2 && args.length < 4)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
float opacity = Float.parseFloat(args[1]);
|
|
||||||
|
|
||||||
if (opacity < 0F || opacity > 1F)
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_OPACITY_USAGE_ADDITIONAL_TEXT, Commands.COMMAND_OVERLAY_OPACITY_USAGE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY = opacity;
|
|
||||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY_CONFIGNAME, args[1]);
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_OPACITY_UPDATED));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_OPACITY_USAGE_ADDITIONAL_TEXT, Commands.COMMAND_OVERLAY_OPACITY_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_OPACITY_USAGE_ADDITIONAL_TEXT, Commands.COMMAND_OVERLAY_OPACITY_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processPositionCommand(ICommandSender commandSender, String[] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
String yPosition, xPosition;
|
|
||||||
|
|
||||||
if (args.length > 2 && args.length < 5)
|
|
||||||
{
|
|
||||||
yPosition = args[1];
|
|
||||||
xPosition = args[2];
|
|
||||||
|
|
||||||
if (yPosition.equalsIgnoreCase(Commands.COMMAND_TOP) && xPosition.equalsIgnoreCase(Commands.COMMAND_LEFT))
|
|
||||||
{
|
|
||||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 0;
|
|
||||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "0");
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_POSITION_TOP_LEFT));
|
|
||||||
}
|
|
||||||
else if (yPosition.equalsIgnoreCase(Commands.COMMAND_TOP) && xPosition.equalsIgnoreCase(Commands.COMMAND_RIGHT))
|
|
||||||
{
|
|
||||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 1;
|
|
||||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "1");
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_POSITION_TOP_RIGHT));
|
|
||||||
}
|
|
||||||
else if (yPosition.equalsIgnoreCase(Commands.COMMAND_BOTTOM) && xPosition.equalsIgnoreCase(Commands.COMMAND_LEFT))
|
|
||||||
{
|
|
||||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 2;
|
|
||||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "2");
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_POSITION_BOTTOM_LEFT));
|
|
||||||
}
|
|
||||||
else if (yPosition.equalsIgnoreCase(Commands.COMMAND_BOTTOM) && xPosition.equalsIgnoreCase(Commands.COMMAND_RIGHT))
|
|
||||||
{
|
|
||||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = 3;
|
|
||||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, "3");
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_POSITION_BOTTOM_RIGHT));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_POSITION_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_POSITION_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
package com.pahimar.ee3.command;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
|
||||||
import com.pahimar.ee3.configuration.GeneralConfiguration;
|
|
||||||
import com.pahimar.ee3.lib.Commands;
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.command.WrongUsageException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* CommandParticles
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class CommandParticles
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void processCommand(ICommandSender commandSender, String[] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
String subCommand;
|
|
||||||
|
|
||||||
if (args.length > 0)
|
|
||||||
{
|
|
||||||
subCommand = args[0];
|
|
||||||
|
|
||||||
if (subCommand.toLowerCase().equals(Commands.COMMAND_ON))
|
|
||||||
{
|
|
||||||
processOnCommand(commandSender);
|
|
||||||
}
|
|
||||||
else if (subCommand.toLowerCase().equals(Commands.COMMAND_OFF))
|
|
||||||
{
|
|
||||||
processOffCommand(commandSender);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_PARTICLES_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_PARTICLES_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processOnCommand(ICommandSender commandSender)
|
|
||||||
{
|
|
||||||
|
|
||||||
ConfigurationSettings.ENABLE_PARTICLE_FX = true;
|
|
||||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_PARTICLE_FX_CONFIGNAME, "true");
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_PARTICLES_TURNED_ON));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processOffCommand(ICommandSender commandSender)
|
|
||||||
{
|
|
||||||
|
|
||||||
ConfigurationSettings.ENABLE_PARTICLE_FX = false;
|
|
||||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_PARTICLE_FX_CONFIGNAME, "false");
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_PARTICLES_TURNED_OFF));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
package com.pahimar.ee3.command;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
|
||||||
import com.pahimar.ee3.configuration.GeneralConfiguration;
|
|
||||||
import com.pahimar.ee3.lib.Commands;
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.command.WrongUsageException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* CommandSounds
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class CommandSounds
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void processCommand(ICommandSender commandSender, String[] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
String subCommand;
|
|
||||||
|
|
||||||
if (args.length > 0)
|
|
||||||
{
|
|
||||||
subCommand = args[0];
|
|
||||||
|
|
||||||
if (subCommand.toLowerCase().equals(Commands.COMMAND_ALL))
|
|
||||||
{
|
|
||||||
processAllCommand(commandSender);
|
|
||||||
}
|
|
||||||
else if (subCommand.toLowerCase().equals(Commands.COMMAND_SELF))
|
|
||||||
{
|
|
||||||
processSelfCommand(commandSender);
|
|
||||||
}
|
|
||||||
else if (subCommand.toLowerCase().equals(Commands.COMMAND_OFF))
|
|
||||||
{
|
|
||||||
processOffCommand(commandSender);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_SOUNDS_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_SOUNDS_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processAllCommand(ICommandSender commandSender)
|
|
||||||
{
|
|
||||||
|
|
||||||
ConfigurationSettings.ENABLE_SOUNDS = Commands.ALL;
|
|
||||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_AUDIO, ConfigurationSettings.ENABLE_SOUNDS_CONFIGNAME, Commands.ALL);
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_SOUNDS_SET_TO_ALL));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processSelfCommand(ICommandSender commandSender)
|
|
||||||
{
|
|
||||||
|
|
||||||
ConfigurationSettings.ENABLE_SOUNDS = Commands.SELF;
|
|
||||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_AUDIO, ConfigurationSettings.ENABLE_SOUNDS_CONFIGNAME, Commands.SELF);
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_SOUNDS_SET_TO_SELF));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processOffCommand(ICommandSender commandSender)
|
|
||||||
{
|
|
||||||
|
|
||||||
ConfigurationSettings.ENABLE_SOUNDS = Commands.OFF;
|
|
||||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_AUDIO, ConfigurationSettings.ENABLE_SOUNDS_CONFIGNAME, Commands.OFF);
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_SOUNDS_TURNED_OFF));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
package com.pahimar.ee3.command;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.helper.VersionHelper;
|
|
||||||
import com.pahimar.ee3.lib.Commands;
|
|
||||||
import net.minecraft.command.ICommandSender;
|
|
||||||
import net.minecraft.command.WrongUsageException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* CommandVersion
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class CommandVersion
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void processCommand(ICommandSender commandSender, String[] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
String subCommand;
|
|
||||||
|
|
||||||
if (args.length > 0)
|
|
||||||
{
|
|
||||||
subCommand = args[0];
|
|
||||||
|
|
||||||
if (subCommand.toLowerCase().equals(Commands.COMMAND_VERSION))
|
|
||||||
{
|
|
||||||
processVersionCommand(commandSender);
|
|
||||||
}
|
|
||||||
else if (subCommand.toLowerCase().equals(Commands.COMMAND_CHANGELOG))
|
|
||||||
{
|
|
||||||
processChangelogCommand(commandSender);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_VERSION_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new WrongUsageException(Commands.COMMAND_VERSION_USAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processVersionCommand(ICommandSender commandSender)
|
|
||||||
{
|
|
||||||
|
|
||||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(VersionHelper.getResultMessage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processChangelogCommand(ICommandSender commandSender)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
package com.pahimar.ee3.configuration;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.BlockIds;
|
|
||||||
import com.pahimar.ee3.lib.Reference;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class BlockConfiguration
|
|
||||||
{
|
|
||||||
protected static void init(File configFile)
|
|
||||||
{
|
|
||||||
Configuration blockConfiguration = new Configuration(configFile);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
blockConfiguration.load();
|
|
||||||
|
|
||||||
BlockIds.ALCHEMICAL_FUEL = blockConfiguration.getBlock(Strings.ALCHEMICAL_FUEL_NAME, BlockIds.ALCHEMICAL_FUEL_DEFAULT).getInt(BlockIds.ALCHEMICAL_FUEL_DEFAULT);
|
|
||||||
BlockIds.CHALK = blockConfiguration.getBlock(Strings.CHALK_NAME, BlockIds.CHALK_DEFAULT).getInt(BlockIds.CHALK_DEFAULT);
|
|
||||||
BlockIds.ALCHEMY_SQUARE = blockConfiguration.getBlock(Strings.ALCHEMY_SQUARE_NAME, BlockIds.ALCHEMY_SQUARE_DEFAULT).getInt(BlockIds.ALCHEMY_SQUARE_DEFAULT);
|
|
||||||
BlockIds.CALCINATOR = blockConfiguration.getBlock(Strings.CALCINATOR_NAME, BlockIds.CALCINATOR_DEFAULT).getInt(BlockIds.CALCINATOR_DEFAULT);
|
|
||||||
BlockIds.ALUDEL_BASE = blockConfiguration.getBlock(Strings.ALUDEL_NAME, BlockIds.ALUDEL_BASE_DEFAULT).getInt(BlockIds.ALUDEL_BASE_DEFAULT);
|
|
||||||
BlockIds.ALCHEMICAL_CHEST = blockConfiguration.getBlock(Strings.ALCHEMICAL_CHEST_NAME, BlockIds.ALCHEMICAL_CHEST_DEFAULT).getInt(BlockIds.ALCHEMICAL_CHEST_DEFAULT);
|
|
||||||
BlockIds.GLASS_BELL = blockConfiguration.getBlock(Strings.GLASS_BELL_NAME, BlockIds.GLASS_BELL_DEFAULT).getInt(BlockIds.GLASS_BELL_DEFAULT);
|
|
||||||
BlockIds.RESEARCH_STATION = blockConfiguration.getBlock(Strings.RESEARCH_STATION_NAME, BlockIds.RESEARCH_STATION_DEFAULT).getInt(BlockIds.RESEARCH_STATION_DEFAULT);
|
|
||||||
BlockIds.INFUSED_CLOTH = blockConfiguration.getBlock(Strings.INFUSED_CLOTH_NAME, BlockIds.INFUSED_CLOTH_DEFAULT).getInt(BlockIds.INFUSED_CLOTH_DEFAULT);
|
|
||||||
BlockIds.INFUSED_WOOD = blockConfiguration.getBlock(Strings.INFUSED_WOOD_NAME, BlockIds.INFUSED_WOOD_DEFAULT).getInt(BlockIds.INFUSED_WOOD_DEFAULT);
|
|
||||||
BlockIds.INFUSED_PLANKS = blockConfiguration.getBlock(Strings.INFUSED_PLANKS_NAME, BlockIds.INFUSED_PLANKS_DEFAULT).getInt(BlockIds.INFUSED_PLANKS_DEFAULT);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
FMLLog.log(Level.SEVERE, e, Reference.MOD_NAME + " has had a problem loading its block configuration");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
blockConfiguration.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package com.pahimar.ee3.configuration;
|
|
||||||
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ConfigurationHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class ConfigurationHandler
|
|
||||||
{
|
|
||||||
public static final String CATEGORY_TRANSMUTATION = "transmutation";
|
|
||||||
public static Configuration configuration;
|
|
||||||
|
|
||||||
public static void init(String configPath)
|
|
||||||
{
|
|
||||||
|
|
||||||
GeneralConfiguration.init(new File(configPath + "general.properties"));
|
|
||||||
BlockConfiguration.init(new File(configPath + "block.properties"));
|
|
||||||
ItemConfiguration.init(new File(configPath + "item.properties"));
|
|
||||||
TransmutationConfiguration.init(new File(configPath + "transmutation.properties"));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,116 +0,0 @@
|
||||||
package com.pahimar.ee3.configuration;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ConfigurationSettings
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class ConfigurationSettings
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Version check related settings
|
|
||||||
*/
|
|
||||||
public static boolean DISPLAY_VERSION_RESULT;
|
|
||||||
public static final String DISPLAY_VERSION_RESULT_CONFIGNAME = "version_check.display_results";
|
|
||||||
public static final boolean DISPLAY_VERSION_RESULT_DEFAULT = true;
|
|
||||||
|
|
||||||
public static String LAST_DISCOVERED_VERSION;
|
|
||||||
public static final String LAST_DISCOVERED_VERSION_CONFIGNAME = "version_check.last_discovered_version";
|
|
||||||
public static final String LAST_DISCOVERED_VERSION_DEFAULT = "";
|
|
||||||
|
|
||||||
public static String LAST_DISCOVERED_VERSION_TYPE;
|
|
||||||
public static final String LAST_DISCOVERED_VERSION_TYPE_CONFIGNAME = "version_check.last_discovered_version_type";
|
|
||||||
public static final String LAST_DISCOVERED_VERSION_TYPE_DEFAULT = "";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Audio config settings
|
|
||||||
*/
|
|
||||||
public static String ENABLE_SOUNDS;
|
|
||||||
public static final String ENABLE_SOUNDS_CONFIGNAME = "sounds.enabled";
|
|
||||||
public static final String ENABLE_SOUNDS_DEFAULT = "all";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Graphic config settings
|
|
||||||
*/
|
|
||||||
// Whether or not EE3 particle fx are enabled
|
|
||||||
public static boolean ENABLE_PARTICLE_FX;
|
|
||||||
public static final String ENABLE_PARTICLE_FX_CONFIGNAME = "particle_fx.enabled";
|
|
||||||
public static final boolean ENABLE_PARTICLE_FX_DEFAULT = true;
|
|
||||||
|
|
||||||
// Whether or not the in world transmutation overlays are enabled
|
|
||||||
public static boolean ENABLE_OVERLAY_WORLD_TRANSMUTATION;
|
|
||||||
public static final String ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME = "world_transmutation_overlay.enabled";
|
|
||||||
public static final boolean ENABLE_OVERLAY_WORLD_TRANSMUTATION_DEFAULT = true;
|
|
||||||
|
|
||||||
public static int TARGET_BLOCK_OVERLAY_POSITION;
|
|
||||||
public static final String TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME = "block_overlay_position";
|
|
||||||
public static final int TARGET_BLOCK_OVERLAY_POSITION_DEFAULT = 3;
|
|
||||||
|
|
||||||
public static float TARGET_BLOCK_OVERLAY_OPACITY;
|
|
||||||
public static final String TARGET_BLOCK_OVERLAY_OPACITY_CONFIGNAME = "block_overlay_opacity";
|
|
||||||
public static final float TARGET_BLOCK_OVERLAY_OPACITY_DEFAULT = 0.75F;
|
|
||||||
|
|
||||||
public static float TARGET_BLOCK_OVERLAY_SCALE;
|
|
||||||
public static final String TARGET_BLOCK_OVERLAY_SCALE_CONFIGNAME = "block_overlay_scale";
|
|
||||||
public static final float TARGET_BLOCK_OVERLAY_SCALE_DEFAULT = 2.5F;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Block related config settings
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Item related config settings
|
|
||||||
*/
|
|
||||||
// The maximum durability for the Minium Stone
|
|
||||||
public static int MINIUM_STONE_MAX_DURABILITY;
|
|
||||||
public static final String MINIUM_STONE_MAX_DURABILITY_CONFIGNAME = Strings.MINIUM_STONE_NAME;
|
|
||||||
public static final int MINIUM_STONE_MAX_DURABILITY_DEFAULT = 1521;
|
|
||||||
|
|
||||||
// The maximum durability for the Philosophers Stone
|
|
||||||
public static int PHILOSOPHERS_STONE_MAX_DURABILITY;
|
|
||||||
public static final String PHILOSOPHERS_STONE_MAX_DURABILITY_CONFIGNAME = Strings.PHILOSOPHERS_STONE_NAME;
|
|
||||||
public static final int PHILOSOPHERS_STONE_MAX_DURABILITY_DEFAULT = 10001;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Keybinding related config settings
|
|
||||||
*/
|
|
||||||
// Extra key
|
|
||||||
public static final String KEYBINDING_EXTRA = "key.extra";
|
|
||||||
public static final int KEYBINDING_EXTRA_DEFAULT = Keyboard.KEY_C;
|
|
||||||
|
|
||||||
// Release key
|
|
||||||
public static final String KEYBINDING_RELEASE = "key.release";
|
|
||||||
public static final int KEYBINDING_RELEASE_DEFAULT = Keyboard.KEY_R;
|
|
||||||
|
|
||||||
// Toggle key
|
|
||||||
public static final String KEYBINDING_TOGGLE = "key.toggle";
|
|
||||||
public static final int KEYBINDING_TOGGLE_DEFAULT = Keyboard.KEY_G;
|
|
||||||
|
|
||||||
// Charge key
|
|
||||||
public static final String KEYBINDING_CHARGE = "key.charge";
|
|
||||||
public static final int KEYBINDING_CHARGE_DEFAULT = Keyboard.KEY_V;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Transmutation related config settings
|
|
||||||
*/
|
|
||||||
// The durability cost for each item transmutation
|
|
||||||
public static int TRANSMUTE_COST_ITEM;
|
|
||||||
public static final String TRANSMUTE_COST_ITEM_CONFIGNAME = Strings.TRANSMUTATION_COST_ITEM;
|
|
||||||
public static final int TRANSMUTE_COST_ITEM_DEFAULT = 1;
|
|
||||||
|
|
||||||
// The durability cost for each block transmutation
|
|
||||||
public static int TRANSMUTE_COST_BLOCK;
|
|
||||||
public static final String TRANSMUTE_COST_BLOCK_CONFIGNAME = Strings.TRANSMUTATION_COST_BLOCK;
|
|
||||||
public static final int TRANSMUTE_COST_BLOCK_DEFAULT = 1;
|
|
||||||
|
|
||||||
// The durability cost for each mob transmutation
|
|
||||||
public static int TRANSMUTE_COST_MOB;
|
|
||||||
public static final String TRANSMUTE_COST_MOB_CONFIGNAME = Strings.TRANSMUTATION_COST_MOB;
|
|
||||||
public static final int TRANSMUTE_COST_MOB_DEFAULT = 1;
|
|
||||||
}
|
|
|
@ -1,96 +0,0 @@
|
||||||
package com.pahimar.ee3.configuration;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.EquivalentExchange3;
|
|
||||||
import com.pahimar.ee3.lib.Reference;
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
|
||||||
import org.apache.logging.log4j.Level;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class GeneralConfiguration
|
|
||||||
{
|
|
||||||
public static final String CATEGORY_KEYBIND = "keybindings";
|
|
||||||
public static final String CATEGORY_GRAPHICS = "graphics";
|
|
||||||
public static final String CATEGORY_AUDIO = "audio";
|
|
||||||
private static Configuration generalConfiguration;
|
|
||||||
|
|
||||||
protected static void init(File configFile)
|
|
||||||
{
|
|
||||||
|
|
||||||
generalConfiguration = new Configuration(configFile);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
generalConfiguration.load();
|
|
||||||
|
|
||||||
/* Version check */
|
|
||||||
ConfigurationSettings.DISPLAY_VERSION_RESULT = generalConfiguration.get(Configuration.CATEGORY_GENERAL, ConfigurationSettings.DISPLAY_VERSION_RESULT_CONFIGNAME, ConfigurationSettings.DISPLAY_VERSION_RESULT_DEFAULT).getBoolean(ConfigurationSettings.DISPLAY_VERSION_RESULT_DEFAULT);
|
|
||||||
ConfigurationSettings.LAST_DISCOVERED_VERSION = generalConfiguration.get(Configuration.CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_CONFIGNAME, ConfigurationSettings.LAST_DISCOVERED_VERSION_DEFAULT).getString();
|
|
||||||
ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE = generalConfiguration.get(Configuration.CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE_CONFIGNAME, ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE_DEFAULT).getString();
|
|
||||||
|
|
||||||
/* Graphics */
|
|
||||||
ConfigurationSettings.ENABLE_PARTICLE_FX = generalConfiguration.get(CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_PARTICLE_FX_CONFIGNAME, ConfigurationSettings.ENABLE_PARTICLE_FX_DEFAULT).getBoolean(ConfigurationSettings.ENABLE_PARTICLE_FX_DEFAULT);
|
|
||||||
ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION = generalConfiguration.get(CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_DEFAULT).getBoolean(ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_DEFAULT);
|
|
||||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION = generalConfiguration.get(CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_CONFIGNAME, ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_DEFAULT).getInt(ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION_DEFAULT);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE = Float.parseFloat(generalConfiguration.get(CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE_CONFIGNAME, ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE_DEFAULT).getString());
|
|
||||||
|
|
||||||
if (ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE <= 0F)
|
|
||||||
{
|
|
||||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE = ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE_DEFAULT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE = ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE_DEFAULT;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY = Float.parseFloat(generalConfiguration.get(CATEGORY_GRAPHICS, ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY_CONFIGNAME, ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY_DEFAULT).getString());
|
|
||||||
|
|
||||||
if (ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY < 0F || ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY > 1F)
|
|
||||||
{
|
|
||||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY = ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY_DEFAULT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY = ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY_DEFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Audio */
|
|
||||||
ConfigurationSettings.ENABLE_SOUNDS = generalConfiguration.get(CATEGORY_AUDIO, ConfigurationSettings.ENABLE_SOUNDS_CONFIGNAME, ConfigurationSettings.ENABLE_SOUNDS_DEFAULT).getString();
|
|
||||||
|
|
||||||
/* KeyBindings */
|
|
||||||
generalConfiguration.addCustomCategoryComment(CATEGORY_KEYBIND, "Keybindings for Equivalent Exchange 3. See http://www.minecraftwiki.net/wiki/Key_codes for mapping of key codes to keyboard keys");
|
|
||||||
EquivalentExchange3.proxy.setKeyBinding(ConfigurationSettings.KEYBINDING_EXTRA, generalConfiguration.get(CATEGORY_KEYBIND, ConfigurationSettings.KEYBINDING_EXTRA, ConfigurationSettings.KEYBINDING_EXTRA_DEFAULT).getInt(ConfigurationSettings.KEYBINDING_EXTRA_DEFAULT));
|
|
||||||
EquivalentExchange3.proxy.setKeyBinding(ConfigurationSettings.KEYBINDING_CHARGE, generalConfiguration.get(CATEGORY_KEYBIND, ConfigurationSettings.KEYBINDING_CHARGE, ConfigurationSettings.KEYBINDING_CHARGE_DEFAULT).getInt(ConfigurationSettings.KEYBINDING_CHARGE_DEFAULT));
|
|
||||||
EquivalentExchange3.proxy.setKeyBinding(ConfigurationSettings.KEYBINDING_TOGGLE, generalConfiguration.get(CATEGORY_KEYBIND, ConfigurationSettings.KEYBINDING_TOGGLE, ConfigurationSettings.KEYBINDING_TOGGLE_DEFAULT).getInt(ConfigurationSettings.KEYBINDING_TOGGLE_DEFAULT));
|
|
||||||
EquivalentExchange3.proxy.setKeyBinding(ConfigurationSettings.KEYBINDING_RELEASE, generalConfiguration.get(CATEGORY_KEYBIND, ConfigurationSettings.KEYBINDING_RELEASE, ConfigurationSettings.KEYBINDING_RELEASE_DEFAULT).getInt(ConfigurationSettings.KEYBINDING_RELEASE_DEFAULT));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
FMLLog.log(Level.ERROR, e, Reference.MOD_NAME + " has had a problem loading its general configuration");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
generalConfiguration.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void set(String categoryName, String propertyName, String newValue)
|
|
||||||
{
|
|
||||||
|
|
||||||
generalConfiguration.load();
|
|
||||||
if (generalConfiguration.getCategoryNames().contains(categoryName))
|
|
||||||
{
|
|
||||||
if (generalConfiguration.getCategory(categoryName).containsKey(propertyName))
|
|
||||||
{
|
|
||||||
generalConfiguration.getCategory(categoryName).get(propertyName).set(newValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
generalConfiguration.save();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
package com.pahimar.ee3.configuration;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.ItemIds;
|
|
||||||
import com.pahimar.ee3.lib.Reference;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
|
||||||
import org.apache.logging.log4j.Level;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class ItemConfiguration
|
|
||||||
{
|
|
||||||
private static final String CATEGORY_DURABILITY = "durability";
|
|
||||||
private static Configuration itemConfiguration;
|
|
||||||
|
|
||||||
protected static void init(File configFile)
|
|
||||||
{
|
|
||||||
itemConfiguration = new Configuration(configFile);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
itemConfiguration.load();
|
|
||||||
|
|
||||||
/* Item configs */
|
|
||||||
ItemIds.MINIUM_SHARD = itemConfiguration.getItem(Strings.MINIUM_SHARD_NAME, ItemIds.MINIUM_SHARD_DEFAULT).getInt(ItemIds.MINIUM_SHARD_DEFAULT);
|
|
||||||
ItemIds.INERT_STONE = itemConfiguration.getItem(Strings.INERT_STONE_NAME, ItemIds.INERT_STONE_DEFAULT).getInt(ItemIds.INERT_STONE_DEFAULT);
|
|
||||||
ItemIds.MINIUM_STONE = itemConfiguration.getItem(Strings.MINIUM_STONE_NAME, ItemIds.MINIUM_STONE_DEFAULT).getInt(ItemIds.MINIUM_STONE_DEFAULT);
|
|
||||||
ItemIds.PHILOSOPHERS_STONE = itemConfiguration.getItem(Strings.PHILOSOPHERS_STONE_NAME, ItemIds.PHILOSOPHERS_STONE_DEFAULT).getInt(ItemIds.PHILOSOPHERS_STONE_DEFAULT);
|
|
||||||
ItemIds.ALCHEMICAL_DUST = itemConfiguration.getItem(Strings.ALCHEMICAL_DUST_NAME, ItemIds.ALCHEMICAL_DUST_DEFAULT).getInt(ItemIds.ALCHEMICAL_DUST_DEFAULT);
|
|
||||||
ItemIds.ALCHEMICAL_BAG = itemConfiguration.getItem(Strings.ALCHEMICAL_BAG_NAME, ItemIds.ALCHEMICAL_BAG_DEFAULT).getInt(ItemIds.ALCHEMICAL_BAG_DEFAULT);
|
|
||||||
ItemIds.CHALK = itemConfiguration.getItem(Strings.CHALK_NAME, ItemIds.CHALK_DEFAULT).getInt(ItemIds.CHALK_DEFAULT);
|
|
||||||
ItemIds.DIVINING_ROD = itemConfiguration.getItem(Strings.DIVINING_ROD_NAME, ItemIds.DIVINING_ROD_DEFAULT).getInt(ItemIds.DIVINING_ROD_DEFAULT);
|
|
||||||
ItemIds.ALCHEMICAL_FUEL = itemConfiguration.getItem(Strings.ALCHEMICAL_FUEL_NAME, ItemIds.ALCHEMICAL_FUEL_DEFAULT).getInt(ItemIds.ALCHEMICAL_FUEL_DEFAULT);
|
|
||||||
ItemIds.ALCHEMICAL_UPGRADE = itemConfiguration.getItem(Strings.ALCHEMICAL_UPGRADE_NAME, ItemIds.ALCHEMICAL_UPGRADE_DEFAULT).getInt(ItemIds.ALCHEMICAL_UPGRADE_DEFAULT);
|
|
||||||
|
|
||||||
/* Item durability configs */
|
|
||||||
ConfigurationSettings.MINIUM_STONE_MAX_DURABILITY = itemConfiguration.get(CATEGORY_DURABILITY, ConfigurationSettings.MINIUM_STONE_MAX_DURABILITY_CONFIGNAME, ConfigurationSettings.MINIUM_STONE_MAX_DURABILITY_DEFAULT).getInt(ConfigurationSettings.MINIUM_STONE_MAX_DURABILITY_DEFAULT);
|
|
||||||
ConfigurationSettings.PHILOSOPHERS_STONE_MAX_DURABILITY = itemConfiguration.get(CATEGORY_DURABILITY, ConfigurationSettings.PHILOSOPHERS_STONE_MAX_DURABILITY_CONFIGNAME, ConfigurationSettings.PHILOSOPHERS_STONE_MAX_DURABILITY_DEFAULT).getInt(ConfigurationSettings.PHILOSOPHERS_STONE_MAX_DURABILITY_DEFAULT);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
FMLLog.log(Level.ERROR, e, Reference.MOD_NAME + " has had a problem loading its item configuration");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
itemConfiguration.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package com.pahimar.ee3.configuration;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Reference;
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
|
||||||
import org.apache.logging.log4j.Level;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class TransmutationConfiguration
|
|
||||||
{
|
|
||||||
private static final String CATEGORY_TRANSMUTATION = "transmutation";
|
|
||||||
private static Configuration transmutationConfiguration;
|
|
||||||
|
|
||||||
protected static void init(File configFile)
|
|
||||||
{
|
|
||||||
|
|
||||||
transmutationConfiguration = new Configuration(configFile);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
transmutationConfiguration.load();
|
|
||||||
|
|
||||||
/* Transmutation configs */
|
|
||||||
ConfigurationSettings.TRANSMUTE_COST_ITEM = transmutationConfiguration.get(CATEGORY_TRANSMUTATION, ConfigurationSettings.TRANSMUTE_COST_ITEM_CONFIGNAME, ConfigurationSettings.TRANSMUTE_COST_ITEM_DEFAULT).getInt(ConfigurationSettings.TRANSMUTE_COST_ITEM_DEFAULT);
|
|
||||||
ConfigurationSettings.TRANSMUTE_COST_BLOCK = transmutationConfiguration.get(CATEGORY_TRANSMUTATION, ConfigurationSettings.TRANSMUTE_COST_BLOCK_CONFIGNAME, ConfigurationSettings.TRANSMUTE_COST_BLOCK_DEFAULT).getInt(ConfigurationSettings.TRANSMUTE_COST_BLOCK_DEFAULT);
|
|
||||||
ConfigurationSettings.TRANSMUTE_COST_MOB = transmutationConfiguration.get(CATEGORY_TRANSMUTATION, ConfigurationSettings.TRANSMUTE_COST_MOB_CONFIGNAME, ConfigurationSettings.TRANSMUTE_COST_MOB_DEFAULT).getInt(ConfigurationSettings.TRANSMUTE_COST_MOB_DEFAULT);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
FMLLog.log(Level.ERROR, e, Reference.MOD_NAME + " has had a problem loading its transmutation configuration");
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
transmutationConfiguration.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
27
src/main/java/com/pahimar/ee3/creativetab/CreativeTab.java
Normal file
27
src/main/java/com/pahimar/ee3/creativetab/CreativeTab.java
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package com.pahimar.ee3.creativetab;
|
||||||
|
|
||||||
|
import com.pahimar.ee3.reference.Reference;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
|
public class CreativeTab
|
||||||
|
{
|
||||||
|
public static final CreativeTabs EE3_TAB = new CreativeTabs(Reference.MOD_ID)
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Item getTabIconItem()
|
||||||
|
{
|
||||||
|
return Items.baked_potato;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public String getTranslatedTabLabel()
|
||||||
|
{
|
||||||
|
return "Equivalent Exchange 3";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,24 +0,0 @@
|
||||||
package com.pahimar.ee3.creativetab;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Reference;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* CreativeTabEE3
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class CreativeTabEE3
|
|
||||||
{
|
|
||||||
public static final CreativeTabs tabEE3 = new CreativeTabs(Reference.MOD_ID)
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Item getTabIconItem()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,70 +0,0 @@
|
||||||
package com.pahimar.ee3.emc;
|
|
||||||
|
|
||||||
public class EmcComponent implements Comparable<EmcComponent>
|
|
||||||
{
|
|
||||||
|
|
||||||
public final EmcType type;
|
|
||||||
public final int weight;
|
|
||||||
|
|
||||||
public EmcComponent(EmcType type, int weight)
|
|
||||||
{
|
|
||||||
|
|
||||||
this.type = type;
|
|
||||||
|
|
||||||
if (weight > 0)
|
|
||||||
{
|
|
||||||
this.weight = weight;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.weight = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmcComponent(EmcType type)
|
|
||||||
{
|
|
||||||
|
|
||||||
this(type, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object object)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!(object instanceof EmcComponent))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
EmcComponent emcComponent = (EmcComponent) object;
|
|
||||||
|
|
||||||
return ((this.type == emcComponent.type) && (this.weight == emcComponent.weight));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return String.format("<EMC Type: %s, Weight: %s>", type, weight);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(EmcComponent emcComponent)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (emcComponent != null)
|
|
||||||
{
|
|
||||||
if (this.type == emcComponent.type)
|
|
||||||
{
|
|
||||||
return (this.weight - emcComponent.weight);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return this.type.compareTo(emcComponent.type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,512 +0,0 @@
|
||||||
package com.pahimar.ee3.emc;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSortedMap;
|
|
||||||
import com.pahimar.ee3.api.OreStack;
|
|
||||||
import com.pahimar.ee3.api.WrappedStack;
|
|
||||||
import com.pahimar.ee3.helper.EmcHelper;
|
|
||||||
import com.pahimar.ee3.lib.Compare;
|
|
||||||
import com.pahimar.ee3.recipe.RecipeRegistry;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class EmcRegistry
|
|
||||||
{
|
|
||||||
private static EmcRegistry emcRegistry = null;
|
|
||||||
|
|
||||||
private ImmutableSortedMap<WrappedStack, EmcValue> stackMappings;
|
|
||||||
private ImmutableSortedMap<EmcValue, List<WrappedStack>> valueMappings;
|
|
||||||
|
|
||||||
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>();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default values
|
|
||||||
*/
|
|
||||||
Map<WrappedStack, EmcValue> defaultValuesMap = EmcValuesDefault.getDefaultValueMap();
|
|
||||||
for (WrappedStack keyStack : defaultValuesMap.keySet())
|
|
||||||
{
|
|
||||||
EmcValue factoredEmcValue = null;
|
|
||||||
WrappedStack factoredKeyStack = null;
|
|
||||||
|
|
||||||
if (keyStack != null && keyStack.getWrappedStack() != null && keyStack.getStackSize() > 0)
|
|
||||||
{
|
|
||||||
if (defaultValuesMap.get(keyStack) != null && Float.compare(defaultValuesMap.get(keyStack).getValue(), 0f) > Compare.EQUALS)
|
|
||||||
{
|
|
||||||
factoredEmcValue = EmcHelper.factorEmcValue(defaultValuesMap.get(keyStack), keyStack.getStackSize());
|
|
||||||
factoredKeyStack = new WrappedStack(keyStack, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (factoredEmcValue != null)
|
|
||||||
{
|
|
||||||
if (stackValueMap.containsKey(factoredKeyStack))
|
|
||||||
{
|
|
||||||
if (factoredEmcValue.compareTo(stackValueMap.get(factoredKeyStack)) == Compare.LESSER_THAN)
|
|
||||||
{
|
|
||||||
stackValueMap.put(factoredKeyStack, factoredEmcValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stackValueMap.put(factoredKeyStack, factoredEmcValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* IMC Pre-assigned values
|
|
||||||
*/
|
|
||||||
Map<WrappedStack, EmcValue> preAssignedValuesMap = EmcValuesIMC.getPreAssignedValues();
|
|
||||||
for (WrappedStack keyStack : preAssignedValuesMap.keySet())
|
|
||||||
{
|
|
||||||
EmcValue factoredEmcValue = null;
|
|
||||||
WrappedStack factoredKeyStack = null;
|
|
||||||
|
|
||||||
if (keyStack != null && keyStack.getWrappedStack() != null && keyStack.getStackSize() > 0)
|
|
||||||
{
|
|
||||||
if (preAssignedValuesMap.get(keyStack) != null && Float.compare(preAssignedValuesMap.get(keyStack).getValue(), 0f) > Compare.EQUALS)
|
|
||||||
{
|
|
||||||
factoredEmcValue = EmcHelper.factorEmcValue(preAssignedValuesMap.get(keyStack), keyStack.getStackSize());
|
|
||||||
factoredKeyStack = new WrappedStack(keyStack, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (factoredEmcValue != null)
|
|
||||||
{
|
|
||||||
if (stackValueMap.containsKey(factoredKeyStack))
|
|
||||||
{
|
|
||||||
if (factoredEmcValue.compareTo(stackValueMap.get(factoredKeyStack)) == Compare.LESSER_THAN)
|
|
||||||
{
|
|
||||||
stackValueMap.put(factoredKeyStack, factoredEmcValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stackValueMap.put(factoredKeyStack, factoredEmcValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Auto-assignment
|
|
||||||
*/
|
|
||||||
// Initialize the maps for the first pass to happen
|
|
||||||
ImmutableSortedMap.Builder<WrappedStack, EmcValue> stackMappingsBuilder = ImmutableSortedMap.naturalOrder();
|
|
||||||
stackMappingsBuilder.putAll(stackValueMap);
|
|
||||||
stackMappings = stackMappingsBuilder.build();
|
|
||||||
Map<WrappedStack, EmcValue> computedStackValues = computeStackMappings();
|
|
||||||
|
|
||||||
// Initialize the pass counter
|
|
||||||
int passNumber = 0;
|
|
||||||
|
|
||||||
while ((computedStackValues.size() > 0) && (passNumber < 16))
|
|
||||||
{
|
|
||||||
// Increment the pass counter
|
|
||||||
passNumber++;
|
|
||||||
|
|
||||||
// Set the values for getEmcValue calls in the auto-assignment computation
|
|
||||||
stackMappingsBuilder = ImmutableSortedMap.naturalOrder();
|
|
||||||
stackMappingsBuilder.putAll(stackValueMap);
|
|
||||||
stackMappings = stackMappingsBuilder.build();
|
|
||||||
|
|
||||||
// Compute stack mappings from existing stack mappings
|
|
||||||
computedStackValues = computeStackMappings();
|
|
||||||
for (WrappedStack keyStack : computedStackValues.keySet())
|
|
||||||
{
|
|
||||||
EmcValue factoredEmcValue = null;
|
|
||||||
WrappedStack factoredKeyStack = null;
|
|
||||||
|
|
||||||
if (keyStack != null && keyStack.getWrappedStack() != null && keyStack.getStackSize() > 0)
|
|
||||||
{
|
|
||||||
if (computedStackValues.get(keyStack) != null && Float.compare(computedStackValues.get(keyStack).getValue(), 0f) > Compare.EQUALS)
|
|
||||||
{
|
|
||||||
factoredEmcValue = EmcHelper.factorEmcValue(computedStackValues.get(keyStack), keyStack.getStackSize());
|
|
||||||
factoredKeyStack = new WrappedStack(keyStack, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (factoredEmcValue != null)
|
|
||||||
{
|
|
||||||
if (stackValueMap.containsKey(factoredKeyStack))
|
|
||||||
{
|
|
||||||
if (factoredEmcValue.compareTo(stackValueMap.get(factoredKeyStack)) == Compare.LESSER_THAN)
|
|
||||||
{
|
|
||||||
stackValueMap.put(factoredKeyStack, factoredEmcValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stackValueMap.put(factoredKeyStack, factoredEmcValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* IMC Post-assigned values
|
|
||||||
*/
|
|
||||||
Map<WrappedStack, EmcValue> postAssignedValuesMap = EmcValuesIMC.getPostAssignedValues();
|
|
||||||
for (WrappedStack keyStack : postAssignedValuesMap.keySet())
|
|
||||||
{
|
|
||||||
EmcValue factoredEmcValue = null;
|
|
||||||
WrappedStack factoredKeyStack = null;
|
|
||||||
|
|
||||||
if (keyStack != null && keyStack.getWrappedStack() != null && keyStack.getStackSize() > 0)
|
|
||||||
{
|
|
||||||
if (postAssignedValuesMap.get(keyStack) != null && Float.compare(postAssignedValuesMap.get(keyStack).getValue(), 0f) > Compare.EQUALS)
|
|
||||||
{
|
|
||||||
factoredEmcValue = EmcHelper.factorEmcValue(postAssignedValuesMap.get(keyStack), keyStack.getStackSize());
|
|
||||||
factoredKeyStack = new WrappedStack(keyStack, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Post auto assignment values are meant to override all over values, so we just take the value given
|
|
||||||
if (factoredEmcValue != null)
|
|
||||||
{
|
|
||||||
stackValueMap.put(factoredKeyStack, factoredEmcValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finalize the stack to value map
|
|
||||||
*/
|
|
||||||
stackMappingsBuilder = ImmutableSortedMap.naturalOrder();
|
|
||||||
stackMappingsBuilder.putAll(stackValueMap);
|
|
||||||
stackMappings = stackMappingsBuilder.build();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Value map resolution
|
|
||||||
*/
|
|
||||||
SortedMap<EmcValue, List<WrappedStack>> tempValueMappings = new TreeMap<EmcValue, List<WrappedStack>>();
|
|
||||||
|
|
||||||
for (WrappedStack stack : stackMappings.keySet())
|
|
||||||
{
|
|
||||||
if (stack != null)
|
|
||||||
{
|
|
||||||
EmcValue value = stackMappings.get(stack);
|
|
||||||
|
|
||||||
if (value != null)
|
|
||||||
{
|
|
||||||
if (tempValueMappings.containsKey(value))
|
|
||||||
{
|
|
||||||
if (!(tempValueMappings.get(value).contains(stack)))
|
|
||||||
{
|
|
||||||
tempValueMappings.get(value).add(stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tempValueMappings.put(value, new ArrayList<WrappedStack>(Arrays.asList(stack)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
valueMappings = ImmutableSortedMap.copyOf(tempValueMappings);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<WrappedStack, EmcValue> computeStackMappings()
|
|
||||||
{
|
|
||||||
Map<WrappedStack, EmcValue> computedStackMap = new HashMap<WrappedStack, EmcValue>();
|
|
||||||
|
|
||||||
for (WrappedStack recipeOutput : RecipeRegistry.getInstance().getRecipeMappings().keySet())
|
|
||||||
{
|
|
||||||
if (!hasEmcValue(recipeOutput.getWrappedStack(), false) && !computedStackMap.containsKey(recipeOutput))
|
|
||||||
{
|
|
||||||
EmcValue lowestValue = null;
|
|
||||||
|
|
||||||
for (List<WrappedStack> recipeInputs : RecipeRegistry.getInstance().getRecipeMappings().get(recipeOutput))
|
|
||||||
{
|
|
||||||
EmcValue computedValue = EmcHelper.computeEmcValueFromList(recipeInputs);
|
|
||||||
computedValue = EmcHelper.factorEmcValue(computedValue, recipeOutput.getStackSize());
|
|
||||||
|
|
||||||
if (computedValue != null)
|
|
||||||
{
|
|
||||||
if (computedValue.compareTo(lowestValue) < 0)
|
|
||||||
{
|
|
||||||
lowestValue = computedValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((lowestValue != null) && (lowestValue.getValue() > 0f))
|
|
||||||
{
|
|
||||||
computedStackMap.put(new WrappedStack(recipeOutput.getWrappedStack()), lowestValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return computedStackMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasEmcValue(Object object, boolean strict)
|
|
||||||
{
|
|
||||||
if (WrappedStack.canBeWrapped(object))
|
|
||||||
{
|
|
||||||
WrappedStack stack = new WrappedStack(object);
|
|
||||||
|
|
||||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(stack.getWrappedStack())))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!strict)
|
|
||||||
{
|
|
||||||
if (stack.getWrappedStack() instanceof ItemStack)
|
|
||||||
{
|
|
||||||
ItemStack wrappedItemStack = (ItemStack) stack.getWrappedStack();
|
|
||||||
|
|
||||||
// If its an OreDictionary item, scan its siblings for values
|
|
||||||
if (OreDictionary.getOreID(wrappedItemStack) != -1)
|
|
||||||
{
|
|
||||||
|
|
||||||
OreStack oreStack = new OreStack(wrappedItemStack);
|
|
||||||
|
|
||||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(oreStack)))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (ItemStack itemStack : OreDictionary.getOres(OreDictionary.getOreID(wrappedItemStack)))
|
|
||||||
{
|
|
||||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(itemStack)))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Else, scan for if there is a wildcard value for it
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (WrappedStack valuedStack : emcRegistry.stackMappings.keySet())
|
|
||||||
{
|
|
||||||
if (valuedStack.getWrappedStack() instanceof ItemStack)
|
|
||||||
{
|
|
||||||
ItemStack valuedItemStack = (ItemStack) valuedStack.getWrappedStack();
|
|
||||||
|
|
||||||
if (valuedItemStack.itemID == wrappedItemStack.itemID)
|
|
||||||
{
|
|
||||||
if (valuedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE || wrappedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (wrappedItemStack.getItem().isDamageable() && wrappedItemStack.isItemDamaged())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (stack.getWrappedStack() instanceof OreStack)
|
|
||||||
{
|
|
||||||
OreStack oreStack = (OreStack)stack.getWrappedStack();
|
|
||||||
for (ItemStack oreItemStack : OreDictionary.getOres(oreStack.oreName))
|
|
||||||
{
|
|
||||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(oreItemStack)))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasEmcValue(Object object)
|
|
||||||
{
|
|
||||||
return hasEmcValue(object, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmcValue getEmcValue(Object object, boolean strict)
|
|
||||||
{
|
|
||||||
if (WrappedStack.canBeWrapped(object))
|
|
||||||
{
|
|
||||||
WrappedStack stack = new WrappedStack(object);
|
|
||||||
|
|
||||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(stack.getWrappedStack())))
|
|
||||||
{
|
|
||||||
return emcRegistry.stackMappings.get(new WrappedStack(stack.getWrappedStack()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!strict)
|
|
||||||
{
|
|
||||||
if (stack.getWrappedStack() instanceof ItemStack)
|
|
||||||
{
|
|
||||||
EmcValue lowestValue = null;
|
|
||||||
ItemStack wrappedItemStack = (ItemStack) stack.getWrappedStack();
|
|
||||||
|
|
||||||
if (OreDictionary.getOreID(wrappedItemStack) != -1)
|
|
||||||
{
|
|
||||||
OreStack oreStack = new OreStack(wrappedItemStack);
|
|
||||||
|
|
||||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(oreStack)))
|
|
||||||
{
|
|
||||||
return emcRegistry.stackMappings.get(new WrappedStack(oreStack));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (ItemStack itemStack : OreDictionary.getOres(OreDictionary.getOreID(wrappedItemStack)))
|
|
||||||
{
|
|
||||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(itemStack)))
|
|
||||||
{
|
|
||||||
if (lowestValue == null)
|
|
||||||
{
|
|
||||||
lowestValue = emcRegistry.stackMappings.get(new WrappedStack(itemStack));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EmcValue itemValue = emcRegistry.stackMappings.get(new WrappedStack(itemStack));
|
|
||||||
|
|
||||||
if (itemValue.compareTo(lowestValue) < 0)
|
|
||||||
{
|
|
||||||
lowestValue = itemValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lowestValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (WrappedStack valuedStack : emcRegistry.stackMappings.keySet())
|
|
||||||
{
|
|
||||||
if (valuedStack.getWrappedStack() instanceof ItemStack)
|
|
||||||
{
|
|
||||||
ItemStack valuedItemStack = (ItemStack) valuedStack.getWrappedStack();
|
|
||||||
|
|
||||||
if (valuedItemStack.itemID == wrappedItemStack.itemID)
|
|
||||||
{
|
|
||||||
if (valuedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE || wrappedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE)
|
|
||||||
{
|
|
||||||
EmcValue stackValue = emcRegistry.stackMappings.get(valuedStack);
|
|
||||||
|
|
||||||
if (stackValue.compareTo(lowestValue) < 0)
|
|
||||||
{
|
|
||||||
lowestValue = stackValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (wrappedItemStack.getItem().isDamageable() && wrappedItemStack.isItemDamaged())
|
|
||||||
{
|
|
||||||
EmcValue stackValue = new EmcValue(emcRegistry.stackMappings.get(valuedStack).getValue() * (1 - (wrappedItemStack.getItemDamage() * 1.0F / wrappedItemStack.getMaxDamage())));
|
|
||||||
|
|
||||||
if (stackValue.compareTo(lowestValue) < 0)
|
|
||||||
{
|
|
||||||
lowestValue = stackValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lowestValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (stack.getWrappedStack() instanceof OreStack)
|
|
||||||
{
|
|
||||||
OreStack oreStack = (OreStack)stack.getWrappedStack();
|
|
||||||
for (ItemStack oreItemStack : OreDictionary.getOres(oreStack.oreName))
|
|
||||||
{
|
|
||||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(oreItemStack)))
|
|
||||||
{
|
|
||||||
return emcRegistry.stackMappings.get(new WrappedStack(oreItemStack));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmcValue getEmcValue(Object object)
|
|
||||||
{
|
|
||||||
return getEmcValue(object, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public List<WrappedStack> getStacksInRange(int start, int finish)
|
|
||||||
{
|
|
||||||
return getStacksInRange(new EmcValue(start), new EmcValue(finish));
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<WrappedStack> getStacksInRange(float start, float finish)
|
|
||||||
{
|
|
||||||
return getStacksInRange(new EmcValue(start), new EmcValue(finish));
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<WrappedStack> getStacksInRange(EmcValue start, EmcValue finish)
|
|
||||||
{
|
|
||||||
List<WrappedStack> stacksInRange = new ArrayList<WrappedStack>();
|
|
||||||
|
|
||||||
SortedMap<EmcValue, List<WrappedStack>> tailMap = emcRegistry.valueMappings.tailMap(start);
|
|
||||||
SortedMap<EmcValue, List<WrappedStack>> headMap = emcRegistry.valueMappings.headMap(finish);
|
|
||||||
|
|
||||||
SortedMap<EmcValue, List<WrappedStack>> smallerMap;
|
|
||||||
SortedMap<EmcValue, List<WrappedStack>> biggerMap;
|
|
||||||
|
|
||||||
if (!tailMap.isEmpty() && !headMap.isEmpty())
|
|
||||||
{
|
|
||||||
|
|
||||||
if (tailMap.size() <= headMap.size())
|
|
||||||
{
|
|
||||||
smallerMap = tailMap;
|
|
||||||
biggerMap = headMap;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
smallerMap = headMap;
|
|
||||||
biggerMap = tailMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (EmcValue value : smallerMap.keySet())
|
|
||||||
{
|
|
||||||
if (biggerMap.containsKey(value))
|
|
||||||
{
|
|
||||||
stacksInRange.addAll(emcRegistry.valueMappings.get(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return stacksInRange;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImmutableSortedMap<WrappedStack, EmcValue> getStackToEmcValueMap()
|
|
||||||
{
|
|
||||||
return stackMappings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImmutableSortedMap<EmcValue, List<WrappedStack>> getEmcValueToStackMap()
|
|
||||||
{
|
|
||||||
return valueMappings;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package com.pahimar.ee3.emc;
|
|
||||||
|
|
||||||
public enum EmcType
|
|
||||||
{
|
|
||||||
OMNI, CORPOREAL, KINETIC, TEMPORAL, ESSENTIA, AMORPHOUS, VOID;
|
|
||||||
|
|
||||||
public static final EmcType[] TYPES = EmcType.values();
|
|
||||||
|
|
||||||
public static final EmcType DEFAULT = EmcType.CORPOREAL;
|
|
||||||
}
|
|
|
@ -1,320 +0,0 @@
|
||||||
package com.pahimar.ee3.emc;
|
|
||||||
|
|
||||||
import com.google.gson.*;
|
|
||||||
import com.pahimar.ee3.helper.LogHelper;
|
|
||||||
import com.pahimar.ee3.lib.Compare;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* EMCEntry
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue>, JsonSerializer<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 = 4;
|
|
||||||
|
|
||||||
public final float[] components;
|
|
||||||
|
|
||||||
public EmcValue()
|
|
||||||
{
|
|
||||||
this(new float[EmcType.TYPES.length]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmcValue(int value)
|
|
||||||
{
|
|
||||||
this((float) value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmcValue(float value)
|
|
||||||
{
|
|
||||||
this(value, EmcType.DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmcValue(float value, EmcComponent component)
|
|
||||||
{
|
|
||||||
this(value, component.type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmcValue(int value, EmcType emcType)
|
|
||||||
{
|
|
||||||
this((float) value, emcType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmcValue(float value, EmcType emcType)
|
|
||||||
{
|
|
||||||
this(value, Arrays.asList(new EmcComponent(emcType)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public EmcValue(float[] components)
|
|
||||||
{
|
|
||||||
if (components.length == EmcType.TYPES.length)
|
|
||||||
{
|
|
||||||
// this.components = components;
|
|
||||||
this.components = new float[components.length];
|
|
||||||
for (int i = 0; i < this.components.length; i++)
|
|
||||||
{
|
|
||||||
BigDecimal bigComponent = BigDecimal.valueOf(components[i]).setScale(PRECISION, BigDecimal.ROUND_HALF_DOWN);
|
|
||||||
this.components[i] = bigComponent.floatValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
|
|
||||||
int totalComponents = 0;
|
|
||||||
|
|
||||||
for (EmcComponent component : collatedComponents)
|
|
||||||
{
|
|
||||||
if (component.weight > 0)
|
|
||||||
{
|
|
||||||
totalComponents += component.weight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (totalComponents > 0)
|
|
||||||
{
|
|
||||||
for (EmcComponent component : collatedComponents)
|
|
||||||
{
|
|
||||||
if (component.weight > 0)
|
|
||||||
{
|
|
||||||
this.components[component.type.ordinal()] = value * (component.weight * 1F / totalComponents);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.components[EmcType.DEFAULT.ordinal()] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < this.components.length; i++)
|
|
||||||
{
|
|
||||||
BigDecimal bigComponent = BigDecimal.valueOf(this.components[i]).setScale(PRECISION, BigDecimal.ROUND_HALF_DOWN);
|
|
||||||
this.components[i] = bigComponent.floatValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserializes an EmcValue object from the given serialized json String
|
|
||||||
*
|
|
||||||
* @param jsonEmcValue
|
|
||||||
* Json encoded String representing a EmcValue object
|
|
||||||
*
|
|
||||||
* @return The EmcValue that was encoded as json, or null if a valid EmcValue could not be decoded from given String
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public static EmcValue createFromJson(String jsonEmcValue)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return gsonSerializer.fromJson(jsonEmcValue, EmcValue.class);
|
|
||||||
}
|
|
||||||
catch (JsonSyntaxException exception)
|
|
||||||
{
|
|
||||||
LogHelper.error(exception.getMessage());
|
|
||||||
}
|
|
||||||
catch (JsonParseException exception)
|
|
||||||
{
|
|
||||||
LogHelper.error(exception.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<EmcComponent> collateComponents(List<EmcComponent> uncollatedComponents)
|
|
||||||
{
|
|
||||||
Integer[] componentCount = new Integer[EmcType.TYPES.length];
|
|
||||||
|
|
||||||
for (EmcComponent emcComponent : uncollatedComponents)
|
|
||||||
{
|
|
||||||
if (componentCount[emcComponent.type.ordinal()] == null)
|
|
||||||
{
|
|
||||||
componentCount[emcComponent.type.ordinal()] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (emcComponent.weight >= 0)
|
|
||||||
{
|
|
||||||
componentCount[emcComponent.type.ordinal()] = componentCount[emcComponent.type.ordinal()] + emcComponent.weight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<EmcComponent> collatedComponents = new ArrayList<EmcComponent>();
|
|
||||||
|
|
||||||
for (int i = 0; i < EmcType.TYPES.length; i++)
|
|
||||||
{
|
|
||||||
if (componentCount[i] != null)
|
|
||||||
{
|
|
||||||
collatedComponents.add(new EmcComponent(EmcType.TYPES[i], componentCount[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.sort(collatedComponents);
|
|
||||||
|
|
||||||
return collatedComponents;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int compareComponents(float[] first, float[] second)
|
|
||||||
{
|
|
||||||
if (first.length == EmcType.TYPES.length && second.length == EmcType.TYPES.length)
|
|
||||||
{
|
|
||||||
|
|
||||||
for (EmcType emcType : EmcType.TYPES)
|
|
||||||
{
|
|
||||||
if (Float.compare(first[emcType.ordinal()], second[emcType.ordinal()]) != Compare.EQUALS)
|
|
||||||
{
|
|
||||||
return Float.compare(first[emcType.ordinal()], second[emcType.ordinal()]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Compare.EQUALS;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new ArrayIndexOutOfBoundsException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getValue()
|
|
||||||
{
|
|
||||||
float sumSubValues = 0;
|
|
||||||
|
|
||||||
for (float subValue : this.components)
|
|
||||||
{
|
|
||||||
if (subValue > 0)
|
|
||||||
{
|
|
||||||
sumSubValues += subValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sumSubValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object object)
|
|
||||||
{
|
|
||||||
return object instanceof EmcValue && (compareTo((EmcValue) object) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
|
|
||||||
stringBuilder.append("[");
|
|
||||||
for (EmcType emcType : EmcType.TYPES)
|
|
||||||
{
|
|
||||||
if (components[emcType.ordinal()] > 0)
|
|
||||||
{
|
|
||||||
stringBuilder.append(String.format(" %s:%s ", emcType, components[emcType.ordinal()]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stringBuilder.append("]");
|
|
||||||
|
|
||||||
return stringBuilder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
int hashCode = 1;
|
|
||||||
|
|
||||||
hashCode = 37 * hashCode + Float.floatToIntBits(getValue());
|
|
||||||
for (float subValue : components)
|
|
||||||
{
|
|
||||||
hashCode = 37 * hashCode + Float.floatToIntBits(subValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hashCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(EmcValue emcValue)
|
|
||||||
{
|
|
||||||
if (emcValue != null)
|
|
||||||
{
|
|
||||||
return compareComponents(this.components, emcValue.components);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.LESSER_THAN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns this EmcValue as a json serialized String
|
|
||||||
*
|
|
||||||
* @return Json serialized String of this EmcValue
|
|
||||||
*/
|
|
||||||
public String toJson()
|
|
||||||
{
|
|
||||||
return gsonSerializer.toJson(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonElement serialize(EmcValue emcValue, Type type, JsonSerializationContext context)
|
|
||||||
{
|
|
||||||
JsonObject jsonEmcValue = new JsonObject();
|
|
||||||
|
|
||||||
for (EmcType emcType : EmcType.TYPES)
|
|
||||||
{
|
|
||||||
jsonEmcValue.addProperty(emcType.toString(), emcValue.components[emcType.ordinal()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return jsonEmcValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EmcValue deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException
|
|
||||||
{
|
|
||||||
|
|
||||||
float[] emcValueComponents = new float[EmcType.TYPES.length];
|
|
||||||
JsonObject jsonEmcValue = (JsonObject) jsonElement;
|
|
||||||
|
|
||||||
for (EmcType emcType : EmcType.TYPES)
|
|
||||||
{
|
|
||||||
if ((jsonEmcValue.get(emcType.toString()) != null) && (jsonEmcValue.get(emcType.toString()).isJsonPrimitive()))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
emcValueComponents[emcType.ordinal()] = jsonEmcValue.get(emcType.toString()).getAsFloat();
|
|
||||||
}
|
|
||||||
catch (UnsupportedOperationException exception)
|
|
||||||
{
|
|
||||||
LogHelper.error(exception.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EmcValue emcValue = new EmcValue(emcValueComponents);
|
|
||||||
|
|
||||||
if (emcValue.getValue() > 0f)
|
|
||||||
{
|
|
||||||
return emcValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,201 +0,0 @@
|
||||||
package com.pahimar.ee3.emc;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.api.OreStack;
|
|
||||||
import com.pahimar.ee3.api.WrappedStack;
|
|
||||||
import com.pahimar.ee3.item.ModItems;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class EmcValuesDefault
|
|
||||||
{
|
|
||||||
private static EmcValuesDefault emcDefaultValues = null;
|
|
||||||
private Map<WrappedStack, EmcValue> valueMap;
|
|
||||||
|
|
||||||
private EmcValuesDefault()
|
|
||||||
{
|
|
||||||
valueMap = new HashMap<WrappedStack, EmcValue>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void lazyInit()
|
|
||||||
{
|
|
||||||
if (emcDefaultValues == null)
|
|
||||||
{
|
|
||||||
emcDefaultValues = new EmcValuesDefault();
|
|
||||||
emcDefaultValues.init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
// OreDictionary assignment
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.cobblestone))), new EmcValue(1));
|
|
||||||
for (int meta = 0; meta < 16; meta++)
|
|
||||||
{
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Item.dyePowder, 1, meta))), new EmcValue(8));
|
|
||||||
}
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.wood))), new EmcValue(32));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.oreDiamond))), new EmcValue(8192));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.oreEmerald))), new EmcValue(8192));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.oreGold))), new EmcValue(2048));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.oreIron))), new EmcValue(256));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.oreLapis))), new EmcValue(864));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.oreNetherQuartz))), new EmcValue(256));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.oreRedstone))), new EmcValue(32));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.oreRedstoneGlowing))), new EmcValue(32));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.planks))), new EmcValue(8));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Item.record11))), new EmcValue(2048));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.woodSingleSlab))), new EmcValue(4));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.stairsWoodOak))), new EmcValue(12));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Item.stick))), new EmcValue(4));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.stone))), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.leaves))), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.sapling))), new EmcValue(32));
|
|
||||||
|
|
||||||
// Fluids
|
|
||||||
valueMap.put(new WrappedStack(FluidRegistry.WATER), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(FluidRegistry.LAVA), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(FluidRegistry.getFluid("milk")), new EmcValue(64));
|
|
||||||
|
|
||||||
/* Building Blocks */
|
|
||||||
valueMap.put(new WrappedStack(Block.stone), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Block.grass), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Block.dirt), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Block.cobblestone), new EmcValue(1));
|
|
||||||
// Bedrock (7:0)
|
|
||||||
valueMap.put(new WrappedStack(Block.sand), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Block.gravel), new EmcValue(4));
|
|
||||||
valueMap.put(new WrappedStack(Block.oreCoal), new EmcValue(32));
|
|
||||||
// Sponge (19:0)
|
|
||||||
valueMap.put(new WrappedStack(Block.glass), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Block.sandStone), new EmcValue(4));
|
|
||||||
valueMap.put(new WrappedStack(Block.cobblestoneMossy), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Block.obsidian), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(Block.ice), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Block.pumpkin), new EmcValue(144));
|
|
||||||
valueMap.put(new WrappedStack(Block.netherrack), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Block.slowSand), new EmcValue(49));
|
|
||||||
valueMap.put(new WrappedStack(new ItemStack(Block.stoneBrick, 1, 1)), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(new ItemStack(Block.stoneBrick, 1, OreDictionary.WILDCARD_VALUE)), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Block.mycelium), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Block.whiteStone), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Block.hardenedClay), new EmcValue(256));
|
|
||||||
|
|
||||||
/* Decoration Blocks */
|
|
||||||
valueMap.put(new WrappedStack(Block.web), new EmcValue(12));
|
|
||||||
valueMap.put(new WrappedStack(new ItemStack(Block.tallGrass.blockID, 1, OreDictionary.WILDCARD_VALUE)), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Block.deadBush), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Block.plantYellow), new EmcValue(16));
|
|
||||||
valueMap.put(new WrappedStack(Block.plantRed), new EmcValue(16));
|
|
||||||
valueMap.put(new WrappedStack(Block.mushroomBrown), new EmcValue(32));
|
|
||||||
valueMap.put(new WrappedStack(Block.mushroomRed), new EmcValue(32));
|
|
||||||
valueMap.put(new WrappedStack(Block.snow), new EmcValue(0.5f));
|
|
||||||
valueMap.put(new WrappedStack(Block.cactus), new EmcValue(8));
|
|
||||||
// Stone Monster Egg (97:0)
|
|
||||||
// Cobblestone Monster Egg (97:1)
|
|
||||||
// Stone Brick Monster Egg (97:2)
|
|
||||||
valueMap.put(new WrappedStack(Block.vine), new EmcValue(8));
|
|
||||||
valueMap.put(new WrappedStack(Block.waterlily), new EmcValue(16));
|
|
||||||
// End Portal (120:0)
|
|
||||||
// Skeleton Skull (397:0)
|
|
||||||
// Wither Skeleton Skull (391:1)
|
|
||||||
// Zombie Head (397:2)
|
|
||||||
// Head (397:3)
|
|
||||||
// Creeper Head (397:4)
|
|
||||||
|
|
||||||
/* Redstone */
|
|
||||||
valueMap.put(new WrappedStack(Item.redstone), new EmcValue(32));
|
|
||||||
|
|
||||||
/* Transportation */
|
|
||||||
valueMap.put(new WrappedStack(Item.saddle), new EmcValue(192));
|
|
||||||
|
|
||||||
/* Miscellaneous */
|
|
||||||
valueMap.put(new WrappedStack(Item.snowball), new EmcValue(0.25f));
|
|
||||||
valueMap.put(new WrappedStack(Item.slimeBall), new EmcValue(24));
|
|
||||||
valueMap.put(new WrappedStack(Item.bone), new EmcValue(24));
|
|
||||||
valueMap.put(new WrappedStack(Item.enderPearl), new EmcValue(1024));
|
|
||||||
// Bottle o'Enchanting (384:0)
|
|
||||||
// Firework Star (402:0)
|
|
||||||
|
|
||||||
/* Foodstuffs */
|
|
||||||
valueMap.put(new WrappedStack(Item.appleRed), new EmcValue(128));
|
|
||||||
valueMap.put(new WrappedStack(Item.porkRaw), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(Item.porkCooked), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(Item.fishRaw), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(Item.fishCooked), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(Item.melon), new EmcValue(16));
|
|
||||||
valueMap.put(new WrappedStack(Item.beefRaw), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(Item.beefCooked), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(Item.chickenRaw), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(Item.chickenCooked), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(Item.rottenFlesh), new EmcValue(24));
|
|
||||||
valueMap.put(new WrappedStack(Item.spiderEye), new EmcValue(128));
|
|
||||||
valueMap.put(new WrappedStack(Item.carrot), new EmcValue(24));
|
|
||||||
valueMap.put(new WrappedStack(Item.potato), new EmcValue(24));
|
|
||||||
valueMap.put(new WrappedStack(Item.bakedPotato), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(Item.poisonousPotato), new EmcValue(24));
|
|
||||||
|
|
||||||
/* Tools */
|
|
||||||
// Name Tag (421:0)
|
|
||||||
|
|
||||||
/* Combat */
|
|
||||||
// Chain Helmet (302:0)
|
|
||||||
// Chain Chestplate (303:0)
|
|
||||||
// Chain Leggings (304:0)
|
|
||||||
// Chain Boots (305:0)
|
|
||||||
|
|
||||||
/* Brewing */
|
|
||||||
valueMap.put(new WrappedStack(Item.ghastTear), new EmcValue(4096));
|
|
||||||
|
|
||||||
/* Materials */
|
|
||||||
valueMap.put(new WrappedStack(new ItemStack(Item.coal, 1, 0)), new EmcValue(32));
|
|
||||||
valueMap.put(new WrappedStack(new ItemStack(Item.coal, 1, 1)), new EmcValue(32));
|
|
||||||
valueMap.put(new WrappedStack(Item.diamond), new EmcValue(8192));
|
|
||||||
valueMap.put(new WrappedStack(Item.ingotIron), new EmcValue(256));
|
|
||||||
valueMap.put(new WrappedStack(Item.ingotGold), new EmcValue(2048));
|
|
||||||
valueMap.put(new WrappedStack(Item.silk), new EmcValue(12));
|
|
||||||
valueMap.put(new WrappedStack(Item.feather), new EmcValue(48));
|
|
||||||
valueMap.put(new WrappedStack(Item.gunpowder), new EmcValue(192));
|
|
||||||
valueMap.put(new WrappedStack(Item.seeds), new EmcValue(16));
|
|
||||||
valueMap.put(new WrappedStack(Item.wheat), new EmcValue(24));
|
|
||||||
valueMap.put(new WrappedStack(Item.flint), new EmcValue(4));
|
|
||||||
valueMap.put(new WrappedStack(Item.leather), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(Item.brick), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(Item.clay), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(Item.reed), new EmcValue(32));
|
|
||||||
valueMap.put(new WrappedStack(Item.egg), new EmcValue(32));
|
|
||||||
valueMap.put(new WrappedStack(Item.glowstone), new EmcValue(384));
|
|
||||||
valueMap.put(new WrappedStack(new ItemStack(Item.dyePowder, 1, 4)), new EmcValue(864));
|
|
||||||
valueMap.put(new WrappedStack(Item.blazeRod), new EmcValue(1536));
|
|
||||||
valueMap.put(new WrappedStack(Item.netherStalkSeeds), new EmcValue(24));
|
|
||||||
valueMap.put(new WrappedStack(Item.emerald), new EmcValue(8192));
|
|
||||||
valueMap.put(new WrappedStack(Item.netherStar), new EmcValue(24576));
|
|
||||||
valueMap.put(new WrappedStack(Item.netherrackBrick), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(Item.netherQuartz), new EmcValue(256));
|
|
||||||
|
|
||||||
/* Equivalent Exchange 3 */
|
|
||||||
/**
|
|
||||||
* Alchemical Dusts
|
|
||||||
*/
|
|
||||||
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 0)), new EmcValue(1));
|
|
||||||
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 1)), new EmcValue(64));
|
|
||||||
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 2)), new EmcValue(2048));
|
|
||||||
valueMap.put(new WrappedStack(new ItemStack(ModItems.alchemicalDust, 1, 3)), new EmcValue(8192));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Minium Shard
|
|
||||||
*/
|
|
||||||
valueMap.put(new WrappedStack(new ItemStack(ModItems.miniumShard)), new EmcValue(8192));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<WrappedStack, EmcValue> getDefaultValueMap()
|
|
||||||
{
|
|
||||||
lazyInit();
|
|
||||||
return emcDefaultValues.valueMap;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
package com.pahimar.ee3.emc;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.api.WrappedStack;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* EmcIMCValues
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class EmcValuesIMC
|
|
||||||
{
|
|
||||||
|
|
||||||
private static Map<WrappedStack, EmcValue> preAssignedValueMap = new TreeMap<WrappedStack, EmcValue>();
|
|
||||||
private static Map<WrappedStack, EmcValue> postAssignedValueMap = new TreeMap<WrappedStack, EmcValue>();
|
|
||||||
|
|
||||||
public static Map<WrappedStack, EmcValue> getPreAssignedValues()
|
|
||||||
{
|
|
||||||
return preAssignedValueMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Map<WrappedStack, EmcValue> getPostAssignedValues()
|
|
||||||
{
|
|
||||||
return postAssignedValueMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addPreAssignedValued(WrappedStack wrappedStack, EmcValue emcValue)
|
|
||||||
{
|
|
||||||
if (wrappedStack != null)
|
|
||||||
{
|
|
||||||
if (!preAssignedValueMap.containsKey(wrappedStack))
|
|
||||||
{
|
|
||||||
preAssignedValueMap.put(wrappedStack, emcValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Log that we already have a value for that
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Logging
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addPostAssignedValued(WrappedStack wrappedStack, EmcValue emcValue)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (wrappedStack != null)
|
|
||||||
{
|
|
||||||
if (!postAssignedValueMap.containsKey(wrappedStack))
|
|
||||||
{
|
|
||||||
postAssignedValueMap.put(wrappedStack, emcValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Log that we already have a value for that
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Logging
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
package com.pahimar.ee3.event;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ActionEvent
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class ActionEvent extends Event
|
|
||||||
{
|
|
||||||
|
|
||||||
public final byte actionType;
|
|
||||||
public final EntityPlayer player;
|
|
||||||
public final World world;
|
|
||||||
public final int x, y, z;
|
|
||||||
public final boolean hasActionOccured;
|
|
||||||
public final String data;
|
|
||||||
public ItemStack itemStack;
|
|
||||||
public ActionResult actionResult;
|
|
||||||
|
|
||||||
public ActionEvent(byte actionType, ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, boolean hasActionOccured, String data)
|
|
||||||
{
|
|
||||||
|
|
||||||
this.actionType = actionType;
|
|
||||||
this.itemStack = itemStack;
|
|
||||||
this.player = player;
|
|
||||||
this.world = world;
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
this.hasActionOccured = hasActionOccured;
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ActionResult
|
|
||||||
{
|
|
||||||
SUCCESS, DEFAULT, FAILURE
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
package com.pahimar.ee3.event;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ActionRequestEvent
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
@Cancelable
|
|
||||||
public class ActionRequestEvent extends PlayerEvent
|
|
||||||
{
|
|
||||||
|
|
||||||
public final ActionEvent modEvent;
|
|
||||||
public final int x, y, z;
|
|
||||||
public final int sideHit;
|
|
||||||
public Result allowEvent;
|
|
||||||
|
|
||||||
public ActionRequestEvent(EntityPlayer player, ActionEvent modEvent, int x, int y, int z, int sideHit)
|
|
||||||
{
|
|
||||||
|
|
||||||
super(player);
|
|
||||||
this.modEvent = modEvent;
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
this.sideHit = sideHit;
|
|
||||||
if (sideHit == -1)
|
|
||||||
{
|
|
||||||
allowEvent = DENY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCanceled(boolean cancel)
|
|
||||||
{
|
|
||||||
|
|
||||||
super.setCanceled(cancel);
|
|
||||||
allowEvent = cancel ? DENY : allowEvent == DENY ? DENY : DEFAULT;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package com.pahimar.ee3.event;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* WorldTransmutationEvent
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class WorldTransmutationEvent extends ActionEvent
|
|
||||||
{
|
|
||||||
|
|
||||||
public int targetID, targetMeta;
|
|
||||||
|
|
||||||
public WorldTransmutationEvent(byte actionType, ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, boolean hasActionOccured, String data)
|
|
||||||
{
|
|
||||||
|
|
||||||
super(actionType, itemStack, player, world, x, y, z, hasActionOccured, data);
|
|
||||||
targetID = Integer.parseInt(data.substring(0, data.indexOf(":")));
|
|
||||||
targetMeta = Integer.parseInt(data.substring(data.indexOf(":") + 1));
|
|
||||||
actionResult = ActionResult.DEFAULT;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package com.pahimar.ee3.handler;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.event.ActionRequestEvent;
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ActionRequestHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class ActionRequestHandler
|
|
||||||
{
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onModActionEvent(ActionRequestEvent event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,109 +1,21 @@
|
||||||
package com.pahimar.ee3.handler;
|
package com.pahimar.ee3.handler;
|
||||||
|
|
||||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
|
||||||
import com.pahimar.ee3.helper.ItemStackNBTHelper;
|
|
||||||
import com.pahimar.ee3.item.ItemAlchemicalBag;
|
|
||||||
import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes;
|
import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes;
|
||||||
import com.pahimar.ee3.item.crafting.RecipesTransmutationStones;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import com.pahimar.ee3.item.crafting.RecipesVanilla;
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import com.pahimar.ee3.recipe.RecipesAludel;
|
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.CraftingManager;
|
import net.minecraft.item.crafting.CraftingManager;
|
||||||
|
|
||||||
/**
|
public class CraftingHandler
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* CraftingHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class CraftingHandler implements ICraftingHandler
|
|
||||||
{
|
{
|
||||||
public static void init()
|
public static void init()
|
||||||
{
|
{
|
||||||
// Register the Crafting Handler
|
|
||||||
GameRegistry.registerCraftingHandler(new CraftingHandler());
|
|
||||||
|
|
||||||
// Add in the ability to dye Alchemical Bags
|
// Add in the ability to dye Alchemical Bags
|
||||||
CraftingManager.getInstance().getRecipeList().add(new RecipesAlchemicalBagDyes());
|
CraftingManager.getInstance().getRecipeList().add(new RecipesAlchemicalBagDyes());
|
||||||
|
|
||||||
// Register our recipes
|
|
||||||
RecipesVanilla.init();
|
|
||||||
RecipesTransmutationStones.init();
|
|
||||||
RecipesAludel.getInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@SubscribeEvent
|
||||||
public void onCrafting(EntityPlayer player, ItemStack itemStack, IInventory craftMatrix)
|
public void onItemCraftedEvent(PlayerEvent.ItemCraftedEvent event)
|
||||||
{
|
|
||||||
if (player.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
doPortableCrafting(player, craftMatrix);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!player.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
// Set the UUID on an Alchemical Bag when picked up from crafting
|
|
||||||
if (itemStack.getItem() instanceof ItemAlchemicalBag)
|
|
||||||
{
|
|
||||||
ItemStackNBTHelper.setUUID(itemStack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSmelting(EntityPlayer player, ItemStack itemStack)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check to see if the crafting is occurring from the portable crafting interface. If so, do durability damage to
|
|
||||||
* the appropriate transmutation stone that was used for portable crafting.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* The player that is completing the crafting
|
|
||||||
* @param craftMatrix
|
|
||||||
* The contents of the crafting matrix
|
|
||||||
*/
|
|
||||||
private void doPortableCrafting(EntityPlayer player, IInventory craftMatrix)
|
|
||||||
{
|
|
||||||
ItemStack openStone = null;
|
|
||||||
|
|
||||||
for (ItemStack itemStack : player.inventory.mainInventory)
|
|
||||||
{
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN))
|
|
||||||
{
|
|
||||||
openStone = itemStack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack itemStack;
|
|
||||||
if (openStone != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < craftMatrix.getSizeInventory(); i++)
|
|
||||||
{
|
|
||||||
itemStack = craftMatrix.getStackInSlot(i);
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN))
|
|
||||||
{
|
|
||||||
openStone = itemStack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (openStone != null)
|
|
||||||
{
|
|
||||||
openStone.damageItem(ConfigurationSettings.TRANSMUTE_COST_ITEM, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,309 +0,0 @@
|
||||||
package com.pahimar.ee3.handler;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.helper.GeneralHelper;
|
|
||||||
import com.pahimar.ee3.helper.LogHelper;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* EquivalencyHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class EquivalencyHandler
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final EquivalencyHandler instance = new EquivalencyHandler();
|
|
||||||
|
|
||||||
private static ArrayList<ArrayList<ItemStack>> equivalencyList = new ArrayList<ArrayList<ItemStack>>();
|
|
||||||
|
|
||||||
public static EquivalencyHandler instance()
|
|
||||||
{
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<ArrayList<ItemStack>> getAllLists()
|
|
||||||
{
|
|
||||||
|
|
||||||
return equivalencyList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addObjects(Object obj1, Object obj2)
|
|
||||||
{
|
|
||||||
|
|
||||||
ItemStack stack1 = GeneralHelper.convertObjectToItemStack(obj1);
|
|
||||||
ItemStack stack2 = GeneralHelper.convertObjectToItemStack(obj2);
|
|
||||||
|
|
||||||
ArrayList<ItemStack> currentList = new ArrayList<ItemStack>();
|
|
||||||
|
|
||||||
Integer stack1Index = getIndexInList(stack1);
|
|
||||||
Integer stack2Index = getIndexInList(stack2);
|
|
||||||
|
|
||||||
if (stack1Index != null && stack2Index != null)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else if (stack1Index != null && stack2Index == null)
|
|
||||||
{
|
|
||||||
currentList = equivalencyList.get(stack1Index.intValue());
|
|
||||||
currentList.add(stack2);
|
|
||||||
equivalencyList.set(stack1Index, currentList);
|
|
||||||
}
|
|
||||||
else if (stack1Index == null && stack2Index != null)
|
|
||||||
{
|
|
||||||
currentList = equivalencyList.get(stack2Index.intValue());
|
|
||||||
currentList.add(stack1);
|
|
||||||
equivalencyList.set(stack2Index, currentList);
|
|
||||||
}
|
|
||||||
else if (stack1Index == null && stack2Index == null)
|
|
||||||
{
|
|
||||||
currentList.add(stack1);
|
|
||||||
currentList.add(stack2);
|
|
||||||
equivalencyList.add(currentList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addObjects(Object... objList)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (objList.length < 2)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < objList.length - 1; i++)
|
|
||||||
{
|
|
||||||
addObjects(objList[i], objList[i + 1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getIndexInList(Object obj)
|
|
||||||
{
|
|
||||||
|
|
||||||
ItemStack checkStack = GeneralHelper.convertObjectToItemStack(obj);
|
|
||||||
ArrayList<ItemStack> currentList;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
while (i < equivalencyList.size())
|
|
||||||
{
|
|
||||||
currentList = equivalencyList.get(i);
|
|
||||||
for (ItemStack currentStack : currentList)
|
|
||||||
{
|
|
||||||
if (ItemStack.areItemStacksEqual(checkStack, currentStack))
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getIndexInList(int id, int meta)
|
|
||||||
{
|
|
||||||
|
|
||||||
ArrayList<ItemStack> currentList;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
while (i < equivalencyList.size())
|
|
||||||
{
|
|
||||||
currentList = equivalencyList.get(i);
|
|
||||||
for (ItemStack currentStack : currentList)
|
|
||||||
{
|
|
||||||
if (id == currentStack.itemID && meta == currentStack.getItemDamage())
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<ItemStack> getEquivalencyList(Object obj)
|
|
||||||
{
|
|
||||||
|
|
||||||
ItemStack checkStack = GeneralHelper.convertObjectToItemStack(obj);
|
|
||||||
|
|
||||||
if (checkStack == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ArrayList<ItemStack> list : equivalencyList)
|
|
||||||
{
|
|
||||||
for (ItemStack currentStack : list)
|
|
||||||
{
|
|
||||||
if (ItemStack.areItemStacksEqual(checkStack, currentStack))
|
|
||||||
{
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<ItemStack> getEquivalencyList(int id, int meta)
|
|
||||||
{
|
|
||||||
|
|
||||||
for (ArrayList<ItemStack> list : equivalencyList)
|
|
||||||
{
|
|
||||||
for (ItemStack currentStack : list)
|
|
||||||
{
|
|
||||||
if (id == currentStack.itemID && meta == currentStack.getItemDamage())
|
|
||||||
{
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getNextInList(Object obj)
|
|
||||||
{
|
|
||||||
|
|
||||||
ItemStack checkStack = GeneralHelper.convertObjectToItemStack(obj);
|
|
||||||
|
|
||||||
if (checkStack != null)
|
|
||||||
{
|
|
||||||
return getNextInList(checkStack.itemID, checkStack.getItemDamage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getNextInList(int id, int meta)
|
|
||||||
{
|
|
||||||
|
|
||||||
ArrayList<ItemStack> list = getEquivalencyList(id, meta);
|
|
||||||
|
|
||||||
ItemStack currentStack;
|
|
||||||
ItemStack returnStack = null;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
if (list.size() == 1)
|
|
||||||
{
|
|
||||||
return list.get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (i < list.size())
|
|
||||||
{
|
|
||||||
currentStack = list.get(i);
|
|
||||||
|
|
||||||
if (id == currentStack.itemID && meta == currentStack.getItemDamage())
|
|
||||||
{
|
|
||||||
returnStack = list.get((i + 1) % list.size());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getPrevInList(Object obj)
|
|
||||||
{
|
|
||||||
|
|
||||||
ItemStack checkStack = GeneralHelper.convertObjectToItemStack(obj);
|
|
||||||
|
|
||||||
if (checkStack != null)
|
|
||||||
{
|
|
||||||
return getPrevInList(checkStack.itemID, checkStack.getItemDamage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getPrevInList(int id, int meta)
|
|
||||||
{
|
|
||||||
|
|
||||||
ArrayList<ItemStack> list = getEquivalencyList(id, meta);
|
|
||||||
|
|
||||||
ItemStack currentStack;
|
|
||||||
ItemStack returnStack = null;
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
if (list.size() == 1)
|
|
||||||
{
|
|
||||||
return list.get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (i < list.size())
|
|
||||||
{
|
|
||||||
currentStack = list.get(i);
|
|
||||||
|
|
||||||
if (id == currentStack.itemID && meta == currentStack.getItemDamage())
|
|
||||||
{
|
|
||||||
int index = (i - 1 + list.size()) % list.size();
|
|
||||||
returnStack = list.get(index);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean areEquivalent(Object obj1, Object obj2)
|
|
||||||
{
|
|
||||||
if (getEquivalencyList(obj1) != null && getEquivalencyList(obj2) != null)
|
|
||||||
{
|
|
||||||
return GeneralHelper.convertObjectToItemStack(obj1).itemID == GeneralHelper.convertObjectToItemStack(obj2).itemID && GeneralHelper.convertObjectToItemStack(obj1).getItemDamage() == GeneralHelper.convertObjectToItemStack(obj2).getItemDamage() || getEquivalencyList(obj1).equals(getEquivalencyList(obj2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ignores stack size for world transmutation */
|
|
||||||
public boolean areWorldEquivalent(Object obj1, Object obj2)
|
|
||||||
{
|
|
||||||
|
|
||||||
ItemStack first = GeneralHelper.convertObjectToItemStack(obj1);
|
|
||||||
if (first == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ItemStack second = GeneralHelper.convertObjectToItemStack(obj2);
|
|
||||||
if (second == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getEquivalencyList(first.itemID, first.getItemDamage()) != null && getEquivalencyList(second.itemID, second.getItemDamage()) != null)
|
|
||||||
{
|
|
||||||
return first.itemID == second.itemID && first.getItemDamage() == second.getItemDamage() || getEquivalencyList(first.itemID, first.getItemDamage()).equals(getEquivalencyList(second.itemID, second.getItemDamage()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void debug()
|
|
||||||
{
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for (ArrayList<ItemStack> list : equivalencyList)
|
|
||||||
{
|
|
||||||
LogHelper.info("equivalencyList[" + i + "]: " + list.toString());
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
package com.pahimar.ee3.handler;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.block.ModBlocks;
|
|
||||||
import com.pahimar.ee3.item.ModItems;
|
|
||||||
import cpw.mods.fml.common.IFuelHandler;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntityFurnace;
|
|
||||||
|
|
||||||
public class FuelHandler implements IFuelHandler
|
|
||||||
{
|
|
||||||
private static final ItemStack ALCHEMICAL_COAL_STACK = new ItemStack(ModItems.alchemicalFuel, 1, 0);
|
|
||||||
private static final ItemStack MOBIUS_FUEL_STACK = new ItemStack(ModItems.alchemicalFuel, 1, 1);
|
|
||||||
private static final ItemStack AETERNALIS_FUEL_STACK = new ItemStack(ModItems.alchemicalFuel, 1, 2);
|
|
||||||
|
|
||||||
private static final ItemStack ALCHEMICAL_COAL_BLOCK_STACK = new ItemStack(ModBlocks.alchemicalFuel, 1, 0);
|
|
||||||
private static final ItemStack MOBIUS_FUEL_BLOCK_STACK = new ItemStack(ModBlocks.alchemicalFuel, 1, 1);
|
|
||||||
private static final ItemStack AETERNALIS_FUEL_BLOCK_STACK = new ItemStack(ModBlocks.alchemicalFuel, 1, 2);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBurnTime(ItemStack fuel)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Alchemical Coal
|
|
||||||
*/
|
|
||||||
if (fuel.itemID == ALCHEMICAL_COAL_STACK.itemID && fuel.getItemDamage() == ALCHEMICAL_COAL_STACK.getItemDamage())
|
|
||||||
{
|
|
||||||
return 8 * TileEntityFurnace.getItemBurnTime(new ItemStack(Item.coal));
|
|
||||||
}
|
|
||||||
else if (fuel.itemID == ALCHEMICAL_COAL_BLOCK_STACK.itemID && fuel.getItemDamage() == ALCHEMICAL_COAL_BLOCK_STACK.getItemDamage())
|
|
||||||
{
|
|
||||||
return 9 * getBurnTime(ALCHEMICAL_COAL_STACK);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Mobius Fuel
|
|
||||||
*/
|
|
||||||
else if (fuel.itemID == MOBIUS_FUEL_STACK.itemID && fuel.getItemDamage() == MOBIUS_FUEL_STACK.getItemDamage())
|
|
||||||
{
|
|
||||||
return 8 * getBurnTime(ALCHEMICAL_COAL_STACK);
|
|
||||||
}
|
|
||||||
else if (fuel.itemID == MOBIUS_FUEL_BLOCK_STACK.itemID && fuel.getItemDamage() == MOBIUS_FUEL_BLOCK_STACK.getItemDamage())
|
|
||||||
{
|
|
||||||
return 9 * getBurnTime(MOBIUS_FUEL_STACK);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Aeternalis Fuel
|
|
||||||
*/
|
|
||||||
else if (fuel.itemID == AETERNALIS_FUEL_STACK.itemID && fuel.getItemDamage() == AETERNALIS_FUEL_STACK.getItemDamage())
|
|
||||||
{
|
|
||||||
return 8 * getBurnTime(MOBIUS_FUEL_STACK);
|
|
||||||
}
|
|
||||||
else if (fuel.itemID == AETERNALIS_FUEL_BLOCK_STACK.itemID && fuel.getItemDamage() == AETERNALIS_FUEL_BLOCK_STACK.getItemDamage())
|
|
||||||
{
|
|
||||||
return 9 * getBurnTime(AETERNALIS_FUEL_STACK);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +1,5 @@
|
||||||
package com.pahimar.ee3.handler;
|
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.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.network.IGuiHandler;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -16,70 +9,12 @@ public class GuiHandler implements IGuiHandler
|
||||||
@Override
|
@Override
|
||||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
if (ID == GuiIds.PORTABLE_CRAFTING)
|
|
||||||
{
|
|
||||||
return new ContainerPortableCrafting(player.inventory, world, x, y, z);
|
|
||||||
}
|
|
||||||
else if (ID == GuiIds.CALCINATOR)
|
|
||||||
{
|
|
||||||
TileCalcinator tileCalcinator = (TileCalcinator) world.getTileEntity(x, y, z);
|
|
||||||
return new ContainerCalcinator(player.inventory, tileCalcinator);
|
|
||||||
}
|
|
||||||
else if (ID == GuiIds.ALCHEMICAL_CHEST)
|
|
||||||
{
|
|
||||||
TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) world.getTileEntity(x, y, z);
|
|
||||||
return new ContainerAlchemicalChest(player.inventory, tileAlchemicalChest);
|
|
||||||
}
|
|
||||||
else if (ID == GuiIds.ALCHEMICAL_BAG)
|
|
||||||
{
|
|
||||||
return new ContainerAlchemicalBag(player, new InventoryAlchemicalBag(player.getHeldItem()));
|
|
||||||
}
|
|
||||||
else if (ID == GuiIds.ALUDEL)
|
|
||||||
{
|
|
||||||
TileAludel tileAludel = (TileAludel) world.getTileEntity(x, y, z);
|
|
||||||
return new ContainerAludel(player.inventory, tileAludel);
|
|
||||||
}
|
|
||||||
else if (ID == GuiIds.GLASS_BELL)
|
|
||||||
{
|
|
||||||
TileGlassBell tileGlassBell = (TileGlassBell) world.getTileEntity(x, y, z);
|
|
||||||
return new ContainerGlassBell(player.inventory, tileGlassBell);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
if (ID == GuiIds.PORTABLE_CRAFTING)
|
|
||||||
{
|
|
||||||
return new GuiPortableCrafting(player, world, x, y, z);
|
|
||||||
}
|
|
||||||
else if (ID == GuiIds.CALCINATOR)
|
|
||||||
{
|
|
||||||
TileCalcinator tileCalcinator = (TileCalcinator) world.getTileEntity(x, y, z);
|
|
||||||
return new GuiCalcinator(player.inventory, tileCalcinator);
|
|
||||||
}
|
|
||||||
else if (ID == GuiIds.ALCHEMICAL_CHEST)
|
|
||||||
{
|
|
||||||
TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) world.getTileEntity(x, y, z);
|
|
||||||
return new GuiAlchemicalChest(player.inventory, tileAlchemicalChest);
|
|
||||||
}
|
|
||||||
else if (ID == GuiIds.ALCHEMICAL_BAG)
|
|
||||||
{
|
|
||||||
return new GuiAlchemicalBag(player, new InventoryAlchemicalBag(player.getHeldItem()));
|
|
||||||
}
|
|
||||||
else if (ID == GuiIds.ALUDEL)
|
|
||||||
{
|
|
||||||
TileAludel tileAludel = (TileAludel) world.getTileEntity(x, y, z);
|
|
||||||
return new GuiAludel(player.inventory, tileAludel);
|
|
||||||
}
|
|
||||||
else if (ID == GuiIds.GLASS_BELL)
|
|
||||||
{
|
|
||||||
TileGlassBell tileGlassBell = (TileGlassBell) world.getTileEntity(x, y, z);
|
|
||||||
return new GuiGlassBell(player.inventory, tileGlassBell);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,76 +1,39 @@
|
||||||
package com.pahimar.ee3.handler;
|
package com.pahimar.ee3.handler;
|
||||||
|
|
||||||
import com.pahimar.ee3.helper.ItemStackNBTHelper;
|
import com.pahimar.ee3.util.NBTHelper;
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
||||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ItemEventHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class ItemEventHandler
|
public class ItemEventHandler
|
||||||
{
|
{
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@SuppressWarnings("unused")
|
public void onItemTossEvent(ItemTossEvent itemTossEvent)
|
||||||
public void onItemPickup(EntityItemPickupEvent event)
|
|
||||||
{
|
{
|
||||||
if (ItemStackNBTHelper.hasTag(event.item.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN))
|
NBTHelper.clearStatefulNBTTags(itemTossEvent.entityItem.getEntityItem());
|
||||||
{
|
|
||||||
ItemStackNBTHelper.removeTag(event.item.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN);
|
|
||||||
}
|
|
||||||
else if (ItemStackNBTHelper.hasTag(event.item.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN))
|
|
||||||
{
|
|
||||||
ItemStackNBTHelper.removeTag(event.item.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN);
|
|
||||||
}
|
|
||||||
else if (ItemStackNBTHelper.hasTag(event.item.getEntityItem(), Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN))
|
|
||||||
{
|
|
||||||
ItemStackNBTHelper.removeTag(event.item.getEntityItem(), Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@SuppressWarnings("unused")
|
public void onItemPickupEvent(PlayerEvent.ItemPickupEvent itemPickupEvent)
|
||||||
public void onItemToss(ItemTossEvent event)
|
|
||||||
{
|
{
|
||||||
if (ItemStackNBTHelper.hasTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN))
|
NBTHelper.clearStatefulNBTTags(itemPickupEvent.pickedUp.getEntityItem());
|
||||||
{
|
|
||||||
ItemStackNBTHelper.removeTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN);
|
|
||||||
}
|
|
||||||
else if (ItemStackNBTHelper.hasTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN))
|
|
||||||
{
|
|
||||||
ItemStackNBTHelper.removeTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN);
|
|
||||||
}
|
|
||||||
else if (ItemStackNBTHelper.hasTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN))
|
|
||||||
{
|
|
||||||
ItemStackNBTHelper.removeTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
@SuppressWarnings("unused")
|
public void onEntityItemPickupEvent(EntityItemPickupEvent entityItemPickupEvent)
|
||||||
public void onPlayerDrop(PlayerDropsEvent event)
|
|
||||||
{
|
{
|
||||||
for (EntityItem entityItem : event.drops)
|
NBTHelper.clearStatefulNBTTags(entityItemPickupEvent.item.getEntityItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onPlayerDropsEvent(PlayerDropsEvent playerDropsEvent)
|
||||||
|
{
|
||||||
|
for (EntityItem entityItem : playerDropsEvent.drops)
|
||||||
{
|
{
|
||||||
if (ItemStackNBTHelper.hasTag(entityItem.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN))
|
NBTHelper.clearStatefulNBTTags(entityItem.getEntityItem());
|
||||||
{
|
|
||||||
ItemStackNBTHelper.removeTag(entityItem.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN);
|
|
||||||
}
|
|
||||||
else if (ItemStackNBTHelper.hasTag(entityItem.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN))
|
|
||||||
{
|
|
||||||
ItemStackNBTHelper.removeTag(entityItem.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN);
|
|
||||||
}
|
|
||||||
else if (ItemStackNBTHelper.hasTag(entityItem.getEntityItem(), Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN))
|
|
||||||
{
|
|
||||||
ItemStackNBTHelper.removeTag(entityItem.getEntityItem(), Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
package com.pahimar.ee3.handler;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
|
||||||
import com.pahimar.ee3.configuration.GeneralConfiguration;
|
|
||||||
import com.pahimar.ee3.helper.VersionHelper;
|
|
||||||
import com.pahimar.ee3.lib.Reference;
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* VersionCheckTickHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class VersionCheckTickHandler implements ITickHandler
|
|
||||||
{
|
|
||||||
|
|
||||||
private static boolean initialized = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (ConfigurationSettings.DISPLAY_VERSION_RESULT)
|
|
||||||
{
|
|
||||||
if (!initialized)
|
|
||||||
{
|
|
||||||
for (TickType tickType : type)
|
|
||||||
{
|
|
||||||
if (tickType == TickType.CLIENT)
|
|
||||||
{
|
|
||||||
if (FMLClientHandler.instance().getClient().currentScreen == null)
|
|
||||||
{
|
|
||||||
if (VersionHelper.getResult() != VersionHelper.UNINITIALIZED || VersionHelper.getResult() != VersionHelper.FINAL_ERROR)
|
|
||||||
{
|
|
||||||
|
|
||||||
initialized = true;
|
|
||||||
|
|
||||||
if (VersionHelper.getResult() == VersionHelper.OUTDATED)
|
|
||||||
{
|
|
||||||
FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(VersionHelper.getResultMessageForClient());
|
|
||||||
GeneralConfiguration.set(Configuration.CATEGORY_GENERAL, ConfigurationSettings.DISPLAY_VERSION_RESULT_CONFIGNAME, "false");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumSet<TickType> ticks()
|
|
||||||
{
|
|
||||||
|
|
||||||
return EnumSet.of(TickType.CLIENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLabel()
|
|
||||||
{
|
|
||||||
|
|
||||||
return Reference.MOD_NAME + ": " + this.getClass().getSimpleName();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package com.pahimar.ee3.handler;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.helper.EmcInitializationHelper;
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
|
||||||
|
|
||||||
public class WorldEventHandler
|
|
||||||
{
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onWorldLoaded(WorldEvent.Load event)
|
|
||||||
{
|
|
||||||
EmcInitializationHelper.initEmcRegistry();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,205 +0,0 @@
|
||||||
package com.pahimar.ee3.handler;
|
|
||||||
|
|
||||||
import com.google.common.eventbus.Subscribe;
|
|
||||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
|
||||||
import com.pahimar.ee3.event.ActionEvent;
|
|
||||||
import com.pahimar.ee3.event.ActionEvent.ActionResult;
|
|
||||||
import com.pahimar.ee3.event.ActionRequestEvent;
|
|
||||||
import com.pahimar.ee3.event.WorldTransmutationEvent;
|
|
||||||
import com.pahimar.ee3.helper.TransmutationHelper;
|
|
||||||
import com.pahimar.ee3.lib.ActionTypes;
|
|
||||||
import com.pahimar.ee3.lib.ItemUpdateTypes;
|
|
||||||
import com.pahimar.ee3.lib.Particles;
|
|
||||||
import com.pahimar.ee3.lib.Sounds;
|
|
||||||
import com.pahimar.ee3.network.PacketTypeHandler;
|
|
||||||
import com.pahimar.ee3.network.packet.PacketItemUpdate;
|
|
||||||
import com.pahimar.ee3.network.packet.PacketSoundEvent;
|
|
||||||
import com.pahimar.ee3.network.packet.PacketSpawnParticle;
|
|
||||||
import cpw.mods.fml.common.eventhandler.Event;
|
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* WorldTransmutationHandler
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class WorldTransmutationHandler
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void handleWorldTransmutation(EntityPlayer thePlayer, int originX, int originY, int originZ, byte rangeX, byte rangeY, byte rangeZ, byte sideHit, String data)
|
|
||||||
{
|
|
||||||
|
|
||||||
ActionRequestEvent actionRequestEvent;
|
|
||||||
ActionEvent actionEvent;
|
|
||||||
|
|
||||||
int lowerBoundX = -1 * rangeX / 2;
|
|
||||||
int upperBoundX = -1 * lowerBoundX;
|
|
||||||
int lowerBoundY = -1 * rangeY / 2;
|
|
||||||
int upperBoundY = -1 * lowerBoundY;
|
|
||||||
int lowerBoundZ = -1 * rangeZ / 2;
|
|
||||||
int upperBoundZ = -1 * lowerBoundZ;
|
|
||||||
boolean anySuccess = false;
|
|
||||||
|
|
||||||
double xShift = 0;
|
|
||||||
double yShift = 0;
|
|
||||||
double zShift = 0;
|
|
||||||
|
|
||||||
int xSign = 1;
|
|
||||||
int ySign = 1;
|
|
||||||
int zSign = 1;
|
|
||||||
|
|
||||||
switch (ForgeDirection.getOrientation(sideHit))
|
|
||||||
{
|
|
||||||
case UP:
|
|
||||||
{
|
|
||||||
yShift = 1.5D;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case DOWN:
|
|
||||||
{
|
|
||||||
yShift = 0.1D;
|
|
||||||
ySign = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case NORTH:
|
|
||||||
{
|
|
||||||
zShift = 1D;
|
|
||||||
zSign = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SOUTH:
|
|
||||||
{
|
|
||||||
zShift = 1D;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EAST:
|
|
||||||
{
|
|
||||||
xShift = 1D;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case WEST:
|
|
||||||
{
|
|
||||||
xShift = 1D;
|
|
||||||
xSign = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case UNKNOWN:
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int x = lowerBoundX; x <= upperBoundX; x++)
|
|
||||||
{
|
|
||||||
for (int y = lowerBoundY; y <= upperBoundY; y++)
|
|
||||||
{
|
|
||||||
for (int z = lowerBoundZ; z <= upperBoundZ; z++)
|
|
||||||
{
|
|
||||||
|
|
||||||
actionEvent = new WorldTransmutationEvent(ActionTypes.TRANSMUTATION, thePlayer.getCurrentEquippedItem(), thePlayer, thePlayer.worldObj, originX + x, originY + y, originZ + z, false, data);
|
|
||||||
|
|
||||||
if (actionEvent != null)
|
|
||||||
{
|
|
||||||
actionRequestEvent = new ActionRequestEvent(thePlayer, actionEvent, originX + x, originY + y, originZ + z, sideHit);
|
|
||||||
MinecraftForge.EVENT_BUS.post(actionRequestEvent);
|
|
||||||
|
|
||||||
if (actionRequestEvent.allowEvent != Event.Result.DENY)
|
|
||||||
{
|
|
||||||
MinecraftForge.EVENT_BUS.post(actionEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (actionEvent.actionResult == ActionResult.SUCCESS)
|
|
||||||
{
|
|
||||||
if (!anySuccess)
|
|
||||||
{
|
|
||||||
anySuccess = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
PacketDispatcher.sendPacketToAllAround(originX + x, originY + y, originZ + z, 64D, thePlayer.worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle(Particles.LARGE_SMOKE, originX + x + xShift * xSign, originY + y + yShift * ySign, originZ + z + zShift * zSign, 0D * xSign, 0.05D * ySign, 0D * zSign)));
|
|
||||||
PacketDispatcher.sendPacketToAllAround(originX + x, originY + y, originZ + z, 64D, thePlayer.worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle(Particles.LARGE_EXPLODE, originX + x + xShift * xSign, originY + y + yShift * ySign, originZ + z + zShift * zSign, 0D * xSign, 0.15D * ySign, 0D * zSign)));
|
|
||||||
}
|
|
||||||
else if (actionEvent.actionResult == ActionResult.FAILURE)
|
|
||||||
{
|
|
||||||
if (!(actionEvent.world.getBlockId(originX + x, originY + y, originZ + z) == 0))
|
|
||||||
{
|
|
||||||
// TODO Fancy particle motion
|
|
||||||
PacketDispatcher.sendPacketToAllAround(originX + x, originY + y, originZ + z, 64D, thePlayer.worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle(Particles.RED_DUST, originX + x + xShift * xSign, originY + y + yShift * ySign, originZ + z + zShift * zSign, 0D * xSign, 0.05D * ySign, 0D * zSign)));
|
|
||||||
PacketDispatcher.sendPacketToAllAround(originX + x, originY + y, originZ + z, 64D, thePlayer.worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSpawnParticle(Particles.WITCH_MAGIC, originX + x + xShift * xSign, originY + y + yShift * ySign, originZ + z + zShift * zSign, 0D * xSign, 0.05D * ySign, 0D * zSign)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (anySuccess)
|
|
||||||
{
|
|
||||||
PacketDispatcher.sendPacketToAllAround(originX, originY, originZ, 64D, thePlayer.worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSoundEvent(thePlayer.username, Sounds.TRANSMUTE, originX, originY, originZ, 0.5F, 1.0F)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PacketDispatcher.sendPacketToAllAround(originX, originY, originZ, 64D, thePlayer.worldObj.provider.dimensionId, PacketTypeHandler.populatePacket(new PacketSoundEvent(thePlayer.username, Sounds.FAIL, originX, originY, originZ, 1.5F, 1.5F)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onWorldTransmutationEvent(WorldTransmutationEvent event)
|
|
||||||
{
|
|
||||||
|
|
||||||
int id = event.world.getBlockId(event.x, event.y, event.z);
|
|
||||||
int meta = event.world.getBlockMetadata(event.x, event.y, event.z);
|
|
||||||
boolean result = false;
|
|
||||||
|
|
||||||
Block currentBlock = Block.blocksList[id];
|
|
||||||
|
|
||||||
if (currentBlock != null)
|
|
||||||
{
|
|
||||||
meta = currentBlock.damageDropped(meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack worldStack = new ItemStack(id, 1, meta);
|
|
||||||
ItemStack targetStack = new ItemStack(event.targetID, 1, event.targetMeta);
|
|
||||||
|
|
||||||
if (!worldStack.isItemEqual(targetStack))
|
|
||||||
{
|
|
||||||
if (EquivalencyHandler.instance().areWorldEquivalent(worldStack, targetStack))
|
|
||||||
{
|
|
||||||
if (event.itemStack != null)
|
|
||||||
{
|
|
||||||
if (event.itemStack.getItemDamage() <= event.itemStack.getMaxDamage())
|
|
||||||
{
|
|
||||||
result = TransmutationHelper.transmuteInWorld(event.world, event.player, event.player.getCurrentEquippedItem(), event.x, event.y, event.z, event.targetID, event.targetMeta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
event.actionResult = ActionResult.SUCCESS;
|
|
||||||
|
|
||||||
int currentSlot = event.player.inventory.currentItem;
|
|
||||||
event.itemStack.damageItem(ConfigurationSettings.TRANSMUTE_COST_BLOCK, event.player);
|
|
||||||
|
|
||||||
if (event.itemStack.stackSize < 1)
|
|
||||||
{
|
|
||||||
event.player.inventory.setInventorySlotContents(currentSlot, null);
|
|
||||||
PacketDispatcher.sendPacketToPlayer(PacketTypeHandler.populatePacket(new PacketItemUpdate((byte) currentSlot, ItemUpdateTypes.DESTROYED)), (Player) event.player);
|
|
||||||
event.player.worldObj.playSoundAtEntity(event.player, "random.break", 0.8F, 0.8F + event.player.worldObj.rand.nextFloat() * 0.4F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
event.actionResult = ActionResult.FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package com.pahimar.ee3.helper;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.CraftingManager;
|
|
||||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
|
||||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
|
||||||
|
|
||||||
public class CraftingHelper
|
|
||||||
{
|
|
||||||
public static void addShapedOreRecipe(ItemStack outputItemStack, Object... objectInputs)
|
|
||||||
{
|
|
||||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(outputItemStack, objectInputs));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addShapelessOreRecipe(ItemStack outputItemStack, Object... objectInputs)
|
|
||||||
{
|
|
||||||
CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(outputItemStack, objectInputs));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,113 +0,0 @@
|
||||||
package com.pahimar.ee3.helper;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.api.OreStack;
|
|
||||||
import com.pahimar.ee3.api.WrappedStack;
|
|
||||||
import com.pahimar.ee3.emc.EmcRegistry;
|
|
||||||
import com.pahimar.ee3.emc.EmcValue;
|
|
||||||
import com.pahimar.ee3.recipe.RecipeRegistry;
|
|
||||||
import cpw.mods.fml.common.registry.GameRegistry;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DebugHelper
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void printOreDictionaryContents()
|
|
||||||
{
|
|
||||||
List<String> oreNames = Arrays.asList(OreDictionary.getOreNames());
|
|
||||||
Collections.sort(oreNames);
|
|
||||||
|
|
||||||
for (String oreName : oreNames)
|
|
||||||
{
|
|
||||||
for (ItemStack itemStack : OreDictionary.getOres(oreName))
|
|
||||||
{
|
|
||||||
LogHelper.debug(String.format("%s: %s", oreName, ItemHelper.toString(itemStack)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printOreStacksWithoutEmcValues()
|
|
||||||
{
|
|
||||||
List<String> oreNames = Arrays.asList(OreDictionary.getOreNames());
|
|
||||||
Collections.sort(oreNames);
|
|
||||||
|
|
||||||
for (String oreName : oreNames)
|
|
||||||
{
|
|
||||||
if (!EmcRegistry.getInstance().hasEmcValue(new OreStack(oreName)))
|
|
||||||
{
|
|
||||||
LogHelper.debug(String.format("OreStack '%s' requires an EmcValue", oreName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printRecipeRegistryContents()
|
|
||||||
{
|
|
||||||
List<WrappedStack> outputStacks = new ArrayList<WrappedStack>(RecipeRegistry.getInstance().getRecipeMappings().keySet());
|
|
||||||
Collections.sort(outputStacks);
|
|
||||||
|
|
||||||
for (WrappedStack outputStack : outputStacks)
|
|
||||||
{
|
|
||||||
for (List<WrappedStack> inputStacks : RecipeRegistry.getInstance().getRecipeMappings().get(outputStack))
|
|
||||||
{
|
|
||||||
LogHelper.debug(String.format("%s <--- %s", outputStack, inputStacks));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printItemsWithoutEmcValues()
|
|
||||||
{
|
|
||||||
printItemsWithoutEmcValues(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printItemsWithoutEmcValues(String modid)
|
|
||||||
{
|
|
||||||
for (WrappedStack wrappedStack : RecipeRegistry.getInstance().getDiscoveredStacks())
|
|
||||||
{
|
|
||||||
if (!EmcRegistry.getInstance().hasEmcValue(wrappedStack))
|
|
||||||
{
|
|
||||||
if (wrappedStack.getWrappedStack() instanceof ItemStack)
|
|
||||||
{
|
|
||||||
ItemStack itemStack = (ItemStack) wrappedStack.getWrappedStack();
|
|
||||||
GameRegistry.UniqueIdentifier uniqueIdentifier = GameRegistry.findUniqueIdentifierFor(itemStack.getItem());
|
|
||||||
if (uniqueIdentifier != null)
|
|
||||||
{
|
|
||||||
if (modid != null)
|
|
||||||
{
|
|
||||||
if (uniqueIdentifier.modId.equalsIgnoreCase(modid))
|
|
||||||
{
|
|
||||||
LogHelper.debug(String.format("Mod '%s': Object '%s' is lacking an EmcValue", uniqueIdentifier.modId, wrappedStack));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogHelper.debug(String.format("Mod '%s': Object '%s' is lacking an EmcValue", uniqueIdentifier.modId, wrappedStack));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printStackToEmcValueMappings()
|
|
||||||
{
|
|
||||||
LogHelper.debug(String.format("There are %s entries in the Stack to EmcValue map", EmcRegistry.getInstance().getStackToEmcValueMap().keySet().size()));
|
|
||||||
for (WrappedStack wrappedStack : EmcRegistry.getInstance().getStackToEmcValueMap().keySet())
|
|
||||||
{
|
|
||||||
LogHelper.debug(String.format("EmcValue for stack '%s': %s", wrappedStack, EmcRegistry.getInstance().getStackToEmcValueMap().get(wrappedStack)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void printEmcValueToStackMappings()
|
|
||||||
{
|
|
||||||
LogHelper.debug(String.format("There are %s entries in the EmcValue to Stack map", EmcRegistry.getInstance().getEmcValueToStackMap().keySet().size()));
|
|
||||||
for (EmcValue emcValue : EmcRegistry.getInstance().getEmcValueToStackMap().keySet())
|
|
||||||
{
|
|
||||||
LogHelper.debug(String.format("Stacks(s) for EmcValue '%s': %s", emcValue, EmcRegistry.getInstance().getEmcValueToStackMap().get(emcValue)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,138 +0,0 @@
|
||||||
package com.pahimar.ee3.helper;
|
|
||||||
|
|
||||||
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 net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class EmcHelper
|
|
||||||
{
|
|
||||||
|
|
||||||
public static List<WrappedStack> filterStacksByEmc(List<WrappedStack> unfilteredStacks, EmcValue filterValue)
|
|
||||||
{
|
|
||||||
List<WrappedStack> filteredStacks = new ArrayList<WrappedStack>();
|
|
||||||
|
|
||||||
for (WrappedStack stack : unfilteredStacks)
|
|
||||||
{
|
|
||||||
if (EmcRegistry.getInstance().hasEmcValue(stack))
|
|
||||||
{
|
|
||||||
EmcValue value = EmcRegistry.getInstance().getEmcValue(stack);
|
|
||||||
boolean satisfiesFilter = true;
|
|
||||||
float[] valueSubValues = value.components;
|
|
||||||
float[] filterValueSubValues = filterValue.components;
|
|
||||||
|
|
||||||
for (int i = 0; i < valueSubValues.length; i++)
|
|
||||||
{
|
|
||||||
if (Float.compare(valueSubValues[i], filterValueSubValues[i]) < 0)
|
|
||||||
{
|
|
||||||
satisfiesFilter = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (satisfiesFilter)
|
|
||||||
{
|
|
||||||
filteredStacks.add(stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return filteredStacks;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public static List<WrappedStack> filterStacksByEmcAndRange(float start, float end, EmcValue filterValue)
|
|
||||||
{
|
|
||||||
return filterStacksByEmc(EmcRegistry.getInstance().getStacksInRange(start, end), filterValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EmcValue computeEmcValueFromList(List<WrappedStack> wrappedStacks)
|
|
||||||
{
|
|
||||||
float[] computedSubValues = new float[EmcType.TYPES.length];
|
|
||||||
|
|
||||||
for (WrappedStack wrappedStack : wrappedStacks)
|
|
||||||
{
|
|
||||||
EmcValue wrappedStackValue;
|
|
||||||
int stackSize = -1;
|
|
||||||
if (wrappedStack.getWrappedStack() instanceof ItemStack)
|
|
||||||
{
|
|
||||||
ItemStack itemStack = (ItemStack) wrappedStack.getWrappedStack();
|
|
||||||
|
|
||||||
// Check if we are dealing with a potential fluid
|
|
||||||
if (FluidContainerRegistry.getFluidForFilledItem(itemStack) != null)
|
|
||||||
{
|
|
||||||
if (itemStack.getItem().getContainerItemStack(itemStack) != null)
|
|
||||||
{
|
|
||||||
stackSize = FluidContainerRegistry.getFluidForFilledItem(itemStack).amount;
|
|
||||||
wrappedStackValue = EmcRegistry.getInstance().getEmcValue(FluidContainerRegistry.getFluidForFilledItem(itemStack));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
else if (itemStack.getItem() != null && itemStack.getItem().getContainerItemStack(itemStack) != null)
|
|
||||||
{
|
|
||||||
wrappedStackValue = new EmcValue(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wrappedStackValue = EmcRegistry.getInstance().getEmcValue(wrappedStack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wrappedStackValue = EmcRegistry.getInstance().getEmcValue(wrappedStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wrappedStackValue != null)
|
|
||||||
{
|
|
||||||
if (stackSize == -1)
|
|
||||||
{
|
|
||||||
stackSize = wrappedStack.getStackSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (EmcType emcType : EmcType.TYPES)
|
|
||||||
{
|
|
||||||
computedSubValues[emcType.ordinal()] += wrappedStackValue.components[emcType.ordinal()] * stackSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EmcValue(computedSubValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EmcValue factorEmcValue(EmcValue emcValue, int factor)
|
|
||||||
{
|
|
||||||
return factorEmcValue(emcValue, (float) factor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EmcValue factorEmcValue(EmcValue emcValue, float factor)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ((Float.compare(factor, 0f) != 0) && (emcValue != null))
|
|
||||||
{
|
|
||||||
float[] factorSubValues = emcValue.components;
|
|
||||||
|
|
||||||
for (int i = 0; i < factorSubValues.length; i++)
|
|
||||||
{
|
|
||||||
factorSubValues[i] = factorSubValues[i] * 1f / factor;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new EmcValue(factorSubValues);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return emcValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package com.pahimar.ee3.helper;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.emc.EmcRegistry;
|
|
||||||
|
|
||||||
public class EmcInitializationHelper implements Runnable
|
|
||||||
{
|
|
||||||
private static EmcInitializationHelper instance = new EmcInitializationHelper();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
EmcRegistry.getInstance();
|
|
||||||
long duration = System.currentTimeMillis() - startTime;
|
|
||||||
if (duration > 10)
|
|
||||||
{
|
|
||||||
LogHelper.info(String.format("DynEmc system initialized after %s ms", duration));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void initEmcRegistry()
|
|
||||||
{
|
|
||||||
new Thread(instance).start();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,116 +0,0 @@
|
||||||
package com.pahimar.ee3.helper;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Compare;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.StatCollector;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
public class FluidHelper
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void registerFluids()
|
|
||||||
{
|
|
||||||
// Register Milk in the FluidRegistry if it hasn't already been done
|
|
||||||
if (!FluidRegistry.isFluidRegistered("milk"))
|
|
||||||
{
|
|
||||||
Fluid milk = new Fluid("milk")
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public String getLocalizedName()
|
|
||||||
{
|
|
||||||
return StatCollector.translateToLocal("item.milk.name");
|
|
||||||
}
|
|
||||||
}.setUnlocalizedName(Item.bucketMilk.getUnlocalizedName());
|
|
||||||
FluidRegistry.registerFluid(milk);
|
|
||||||
FluidContainerRegistry.registerFluidContainer(new FluidStack(milk, 1000), new ItemStack(Item.bucketMilk), new ItemStack(Item.bucketEmpty));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int compare(FluidStack fluidStack1, FluidStack fluidStack2)
|
|
||||||
{
|
|
||||||
return comparator.compare(fluidStack1, fluidStack2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toString(FluidStack fluidStack)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (fluidStack != null)
|
|
||||||
{
|
|
||||||
return String.format("%sxfluidStack.%s", fluidStack.amount, fluidStack.getFluid().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return "fluidStack[null]";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Comparator<FluidStack> comparator = new Comparator<FluidStack>()
|
|
||||||
{
|
|
||||||
|
|
||||||
public int compare(FluidStack fluidStack1, FluidStack fluidStack2)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (fluidStack1 != null)
|
|
||||||
{
|
|
||||||
if (fluidStack2 != null)
|
|
||||||
{
|
|
||||||
if (fluidStack1.fluidID == fluidStack2.fluidID)
|
|
||||||
{
|
|
||||||
if (fluidStack1.amount == fluidStack2.amount)
|
|
||||||
{
|
|
||||||
if (fluidStack1.tag != null)
|
|
||||||
{
|
|
||||||
if (fluidStack2.tag != null)
|
|
||||||
{
|
|
||||||
return (fluidStack1.tag.hashCode() - fluidStack2.tag.hashCode());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.LESSER_THAN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (fluidStack2.tag != null)
|
|
||||||
{
|
|
||||||
return Compare.GREATER_THAN;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.EQUALS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (fluidStack1.amount - fluidStack2.amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (fluidStack1.fluidID - fluidStack2.fluidID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.LESSER_THAN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (fluidStack2 != null)
|
|
||||||
{
|
|
||||||
return Compare.GREATER_THAN;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Compare.EQUALS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package com.pahimar.ee3.helper;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* GeneralHelper
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class GeneralHelper
|
|
||||||
{
|
|
||||||
|
|
||||||
public static ItemStack convertObjectToItemStack(Object obj)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (obj instanceof Item)
|
|
||||||
{
|
|
||||||
return new ItemStack((Item) obj);
|
|
||||||
}
|
|
||||||
else if (obj instanceof Block)
|
|
||||||
{
|
|
||||||
return new ItemStack((Block) obj);
|
|
||||||
}
|
|
||||||
else if (obj instanceof ItemStack)
|
|
||||||
{
|
|
||||||
return (ItemStack) obj;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object[] convertSingleStackToPluralStacks(ItemStack stack)
|
|
||||||
{
|
|
||||||
|
|
||||||
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
|
|
||||||
ItemStack currentStack;
|
|
||||||
|
|
||||||
for (int i = 0; i < stack.stackSize; i++)
|
|
||||||
{
|
|
||||||
currentStack = new ItemStack(stack.itemID, 1, stack.getItemDamage());
|
|
||||||
list.add(currentStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list.toArray();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,160 +0,0 @@
|
||||||
package com.pahimar.ee3.helper;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Colours;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ItemDropHelper
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class ItemHelper
|
|
||||||
{
|
|
||||||
private static double rand;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compares two ItemStacks for equality, testing itemID, metaData, stackSize, and their NBTTagCompounds (if they are
|
|
||||||
* present)
|
|
||||||
*
|
|
||||||
* @param first
|
|
||||||
* The first ItemStack being tested for equality
|
|
||||||
* @param second
|
|
||||||
* The second ItemStack being tested for equality
|
|
||||||
*
|
|
||||||
* @return true if the two ItemStacks are equivalent, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean equals(ItemStack first, ItemStack second)
|
|
||||||
{
|
|
||||||
return (comparator.compare(first, second) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int compare(ItemStack itemStack1, ItemStack itemStack2)
|
|
||||||
{
|
|
||||||
return comparator.compare(itemStack1, itemStack2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toString(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
return String.format("%sxitemStack[%s:%s:%s:%s]", itemStack.stackSize, itemStack.itemID, itemStack.getItemDamage(), itemStack.getUnlocalizedName(), itemStack.getItem().getClass().getCanonicalName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return "null";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasColor(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
return itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(Strings.NBT_ITEM_DISPLAY) && itemStack.getTagCompound().getCompoundTag(Strings.NBT_ITEM_DISPLAY).hasKey(Strings.NBT_ITEM_COLOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getColor(ItemStack itemStack)
|
|
||||||
{
|
|
||||||
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
|
|
||||||
|
|
||||||
if (nbtTagCompound == null)
|
|
||||||
{
|
|
||||||
return Integer.parseInt(Colours.PURE_WHITE, 16);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NBTTagCompound displayTagCompound = nbtTagCompound.getCompoundTag(Strings.NBT_ITEM_DISPLAY);
|
|
||||||
return displayTagCompound == null ? Integer.parseInt(Colours.PURE_WHITE, 16) : displayTagCompound.hasKey(Strings.NBT_ITEM_COLOR) ? displayTagCompound.getInteger(Strings.NBT_ITEM_COLOR) : Integer.parseInt(Colours.PURE_WHITE, 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setColor(ItemStack itemStack, int color)
|
|
||||||
{
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
|
|
||||||
|
|
||||||
if (nbtTagCompound == null)
|
|
||||||
{
|
|
||||||
nbtTagCompound = new NBTTagCompound();
|
|
||||||
itemStack.setTagCompound(nbtTagCompound);
|
|
||||||
}
|
|
||||||
|
|
||||||
NBTTagCompound colourTagCompound = nbtTagCompound.getCompoundTag(Strings.NBT_ITEM_DISPLAY);
|
|
||||||
|
|
||||||
if (!nbtTagCompound.hasKey(Strings.NBT_ITEM_DISPLAY))
|
|
||||||
{
|
|
||||||
nbtTagCompound.setCompoundTag(Strings.NBT_ITEM_DISPLAY, colourTagCompound);
|
|
||||||
}
|
|
||||||
|
|
||||||
colourTagCompound.setInteger(Strings.NBT_ITEM_COLOR, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Comparator<ItemStack> comparator = new Comparator<ItemStack>()
|
|
||||||
{
|
|
||||||
public int compare(ItemStack itemStack1, ItemStack itemStack2)
|
|
||||||
{
|
|
||||||
if (itemStack1 != null && itemStack2 != null)
|
|
||||||
{
|
|
||||||
// Sort on itemID
|
|
||||||
if (itemStack1.itemID == itemStack2.itemID)
|
|
||||||
{
|
|
||||||
|
|
||||||
// Then sort on meta
|
|
||||||
if (itemStack1.getItemDamage() == itemStack2.getItemDamage())
|
|
||||||
{
|
|
||||||
|
|
||||||
// Then sort on NBT
|
|
||||||
if (itemStack1.hasTagCompound() && itemStack2.hasTagCompound())
|
|
||||||
{
|
|
||||||
|
|
||||||
// Then sort on stack size
|
|
||||||
if (itemStack1.getTagCompound().equals(itemStack2.getTagCompound()))
|
|
||||||
{
|
|
||||||
return (itemStack1.stackSize - itemStack2.stackSize);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (itemStack1.getTagCompound().hashCode() - itemStack2.getTagCompound().hashCode());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!(itemStack1.hasTagCompound()) && itemStack2.hasTagCompound())
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (itemStack1.hasTagCompound() && !(itemStack2.hasTagCompound()))
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (itemStack1.stackSize - itemStack2.stackSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (itemStack1.getItemDamage() - itemStack2.getItemDamage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return (itemStack1.itemID - itemStack2.itemID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (itemStack1 != null && itemStack2 == null)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (itemStack1 == null && itemStack2 != null)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,222 +0,0 @@
|
||||||
package com.pahimar.ee3.helper;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.api.EnergyStack;
|
|
||||||
import com.pahimar.ee3.api.OreStack;
|
|
||||||
import com.pahimar.ee3.api.WrappedStack;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
|
||||||
import net.minecraft.item.crafting.ShapedRecipes;
|
|
||||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
|
||||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
|
||||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* RecipeHelper
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class RecipeHelper
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of elements that constitute the input in a crafting recipe
|
|
||||||
*
|
|
||||||
* @param recipe
|
|
||||||
* The IRecipe being examined
|
|
||||||
*
|
|
||||||
* @return List of elements that constitute the input of the given IRecipe. Could be an ItemStack or an Arraylist
|
|
||||||
*/
|
|
||||||
public static ArrayList<WrappedStack> getRecipeInputs(IRecipe recipe)
|
|
||||||
{
|
|
||||||
|
|
||||||
ArrayList<WrappedStack> recipeInputs = new ArrayList<WrappedStack>();
|
|
||||||
|
|
||||||
if (recipe instanceof ShapedRecipes)
|
|
||||||
{
|
|
||||||
|
|
||||||
ShapedRecipes shapedRecipe = (ShapedRecipes) recipe;
|
|
||||||
|
|
||||||
for (int i = 0; i < shapedRecipe.recipeItems.length; i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (shapedRecipe.recipeItems[i] instanceof ItemStack)
|
|
||||||
{
|
|
||||||
|
|
||||||
ItemStack itemStack = shapedRecipe.recipeItems[i].copy();
|
|
||||||
|
|
||||||
if (itemStack.stackSize > 1)
|
|
||||||
{
|
|
||||||
itemStack.stackSize = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
recipeInputs.add(new WrappedStack(itemStack));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (recipe instanceof ShapelessRecipes)
|
|
||||||
{
|
|
||||||
|
|
||||||
ShapelessRecipes shapelessRecipe = (ShapelessRecipes) recipe;
|
|
||||||
|
|
||||||
for (Object object : shapelessRecipe.recipeItems)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (object instanceof ItemStack)
|
|
||||||
{
|
|
||||||
|
|
||||||
ItemStack itemStack = ((ItemStack) object).copy();
|
|
||||||
|
|
||||||
if (itemStack.stackSize > 1)
|
|
||||||
{
|
|
||||||
itemStack.stackSize = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
recipeInputs.add(new WrappedStack(itemStack));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (recipe instanceof ShapedOreRecipe)
|
|
||||||
{
|
|
||||||
|
|
||||||
ShapedOreRecipe shapedOreRecipe = (ShapedOreRecipe) recipe;
|
|
||||||
|
|
||||||
for (int i = 0; i < shapedOreRecipe.getInput().length; i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the element is a list, then it is an OreStack
|
|
||||||
*/
|
|
||||||
if (shapedOreRecipe.getInput()[i] instanceof ArrayList)
|
|
||||||
{
|
|
||||||
WrappedStack oreStack = new WrappedStack(shapedOreRecipe.getInput()[i]);
|
|
||||||
|
|
||||||
if (oreStack.getWrappedStack() instanceof OreStack)
|
|
||||||
{
|
|
||||||
recipeInputs.add(oreStack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (shapedOreRecipe.getInput()[i] instanceof ItemStack)
|
|
||||||
{
|
|
||||||
|
|
||||||
ItemStack itemStack = ((ItemStack) shapedOreRecipe.getInput()[i]).copy();
|
|
||||||
|
|
||||||
if (itemStack.stackSize > 1)
|
|
||||||
{
|
|
||||||
itemStack.stackSize = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
recipeInputs.add(new WrappedStack(itemStack));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (recipe instanceof ShapelessOreRecipe)
|
|
||||||
{
|
|
||||||
|
|
||||||
ShapelessOreRecipe shapelessOreRecipe = (ShapelessOreRecipe) recipe;
|
|
||||||
|
|
||||||
for (Object object : shapelessOreRecipe.getInput())
|
|
||||||
{
|
|
||||||
|
|
||||||
if (object instanceof ArrayList)
|
|
||||||
{
|
|
||||||
recipeInputs.add(new WrappedStack(object));
|
|
||||||
}
|
|
||||||
else if (object instanceof ItemStack)
|
|
||||||
{
|
|
||||||
|
|
||||||
ItemStack itemStack = ((ItemStack) object).copy();
|
|
||||||
|
|
||||||
if (itemStack.stackSize > 1)
|
|
||||||
{
|
|
||||||
itemStack.stackSize = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
recipeInputs.add(new WrappedStack(itemStack));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return recipeInputs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collates an uncollated, unsorted List of Objects into a sorted, collated List of WrappedStacks
|
|
||||||
*
|
|
||||||
* @param uncollatedStacks
|
|
||||||
* List of objects for collating
|
|
||||||
*
|
|
||||||
* @return A sorted, collated List of WrappedStacks
|
|
||||||
*/
|
|
||||||
public static List<WrappedStack> collateInputStacks(List<?> uncollatedStacks)
|
|
||||||
{
|
|
||||||
|
|
||||||
List<WrappedStack> collatedStacks = new ArrayList<WrappedStack>();
|
|
||||||
|
|
||||||
WrappedStack stack;
|
|
||||||
boolean found;
|
|
||||||
|
|
||||||
for (Object object : uncollatedStacks)
|
|
||||||
{
|
|
||||||
|
|
||||||
found = false;
|
|
||||||
|
|
||||||
if (WrappedStack.canBeWrapped(object))
|
|
||||||
{
|
|
||||||
|
|
||||||
stack = new WrappedStack(object);
|
|
||||||
|
|
||||||
if (collatedStacks.isEmpty())
|
|
||||||
{
|
|
||||||
collatedStacks.add(stack);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
for (WrappedStack collatedStack : collatedStacks)
|
|
||||||
{
|
|
||||||
if (collatedStack.getWrappedStack() != null)
|
|
||||||
{
|
|
||||||
if (stack.getWrappedStack() instanceof ItemStack && collatedStack.getWrappedStack() instanceof ItemStack)
|
|
||||||
{
|
|
||||||
if (ItemHelper.equals((ItemStack) stack.getWrappedStack(), (ItemStack) collatedStack.getWrappedStack()))
|
|
||||||
{
|
|
||||||
collatedStack.setStackSize(collatedStack.getStackSize() + stack.getStackSize());
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (stack.getWrappedStack() instanceof OreStack && collatedStack.getWrappedStack() instanceof OreStack)
|
|
||||||
{
|
|
||||||
if (OreStack.compareOreNames((OreStack) stack.getWrappedStack(), (OreStack) collatedStack.getWrappedStack()))
|
|
||||||
{
|
|
||||||
collatedStack.setStackSize(collatedStack.getStackSize() + stack.getStackSize());
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (stack.getWrappedStack() instanceof EnergyStack && collatedStack.getWrappedStack() instanceof EnergyStack)
|
|
||||||
{
|
|
||||||
if (EnergyStack.compareEnergyNames((EnergyStack) stack.getWrappedStack(), (EnergyStack) collatedStack.getWrappedStack()))
|
|
||||||
{
|
|
||||||
collatedStack.setStackSize(collatedStack.getStackSize() + stack.getStackSize());
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
collatedStacks.add(stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Collections.sort(collatedStacks);
|
|
||||||
return collatedStacks;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package com.pahimar.ee3.helper;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Reference;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public class ResourceLocationHelper
|
|
||||||
{
|
|
||||||
public static ResourceLocation getResourceLocation(String modId, String path)
|
|
||||||
{
|
|
||||||
return new ResourceLocation(modId, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResourceLocation getResourceLocation(String path)
|
|
||||||
{
|
|
||||||
return getResourceLocation(Reference.MOD_ID.toLowerCase(), path);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,179 +0,0 @@
|
||||||
package com.pahimar.ee3.helper;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.handler.EquivalencyHandler;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* TransmutationHelper
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class TransmutationHelper
|
|
||||||
{
|
|
||||||
|
|
||||||
public static ItemStack previousBlockStack = null;
|
|
||||||
public static ItemStack currentBlockStack = null;
|
|
||||||
public static ItemStack targetBlockStack = null;
|
|
||||||
|
|
||||||
public static boolean transmuteInWorld(World world, EntityPlayer player, ItemStack stack, int x, int y, int z, int targetID, int targetMeta)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (Block.blocksList[targetID] != null)
|
|
||||||
{
|
|
||||||
world.setBlock(x, y, z, targetID, targetMeta, 2);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String formatTargetBlockInfo(ItemStack targetBlock)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (targetBlock != null)
|
|
||||||
{
|
|
||||||
return TransmutationHelper.targetBlockStack.itemID + ":" + TransmutationHelper.targetBlockStack.getItemDamage();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateTargetBlock(World world, int x, int y, int z)
|
|
||||||
{
|
|
||||||
|
|
||||||
int id = world.getBlockId(x, y, z);
|
|
||||||
int meta = world.getBlockMetadata(x, y, z);
|
|
||||||
|
|
||||||
Block currentBlock = Block.blocksList[id];
|
|
||||||
|
|
||||||
if (currentBlock != null)
|
|
||||||
{
|
|
||||||
meta = currentBlock.damageDropped(meta);
|
|
||||||
|
|
||||||
currentBlockStack = new ItemStack(id, 1, meta);
|
|
||||||
|
|
||||||
if (previousBlockStack == null)
|
|
||||||
{
|
|
||||||
previousBlockStack = currentBlockStack;
|
|
||||||
targetBlockStack = getNextBlock(currentBlockStack.itemID, currentBlockStack.getItemDamage());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!EquivalencyHandler.instance().areEquivalent(TransmutationHelper.previousBlockStack, currentBlockStack))
|
|
||||||
{
|
|
||||||
previousBlockStack = currentBlockStack;
|
|
||||||
targetBlockStack = getNextBlock(currentBlockStack.itemID, currentBlockStack.getItemDamage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack getNextBlock(int id, int meta)
|
|
||||||
{
|
|
||||||
|
|
||||||
ArrayList<ItemStack> list = EquivalencyHandler.instance().getEquivalencyList(id, meta);
|
|
||||||
|
|
||||||
ItemStack nextStack = null;
|
|
||||||
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
return getNextBlock(id, meta, id, meta);
|
|
||||||
}
|
|
||||||
return nextStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ItemStack getNextBlock(int id, int meta, int origId, int origMeta)
|
|
||||||
{
|
|
||||||
|
|
||||||
ArrayList<ItemStack> list = EquivalencyHandler.instance().getEquivalencyList(id, meta);
|
|
||||||
|
|
||||||
ItemStack nextStack = null;
|
|
||||||
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
nextStack = EquivalencyHandler.instance().getNextInList(id, meta);
|
|
||||||
nextStack.stackSize = 1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the current item is the same as the original one we started
|
|
||||||
* with, then we have recursed through the entire list and not found
|
|
||||||
* a next block so return the original. This is the "base case" for
|
|
||||||
* the recursion.
|
|
||||||
*/
|
|
||||||
if (nextStack.itemID == origId && nextStack.getItemDamage() == origMeta)
|
|
||||||
{
|
|
||||||
return nextStack;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (nextStack.getItem() instanceof ItemBlock)
|
|
||||||
{
|
|
||||||
return nextStack;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return getNextBlock(nextStack.itemID, nextStack.getItemDamage(), origId, origMeta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// In the event the list is null, return null
|
|
||||||
return nextStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack getPreviousBlock(int itemID, int meta)
|
|
||||||
{
|
|
||||||
|
|
||||||
ArrayList<ItemStack> list = EquivalencyHandler.instance().getEquivalencyList(itemID, meta);
|
|
||||||
|
|
||||||
ItemStack prevStack = null;
|
|
||||||
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
return getPreviousBlock(itemID, meta, itemID, meta);
|
|
||||||
}
|
|
||||||
return prevStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ItemStack getPreviousBlock(int id, int meta, int origId, int origMeta)
|
|
||||||
{
|
|
||||||
|
|
||||||
ArrayList<ItemStack> list = EquivalencyHandler.instance().getEquivalencyList(id, meta);
|
|
||||||
|
|
||||||
ItemStack prevStack = null;
|
|
||||||
if (list != null)
|
|
||||||
{
|
|
||||||
prevStack = EquivalencyHandler.instance().getPrevInList(id, meta);
|
|
||||||
prevStack.stackSize = 1;
|
|
||||||
|
|
||||||
if (prevStack.itemID == origId && prevStack.getItemDamage() == origMeta)
|
|
||||||
{
|
|
||||||
return prevStack;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (prevStack.getItem() instanceof ItemBlock)
|
|
||||||
{
|
|
||||||
return prevStack;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return getPreviousBlock(prevStack.itemID, prevStack.getItemDamage(), origId, origMeta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// In the event the list is null, return null
|
|
||||||
return prevStack;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,235 +0,0 @@
|
||||||
package com.pahimar.ee3.helper;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
|
||||||
import com.pahimar.ee3.configuration.GeneralConfiguration;
|
|
||||||
import com.pahimar.ee3.lib.Colours;
|
|
||||||
import com.pahimar.ee3.lib.Reference;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import cpw.mods.fml.common.Loader;
|
|
||||||
import net.minecraft.util.StatCollector;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* VersionHelper
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class VersionHelper implements Runnable
|
|
||||||
{
|
|
||||||
|
|
||||||
// TODO Switch how versions are looked up from xml to json (for changelog support)
|
|
||||||
|
|
||||||
// All possible results of the remote version number check
|
|
||||||
public static final byte UNINITIALIZED = 0;
|
|
||||||
// Var to hold the result of the remote version check, initially set to uninitialized
|
|
||||||
private static byte result = UNINITIALIZED;
|
|
||||||
public static final byte CURRENT = 1;
|
|
||||||
public static final byte OUTDATED = 2;
|
|
||||||
public static final byte ERROR = 3;
|
|
||||||
public static final byte FINAL_ERROR = 4;
|
|
||||||
public static final byte MC_VERSION_NOT_FOUND = 5;
|
|
||||||
// The (publicly available) remote version number authority file
|
|
||||||
private static final String REMOTE_VERSION_XML_FILE = "https://raw.github.com/pahimar/Equivalent-Exchange-3/master/version.xml";
|
|
||||||
public static Properties remoteVersionProperties = new Properties();
|
|
||||||
public static String remoteVersion = null;
|
|
||||||
public static String remoteUpdateLocation = null;
|
|
||||||
private static VersionHelper instance = new VersionHelper();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks the version of the currently running instance of the mod against the remote version authority, and sets
|
|
||||||
* the result of the check appropriately
|
|
||||||
*/
|
|
||||||
public static void checkVersion()
|
|
||||||
{
|
|
||||||
|
|
||||||
InputStream remoteVersionRepoStream = null;
|
|
||||||
result = UNINITIALIZED;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
URL remoteVersionURL = new URL(REMOTE_VERSION_XML_FILE);
|
|
||||||
remoteVersionRepoStream = remoteVersionURL.openStream();
|
|
||||||
remoteVersionProperties.loadFromXML(remoteVersionRepoStream);
|
|
||||||
|
|
||||||
String remoteVersionProperty = remoteVersionProperties.getProperty(Loader.instance().getMCVersionString());
|
|
||||||
|
|
||||||
if (remoteVersionProperty != null)
|
|
||||||
{
|
|
||||||
String[] remoteVersionTokens = remoteVersionProperty.split("\\|");
|
|
||||||
|
|
||||||
if (remoteVersionTokens.length >= 2)
|
|
||||||
{
|
|
||||||
remoteVersion = remoteVersionTokens[0];
|
|
||||||
remoteUpdateLocation = remoteVersionTokens[1];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (remoteVersion != null)
|
|
||||||
{
|
|
||||||
if (!ConfigurationSettings.LAST_DISCOVERED_VERSION.equalsIgnoreCase(remoteVersion))
|
|
||||||
{
|
|
||||||
GeneralConfiguration.set(Configuration.CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_CONFIGNAME, remoteVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (remoteVersion.equalsIgnoreCase(getVersionForCheck()))
|
|
||||||
{
|
|
||||||
result = CURRENT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = OUTDATED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = MC_VERSION_NOT_FOUND;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
// NOOP
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (result == UNINITIALIZED)
|
|
||||||
{
|
|
||||||
result = ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (remoteVersionRepoStream != null)
|
|
||||||
{
|
|
||||||
remoteVersionRepoStream.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// NOOP
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getVersionForCheck()
|
|
||||||
{
|
|
||||||
|
|
||||||
String[] versionTokens = Reference.VERSION_NUMBER.split(" ");
|
|
||||||
|
|
||||||
if (versionTokens.length >= 1)
|
|
||||||
{
|
|
||||||
return versionTokens[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Reference.VERSION_NUMBER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void logResult()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (result == CURRENT || result == OUTDATED)
|
|
||||||
{
|
|
||||||
LogHelper.info(getResultMessage());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogHelper.warn(getResultMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getResultMessage()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (result == UNINITIALIZED)
|
|
||||||
{
|
|
||||||
return StatCollector.translateToLocal(Strings.UNINITIALIZED_MESSAGE);
|
|
||||||
}
|
|
||||||
else if (result == CURRENT)
|
|
||||||
{
|
|
||||||
return StatCollector.translateToLocalFormatted(Strings.CURRENT_MESSAGE, Reference.MOD_NAME, Loader.instance().getMCVersionString());
|
|
||||||
}
|
|
||||||
else if (result == OUTDATED && remoteVersion != null && remoteUpdateLocation != null)
|
|
||||||
{
|
|
||||||
return StatCollector.translateToLocalFormatted(Strings.OUTDATED_MESSAGE, Reference.MOD_NAME, remoteVersion, Loader.instance().getMCVersionString(), remoteUpdateLocation);
|
|
||||||
}
|
|
||||||
else if (result == ERROR)
|
|
||||||
{
|
|
||||||
return StatCollector.translateToLocal(Strings.GENERAL_ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
else if (result == FINAL_ERROR)
|
|
||||||
{
|
|
||||||
return StatCollector.translateToLocal(Strings.FINAL_ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
else if (result == MC_VERSION_NOT_FOUND)
|
|
||||||
{
|
|
||||||
return StatCollector.translateToLocalFormatted(Strings.MC_VERSION_NOT_FOUND, Reference.MOD_NAME, Loader.instance().getMCVersionString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = ERROR;
|
|
||||||
return StatCollector.translateToLocal(Strings.GENERAL_ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getResultMessageForClient()
|
|
||||||
{
|
|
||||||
|
|
||||||
return StatCollector.translateToLocalFormatted(Strings.OUTDATED_MESSAGE, Colours.TEXT_COLOUR_PREFIX_YELLOW + Reference.MOD_NAME + Colours.TEXT_COLOUR_PREFIX_WHITE, Colours.TEXT_COLOUR_PREFIX_YELLOW + VersionHelper.remoteVersion + Colours.TEXT_COLOUR_PREFIX_WHITE, Colours.TEXT_COLOUR_PREFIX_YELLOW + Loader.instance().getMCVersionString() + Colours.TEXT_COLOUR_PREFIX_WHITE, Colours.TEXT_COLOUR_PREFIX_YELLOW + VersionHelper.remoteUpdateLocation + Colours.TEXT_COLOUR_PREFIX_WHITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte getResult()
|
|
||||||
{
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void execute()
|
|
||||||
{
|
|
||||||
new Thread(instance).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
LogHelper.info(StatCollector.translateToLocalFormatted(Strings.VERSION_CHECK_INIT_LOG_MESSAGE, REMOTE_VERSION_XML_FILE));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
while (count < Reference.VERSION_CHECK_ATTEMPTS - 1 && (result == UNINITIALIZED || result == ERROR))
|
|
||||||
{
|
|
||||||
|
|
||||||
checkVersion();
|
|
||||||
count++;
|
|
||||||
logResult();
|
|
||||||
|
|
||||||
if (result == UNINITIALIZED || result == ERROR)
|
|
||||||
{
|
|
||||||
Thread.sleep(10000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == ERROR)
|
|
||||||
{
|
|
||||||
result = FINAL_ERROR;
|
|
||||||
logResult();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,329 +0,0 @@
|
||||||
package com.pahimar.ee3.imc;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.pahimar.ee3.EquivalentExchange3;
|
|
||||||
import com.pahimar.ee3.api.OreStack;
|
|
||||||
import com.pahimar.ee3.api.RecipeMapping;
|
|
||||||
import com.pahimar.ee3.api.StackValueMapping;
|
|
||||||
import com.pahimar.ee3.api.WrappedStack;
|
|
||||||
import com.pahimar.ee3.emc.EmcRegistry;
|
|
||||||
import com.pahimar.ee3.emc.EmcValue;
|
|
||||||
import com.pahimar.ee3.emc.EmcValuesIMC;
|
|
||||||
import com.pahimar.ee3.lib.Reference;
|
|
||||||
import com.pahimar.ee3.recipe.RecipesIMC;
|
|
||||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
|
||||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
|
||||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class InterModCommsHandler implements ITickHandler, IScheduledTickHandler
|
|
||||||
{
|
|
||||||
private static Gson gson = new Gson();
|
|
||||||
|
|
||||||
// TODO Logging
|
|
||||||
|
|
||||||
public static void processIMCMessages(IMCEvent event)
|
|
||||||
{
|
|
||||||
for (IMCMessage imcMessage : event.getMessages())
|
|
||||||
{
|
|
||||||
processIMCMessage(imcMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void processIMCMessage(IMCMessage imcMessage)
|
|
||||||
{
|
|
||||||
String requestedOperation = imcMessage.key;
|
|
||||||
|
|
||||||
if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.RECIPE_ADD))
|
|
||||||
{
|
|
||||||
processAddRecipeMessage(imcMessage);
|
|
||||||
}
|
|
||||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_ASSIGN_VALUE_PRE))
|
|
||||||
{
|
|
||||||
processPreAssignEmcValueMessage(imcMessage);
|
|
||||||
}
|
|
||||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_ASSIGN_VALUE_POST))
|
|
||||||
{
|
|
||||||
processPostAssignEmcValueMessage(imcMessage);
|
|
||||||
}
|
|
||||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_HAS_VALUE))
|
|
||||||
{
|
|
||||||
processHasEmcValueMessage(imcMessage);
|
|
||||||
}
|
|
||||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_GET_VALUE))
|
|
||||||
{
|
|
||||||
processGetEmcValueMessage(imcMessage);
|
|
||||||
}
|
|
||||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_SIMPLE_ASSIGN_VALUE_PRE))
|
|
||||||
{
|
|
||||||
processSimplePreAssignEmcValueMessage(imcMessage);
|
|
||||||
}
|
|
||||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_SIMPLE_ASSIGN_VALUE_POST))
|
|
||||||
{
|
|
||||||
processSimplePostAssignEmcValueMessage(imcMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processAddRecipeMessage(IMCMessage imcMessage)
|
|
||||||
{
|
|
||||||
if (imcMessage.getMessageType() == String.class)
|
|
||||||
{
|
|
||||||
RecipeMapping recipeMapping = RecipeMapping.createFromJson(imcMessage.getStringValue());
|
|
||||||
|
|
||||||
if (recipeMapping != null)
|
|
||||||
{
|
|
||||||
|
|
||||||
WrappedStack outputWrappedStack = recipeMapping.outputWrappedStack;
|
|
||||||
List<WrappedStack> inputWrappedStacks = recipeMapping.inputWrappedStacks;
|
|
||||||
|
|
||||||
RecipesIMC.addRecipe(outputWrappedStack, inputWrappedStacks);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Log that the message payloads json was invalid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Log that the message payload is of an invalid type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processPreAssignEmcValueMessage(IMCMessage imcMessage)
|
|
||||||
{
|
|
||||||
if (imcMessage.getMessageType() == String.class)
|
|
||||||
{
|
|
||||||
StackValueMapping stackValueMapping = StackValueMapping.createFromJson(imcMessage.getStringValue());
|
|
||||||
|
|
||||||
if (stackValueMapping != null)
|
|
||||||
{
|
|
||||||
WrappedStack wrappedStack = stackValueMapping.wrappedStack;
|
|
||||||
EmcValue emcValue = new EmcValue(stackValueMapping.emcValue.getValue());
|
|
||||||
|
|
||||||
EmcValuesIMC.addPreAssignedValued(wrappedStack, emcValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Log that the message payloads json was invalid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Log that the message payload is of an invalid type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processPostAssignEmcValueMessage(IMCMessage imcMessage)
|
|
||||||
{
|
|
||||||
if (imcMessage.getMessageType() == String.class)
|
|
||||||
{
|
|
||||||
StackValueMapping stackValueMapping = StackValueMapping.createFromJson(imcMessage.getStringValue());
|
|
||||||
|
|
||||||
if (stackValueMapping != null)
|
|
||||||
{
|
|
||||||
WrappedStack wrappedStack = stackValueMapping.wrappedStack;
|
|
||||||
EmcValue emcValue = new EmcValue(stackValueMapping.emcValue.getValue());
|
|
||||||
|
|
||||||
EmcValuesIMC.addPostAssignedValued(wrappedStack, emcValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Log that the message payloads json was invalid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Log that the message payload is of an invalid type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processHasEmcValueMessage(IMCMessage imcMessage)
|
|
||||||
{
|
|
||||||
if (imcMessage.getMessageType() == String.class)
|
|
||||||
{
|
|
||||||
WrappedStack wrappedStack = WrappedStack.createFromJson(imcMessage.getStringValue());
|
|
||||||
|
|
||||||
if (wrappedStack != null)
|
|
||||||
{
|
|
||||||
FMLInterModComms.sendRuntimeMessage(
|
|
||||||
EquivalentExchange3.instance,
|
|
||||||
imcMessage.getSender(),
|
|
||||||
InterModCommsOperations.EMC_RETURN_HAS_VALUE,
|
|
||||||
String.format("%s==%s", imcMessage.getStringValue(), String.valueOf(EmcRegistry.getInstance().hasEmcValue(wrappedStack))));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Log that the message payloads json was invalid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (imcMessage.getMessageType() == ItemStack.class)
|
|
||||||
{
|
|
||||||
ItemStack itemStack = imcMessage.getItemStackValue();
|
|
||||||
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
FMLInterModComms.sendRuntimeMessage(
|
|
||||||
EquivalentExchange3.instance,
|
|
||||||
imcMessage.getSender(),
|
|
||||||
InterModCommsOperations.EMC_RETURN_HAS_VALUE,
|
|
||||||
String.format("%s==%s", gson.toJson(itemStack), String.valueOf(EmcRegistry.getInstance().hasEmcValue(itemStack))));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Logging
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Log that the message payload is of an invalid type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processGetEmcValueMessage(IMCMessage imcMessage)
|
|
||||||
{
|
|
||||||
if (imcMessage.getMessageType() == String.class)
|
|
||||||
{
|
|
||||||
WrappedStack wrappedStack = WrappedStack.createFromJson(imcMessage.getStringValue());
|
|
||||||
|
|
||||||
if (wrappedStack != null)
|
|
||||||
{
|
|
||||||
FMLInterModComms.sendRuntimeMessage(
|
|
||||||
EquivalentExchange3.instance,
|
|
||||||
imcMessage.getSender(),
|
|
||||||
InterModCommsOperations.EMC_RETURN_GET_VALUE,
|
|
||||||
String.format("%s==%s", imcMessage.getStringValue(), EmcRegistry.getInstance().getEmcValue(wrappedStack).toJson()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Log that the message payloads json was invalid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (imcMessage.getMessageType() == ItemStack.class)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Reply back to the mod that queried for the existance of an EmcValue for the given ItemStack
|
|
||||||
*/
|
|
||||||
ItemStack itemStack = imcMessage.getItemStackValue();
|
|
||||||
|
|
||||||
FMLInterModComms.sendRuntimeMessage(
|
|
||||||
EquivalentExchange3.instance,
|
|
||||||
imcMessage.getSender(),
|
|
||||||
InterModCommsOperations.EMC_RETURN_GET_VALUE,
|
|
||||||
String.format("%s==%s", gson.toJson(itemStack), EmcRegistry.getInstance().getEmcValue(itemStack).toJson()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO Log that the message payload is of an invalid type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processSimplePreAssignEmcValueMessage(IMCMessage imcMessage)
|
|
||||||
{
|
|
||||||
NBTTagCompound tagCompound = imcMessage.getNBTValue();
|
|
||||||
if (tagCompound.hasKey("emcValue"))
|
|
||||||
{
|
|
||||||
WrappedStack wrappedStack;
|
|
||||||
EmcValue emcValue = new EmcValue(tagCompound.getFloat("emcValue"));
|
|
||||||
|
|
||||||
if (tagCompound.hasKey("itemStack"))
|
|
||||||
{
|
|
||||||
wrappedStack = new WrappedStack(ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag("itemStack")));
|
|
||||||
}
|
|
||||||
else if (tagCompound.hasKey("oreName"))
|
|
||||||
{
|
|
||||||
wrappedStack = new WrappedStack(new OreStack(tagCompound.getString("oreName")));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO log that the message didn't contain either a itemstack or a ore dictionary name
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
EmcValuesIMC.addPreAssignedValued(wrappedStack, emcValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO log that no EMC value was sent in the message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processSimplePostAssignEmcValueMessage(IMCMessage imcMessage)
|
|
||||||
{
|
|
||||||
NBTTagCompound tagCompound = imcMessage.getNBTValue();
|
|
||||||
if (tagCompound.hasKey("emcValue"))
|
|
||||||
{
|
|
||||||
WrappedStack wrappedStack;
|
|
||||||
EmcValue emcValue = new EmcValue(tagCompound.getFloat("emcValue"));
|
|
||||||
|
|
||||||
if (tagCompound.hasKey("itemStack"))
|
|
||||||
{
|
|
||||||
wrappedStack = new WrappedStack(ItemStack.loadItemStackFromNBT(tagCompound.getCompoundTag("itemStack")));
|
|
||||||
}
|
|
||||||
else if (tagCompound.hasKey("oreName"))
|
|
||||||
{
|
|
||||||
wrappedStack = new WrappedStack(new OreStack(tagCompound.getString("oreName")));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO log that the message didn't contain either a itemstack or a ore dictionary name
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
EmcValuesIMC.addPostAssignedValued(wrappedStack, emcValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO log that no EMC value was sent in the message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runtime fetching and processing of IMC messages
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
|
||||||
{
|
|
||||||
for (TickType tickType : type)
|
|
||||||
{
|
|
||||||
if (tickType == TickType.SERVER)
|
|
||||||
{
|
|
||||||
ImmutableList<IMCMessage> runtimeIMCMessages = FMLInterModComms.fetchRuntimeMessages(EquivalentExchange3.instance);
|
|
||||||
|
|
||||||
for (IMCMessage imcMessage : runtimeIMCMessages)
|
|
||||||
{
|
|
||||||
InterModCommsHandler.processIMCMessage(imcMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EnumSet<TickType> ticks()
|
|
||||||
{
|
|
||||||
return EnumSet.of(TickType.SERVER);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLabel()
|
|
||||||
{
|
|
||||||
return Reference.MOD_NAME + ": " + this.getClass().getSimpleName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int nextTickSpacing()
|
|
||||||
{
|
|
||||||
|
|
||||||
return Reference.ONE_SECOND_IN_TICKS;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package com.pahimar.ee3.imc;
|
|
||||||
|
|
||||||
public class InterModCommsOperations
|
|
||||||
{
|
|
||||||
|
|
||||||
// Interacting with the Recipe Registry
|
|
||||||
public static final String RECIPE_ADD = "recipe-add";
|
|
||||||
|
|
||||||
// Interacting with the EMC value mappings
|
|
||||||
public static final String EMC_ASSIGN_VALUE_PRE = "emc-assign-value-pre";
|
|
||||||
public static final String EMC_ASSIGN_VALUE_POST = "emc-assign-value-post";
|
|
||||||
public static final String EMC_HAS_VALUE = "emc-has-value";
|
|
||||||
public static final String EMC_RETURN_HAS_VALUE = "emc-return-has-value";
|
|
||||||
public static final String EMC_GET_VALUE = "emc-get-value";
|
|
||||||
public static final String EMC_RETURN_GET_VALUE = "emc-return-get-value";
|
|
||||||
public static final String EMC_SIMPLE_ASSIGN_VALUE_PRE = "emc-simple-assign-value-pre";
|
|
||||||
public static final String EMC_SIMPLE_ASSIGN_VALUE_POST = "emc-simple-assign-value-post";
|
|
||||||
}
|
|
|
@ -1,212 +0,0 @@
|
||||||
package com.pahimar.ee3.inventory;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.helper.ItemStackNBTHelper;
|
|
||||||
import com.pahimar.ee3.item.ItemAlchemicalBag;
|
|
||||||
import com.pahimar.ee3.lib.Strings;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.inventory.Slot;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ContainerAlchemicalBag
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class ContainerAlchemicalBag extends Container
|
|
||||||
{
|
|
||||||
private final EntityPlayer entityPlayer;
|
|
||||||
private final InventoryAlchemicalBag inventoryAlchemicalBag;
|
|
||||||
|
|
||||||
private int bagInventoryRows;
|
|
||||||
private int bagInventoryColumns;
|
|
||||||
|
|
||||||
// Small Bag
|
|
||||||
public static final int SMALL_BAG_INVENTORY_ROWS = 4;
|
|
||||||
public static final int SMALL_BAG_INVENTORY_COLUMNS = 12;
|
|
||||||
|
|
||||||
// Medium Bag
|
|
||||||
public static final int MEDIUM_BAG_INVENTORY_ROWS = 7;
|
|
||||||
public static final int MEDIUM_BAG_INVENTORY_COLUMNS = 12;
|
|
||||||
|
|
||||||
// Large Bag
|
|
||||||
public static final int LARGE_BAG_INVENTORY_ROWS = 9;
|
|
||||||
public static final int LARGE_BAG_INVENTORY_COLUMNS = 13;
|
|
||||||
|
|
||||||
// Player Inventory
|
|
||||||
private final int PLAYER_INVENTORY_ROWS = 3;
|
|
||||||
private final int PLAYER_INVENTORY_COLUMNS = 9;
|
|
||||||
|
|
||||||
public ContainerAlchemicalBag(EntityPlayer entityPlayer, InventoryAlchemicalBag inventoryAlchemicalBag)
|
|
||||||
{
|
|
||||||
this.entityPlayer = entityPlayer;
|
|
||||||
this.inventoryAlchemicalBag = inventoryAlchemicalBag;
|
|
||||||
|
|
||||||
if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0)
|
|
||||||
{
|
|
||||||
bagInventoryRows = SMALL_BAG_INVENTORY_ROWS;
|
|
||||||
bagInventoryColumns = SMALL_BAG_INVENTORY_COLUMNS;
|
|
||||||
}
|
|
||||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1)
|
|
||||||
{
|
|
||||||
bagInventoryRows = MEDIUM_BAG_INVENTORY_ROWS;
|
|
||||||
bagInventoryColumns = MEDIUM_BAG_INVENTORY_COLUMNS;
|
|
||||||
}
|
|
||||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2)
|
|
||||||
{
|
|
||||||
bagInventoryRows = LARGE_BAG_INVENTORY_ROWS;
|
|
||||||
bagInventoryColumns = LARGE_BAG_INVENTORY_COLUMNS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the Alchemical Chest slots to the container
|
|
||||||
for (int bagRowIndex = 0; bagRowIndex < bagInventoryRows; ++bagRowIndex)
|
|
||||||
{
|
|
||||||
for (int bagColumnIndex = 0; bagColumnIndex < bagInventoryColumns; ++bagColumnIndex)
|
|
||||||
{
|
|
||||||
if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new SlotAlchemicalBag(this, inventoryAlchemicalBag, entityPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 18 + bagRowIndex * 18));
|
|
||||||
}
|
|
||||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new SlotAlchemicalBag(this, inventoryAlchemicalBag, entityPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 18 + bagRowIndex * 18));
|
|
||||||
}
|
|
||||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new SlotAlchemicalBag(this, inventoryAlchemicalBag, entityPlayer, bagColumnIndex + bagRowIndex * bagInventoryColumns, 8 + bagColumnIndex * 18, 8 + bagRowIndex * 18));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the player's inventory slots to the container
|
|
||||||
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
|
|
||||||
{
|
|
||||||
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
|
|
||||||
{
|
|
||||||
if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(entityPlayer.inventory, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 104 + inventoryRowIndex * 18));
|
|
||||||
}
|
|
||||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(entityPlayer.inventory, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 158 + inventoryRowIndex * 18));
|
|
||||||
}
|
|
||||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(entityPlayer.inventory, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 44 + inventoryColumnIndex * 18, 174 + inventoryRowIndex * 18));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the player's action bar slots to the container
|
|
||||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
|
|
||||||
{
|
|
||||||
if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 0)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(entityPlayer.inventory, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 162));
|
|
||||||
}
|
|
||||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 1)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(entityPlayer.inventory, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 216));
|
|
||||||
}
|
|
||||||
else if (inventoryAlchemicalBag.parentItemStack.getItemDamage() == 2)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(entityPlayer.inventory, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 232));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canInteractWith(EntityPlayer var1)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onContainerClosed(EntityPlayer entityPlayer)
|
|
||||||
{
|
|
||||||
super.onContainerClosed(entityPlayer);
|
|
||||||
|
|
||||||
if (!entityPlayer.worldObj.isRemote)
|
|
||||||
{
|
|
||||||
// We can probably do this better now considering the InventoryAlchemicalBag has a findParent method
|
|
||||||
InventoryPlayer invPlayer = entityPlayer.inventory;
|
|
||||||
for (ItemStack itemStack : invPlayer.mainInventory)
|
|
||||||
{
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN))
|
|
||||||
{
|
|
||||||
ItemStackNBTHelper.removeTag(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
saveInventory(entityPlayer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
|
|
||||||
{
|
|
||||||
ItemStack newItemStack = null;
|
|
||||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
|
||||||
|
|
||||||
if (slot != null && slot.getHasStack())
|
|
||||||
{
|
|
||||||
ItemStack itemStack = slot.getStack();
|
|
||||||
newItemStack = itemStack.copy();
|
|
||||||
|
|
||||||
// Attempt to shift click something from the bag inventory into the player inventory
|
|
||||||
if (slotIndex < bagInventoryRows * bagInventoryColumns)
|
|
||||||
{
|
|
||||||
if (!this.mergeItemStack(itemStack, bagInventoryRows * bagInventoryColumns, inventorySlots.size(), false))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Special case if we are dealing with an Alchemical Bag being shift clicked
|
|
||||||
else if (itemStack.getItem() instanceof ItemAlchemicalBag)
|
|
||||||
{
|
|
||||||
// Attempt to shift click a bag from the player inventory into the hot bar inventory
|
|
||||||
if (slotIndex < (bagInventoryRows * bagInventoryColumns) + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS))
|
|
||||||
{
|
|
||||||
if (!this.mergeItemStack(itemStack, (bagInventoryRows * bagInventoryColumns) + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), inventorySlots.size(), false))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Attempt to shift click a bag from the hot bar inventory into the player inventory
|
|
||||||
else if (!this.mergeItemStack(itemStack, bagInventoryRows * bagInventoryColumns, (bagInventoryRows * bagInventoryColumns) + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), false))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Attempt to shift click a non-Alchemical Bag into the bag inventory
|
|
||||||
else if (!this.mergeItemStack(itemStack, 0, bagInventoryRows * bagInventoryColumns, false))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (itemStack.stackSize == 0)
|
|
||||||
{
|
|
||||||
slot.putStack(null);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
slot.onSlotChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return newItemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveInventory(EntityPlayer entityPlayer)
|
|
||||||
{
|
|
||||||
inventoryAlchemicalBag.onGuiSaved(entityPlayer);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,173 +0,0 @@
|
||||||
package com.pahimar.ee3.inventory;
|
|
||||||
|
|
||||||
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.inventory.Slot;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* ContainerAlchemicalChest
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public class ContainerAlchemicalChest extends Container
|
|
||||||
{
|
|
||||||
private TileAlchemicalChest tileAlchemicalChest;
|
|
||||||
|
|
||||||
private int chestInventoryRows;
|
|
||||||
private int chestInventoryColumns;
|
|
||||||
|
|
||||||
// Small Chest
|
|
||||||
public static final int SMALL_CHEST_INVENTORY_ROWS = 4;
|
|
||||||
public static final int SMALL_CHEST_INVENTORY_COLUMNS = 12;
|
|
||||||
public static final int SMALL_INVENTORY_SIZE = SMALL_CHEST_INVENTORY_ROWS * SMALL_CHEST_INVENTORY_COLUMNS;
|
|
||||||
|
|
||||||
// Medium Chest
|
|
||||||
public static final int MEDIUM_CHEST_INVENTORY_ROWS = 7;
|
|
||||||
public static final int MEDIUM_CHEST_INVENTORY_COLUMNS = 12;
|
|
||||||
public static final int MEDIUM_INVENTORY_SIZE = MEDIUM_CHEST_INVENTORY_ROWS * MEDIUM_CHEST_INVENTORY_COLUMNS;
|
|
||||||
|
|
||||||
// Large Chest
|
|
||||||
public static final int LARGE_CHEST_INVENTORY_ROWS = 9;
|
|
||||||
public static final int LARGE_CHEST_INVENTORY_COLUMNS = 13;
|
|
||||||
public static final int LARGE_INVENTORY_SIZE = LARGE_CHEST_INVENTORY_ROWS * LARGE_CHEST_INVENTORY_COLUMNS;
|
|
||||||
|
|
||||||
// Player Inventory
|
|
||||||
private final int PLAYER_INVENTORY_ROWS = 3;
|
|
||||||
private final int PLAYER_INVENTORY_COLUMNS = 9;
|
|
||||||
|
|
||||||
public ContainerAlchemicalChest(InventoryPlayer inventoryPlayer, TileAlchemicalChest tileAlchemicalChest)
|
|
||||||
{
|
|
||||||
this.tileAlchemicalChest = tileAlchemicalChest;
|
|
||||||
tileAlchemicalChest.openChest();
|
|
||||||
|
|
||||||
if (this.tileAlchemicalChest.getState() == 0)
|
|
||||||
{
|
|
||||||
chestInventoryRows = SMALL_CHEST_INVENTORY_ROWS;
|
|
||||||
chestInventoryColumns = SMALL_CHEST_INVENTORY_COLUMNS;
|
|
||||||
}
|
|
||||||
else if (this.tileAlchemicalChest.getState() == 1)
|
|
||||||
{
|
|
||||||
chestInventoryRows = MEDIUM_CHEST_INVENTORY_ROWS;
|
|
||||||
chestInventoryColumns = MEDIUM_CHEST_INVENTORY_COLUMNS;
|
|
||||||
}
|
|
||||||
else if (this.tileAlchemicalChest.getState() == 2)
|
|
||||||
{
|
|
||||||
chestInventoryRows = LARGE_CHEST_INVENTORY_ROWS;
|
|
||||||
chestInventoryColumns = LARGE_CHEST_INVENTORY_COLUMNS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the Alchemical Chest slots to the container
|
|
||||||
for (int chestRowIndex = 0; chestRowIndex < chestInventoryRows; ++chestRowIndex)
|
|
||||||
{
|
|
||||||
for (int chestColumnIndex = 0; chestColumnIndex < chestInventoryColumns; ++chestColumnIndex)
|
|
||||||
{
|
|
||||||
if (this.tileAlchemicalChest.getState() == 0)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(tileAlchemicalChest, chestColumnIndex + chestRowIndex * chestInventoryColumns, 8 + chestColumnIndex * 18, 18 + chestRowIndex * 18));
|
|
||||||
}
|
|
||||||
else if (this.tileAlchemicalChest.getState() == 1)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(tileAlchemicalChest, chestColumnIndex + chestRowIndex * chestInventoryColumns, 8 + chestColumnIndex * 18, 18 + chestRowIndex * 18));
|
|
||||||
}
|
|
||||||
else if (this.tileAlchemicalChest.getState() == 2)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(tileAlchemicalChest, chestColumnIndex + chestRowIndex * chestInventoryColumns, 8 + chestColumnIndex * 18, 8 + chestRowIndex * 18));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the player's inventory slots to the container
|
|
||||||
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
|
|
||||||
{
|
|
||||||
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
|
|
||||||
{
|
|
||||||
if (this.tileAlchemicalChest.getState() == 0)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 104 + inventoryRowIndex * 18));
|
|
||||||
}
|
|
||||||
else if (this.tileAlchemicalChest.getState() == 1)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 35 + inventoryColumnIndex * 18, 158 + inventoryRowIndex * 18));
|
|
||||||
}
|
|
||||||
else if (this.tileAlchemicalChest.getState() == 2)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 44 + inventoryColumnIndex * 18, 174 + inventoryRowIndex * 18));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the player's action bar slots to the container
|
|
||||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
|
|
||||||
{
|
|
||||||
if (this.tileAlchemicalChest.getState() == 0)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 162));
|
|
||||||
}
|
|
||||||
else if (this.tileAlchemicalChest.getState() == 1)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 35 + actionBarSlotIndex * 18, 216));
|
|
||||||
}
|
|
||||||
else if (this.tileAlchemicalChest.getState() == 2)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 232));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canInteractWith(EntityPlayer var1)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback for when the crafting gui is closed.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onContainerClosed(EntityPlayer entityPlayer)
|
|
||||||
{
|
|
||||||
super.onContainerClosed(entityPlayer);
|
|
||||||
tileAlchemicalChest.closeChest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
|
|
||||||
{
|
|
||||||
ItemStack newItemStack = null;
|
|
||||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
|
||||||
|
|
||||||
if (slot != null && slot.getHasStack())
|
|
||||||
{
|
|
||||||
ItemStack itemStack = slot.getStack();
|
|
||||||
newItemStack = itemStack.copy();
|
|
||||||
|
|
||||||
if (slotIndex < chestInventoryRows * chestInventoryColumns)
|
|
||||||
{
|
|
||||||
if (!this.mergeItemStack(itemStack, chestInventoryRows * chestInventoryColumns, inventorySlots.size(), false))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!this.mergeItemStack(itemStack, 0, chestInventoryRows * chestInventoryColumns, false))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemStack.stackSize == 0)
|
|
||||||
{
|
|
||||||
slot.putStack(null);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
slot.onSlotChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return newItemStack;
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue