Switched to LF vs CRLF line breaks, and code formatting changes
This commit is contained in:
parent
c185649e2e
commit
aeaad5d046
134
build.gradle
134
build.gradle
|
@ -23,36 +23,36 @@ configFile.withReader {
|
|||
project.ext.config = new ConfigSlurper().parse prop
|
||||
}
|
||||
|
||||
group = "com.pahimar.ee3"
|
||||
group = "com.pahimar.ee3"
|
||||
version = config.mod_version + "." + config.build_number
|
||||
archivesBaseName = "EquivalentExchange3"
|
||||
|
||||
minecraft {
|
||||
version = config.minecraft_version + "-" + config.forge_version
|
||||
assetDir = "run/assets"
|
||||
|
||||
|
||||
replaceIn "lib/Reference.java"
|
||||
if (project.hasProperty("ee3_signature"))
|
||||
replace "@FINGERPRINT@", project.ee3_signature
|
||||
}
|
||||
|
||||
processResources
|
||||
{
|
||||
// replace stuff in the files we want.
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
include 'version.properties'
|
||||
|
||||
// replaces
|
||||
expand 'version': project.config.mod_version, 'buildnumber': project.config.build_number
|
||||
}
|
||||
|
||||
// copy everything else, thats we didnt do before
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
exclude 'version.properties'
|
||||
}
|
||||
}
|
||||
{
|
||||
// replace stuff in the files we want.
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
include 'version.properties'
|
||||
|
||||
// replaces
|
||||
expand 'version': project.config.mod_version, 'buildnumber': project.config.build_number
|
||||
}
|
||||
|
||||
// copy everything else, thats we didnt do before
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
exclude 'version.properties'
|
||||
}
|
||||
}
|
||||
|
||||
// BEYOND THIS POINT..
|
||||
// IS STUFF THATS FOR RELEASING...
|
||||
|
@ -60,10 +60,10 @@ processResources
|
|||
// verify the properties exist.. or initialize.
|
||||
if (!project.hasProperty("keystore_location")) // keystore stuff
|
||||
ext.keystore_location = ".";
|
||||
|
||||
|
||||
if (!project.hasProperty("ee3_keystore_alias")) // keystore stuff
|
||||
ext.ee3_keystore_alias = "";
|
||||
|
||||
|
||||
if (!project.hasProperty("keystore_password")) // keystore stuff
|
||||
ext.keystore_password = "";
|
||||
|
||||
|
@ -71,57 +71,57 @@ if (!project.hasProperty("ee3_release_loc")) // release loc
|
|||
ext.ee3_release_loc = ".";
|
||||
else
|
||||
ee3_release_loc = ee3_release_loc.replace('{MC}', minecraft.version).replace('{MODVER}', config.mod_version).replace('{BUILD}', config.build_number)
|
||||
|
||||
task("signJar", dependsOn: "reobf")
|
||||
{
|
||||
inputs.file jar.getArchivePath()
|
||||
inputs.file keystore_location
|
||||
inputs.property "ee3_keystore_alias", ee3_keystore_alias
|
||||
inputs.property "keystore_password", keystore_password
|
||||
outputs.file jar.getArchivePath()
|
||||
|
||||
// only sign if the keystore exists
|
||||
onlyIf {
|
||||
return keystore_location != "."
|
||||
}
|
||||
|
||||
// the actual action.. sign the jar.
|
||||
doLast {
|
||||
ant.signjar(
|
||||
destDir: jar.destinationDir,
|
||||
jar: jar.getArchivePath(),
|
||||
keystore: keystore_location,
|
||||
alias: ee3_keystore_alias,
|
||||
storepass: keystore_password
|
||||
)
|
||||
}
|
||||
}
|
||||
task("signJar", dependsOn: "reobf")
|
||||
{
|
||||
inputs.file jar.getArchivePath()
|
||||
inputs.file keystore_location
|
||||
inputs.property "ee3_keystore_alias", ee3_keystore_alias
|
||||
inputs.property "keystore_password", keystore_password
|
||||
outputs.file jar.getArchivePath()
|
||||
|
||||
// only sign if the keystore exists
|
||||
onlyIf {
|
||||
return keystore_location != "."
|
||||
}
|
||||
|
||||
// the actual action.. sign the jar.
|
||||
doLast {
|
||||
ant.signjar(
|
||||
destDir: jar.destinationDir,
|
||||
jar: jar.getArchivePath(),
|
||||
keystore: keystore_location,
|
||||
alias: ee3_keystore_alias,
|
||||
storepass: keystore_password
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
task("incrementBuildNumber")
|
||||
{
|
||||
// increment build number
|
||||
doFirst {
|
||||
// increment
|
||||
config.build_number = (config.build_number.toString().toInteger()) + 1
|
||||
|
||||
// write back to the file
|
||||
configFile.withWriter {
|
||||
config.toProperties().store(it, "")
|
||||
{
|
||||
// increment build number
|
||||
doFirst {
|
||||
// increment
|
||||
config.build_number = (config.build_number.toString().toInteger()) + 1
|
||||
|
||||
// write back to the file
|
||||
configFile.withWriter {
|
||||
config.toProperties().store(it, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task("release", type: Copy)
|
||||
{
|
||||
dependsOn "incrementBuildNumber"
|
||||
dependsOn "signJar"
|
||||
{
|
||||
dependsOn "incrementBuildNumber"
|
||||
dependsOn "signJar"
|
||||
|
||||
eachFile { file ->
|
||||
logger.info "copying ${file}"
|
||||
}
|
||||
|
||||
// only if the release location isnt empty.
|
||||
onlyIf {
|
||||
return project.ee3_release_loc != "."
|
||||
}
|
||||
}
|
||||
eachFile { file ->
|
||||
logger.info "copying ${file}"
|
||||
}
|
||||
|
||||
// only if the release location isnt empty.
|
||||
onlyIf {
|
||||
return project.ee3_release_loc != "."
|
||||
}
|
||||
}
|
|
@ -1,23 +1,11 @@
|
|||
package com.pahimar.ee3;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import com.pahimar.ee3.block.ModBlocks;
|
||||
import com.pahimar.ee3.command.CommandHandler;
|
||||
import com.pahimar.ee3.configuration.ConfigurationHandler;
|
||||
import com.pahimar.ee3.core.handler.ActionRequestHandler;
|
||||
import com.pahimar.ee3.core.handler.CraftingHandler;
|
||||
import com.pahimar.ee3.core.handler.EntityLivingHandler;
|
||||
import com.pahimar.ee3.core.handler.ItemEventHandler;
|
||||
import com.pahimar.ee3.core.handler.ItemTooltipEventHandler;
|
||||
import com.pahimar.ee3.core.handler.PlayerDestroyItemHandler;
|
||||
import com.pahimar.ee3.core.handler.VersionCheckTickHandler;
|
||||
import com.pahimar.ee3.core.handler.WorldTransmutationHandler;
|
||||
import com.pahimar.ee3.core.handler.*;
|
||||
import com.pahimar.ee3.core.handler.addon.AddonIMCHandler;
|
||||
import com.pahimar.ee3.core.helper.ItemHelper;
|
||||
import com.pahimar.ee3.core.helper.LogHelper;
|
||||
import com.pahimar.ee3.core.helper.VersionHelper;
|
||||
import com.pahimar.ee3.core.proxy.CommonProxy;
|
||||
|
@ -25,39 +13,46 @@ import com.pahimar.ee3.creativetab.CreativeTabEE3;
|
|||
import com.pahimar.ee3.emc.EmcRegistry;
|
||||
import com.pahimar.ee3.imc.InterModCommsHandler;
|
||||
import com.pahimar.ee3.item.ModItems;
|
||||
import com.pahimar.ee3.item.OreStack;
|
||||
import com.pahimar.ee3.item.crafting.RecipeRegistry;
|
||||
import com.pahimar.ee3.item.crafting.RecipesAlchemicalBagDyes;
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import com.pahimar.ee3.network.PacketHandler;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLFingerprintViolationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.*;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* EquivalentExchange3
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, dependencies = Reference.DEPENDENCIES, certificateFingerprint = Reference.FINGERPRINT)
|
||||
@NetworkMod(channels = { Reference.CHANNEL_NAME }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
||||
public class EquivalentExchange3 {
|
||||
@NetworkMod(channels = {Reference.CHANNEL_NAME}, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
||||
public class EquivalentExchange3
|
||||
{
|
||||
|
||||
@Instance(Reference.MOD_ID)
|
||||
public static EquivalentExchange3 instance;
|
||||
|
@ -68,28 +63,33 @@ public class EquivalentExchange3 {
|
|||
public static CreativeTabs tabsEE3 = new CreativeTabEE3(CreativeTabs.getNextID(), Reference.MOD_ID);
|
||||
|
||||
@EventHandler
|
||||
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@")) {
|
||||
if (Reference.FINGERPRINT.equals("@FINGERPRINT@"))
|
||||
{
|
||||
LogHelper.warning(Strings.NO_FINGERPRINT_MESSAGE);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
LogHelper.severe(Strings.INVALID_FINGERPRINT_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
public void serverStarting(FMLServerStartingEvent event)
|
||||
{
|
||||
|
||||
// Initialize the custom commands
|
||||
CommandHandler.initCommands(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
|
||||
// set version number
|
||||
event.getModMetadata().version = Reference.VERSION_NUMBER;
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class EquivalentExchange3 {
|
|||
|
||||
// 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);
|
||||
|
||||
|
@ -126,7 +126,8 @@ public class EquivalentExchange3 {
|
|||
|
||||
@EventHandler
|
||||
@SuppressWarnings("unchecked")
|
||||
public void load(FMLInitializationEvent event) {
|
||||
public void load(FMLInitializationEvent event)
|
||||
{
|
||||
|
||||
// Register the GUI Handler
|
||||
NetworkRegistry.instance().registerGuiHandler(instance, proxy);
|
||||
|
@ -159,19 +160,36 @@ public class EquivalentExchange3 {
|
|||
|
||||
// Add in the ability to dye Alchemical Bags
|
||||
CraftingManager.getInstance().getRecipeList().add(new RecipesAlchemicalBagDyes());
|
||||
|
||||
|
||||
// Initialize addons (which work with IMC, and must be used in Init)
|
||||
AddonIMCHandler.init();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void modsLoaded(FMLPostInitializationEvent event) {
|
||||
|
||||
public void modsLoaded(FMLPostInitializationEvent event)
|
||||
{
|
||||
|
||||
LogHelper.debug(RecipeRegistry.getInstance().toString());
|
||||
|
||||
EmcRegistry.lazyInit();
|
||||
|
||||
List<String> oreNames = Arrays.asList(OreDictionary.getOreNames());
|
||||
Collections.sort(oreNames);
|
||||
for (String oreName : oreNames)
|
||||
{
|
||||
if (!EmcRegistry.hasEmcValue(new OreStack(oreName)))
|
||||
{
|
||||
for (ItemStack itemStack : OreDictionary.getOres(oreName))
|
||||
{
|
||||
LogHelper.debug(String.format("%s: %s", oreName, ItemHelper.toString(itemStack)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleIMCMessages(IMCEvent event) {
|
||||
public void handleIMCMessages(IMCEvent event)
|
||||
{
|
||||
|
||||
InterModCommsHandler.processIMCMessages(event);
|
||||
}
|
||||
|
|
|
@ -1,37 +1,62 @@
|
|||
package com.pahimar.ee3.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.pahimar.ee3.item.WrappedStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RecipeMapping
|
||||
{
|
||||
private static Gson gsonSerializer = new Gson();
|
||||
|
||||
|
||||
public final WrappedStack outputWrappedStack;
|
||||
public final List<WrappedStack> inputWrappedStacks;
|
||||
|
||||
public RecipeMapping(WrappedStack outputWrappedStack, List<WrappedStack> inputWrappedStacks) {
|
||||
this.outputWrappedStack = outputWrappedStack;
|
||||
this.inputWrappedStacks = inputWrappedStacks;
|
||||
}
|
||||
|
||||
public static RecipeMapping createFromJson(String jsonRecipeMapping) {
|
||||
|
||||
try {
|
||||
return (RecipeMapping) gsonSerializer.fromJson(jsonRecipeMapping, RecipeMapping.class);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
catch (JsonSyntaxException exception) {
|
||||
|
||||
if (inputStacks.size() == wrappedStacks.size())
|
||||
{
|
||||
this.inputWrappedStacks = wrappedStacks;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inputWrappedStacks = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static RecipeMapping createFromJson(String jsonRecipeMapping)
|
||||
{
|
||||
try
|
||||
{
|
||||
return gsonSerializer.fromJson(jsonRecipeMapping, RecipeMapping.class);
|
||||
}
|
||||
catch (JsonSyntaxException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
// TODO Log something regarding the failed parse
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
|
||||
public String toJson()
|
||||
{
|
||||
return gsonSerializer.toJson(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,50 +1,48 @@
|
|||
package com.pahimar.ee3.api;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.*;
|
||||
import com.pahimar.ee3.emc.EmcValue;
|
||||
import com.pahimar.ee3.item.WrappedStack;
|
||||
|
||||
public class StackValueMapping implements JsonSerializer<StackValueMapping>, JsonDeserializer<StackValueMapping>{
|
||||
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() {
|
||||
public StackValueMapping()
|
||||
{
|
||||
wrappedStack = null;
|
||||
emcValue = null;
|
||||
}
|
||||
|
||||
public StackValueMapping(Object object, EmcValue emcValue) {
|
||||
|
||||
public StackValueMapping(Object object, EmcValue emcValue)
|
||||
{
|
||||
this.wrappedStack = new WrappedStack(object);
|
||||
this.emcValue = emcValue;
|
||||
}
|
||||
|
||||
public static StackValueMapping createFromJson(String jsonStackValueMapping) {
|
||||
|
||||
try {
|
||||
|
||||
public static StackValueMapping createFromJson(String jsonStackValueMapping)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
return (StackValueMapping) gsonSerializer.fromJson(jsonStackValueMapping, StackValueMapping.class);
|
||||
}
|
||||
catch (JsonSyntaxException exception) {
|
||||
catch (JsonSyntaxException exception)
|
||||
{
|
||||
// TODO Log something regarding the failed parse
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
|
||||
public String toJson()
|
||||
{
|
||||
return gsonSerializer.toJson(this);
|
||||
}
|
||||
|
||||
|
@ -52,48 +50,55 @@ public class StackValueMapping implements JsonSerializer<StackValueMapping>, Jso
|
|||
* @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) {
|
||||
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 {
|
||||
public StackValueMapping deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
|
||||
if (!jsonElement.isJsonPrimitive())
|
||||
{
|
||||
|
||||
if (!jsonElement.isJsonPrimitive()) {
|
||||
|
||||
JsonObject jsonStackValueMapping = (JsonObject) jsonElement;
|
||||
|
||||
|
||||
WrappedStack wrappedStack = null;
|
||||
EmcValue emcValue = null;
|
||||
|
||||
if (jsonStackValueMapping.get("wrappedStack") != null) {
|
||||
|
||||
if (jsonStackValueMapping.get("wrappedStack") != null)
|
||||
{
|
||||
wrappedStack = new WrappedStack().deserialize(jsonStackValueMapping.get("wrappedStack").getAsJsonObject(), type, context);
|
||||
}
|
||||
|
||||
if (jsonStackValueMapping.get("emcValue") != null) {
|
||||
|
||||
if (jsonStackValueMapping.get("emcValue") != null)
|
||||
{
|
||||
emcValue = new EmcValue().deserialize(jsonStackValueMapping.get("emcValue").getAsJsonObject(), type, context);
|
||||
}
|
||||
|
||||
if (wrappedStack instanceof WrappedStack && emcValue instanceof EmcValue) {
|
||||
|
||||
if (wrappedStack instanceof WrappedStack && emcValue instanceof EmcValue)
|
||||
{
|
||||
return new StackValueMapping(wrappedStack, emcValue);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.pahimar.ee3.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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 net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -12,22 +15,18 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
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 java.util.Random;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* BlockAlchemicalChest
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class BlockAlchemicalChest extends BlockEE {
|
||||
public class BlockAlchemicalChest extends BlockEE
|
||||
{
|
||||
|
||||
/**
|
||||
* Is the random generator used by alchemical chest to drop the inventory
|
||||
|
@ -35,7 +34,8 @@ public class BlockAlchemicalChest extends BlockEE {
|
|||
*/
|
||||
private Random rand = new Random();
|
||||
|
||||
public BlockAlchemicalChest(int id) {
|
||||
public BlockAlchemicalChest(int id)
|
||||
{
|
||||
|
||||
super(id, Material.wood);
|
||||
this.setUnlocalizedName(Strings.ALCHEMICAL_CHEST_NAME);
|
||||
|
@ -44,60 +44,67 @@ public class BlockAlchemicalChest extends BlockEE {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName() {
|
||||
|
||||
StringBuilder unlocalizedName = new StringBuilder();
|
||||
|
||||
unlocalizedName.append("tile.");
|
||||
unlocalizedName.append(Strings.RESOURCE_PREFIX);
|
||||
unlocalizedName.append(Strings.ALCHEMICAL_CHEST_NAME);
|
||||
|
||||
return unlocalizedName.toString();
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return String.format("tile.%s%s", Strings.RESOURCE_PREFIX, Strings.ALCHEMICAL_CHEST_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world) {
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
|
||||
return new TileAlchemicalChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
public int getRenderType()
|
||||
{
|
||||
|
||||
return RenderIds.alchemicalChestRender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, int id, int meta) {
|
||||
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) {
|
||||
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 true;
|
||||
}
|
||||
else if (world.isBlockSolidOnSide(x, y + 1, z, ForgeDirection.DOWN))
|
||||
{
|
||||
return true;
|
||||
else {
|
||||
if (!world.isRemote) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileAlchemicalChest != null) {
|
||||
if (tileAlchemicalChest != null)
|
||||
{
|
||||
player.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_CHEST, world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
@ -106,27 +113,33 @@ public class BlockAlchemicalChest extends BlockEE {
|
|||
}
|
||||
}
|
||||
|
||||
private void dropInventory(World world, int x, int y, int z) {
|
||||
private 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++) {
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
||||
{
|
||||
|
||||
ItemStack itemStack = inventory.getStackInSlot(i);
|
||||
|
||||
if (itemStack != null && itemStack.stackSize > 0) {
|
||||
if (itemStack != null && itemStack.stackSize > 0)
|
||||
{
|
||||
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()) {
|
||||
if (itemStack.hasTagCompound())
|
||||
{
|
||||
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package com.pahimar.ee3.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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.TileGlassBell;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
|
@ -14,23 +18,18 @@ import net.minecraft.world.IBlockAccess;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
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.TileGlassBell;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* BlockAludel
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class BlockAludelBase extends BlockEE {
|
||||
public class BlockAludelBase extends BlockEE
|
||||
{
|
||||
|
||||
/**
|
||||
* Is the random generator used by aludel to drop the inventory contents in
|
||||
|
@ -38,7 +37,8 @@ public class BlockAludelBase extends BlockEE {
|
|||
*/
|
||||
private Random rand = new Random();
|
||||
|
||||
public BlockAludelBase(int id) {
|
||||
public BlockAludelBase(int id)
|
||||
{
|
||||
|
||||
super(id, Material.anvil);
|
||||
this.setUnlocalizedName(Strings.ALUDEL_NAME);
|
||||
|
@ -48,47 +48,44 @@ public class BlockAludelBase extends BlockEE {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName() {
|
||||
|
||||
StringBuilder unlocalizedName = new StringBuilder();
|
||||
|
||||
unlocalizedName.append("tile.");
|
||||
unlocalizedName.append(Strings.RESOURCE_PREFIX);
|
||||
unlocalizedName.append(Strings.ALUDEL_NAME);
|
||||
|
||||
return unlocalizedName.toString();
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return String.format("tile.%s%s", Strings.RESOURCE_PREFIX, Strings.ALUDEL_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world) {
|
||||
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
return new TileAludel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
public int getRenderType()
|
||||
{
|
||||
|
||||
return RenderIds.aludelRender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, int id, int meta) {
|
||||
public void breakBlock(World world, int x, int y, int z, int id, int meta)
|
||||
{
|
||||
|
||||
dropInventory(world, x, y, z);
|
||||
|
||||
if (world.getBlockTileEntity(x, y + 1, z) instanceof TileGlassBell) {
|
||||
if (world.getBlockTileEntity(x, y + 1, z) instanceof TileGlassBell)
|
||||
{
|
||||
world.markBlockForUpdate(x, y + 1, z);
|
||||
world.updateAllLightTypes(x, y + 1, z);
|
||||
}
|
||||
|
@ -97,15 +94,21 @@ public class BlockAludelBase extends BlockEE {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
|
||||
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) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileAludel != null) {
|
||||
if (tileAludel != null)
|
||||
{
|
||||
player.openGui(EquivalentExchange3.instance, GuiIds.ALUDEL, world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
@ -115,17 +118,20 @@ public class BlockAludelBase extends BlockEE {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) {
|
||||
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) != null && world.getBlockTileEntity(x, y + 1, z) instanceof TileGlassBell) {
|
||||
if (world.getBlockTileEntity(x, y + 1, z) != null && 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) != null && world.getBlockTileEntity(x, y, z) instanceof TileAludel) {
|
||||
if (world.getBlockTileEntity(x, y, z) != null && world.getBlockTileEntity(x, y, z) instanceof TileAludel)
|
||||
{
|
||||
|
||||
TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
|
@ -139,32 +145,39 @@ public class BlockAludelBase extends BlockEE {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void dropInventory(World world, int x, int y, int z) {
|
||||
private 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++) {
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
||||
{
|
||||
|
||||
ItemStack itemStack = inventory.getStackInSlot(i);
|
||||
|
||||
if (itemStack != null && itemStack.stackSize > 0) {
|
||||
if (itemStack != null && itemStack.stackSize > 0)
|
||||
{
|
||||
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()) {
|
||||
if (itemStack.hasTagCompound())
|
||||
{
|
||||
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.pahimar.ee3.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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.TileCalcinator;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -11,22 +14,18 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
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.TileCalcinator;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* BlockCalcinator
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class BlockCalcinator extends BlockEE {
|
||||
public class BlockCalcinator extends BlockEE
|
||||
{
|
||||
|
||||
/**
|
||||
* Is the random generator used by calcinator to drop the inventory contents
|
||||
|
@ -34,7 +33,8 @@ public class BlockCalcinator extends BlockEE {
|
|||
*/
|
||||
private Random rand = new Random();
|
||||
|
||||
public BlockCalcinator(int id) {
|
||||
public BlockCalcinator(int id)
|
||||
{
|
||||
|
||||
super(id, Material.rock);
|
||||
this.setUnlocalizedName(Strings.CALCINATOR_NAME);
|
||||
|
@ -44,58 +44,63 @@ public class BlockCalcinator extends BlockEE {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName() {
|
||||
|
||||
StringBuilder unlocalizedName = new StringBuilder();
|
||||
|
||||
unlocalizedName.append("tile.");
|
||||
unlocalizedName.append(Strings.RESOURCE_PREFIX);
|
||||
unlocalizedName.append(Strings.CALCINATOR_NAME);
|
||||
|
||||
return unlocalizedName.toString();
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return String.format("tile.%s%s", Strings.RESOURCE_PREFIX, Strings.CALCINATOR_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world) {
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
|
||||
return new TileCalcinator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
public int getRenderType()
|
||||
{
|
||||
|
||||
return RenderIds.calcinatorRender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, int id, int meta) {
|
||||
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) {
|
||||
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) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
TileCalcinator tileCalcinator = (TileCalcinator) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileCalcinator != null) {
|
||||
if (tileCalcinator != null)
|
||||
{
|
||||
player.openGui(EquivalentExchange3.instance, GuiIds.CALCINATOR, world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
@ -104,27 +109,33 @@ public class BlockCalcinator extends BlockEE {
|
|||
}
|
||||
}
|
||||
|
||||
private void dropInventory(World world, int x, int y, int z) {
|
||||
private 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++) {
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
||||
{
|
||||
|
||||
ItemStack itemStack = inventory.getStackInSlot(i);
|
||||
|
||||
if (itemStack != null && itemStack.stackSize > 0) {
|
||||
if (itemStack != null && itemStack.stackSize > 0)
|
||||
{
|
||||
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()) {
|
||||
if (itemStack.hasTagCompound())
|
||||
{
|
||||
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.pahimar.ee3.block;
|
||||
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
import com.pahimar.ee3.tileentity.TileEE;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
|
@ -9,36 +13,33 @@ import net.minecraft.util.MathHelper;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
import com.pahimar.ee3.tileentity.TileEE;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* BlockEE
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public abstract class BlockEE extends BlockContainer {
|
||||
public abstract class BlockEE extends BlockContainer
|
||||
{
|
||||
|
||||
public BlockEE(int id, Material material) {
|
||||
public BlockEE(int id, Material material)
|
||||
{
|
||||
|
||||
super(id, material);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister) {
|
||||
public void registerIcons(IconRegister iconRegister)
|
||||
{
|
||||
|
||||
blockIcon = iconRegister.registerIcon(String.format("%s:%s", Reference.MOD_ID.toLowerCase(), getUnwrappedUnlocalizedName(this.getUnlocalizedName())));
|
||||
}
|
||||
|
||||
protected String getUnwrappedUnlocalizedName(String unlocalizedName) {
|
||||
protected String getUnwrappedUnlocalizedName(String unlocalizedName)
|
||||
{
|
||||
|
||||
return unlocalizedName.substring(unlocalizedName.indexOf(":") + 1);
|
||||
}
|
||||
|
@ -47,27 +48,33 @@ public abstract class BlockEE extends BlockContainer {
|
|||
* Sets the direction of the block when placed
|
||||
*/
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) {
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack)
|
||||
{
|
||||
|
||||
int direction = 0;
|
||||
int facing = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
|
||||
if (facing == 0) {
|
||||
if (facing == 0)
|
||||
{
|
||||
direction = ForgeDirection.NORTH.ordinal();
|
||||
}
|
||||
else if (facing == 1) {
|
||||
else if (facing == 1)
|
||||
{
|
||||
direction = ForgeDirection.EAST.ordinal();
|
||||
}
|
||||
else if (facing == 2) {
|
||||
else if (facing == 2)
|
||||
{
|
||||
direction = ForgeDirection.SOUTH.ordinal();
|
||||
}
|
||||
else if (facing == 3) {
|
||||
else if (facing == 3)
|
||||
{
|
||||
direction = ForgeDirection.WEST.ordinal();
|
||||
}
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, direction, 3);
|
||||
|
||||
if (itemStack.hasDisplayName()) {
|
||||
if (itemStack.hasDisplayName())
|
||||
{
|
||||
((TileEE) world.getBlockTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package com.pahimar.ee3.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
@ -17,15 +22,10 @@ import net.minecraft.world.IBlockAccess;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
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 java.util.Random;
|
||||
|
||||
public class BlockGlassBell extends BlockEE {
|
||||
public class BlockGlassBell extends BlockEE
|
||||
{
|
||||
|
||||
/**
|
||||
* Is the random generator used by glass bell to drop the inventory contents
|
||||
|
@ -33,7 +33,8 @@ public class BlockGlassBell extends BlockEE {
|
|||
*/
|
||||
private Random rand = new Random();
|
||||
|
||||
public BlockGlassBell(int id) {
|
||||
public BlockGlassBell(int id)
|
||||
{
|
||||
|
||||
super(id, Material.glass);
|
||||
this.setUnlocalizedName(Strings.GLASS_BELL_NAME);
|
||||
|
@ -42,64 +43,70 @@ public class BlockGlassBell extends BlockEE {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName() {
|
||||
|
||||
StringBuilder unlocalizedName = new StringBuilder();
|
||||
|
||||
unlocalizedName.append("tile.");
|
||||
unlocalizedName.append(Strings.RESOURCE_PREFIX);
|
||||
unlocalizedName.append(Strings.GLASS_BELL_NAME);
|
||||
|
||||
return unlocalizedName.toString();
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return String.format("tile.%s%s", Strings.RESOURCE_PREFIX, Strings.GLASS_BELL_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world) {
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
|
||||
return new TileGlassBell();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
public int getRenderType()
|
||||
{
|
||||
|
||||
return RenderIds.glassBell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, int id, int meta) {
|
||||
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) {
|
||||
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) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
TileEntity tileEntityGlassBell = world.getBlockTileEntity(x, y, z);
|
||||
TileEntity tileEntityAludel = world.getBlockTileEntity(x, y - 1, z);
|
||||
|
||||
if (tileEntityAludel instanceof TileAludel && tileEntityGlassBell instanceof TileGlassBell) {
|
||||
if (tileEntityAludel instanceof TileAludel && tileEntityGlassBell instanceof TileGlassBell)
|
||||
{
|
||||
player.openGui(EquivalentExchange3.instance, GuiIds.ALUDEL, world, x, y - 1, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (tileEntityGlassBell != null) {
|
||||
if (tileEntityGlassBell != null)
|
||||
{
|
||||
player.openGui(EquivalentExchange3.instance, GuiIds.GLASS_BELL, world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
@ -109,16 +116,20 @@ public class BlockGlassBell extends BlockEE {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) {
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack)
|
||||
{
|
||||
|
||||
if (itemStack.hasDisplayName()) {
|
||||
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) {
|
||||
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 {
|
||||
else
|
||||
{
|
||||
((TileEE) world.getBlockTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z));
|
||||
}
|
||||
|
||||
|
@ -126,7 +137,8 @@ public class BlockGlassBell extends BlockEE {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData) {
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData)
|
||||
{
|
||||
|
||||
return sideHit;
|
||||
}
|
||||
|
@ -136,41 +148,52 @@ public class BlockGlassBell extends BlockEE {
|
|||
* 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) {
|
||||
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec)
|
||||
{
|
||||
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null) {
|
||||
if (tileEntity instanceof TileGlassBell) {
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity instanceof TileGlassBell)
|
||||
{
|
||||
|
||||
TileGlassBell tileGlassBell = (TileGlassBell) tileEntity;
|
||||
|
||||
switch (tileGlassBell.getOrientation()) {
|
||||
case DOWN: {
|
||||
switch (tileGlassBell.getOrientation())
|
||||
{
|
||||
case DOWN:
|
||||
{
|
||||
this.setBlockBounds(0.125F, 0.33F, 0.125F, 0.875F, 1.0F, 0.875F);
|
||||
break;
|
||||
}
|
||||
case UP: {
|
||||
case UP:
|
||||
{
|
||||
this.setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.66F, 0.875F);
|
||||
break;
|
||||
}
|
||||
case NORTH: {
|
||||
case NORTH:
|
||||
{
|
||||
this.setBlockBounds(0.125F, 0.125F, 0.33F, 0.875F, 0.875F, 1.0F);
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
case SOUTH:
|
||||
{
|
||||
this.setBlockBounds(0.125F, 0.125F, 0.0F, 0.875F, 0.875F, 0.66F);
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
case EAST:
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.125F, 0.125F, 0.66F, 0.875F, 0.875F);
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
case WEST:
|
||||
{
|
||||
this.setBlockBounds(0.33F, 0.125F, 0.125F, 1.0F, 0.875F, 0.875F);
|
||||
break;
|
||||
}
|
||||
case UNKNOWN: {
|
||||
case UNKNOWN:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -181,53 +204,66 @@ public class BlockGlassBell extends BlockEE {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
|
||||
ItemStack itemStack;
|
||||
|
||||
if (world.getBlockTileEntity(x, y, z) instanceof TileGlassBell) {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
private void dropInventory(World world, int x, int y, int z) {
|
||||
private 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++) {
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
||||
{
|
||||
|
||||
ItemStack itemStack = inventory.getStackInSlot(i);
|
||||
|
||||
if (itemStack != null && itemStack.stackSize > 0) {
|
||||
if (itemStack != null && itemStack.stackSize > 0)
|
||||
{
|
||||
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()) {
|
||||
if (itemStack.hasTagCompound())
|
||||
{
|
||||
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
package com.pahimar.ee3.block;
|
||||
|
||||
import com.pahimar.ee3.lib.BlockIds;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
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
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ModBlocks {
|
||||
public class ModBlocks
|
||||
{
|
||||
|
||||
/* Mod block instances */
|
||||
public static Block calcinator;
|
||||
|
@ -26,7 +24,8 @@ public class ModBlocks {
|
|||
public static Block alchemicalChest;
|
||||
public static Block glassBell;
|
||||
|
||||
public static void init() {
|
||||
public static void init()
|
||||
{
|
||||
|
||||
calcinator = new BlockCalcinator(BlockIds.CALCINATOR);
|
||||
aludelBase = new BlockAludelBase(BlockIds.ALUDEL_BASE);
|
||||
|
@ -41,9 +40,10 @@ public class ModBlocks {
|
|||
initBlockRecipes();
|
||||
}
|
||||
|
||||
private static void initBlockRecipes() {
|
||||
private static void initBlockRecipes()
|
||||
{
|
||||
|
||||
GameRegistry.addRecipe(new ItemStack(glassBell), new Object[] { "iii", "i i", "i i", Character.valueOf('i'), Block.glass });
|
||||
GameRegistry.addRecipe(new ItemStack(aludelBase), new Object[] { "iii", "sis", "iii", Character.valueOf('i'), Item.ingotIron, Character.valueOf('s'), Block.stone });
|
||||
GameRegistry.addRecipe(new ItemStack(glassBell), new Object[] {"iii", "i i", "i i", 'i', Block.glass});
|
||||
GameRegistry.addRecipe(new ItemStack(aludelBase), new Object[] {"iii", "sis", "iii", 'i', Item.ingotIron, 's', Block.stone});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,36 @@
|
|||
package com.pahimar.ee3.client.audio;
|
||||
|
||||
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
import com.pahimar.ee3.core.helper.LogHelper;
|
||||
import com.pahimar.ee3.lib.Sounds;
|
||||
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* SoundHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class SoundHandler {
|
||||
public class SoundHandler
|
||||
{
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onSoundLoad(SoundLoadEvent event) {
|
||||
public void onSoundLoad(SoundLoadEvent event)
|
||||
{
|
||||
|
||||
// For each custom sound file we have defined in Sounds
|
||||
for (String soundFile : Sounds.soundFiles) {
|
||||
for (String soundFile : Sounds.soundFiles)
|
||||
{
|
||||
// Try to add the custom sound file to the pool of sounds
|
||||
try {
|
||||
try
|
||||
{
|
||||
event.manager.addSound(soundFile);
|
||||
}
|
||||
// If we cannot add the custom sound file to the pool, log the exception
|
||||
catch (Exception e) {
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHelper.warning("Failed loading sound file: " + soundFile);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,31 @@
|
|||
package com.pahimar.ee3.client.gui.inventory;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.pahimar.ee3.core.helper.ItemStackNBTHelper;
|
||||
import com.pahimar.ee3.inventory.ContainerAlchemicalBag;
|
||||
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.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* GuiAlchemicalBag
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiAlchemicalBag extends GuiContainer {
|
||||
public class GuiAlchemicalBag extends GuiContainer
|
||||
{
|
||||
|
||||
public GuiAlchemicalBag(InventoryPlayer inventoryPlayer) {
|
||||
public GuiAlchemicalBag(InventoryPlayer inventoryPlayer)
|
||||
{
|
||||
|
||||
super(new ContainerAlchemicalBag(inventoryPlayer));
|
||||
xSize = 248;
|
||||
|
@ -35,14 +33,16 @@ public class GuiAlchemicalBag extends GuiContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
||||
{
|
||||
|
||||
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_ALCHEMICAL_BAG_NAME), 8, 6, 4210752);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 44, ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) {
|
||||
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y)
|
||||
{
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
|
@ -55,14 +55,19 @@ public class GuiAlchemicalBag extends GuiContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
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)) {
|
||||
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,34 +1,32 @@
|
|||
package com.pahimar.ee3.client.gui.inventory;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiAlchemicalChest extends GuiContainer {
|
||||
public class GuiAlchemicalChest extends GuiContainer
|
||||
{
|
||||
|
||||
private TileAlchemicalChest tileAlchemicalChest;
|
||||
|
||||
public GuiAlchemicalChest(InventoryPlayer inventoryPlayer, TileAlchemicalChest alchemicalChest) {
|
||||
public GuiAlchemicalChest(InventoryPlayer inventoryPlayer, TileAlchemicalChest alchemicalChest)
|
||||
{
|
||||
|
||||
super(new ContainerAlchemicalChest(inventoryPlayer, alchemicalChest));
|
||||
tileAlchemicalChest = alchemicalChest;
|
||||
|
@ -37,14 +35,16 @@ public class GuiAlchemicalChest extends GuiContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
||||
{
|
||||
|
||||
fontRenderer.drawString(tileAlchemicalChest.isInvNameLocalized() ? tileAlchemicalChest.getInvName() : StatCollector.translateToLocal(tileAlchemicalChest.getInvName()), 8, 6, 4210752);
|
||||
fontRenderer.drawString(StatCollector.translateToLocal(Strings.CONTAINER_INVENTORY), 44, ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) {
|
||||
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y)
|
||||
{
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
|
|
|
@ -1,34 +1,32 @@
|
|||
package com.pahimar.ee3.client.gui.inventory;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiAludel extends GuiContainer {
|
||||
public class GuiAludel extends GuiContainer
|
||||
{
|
||||
|
||||
private TileAludel tileAludel;
|
||||
|
||||
public GuiAludel(InventoryPlayer inventoryPlayer, TileAludel tileAludel) {
|
||||
public GuiAludel(InventoryPlayer inventoryPlayer, TileAludel tileAludel)
|
||||
{
|
||||
|
||||
super(new ContainerAludel(inventoryPlayer, tileAludel));
|
||||
this.tileAludel = tileAludel;
|
||||
|
@ -37,7 +35,8 @@ public class GuiAludel extends GuiContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
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);
|
||||
|
@ -45,7 +44,8 @@ public class GuiAludel extends GuiContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
|
||||
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);
|
||||
|
|
|
@ -1,34 +1,32 @@
|
|||
package com.pahimar.ee3.client.gui.inventory;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiCalcinator extends GuiContainer {
|
||||
public class GuiCalcinator extends GuiContainer
|
||||
{
|
||||
|
||||
private TileCalcinator tileCalcinator;
|
||||
|
||||
public GuiCalcinator(InventoryPlayer player, TileCalcinator tileCalcinator) {
|
||||
public GuiCalcinator(InventoryPlayer player, TileCalcinator tileCalcinator)
|
||||
{
|
||||
|
||||
super(new ContainerCalcinator(player, tileCalcinator));
|
||||
ySize = 176;
|
||||
|
@ -36,7 +34,8 @@ public class GuiCalcinator extends GuiContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
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);
|
||||
|
@ -44,7 +43,8 @@ public class GuiCalcinator extends GuiContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) {
|
||||
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y)
|
||||
{
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
|
|
|
@ -1,34 +1,32 @@
|
|||
package com.pahimar.ee3.client.gui.inventory;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiGlassBell extends GuiContainer {
|
||||
public class GuiGlassBell extends GuiContainer
|
||||
{
|
||||
|
||||
private TileGlassBell tileGlassBell;
|
||||
|
||||
public GuiGlassBell(InventoryPlayer inventoryPlayer, TileGlassBell tileGlassBell) {
|
||||
public GuiGlassBell(InventoryPlayer inventoryPlayer, TileGlassBell tileGlassBell)
|
||||
{
|
||||
|
||||
super(new ContainerGlassBell(inventoryPlayer, tileGlassBell));
|
||||
this.tileGlassBell = tileGlassBell;
|
||||
|
@ -37,7 +35,8 @@ public class GuiGlassBell extends GuiContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
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);
|
||||
|
@ -45,7 +44,8 @@ public class GuiGlassBell extends GuiContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
|
||||
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);
|
||||
|
|
|
@ -1,34 +1,32 @@
|
|||
package com.pahimar.ee3.client.gui.inventory;
|
||||
|
||||
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;
|
||||
|
||||
import com.pahimar.ee3.core.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
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiPortableCrafting extends GuiContainer {
|
||||
public class GuiPortableCrafting extends GuiContainer
|
||||
{
|
||||
|
||||
public GuiPortableCrafting(EntityPlayer player, World world, int x, int y, int z) {
|
||||
public GuiPortableCrafting(EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
|
||||
super(new ContainerPortableCrafting(player.inventory, world, x, y, z));
|
||||
}
|
||||
|
@ -38,7 +36,8 @@ public class GuiPortableCrafting extends GuiContainer {
|
|||
* the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
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);
|
||||
|
@ -49,7 +48,8 @@ public class GuiPortableCrafting extends GuiContainer {
|
|||
* items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
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);
|
||||
|
@ -59,14 +59,19 @@ public class GuiPortableCrafting extends GuiContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
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)) {
|
||||
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,38 +1,37 @@
|
|||
package com.pahimar.ee3.client.gui.inventory;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.pahimar.ee3.core.helper.ItemStackNBTHelper;
|
||||
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.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* GuiPortableTransmutation
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiPortableTransmutation extends GuiContainer {
|
||||
public class GuiPortableTransmutation extends GuiContainer
|
||||
{
|
||||
|
||||
public GuiPortableTransmutation(Container par1Container) {
|
||||
public GuiPortableTransmutation(Container par1Container)
|
||||
{
|
||||
|
||||
super(par1Container);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
|
||||
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_PORTABLE_TRANSMUTATION);
|
||||
|
@ -42,14 +41,19 @@ public class GuiPortableTransmutation extends GuiContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
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_TRANSMUTATION_GUI_OPEN)) {
|
||||
if (mc.thePlayer != null)
|
||||
{
|
||||
for (ItemStack itemStack : mc.thePlayer.inventory.mainInventory)
|
||||
{
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN))
|
||||
{
|
||||
ItemStackNBTHelper.removeTag(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
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;
|
||||
|
||||
import com.pahimar.ee3.lib.Models;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ModelAludel
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelAludel {
|
||||
public class ModelAludel
|
||||
{
|
||||
|
||||
private IModelCustom modelAludel;
|
||||
|
||||
public ModelAludel() {
|
||||
public ModelAludel()
|
||||
{
|
||||
|
||||
modelAludel = AdvancedModelLoader.loadModel(Models.ALUDEL);
|
||||
}
|
||||
|
||||
public void render() {
|
||||
public void render()
|
||||
{
|
||||
|
||||
modelAludel.renderPart("Base");
|
||||
}
|
||||
|
|
|
@ -1,38 +1,39 @@
|
|||
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;
|
||||
|
||||
import com.pahimar.ee3.lib.Models;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* ModelCalcinator
|
||||
*
|
||||
* <p/>
|
||||
* Model for the Calcinator
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelCalcinator {
|
||||
public class ModelCalcinator
|
||||
{
|
||||
|
||||
private IModelCustom modelCalcinator;
|
||||
|
||||
public ModelCalcinator() {
|
||||
public ModelCalcinator()
|
||||
{
|
||||
|
||||
modelCalcinator = AdvancedModelLoader.loadModel(Models.CALCINATOR);
|
||||
}
|
||||
|
||||
public void render() {
|
||||
public void render()
|
||||
{
|
||||
|
||||
modelCalcinator.renderAll();
|
||||
}
|
||||
|
||||
public void renderPart(String partName) {
|
||||
public void renderPart(String partName)
|
||||
{
|
||||
|
||||
modelCalcinator.renderPart(partName);
|
||||
}
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
package com.pahimar.ee3.client.model;
|
||||
|
||||
import com.pahimar.ee3.lib.Models;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
|
||||
import com.pahimar.ee3.lib.Models;
|
||||
|
||||
public class ModelGlassBell {
|
||||
public class ModelGlassBell
|
||||
{
|
||||
|
||||
private IModelCustom modelGlassBell;
|
||||
|
||||
public ModelGlassBell() {
|
||||
public ModelGlassBell()
|
||||
{
|
||||
|
||||
modelGlassBell = AdvancedModelLoader.loadModel(Models.GLASS_BELL);
|
||||
}
|
||||
|
||||
public void render() {
|
||||
public void render()
|
||||
{
|
||||
|
||||
modelGlassBell.renderPart("Bell");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.pahimar.ee3.client.renderer;
|
||||
|
||||
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;
|
||||
|
@ -7,27 +9,23 @@ import net.minecraft.client.renderer.Tessellator;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Icon;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.pahimar.ee3.lib.Textures;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* RenderUtils
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class RenderUtils {
|
||||
public class RenderUtils
|
||||
{
|
||||
|
||||
private static int rotationAngle = 0;
|
||||
|
||||
public static void renderRotatingBlockIntoGUI(FontRenderer fontRenderer, ItemStack stack, int x, int y, float zLevel, float scale) {
|
||||
public static void renderRotatingBlockIntoGUI(FontRenderer fontRenderer, ItemStack stack, int x, int y, float zLevel, float scale)
|
||||
{
|
||||
|
||||
RenderBlocks renderBlocks = new RenderBlocks();
|
||||
|
||||
|
@ -39,7 +37,7 @@ public class RenderUtils {
|
|||
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 + 1 * rotationAngle, 0.0F, 1.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);
|
||||
|
@ -56,7 +54,8 @@ public class RenderUtils {
|
|||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static void renderItemIntoGUI(FontRenderer fontRenderer, ItemStack itemStack, int x, int y, float opacity, float scale) {
|
||||
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);
|
||||
|
@ -71,14 +70,15 @@ public class RenderUtils {
|
|||
|
||||
}
|
||||
|
||||
public static void drawTexturedQuad(int x, int y, Icon icon, float width, float height, double zLevel) {
|
||||
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 + 0, y + height, zLevel, icon.getMinU(), icon.getMaxV());
|
||||
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 + 0, zLevel, icon.getMaxU(), icon.getMinV());
|
||||
tessellator.addVertexWithUV(x + 0, y + 0, zLevel, icon.getMinU(), icon.getMinV());
|
||||
tessellator.addVertexWithUV(x + width, y, zLevel, icon.getMaxU(), icon.getMinV());
|
||||
tessellator.addVertexWithUV(x, y, zLevel, icon.getMinU(), icon.getMinV());
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,65 +1,71 @@
|
|||
package com.pahimar.ee3.client.renderer.item;
|
||||
|
||||
import net.minecraft.client.model.ModelChest;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ItemAlchemicalChestRenderer implements IItemRenderer {
|
||||
public class ItemAlchemicalChestRenderer implements IItemRenderer
|
||||
{
|
||||
|
||||
private ModelChest modelChest;
|
||||
|
||||
public ItemAlchemicalChestRenderer() {
|
||||
public ItemAlchemicalChestRenderer()
|
||||
{
|
||||
|
||||
modelChest = new ModelChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
||||
{
|
||||
|
||||
switch (type) {
|
||||
case ENTITY: {
|
||||
switch (type)
|
||||
{
|
||||
case ENTITY:
|
||||
{
|
||||
renderAlchemicalChest(0.5F, 0.5F, 0.5F);
|
||||
break;
|
||||
}
|
||||
case EQUIPPED: {
|
||||
case EQUIPPED:
|
||||
{
|
||||
renderAlchemicalChest(1.0F, 1.0F, 1.0F);
|
||||
break;
|
||||
}
|
||||
case EQUIPPED_FIRST_PERSON: {
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
{
|
||||
renderAlchemicalChest(1.0F, 1.0F, 1.0F);
|
||||
break;
|
||||
}
|
||||
case INVENTORY: {
|
||||
case INVENTORY:
|
||||
{
|
||||
renderAlchemicalChest(0.0F, 0.075F, 0.0F);
|
||||
break;
|
||||
}
|
||||
|
@ -68,7 +74,8 @@ public class ItemAlchemicalChestRenderer implements IItemRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
private void renderAlchemicalChest(float x, float y, float z) {
|
||||
private void renderAlchemicalChest(float x, float y, float z)
|
||||
{
|
||||
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.MODEL_ALCHEMICAL_CHEST);
|
||||
GL11.glPushMatrix(); //start
|
||||
|
|
|
@ -1,74 +1,80 @@
|
|||
package com.pahimar.ee3.client.renderer.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ItemAludelRenderer implements IItemRenderer {
|
||||
public class ItemAludelRenderer implements IItemRenderer
|
||||
{
|
||||
|
||||
private ModelAludel modelAludel;
|
||||
|
||||
public ItemAludelRenderer() {
|
||||
public ItemAludelRenderer()
|
||||
{
|
||||
|
||||
modelAludel = new ModelAludel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
||||
{
|
||||
|
||||
switch (type) {
|
||||
case ENTITY: {
|
||||
switch (type)
|
||||
{
|
||||
case ENTITY:
|
||||
{
|
||||
renderAludel(-0.5F, -0.38F, 0.5F, 1.0F);
|
||||
return;
|
||||
}
|
||||
case EQUIPPED: {
|
||||
case EQUIPPED:
|
||||
{
|
||||
renderAludel(0.0F, 0.0F, 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
case EQUIPPED_FIRST_PERSON: {
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
{
|
||||
renderAludel(0.0F, 0.0F, 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
case INVENTORY: {
|
||||
case INVENTORY:
|
||||
{
|
||||
renderAludel(-1.0F, -0.9F, 0.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void renderAludel(float x, float y, float z, float scale) {
|
||||
private void renderAludel(float x, float y, float z, float scale)
|
||||
{
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
|
|
@ -1,65 +1,71 @@
|
|||
package com.pahimar.ee3.client.renderer.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ItemCalcinatorRenderer implements IItemRenderer {
|
||||
public class ItemCalcinatorRenderer implements IItemRenderer
|
||||
{
|
||||
|
||||
private ModelCalcinator modelCalcinator;
|
||||
|
||||
public ItemCalcinatorRenderer() {
|
||||
public ItemCalcinatorRenderer()
|
||||
{
|
||||
|
||||
modelCalcinator = new ModelCalcinator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
||||
{
|
||||
|
||||
switch (type) {
|
||||
case ENTITY: {
|
||||
switch (type)
|
||||
{
|
||||
case ENTITY:
|
||||
{
|
||||
renderCalcinator(-0.5F, 0.0F, 0.5F, 1.0F);
|
||||
return;
|
||||
}
|
||||
case EQUIPPED: {
|
||||
case EQUIPPED:
|
||||
{
|
||||
renderCalcinator(0.0F, 0.0F, 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
case EQUIPPED_FIRST_PERSON: {
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
{
|
||||
renderCalcinator(0.0F, 0.0F, 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
case INVENTORY: {
|
||||
case INVENTORY:
|
||||
{
|
||||
renderCalcinator(0.0F, -0.1F, 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
@ -68,7 +74,8 @@ public class ItemCalcinatorRenderer implements IItemRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
private void renderCalcinator(float x, float y, float z, float scale) {
|
||||
private void renderCalcinator(float x, float y, float z, float scale)
|
||||
{
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
|
|
@ -1,65 +1,71 @@
|
|||
package com.pahimar.ee3.client.renderer.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ItemGlassBellRenderer implements IItemRenderer {
|
||||
public class ItemGlassBellRenderer implements IItemRenderer
|
||||
{
|
||||
|
||||
private ModelGlassBell modelGlassBell;
|
||||
|
||||
public ItemGlassBellRenderer() {
|
||||
public ItemGlassBellRenderer()
|
||||
{
|
||||
|
||||
modelGlassBell = new ModelGlassBell();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
|
||||
{
|
||||
|
||||
switch (type) {
|
||||
case ENTITY: {
|
||||
switch (type)
|
||||
{
|
||||
case ENTITY:
|
||||
{
|
||||
renderGlassBell(-0.5F, -1.2F, 0.5F, 1.4F);
|
||||
return;
|
||||
}
|
||||
case EQUIPPED: {
|
||||
case EQUIPPED:
|
||||
{
|
||||
renderGlassBell(-0.2F, -0.85F, 0.8F, 1.4F);
|
||||
return;
|
||||
}
|
||||
case EQUIPPED_FIRST_PERSON: {
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
{
|
||||
renderGlassBell(-0.2F, -0.85F, 0.8F, 1.4F);
|
||||
return;
|
||||
}
|
||||
case INVENTORY: {
|
||||
case INVENTORY:
|
||||
{
|
||||
renderGlassBell(-1.0F, -1.675F, 0.0F, 1.4F);
|
||||
return;
|
||||
}
|
||||
|
@ -68,7 +74,8 @@ public class ItemGlassBellRenderer implements IItemRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
private void renderGlassBell(float x, float y, float z, float scale) {
|
||||
private void renderGlassBell(float x, float y, float z, float scale)
|
||||
{
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
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 net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* TileEntityAlchemicalChestRenderer
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TileEntityAlchemicalChestRenderer extends
|
||||
TileEntitySpecialRenderer {
|
||||
TileEntitySpecialRenderer
|
||||
{
|
||||
|
||||
private ModelChest modelChest = new ModelChest();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
|
||||
{
|
||||
|
||||
if (tileEntity instanceof TileAlchemicalChest) {
|
||||
if (tileEntity instanceof TileAlchemicalChest)
|
||||
{
|
||||
|
||||
TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) tileEntity;
|
||||
ForgeDirection direction = null;
|
||||
|
||||
if (tileAlchemicalChest.getWorldObj() != null) {
|
||||
if (tileAlchemicalChest.getWorldObj() != null)
|
||||
{
|
||||
direction = ForgeDirection.getOrientation(tileAlchemicalChest.getBlockMetadata());
|
||||
}
|
||||
|
||||
|
@ -51,17 +51,22 @@ public class TileEntityAlchemicalChestRenderer extends
|
|||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
short angle = 0;
|
||||
|
||||
if (direction != null) {
|
||||
if (direction == ForgeDirection.NORTH) {
|
||||
if (direction != null)
|
||||
{
|
||||
if (direction == ForgeDirection.NORTH)
|
||||
{
|
||||
angle = 180;
|
||||
}
|
||||
else if (direction == ForgeDirection.SOUTH) {
|
||||
else if (direction == ForgeDirection.SOUTH)
|
||||
{
|
||||
angle = 0;
|
||||
}
|
||||
else if (direction == ForgeDirection.WEST) {
|
||||
else if (direction == ForgeDirection.WEST)
|
||||
{
|
||||
angle = 90;
|
||||
}
|
||||
else if (direction == ForgeDirection.EAST) {
|
||||
else if (direction == ForgeDirection.EAST)
|
||||
{
|
||||
angle = -90;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
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;
|
||||
|
@ -8,51 +15,46 @@ import net.minecraft.item.ItemBlock;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* TileEntityAludelRenderer
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TileEntityAludelRenderer extends TileEntitySpecialRenderer {
|
||||
public class TileEntityAludelRenderer extends TileEntitySpecialRenderer
|
||||
{
|
||||
|
||||
private ModelAludel modelAludel = new ModelAludel();
|
||||
private final RenderItem customRenderItem;
|
||||
|
||||
public TileEntityAludelRenderer() {
|
||||
public TileEntityAludelRenderer()
|
||||
{
|
||||
|
||||
customRenderItem = new RenderItem() {
|
||||
customRenderItem = new RenderItem()
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean shouldBob() {
|
||||
public boolean shouldBob()
|
||||
{
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
customRenderItem.setRenderManager(RenderManager.instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
|
||||
{
|
||||
|
||||
if (tileEntity instanceof TileAludel) {
|
||||
if (tileEntity instanceof TileAludel)
|
||||
{
|
||||
|
||||
TileAludel tileAludel = (TileAludel) tileEntity;
|
||||
|
||||
|
@ -77,8 +79,10 @@ public class TileEntityAludelRenderer extends TileEntitySpecialRenderer {
|
|||
|
||||
TileEntity tileGlassBell = tileAludel.worldObj.getBlockTileEntity(tileAludel.xCoord, tileAludel.yCoord + 1, tileAludel.zCoord);
|
||||
|
||||
if (tileGlassBell instanceof TileGlassBell) {
|
||||
if (tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX) != null) {
|
||||
if (tileGlassBell instanceof TileGlassBell)
|
||||
{
|
||||
if (tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX) != null)
|
||||
{
|
||||
|
||||
float scaleFactor = getGhostItemScaleFactor(tileAludel.getStackInSlot(TileAludel.INPUT_INVENTORY_INDEX));
|
||||
float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
|
||||
|
@ -101,37 +105,46 @@ public class TileEntityAludelRenderer extends TileEntitySpecialRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
private void scaleTranslateRotate(double x, double y, double z, ForgeDirection orientation) {
|
||||
private void scaleTranslateRotate(double x, double y, double z, ForgeDirection orientation)
|
||||
{
|
||||
|
||||
if (orientation == ForgeDirection.NORTH) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
private float getGhostItemScaleFactor(ItemStack itemStack)
|
||||
{
|
||||
|
||||
float scaleFactor = 1.0F;
|
||||
|
||||
if (itemStack != null) {
|
||||
if (itemStack.getItem() instanceof ItemBlock) {
|
||||
switch (customRenderItem.getMiniBlockCount(itemStack)) {
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (itemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
switch (customRenderItem.getMiniBlockCount(itemStack))
|
||||
{
|
||||
case 1:
|
||||
return 0.90F;
|
||||
case 2:
|
||||
|
@ -146,8 +159,10 @@ public class TileEntityAludelRenderer extends TileEntitySpecialRenderer {
|
|||
return 0.90F;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (customRenderItem.getMiniItemCount(itemStack)) {
|
||||
else
|
||||
{
|
||||
switch (customRenderItem.getMiniItemCount(itemStack))
|
||||
{
|
||||
case 1:
|
||||
return 0.65F;
|
||||
case 2:
|
||||
|
|
|
@ -1,36 +1,35 @@
|
|||
package com.pahimar.ee3.client.renderer.tileentity;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.pahimar.ee3.client.model.ModelCalcinator;
|
||||
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 org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* TileEntityCalcinatorRenderer
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TileEntityCalcinatorRenderer extends TileEntitySpecialRenderer {
|
||||
public class TileEntityCalcinatorRenderer extends TileEntitySpecialRenderer
|
||||
{
|
||||
|
||||
private ModelCalcinator modelCalcinator = new ModelCalcinator();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
|
||||
{
|
||||
|
||||
if (tileEntity instanceof TileCalcinator) {
|
||||
if (tileEntity instanceof TileCalcinator)
|
||||
{
|
||||
TileCalcinator tileCalcinator = (TileCalcinator) tileEntity;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
@ -48,7 +47,8 @@ public class TileEntityCalcinatorRenderer extends TileEntitySpecialRenderer {
|
|||
// Render
|
||||
modelCalcinator.renderPart("Calcinator");
|
||||
|
||||
if (tileCalcinator.getStackInSlot(TileCalcinator.OUTPUT_INVENTORY_INDEX) != null) {
|
||||
if (tileCalcinator.getStackInSlot(TileCalcinator.OUTPUT_INVENTORY_INDEX) != null)
|
||||
{
|
||||
modelCalcinator.renderPart("Dust");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
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;
|
||||
|
@ -8,50 +14,45 @@ import net.minecraft.item.ItemBlock;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* TileEntityGlassBellRenderer
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer {
|
||||
public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer
|
||||
{
|
||||
|
||||
private ModelGlassBell modelGlassBell = new ModelGlassBell();
|
||||
private final RenderItem customRenderItem;
|
||||
|
||||
public TileEntityGlassBellRenderer() {
|
||||
|
||||
customRenderItem = new RenderItem() {
|
||||
public TileEntityGlassBellRenderer()
|
||||
{
|
||||
|
||||
customRenderItem = new RenderItem()
|
||||
{
|
||||
@Override
|
||||
public boolean shouldBob() {
|
||||
public boolean shouldBob()
|
||||
{
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
customRenderItem.setRenderManager(RenderManager.instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick)
|
||||
{
|
||||
|
||||
if (tileEntity instanceof TileGlassBell) {
|
||||
if (tileEntity instanceof TileGlassBell)
|
||||
{
|
||||
TileGlassBell tileGlassBell = (TileGlassBell) tileEntity;
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
@ -77,7 +78,8 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer {
|
|||
*/
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if (tileGlassBell.getStackInSlot(TileGlassBell.DISPLAY_SLOT_INVENTORY_INDEX) != null) {
|
||||
if (tileGlassBell.getStackInSlot(TileGlassBell.DISPLAY_SLOT_INVENTORY_INDEX) != null)
|
||||
{
|
||||
|
||||
float scaleFactor = getGhostItemScaleFactor(tileGlassBell.getStackInSlot(TileGlassBell.DISPLAY_SLOT_INVENTORY_INDEX));
|
||||
float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
|
||||
|
@ -100,136 +102,169 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
private void renderGlassBellByOrientation(double x, double y, double z, ForgeDirection forgeDirection) {
|
||||
private void renderGlassBellByOrientation(double x, double y, double z, ForgeDirection forgeDirection)
|
||||
{
|
||||
|
||||
switch (forgeDirection) {
|
||||
case DOWN: {
|
||||
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: {
|
||||
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: {
|
||||
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: {
|
||||
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: {
|
||||
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: {
|
||||
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: {
|
||||
case UNKNOWN:
|
||||
{
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
return;
|
||||
default:
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void translateGhostItemByOrientation(ItemStack ghostItemStack, double x, double y, double z, ForgeDirection forgeDirection) {
|
||||
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: {
|
||||
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: {
|
||||
case UP:
|
||||
{
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.25F, (float) z + 0.5F);
|
||||
return;
|
||||
}
|
||||
case NORTH: {
|
||||
case NORTH:
|
||||
{
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.7F);
|
||||
return;
|
||||
}
|
||||
case SOUTH: {
|
||||
case SOUTH:
|
||||
{
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.3F);
|
||||
return;
|
||||
}
|
||||
case EAST: {
|
||||
case EAST:
|
||||
{
|
||||
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.5F, (float) z + 0.5F);
|
||||
return;
|
||||
}
|
||||
case WEST: {
|
||||
case WEST:
|
||||
{
|
||||
GL11.glTranslatef((float) x + 0.70F, (float) y + 0.5F, (float) z + 0.5F);
|
||||
return;
|
||||
}
|
||||
case UNKNOWN: {
|
||||
case UNKNOWN:
|
||||
{
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
return;
|
||||
default:
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (forgeDirection) {
|
||||
case DOWN: {
|
||||
else
|
||||
{
|
||||
switch (forgeDirection)
|
||||
{
|
||||
case DOWN:
|
||||
{
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.6F, (float) z + 0.5F);
|
||||
return;
|
||||
}
|
||||
case UP: {
|
||||
case UP:
|
||||
{
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.20F, (float) z + 0.5F);
|
||||
return;
|
||||
}
|
||||
case NORTH: {
|
||||
case NORTH:
|
||||
{
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.7F);
|
||||
return;
|
||||
}
|
||||
case SOUTH: {
|
||||
case SOUTH:
|
||||
{
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 0.4F, (float) z + 0.3F);
|
||||
return;
|
||||
}
|
||||
case EAST: {
|
||||
case EAST:
|
||||
{
|
||||
GL11.glTranslatef((float) x + 0.3F, (float) y + 0.4F, (float) z + 0.5F);
|
||||
return;
|
||||
}
|
||||
case WEST: {
|
||||
case WEST:
|
||||
{
|
||||
GL11.glTranslatef((float) x + 0.70F, (float) y + 0.4F, (float) z + 0.5F);
|
||||
return;
|
||||
}
|
||||
case UNKNOWN: {
|
||||
case UNKNOWN:
|
||||
{
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
return;
|
||||
default:
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float getGhostItemScaleFactor(ItemStack itemStack) {
|
||||
private float getGhostItemScaleFactor(ItemStack itemStack)
|
||||
{
|
||||
|
||||
float scaleFactor = 1.0F;
|
||||
|
||||
if (itemStack != null) {
|
||||
if (itemStack.getItem() instanceof ItemBlock) {
|
||||
switch (customRenderItem.getMiniBlockCount(itemStack)) {
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (itemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
switch (customRenderItem.getMiniBlockCount(itemStack))
|
||||
{
|
||||
case 1:
|
||||
return 0.90F;
|
||||
case 2:
|
||||
|
@ -244,8 +279,10 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer {
|
|||
return 0.90F;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (customRenderItem.getMiniItemCount(itemStack)) {
|
||||
else
|
||||
{
|
||||
switch (customRenderItem.getMiniItemCount(itemStack))
|
||||
{
|
||||
case 1:
|
||||
return 0.65F;
|
||||
case 2:
|
||||
|
|
|
@ -1,113 +1,152 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 com.pahimar.ee3.lib.Commands;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* CommandEE
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class CommandEE extends CommandBase {
|
||||
public class CommandEE extends CommandBase
|
||||
{
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
public String getCommandName()
|
||||
{
|
||||
|
||||
return Commands.COMMAND_EE3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCommandSenderUseCommand(ICommandSender commandSender) {
|
||||
public boolean canCommandSenderUseCommand(ICommandSender commandSender)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public List addTabCompletionOptions(ICommandSender commandSender, String[] args) {
|
||||
public List addTabCompletionOptions(ICommandSender commandSender, String[] args)
|
||||
{
|
||||
|
||||
switch (args.length) {
|
||||
case 1: {
|
||||
return getListOfStringsMatchingLastWord(args, new String[] { Commands.COMMAND_OVERLAY, Commands.COMMAND_PARTICLES, Commands.COMMAND_SOUNDS, Commands.COMMAND_VERSION });
|
||||
switch (args.length)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
return getListOfStringsMatchingLastWord(args, new String[] {Commands.COMMAND_OVERLAY, Commands.COMMAND_PARTICLES, Commands.COMMAND_SOUNDS, Commands.COMMAND_VERSION});
|
||||
}
|
||||
case 2: {
|
||||
case 2:
|
||||
{
|
||||
if (args[0].equalsIgnoreCase(Commands.COMMAND_OVERLAY))
|
||||
return getListOfStringsMatchingLastWord(args, new String[] { Commands.COMMAND_ON, Commands.COMMAND_OFF, Commands.COMMAND_POSITION, Commands.COMMAND_SCALE, Commands.COMMAND_OPACITY });
|
||||
{
|
||||
return getListOfStringsMatchingLastWord(args, new String[] {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, new String[] { Commands.COMMAND_ON, Commands.COMMAND_OFF });
|
||||
{
|
||||
return getListOfStringsMatchingLastWord(args, new String[] {Commands.COMMAND_ON, Commands.COMMAND_OFF});
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase(Commands.COMMAND_SOUNDS))
|
||||
return getListOfStringsMatchingLastWord(args, new String[] { Commands.COMMAND_ALL, Commands.COMMAND_SELF, Commands.COMMAND_OFF });
|
||||
{
|
||||
return getListOfStringsMatchingLastWord(args, new String[] {Commands.COMMAND_ALL, Commands.COMMAND_SELF, Commands.COMMAND_OFF});
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase(Commands.COMMAND_VERSION))
|
||||
return getListOfStringsMatchingLastWord(args, new String[] { Commands.COMMAND_CHANGELOG });
|
||||
}
|
||||
case 3: {
|
||||
if (args[0].equalsIgnoreCase(Commands.COMMAND_OVERLAY)) {
|
||||
if (args[1].equalsIgnoreCase(Commands.COMMAND_POSITION))
|
||||
return getListOfStringsMatchingLastWord(args, new String[] { Commands.COMMAND_TOP, Commands.COMMAND_BOTTOM });
|
||||
{
|
||||
return getListOfStringsMatchingLastWord(args, new String[] {Commands.COMMAND_CHANGELOG});
|
||||
}
|
||||
}
|
||||
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, new String[] { Commands.COMMAND_LEFT, Commands.COMMAND_RIGHT });
|
||||
case 3:
|
||||
{
|
||||
if (args[0].equalsIgnoreCase(Commands.COMMAND_OVERLAY))
|
||||
{
|
||||
if (args[1].equalsIgnoreCase(Commands.COMMAND_POSITION))
|
||||
{
|
||||
return getListOfStringsMatchingLastWord(args, new String[] {Commands.COMMAND_TOP, Commands.COMMAND_BOTTOM});
|
||||
}
|
||||
}
|
||||
}
|
||||
default: {
|
||||
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, new String[] {Commands.COMMAND_LEFT, Commands.COMMAND_RIGHT});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender commandSender, String[] args) {
|
||||
public void processCommand(ICommandSender commandSender, String[] args)
|
||||
{
|
||||
|
||||
if (args.length > 0) {
|
||||
if (args.length > 0)
|
||||
{
|
||||
String commandName = args[0];
|
||||
System.arraycopy(args, 1, args, 0, args.length - 1);
|
||||
|
||||
if (commandName.equalsIgnoreCase(Commands.COMMAND_OVERLAY)) {
|
||||
if (commandName.equalsIgnoreCase(Commands.COMMAND_OVERLAY))
|
||||
{
|
||||
CommandOverlay.processCommand(commandSender, args);
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase(Commands.COMMAND_PARTICLES)) {
|
||||
else if (commandName.equalsIgnoreCase(Commands.COMMAND_PARTICLES))
|
||||
{
|
||||
CommandParticles.processCommand(commandSender, args);
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase(Commands.COMMAND_SOUNDS)) {
|
||||
else if (commandName.equalsIgnoreCase(Commands.COMMAND_SOUNDS))
|
||||
{
|
||||
CommandSounds.processCommand(commandSender, args);
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase(Commands.COMMAND_VERSION)) {
|
||||
else if (commandName.equalsIgnoreCase(Commands.COMMAND_VERSION))
|
||||
{
|
||||
CommandVersion.processCommand(commandSender, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_EE3_USAGE, new Object[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_EE3_USAGE, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender) {
|
||||
public String getCommandUsage(ICommandSender icommandsender)
|
||||
{
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(Object obj) {
|
||||
public int compareTo(Object obj)
|
||||
{
|
||||
if (obj instanceof ICommand)
|
||||
return this.compareTo((ICommand)obj);
|
||||
{
|
||||
return this.compareTo((ICommand) obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,16 +4,17 @@ import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
|||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* CommandHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class CommandHandler {
|
||||
public class CommandHandler
|
||||
{
|
||||
|
||||
public static void initCommands(FMLServerStartingEvent event) {
|
||||
public static void initCommands(FMLServerStartingEvent event)
|
||||
{
|
||||
|
||||
event.registerServerCommand(new CommandEE());
|
||||
}
|
||||
|
|
|
@ -1,145 +1,182 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
|
||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
||||
import com.pahimar.ee3.configuration.GeneralConfiguration;
|
||||
import com.pahimar.ee3.lib.Commands;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* CommandOverlay
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class CommandOverlay {
|
||||
public class CommandOverlay
|
||||
{
|
||||
|
||||
public static void processCommand(ICommandSender commandSender, String[] args) {
|
||||
public static void processCommand(ICommandSender commandSender, String[] args)
|
||||
{
|
||||
|
||||
if (args.length > 0) {
|
||||
if (args.length > 0)
|
||||
{
|
||||
String subCommand = args[0];
|
||||
|
||||
if (subCommand.equalsIgnoreCase(Commands.COMMAND_ON)) {
|
||||
if (subCommand.equalsIgnoreCase(Commands.COMMAND_ON))
|
||||
{
|
||||
processOnCommand(commandSender);
|
||||
}
|
||||
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_OFF)) {
|
||||
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_OFF))
|
||||
{
|
||||
processOffCommand(commandSender);
|
||||
}
|
||||
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_OPACITY)) {
|
||||
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_OPACITY))
|
||||
{
|
||||
processOpacityCommand(commandSender, args);
|
||||
}
|
||||
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_SCALE)) {
|
||||
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_SCALE))
|
||||
{
|
||||
processScaleCommand(commandSender, args);
|
||||
}
|
||||
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_POSITION)) {
|
||||
else if (subCommand.equalsIgnoreCase(Commands.COMMAND_POSITION))
|
||||
{
|
||||
processPositionCommand(commandSender, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_USAGE, new Object[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_USAGE, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void processOnCommand(ICommandSender commandSender) {
|
||||
private static void processOnCommand(ICommandSender commandSender)
|
||||
{
|
||||
|
||||
ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION = true;
|
||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME, Strings.TRUE);
|
||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_TURNED_ON));
|
||||
}
|
||||
|
||||
private static void processOffCommand(ICommandSender commandSender) {
|
||||
private static void processOffCommand(ICommandSender commandSender)
|
||||
{
|
||||
|
||||
ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION = false;
|
||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION_CONFIGNAME, Strings.FALSE);
|
||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_OVERLAY_TURNED_OFF));
|
||||
}
|
||||
|
||||
private static void processScaleCommand(ICommandSender commandSender, String[] args) {
|
||||
private static void processScaleCommand(ICommandSender commandSender, String[] args)
|
||||
{
|
||||
|
||||
if (args.length > 2 && args.length < 4) {
|
||||
try {
|
||||
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, new Object[] { Commands.COMMAND_OVERLAY_SCALE_USAGE });
|
||||
if (scale <= 0F)
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_SCALE_USAGE_ADDITIONAL_TEXT, new Object[] {Commands.COMMAND_OVERLAY_SCALE_USAGE});
|
||||
}
|
||||
else {
|
||||
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, new Object[] { Commands.COMMAND_OVERLAY_SCALE_USAGE });
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_SCALE_USAGE_ADDITIONAL_TEXT, new Object[] {Commands.COMMAND_OVERLAY_SCALE_USAGE});
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_SCALE_USAGE_ADDITIONAL_TEXT, new Object[] { Commands.COMMAND_OVERLAY_SCALE_USAGE });
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_SCALE_USAGE_ADDITIONAL_TEXT, new Object[] {Commands.COMMAND_OVERLAY_SCALE_USAGE});
|
||||
}
|
||||
}
|
||||
|
||||
private static void processOpacityCommand(ICommandSender commandSender, String[] args) {
|
||||
private static void processOpacityCommand(ICommandSender commandSender, String[] args)
|
||||
{
|
||||
|
||||
if (args.length > 2 && args.length < 4) {
|
||||
try {
|
||||
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, new Object[] { Commands.COMMAND_OVERLAY_OPACITY_USAGE });
|
||||
if (opacity < 0F || opacity > 1F)
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_OPACITY_USAGE_ADDITIONAL_TEXT, new Object[] {Commands.COMMAND_OVERLAY_OPACITY_USAGE});
|
||||
}
|
||||
else {
|
||||
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, new Object[] { Commands.COMMAND_OVERLAY_OPACITY_USAGE });
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_OPACITY_USAGE_ADDITIONAL_TEXT, new Object[] {Commands.COMMAND_OVERLAY_OPACITY_USAGE});
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_OPACITY_USAGE_ADDITIONAL_TEXT, new Object[] { Commands.COMMAND_OVERLAY_OPACITY_USAGE });
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_OPACITY_USAGE_ADDITIONAL_TEXT, new Object[] {Commands.COMMAND_OVERLAY_OPACITY_USAGE});
|
||||
}
|
||||
}
|
||||
|
||||
private static void processPositionCommand(ICommandSender commandSender, String[] args) {
|
||||
private static void processPositionCommand(ICommandSender commandSender, String[] args)
|
||||
{
|
||||
|
||||
String yPosition, xPosition;
|
||||
|
||||
if (args.length > 2 && args.length < 5) {
|
||||
if (args.length > 2 && args.length < 5)
|
||||
{
|
||||
yPosition = args[1];
|
||||
xPosition = args[2];
|
||||
|
||||
if (yPosition.equalsIgnoreCase(Commands.COMMAND_TOP) && xPosition.equalsIgnoreCase(Commands.COMMAND_LEFT)) {
|
||||
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)) {
|
||||
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)) {
|
||||
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)) {
|
||||
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, new Object[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_OVERLAY_POSITION_USAGE, new Object[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,53 +1,62 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
|
||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
||||
import com.pahimar.ee3.configuration.GeneralConfiguration;
|
||||
import com.pahimar.ee3.lib.Commands;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* CommandParticles
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class CommandParticles {
|
||||
public class CommandParticles
|
||||
{
|
||||
|
||||
public static void processCommand(ICommandSender commandSender, String[] args) {
|
||||
public static void processCommand(ICommandSender commandSender, String[] args)
|
||||
{
|
||||
|
||||
String subCommand;
|
||||
|
||||
if (args.length > 0) {
|
||||
if (args.length > 0)
|
||||
{
|
||||
subCommand = args[0];
|
||||
|
||||
if (subCommand.toLowerCase().equals(Commands.COMMAND_ON)) {
|
||||
if (subCommand.toLowerCase().equals(Commands.COMMAND_ON))
|
||||
{
|
||||
processOnCommand(commandSender);
|
||||
}
|
||||
else if (subCommand.toLowerCase().equals(Commands.COMMAND_OFF)) {
|
||||
else if (subCommand.toLowerCase().equals(Commands.COMMAND_OFF))
|
||||
{
|
||||
processOffCommand(commandSender);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_PARTICLES_USAGE, new Object[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_PARTICLES_USAGE, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void processOnCommand(ICommandSender commandSender) {
|
||||
private static void processOnCommand(ICommandSender commandSender)
|
||||
{
|
||||
|
||||
ConfigurationSettings.ENABLE_PARTICLE_FX = true;
|
||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_PARTICLE_FX_CONFIGNAME, Strings.TRUE);
|
||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(Commands.COMMAND_PARTICLES_TURNED_ON));
|
||||
}
|
||||
|
||||
private static void processOffCommand(ICommandSender commandSender) {
|
||||
private static void processOffCommand(ICommandSender commandSender)
|
||||
{
|
||||
|
||||
ConfigurationSettings.ENABLE_PARTICLE_FX = false;
|
||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_PARTICLE_FX_CONFIGNAME, Strings.FALSE);
|
||||
|
|
|
@ -1,62 +1,73 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
|
||||
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;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* CommandSounds
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class CommandSounds {
|
||||
public class CommandSounds
|
||||
{
|
||||
|
||||
public static void processCommand(ICommandSender commandSender, String[] args) {
|
||||
public static void processCommand(ICommandSender commandSender, String[] args)
|
||||
{
|
||||
|
||||
String subCommand;
|
||||
|
||||
if (args.length > 0) {
|
||||
if (args.length > 0)
|
||||
{
|
||||
subCommand = args[0];
|
||||
|
||||
if (subCommand.toLowerCase().equals(Commands.COMMAND_ALL)) {
|
||||
if (subCommand.toLowerCase().equals(Commands.COMMAND_ALL))
|
||||
{
|
||||
processAllCommand(commandSender);
|
||||
}
|
||||
else if (subCommand.toLowerCase().equals(Commands.COMMAND_SELF)) {
|
||||
else if (subCommand.toLowerCase().equals(Commands.COMMAND_SELF))
|
||||
{
|
||||
processSelfCommand(commandSender);
|
||||
}
|
||||
else if (subCommand.toLowerCase().equals(Commands.COMMAND_OFF)) {
|
||||
else if (subCommand.toLowerCase().equals(Commands.COMMAND_OFF))
|
||||
{
|
||||
processOffCommand(commandSender);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_SOUNDS_USAGE, new Object[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_SOUNDS_USAGE, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void processAllCommand(ICommandSender commandSender) {
|
||||
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) {
|
||||
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) {
|
||||
private static void processOffCommand(ICommandSender commandSender)
|
||||
{
|
||||
|
||||
ConfigurationSettings.ENABLE_SOUNDS = Commands.OFF;
|
||||
GeneralConfiguration.set(GeneralConfiguration.CATEGORY_AUDIO, ConfigurationSettings.ENABLE_SOUNDS_CONFIGNAME, Commands.OFF);
|
||||
|
|
|
@ -1,49 +1,58 @@
|
|||
package com.pahimar.ee3.command;
|
||||
|
||||
import com.pahimar.ee3.core.helper.VersionHelper;
|
||||
import com.pahimar.ee3.lib.Commands;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
|
||||
import com.pahimar.ee3.core.helper.VersionHelper;
|
||||
import com.pahimar.ee3.lib.Commands;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* CommandVersion
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class CommandVersion {
|
||||
public class CommandVersion
|
||||
{
|
||||
|
||||
public static void processCommand(ICommandSender commandSender, String[] args) {
|
||||
public static void processCommand(ICommandSender commandSender, String[] args)
|
||||
{
|
||||
|
||||
String subCommand;
|
||||
|
||||
if (args.length > 0) {
|
||||
if (args.length > 0)
|
||||
{
|
||||
subCommand = args[0];
|
||||
|
||||
if (subCommand.toLowerCase().equals(Commands.COMMAND_VERSION)) {
|
||||
if (subCommand.toLowerCase().equals(Commands.COMMAND_VERSION))
|
||||
{
|
||||
processVersionCommand(commandSender);
|
||||
}
|
||||
else if (subCommand.toLowerCase().equals(Commands.COMMAND_CHANGELOG)) {
|
||||
else if (subCommand.toLowerCase().equals(Commands.COMMAND_CHANGELOG))
|
||||
{
|
||||
processChangelogCommand(commandSender);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_VERSION_USAGE, new Object[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException(Commands.COMMAND_VERSION_USAGE, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void processVersionCommand(ICommandSender commandSender) {
|
||||
private static void processVersionCommand(ICommandSender commandSender)
|
||||
{
|
||||
|
||||
commandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationKey(VersionHelper.getResultMessage()));
|
||||
}
|
||||
|
||||
private static void processChangelogCommand(ICommandSender commandSender) {
|
||||
private static void processChangelogCommand(ICommandSender commandSender)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
package com.pahimar.ee3.configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraftforge.common.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 net.minecraftforge.common.Configuration;
|
||||
|
||||
public class BlockConfiguration {
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
private static Configuration blockConfiguration;
|
||||
public class BlockConfiguration
|
||||
{
|
||||
|
||||
protected static void init(File configFile) {
|
||||
protected static void init(File configFile)
|
||||
{
|
||||
|
||||
blockConfiguration = new Configuration(configFile);
|
||||
Configuration blockConfiguration = new Configuration(configFile);
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
blockConfiguration.load();
|
||||
|
||||
/* Block configs */
|
||||
|
@ -28,10 +27,12 @@ public class BlockConfiguration {
|
|||
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);
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, Reference.MOD_NAME + " has had a problem loading its block configuration");
|
||||
}
|
||||
finally {
|
||||
finally
|
||||
{
|
||||
blockConfiguration.save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
package com.pahimar.ee3.configuration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraftforge.common.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ConfigurationHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ConfigurationHandler {
|
||||
public class ConfigurationHandler
|
||||
{
|
||||
|
||||
public static Configuration configuration;
|
||||
|
||||
public static final String CATEGORY_TRANSMUTATION = "transmutation";
|
||||
|
||||
public static void init(String configPath) {
|
||||
public static void init(String configPath)
|
||||
{
|
||||
|
||||
GeneralConfiguration.init(new File(configPath + "general.properties"));
|
||||
BlockConfiguration.init(new File(configPath + "block.properties"));
|
||||
|
|
|
@ -4,14 +4,14 @@ import com.pahimar.ee3.lib.Strings;
|
|||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ConfigurationSettings
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ConfigurationSettings {
|
||||
public class ConfigurationSettings
|
||||
{
|
||||
|
||||
/*
|
||||
* Version check related settings
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package com.pahimar.ee3.configuration;
|
||||
|
||||
import static net.minecraftforge.common.Configuration.CATEGORY_GENERAL;
|
||||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import static net.minecraftforge.common.Configuration.CATEGORY_GENERAL;
|
||||
|
||||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
public class GeneralConfiguration {
|
||||
public class GeneralConfiguration
|
||||
{
|
||||
|
||||
private static Configuration generalConfiguration;
|
||||
|
||||
|
@ -20,11 +19,13 @@ public class GeneralConfiguration {
|
|||
public static final String CATEGORY_GRAPHICS = "graphics";
|
||||
public static final String CATEGORY_AUDIO = "audio";
|
||||
|
||||
protected static void init(File configFile) {
|
||||
protected static void init(File configFile)
|
||||
{
|
||||
|
||||
generalConfiguration = new Configuration(configFile);
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
generalConfiguration.load();
|
||||
|
||||
/* Version check */
|
||||
|
@ -36,24 +37,30 @@ public class GeneralConfiguration {
|
|||
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 {
|
||||
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) {
|
||||
if (ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE <= 0F)
|
||||
{
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE = ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE_DEFAULT;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception e)
|
||||
{
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE = ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE_DEFAULT;
|
||||
}
|
||||
try {
|
||||
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) {
|
||||
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) {
|
||||
catch (Exception e)
|
||||
{
|
||||
ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY = ConfigurationSettings.TARGET_BLOCK_OVERLAY_OPACITY_DEFAULT;
|
||||
}
|
||||
|
||||
|
@ -67,19 +74,24 @@ public class GeneralConfiguration {
|
|||
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) {
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, Reference.MOD_NAME + " has had a problem loading its general configuration");
|
||||
}
|
||||
finally {
|
||||
finally
|
||||
{
|
||||
generalConfiguration.save();
|
||||
}
|
||||
}
|
||||
|
||||
public static void set(String categoryName, String propertyName, String newValue) {
|
||||
|
||||
public static void set(String categoryName, String propertyName, String newValue)
|
||||
{
|
||||
|
||||
generalConfiguration.load();
|
||||
if (generalConfiguration.getCategoryNames().contains(categoryName)) {
|
||||
if (generalConfiguration.getCategory(categoryName).containsKey(propertyName)) {
|
||||
if (generalConfiguration.getCategoryNames().contains(categoryName))
|
||||
{
|
||||
if (generalConfiguration.getCategory(categoryName).containsKey(propertyName))
|
||||
{
|
||||
generalConfiguration.getCategory(categoryName).get(propertyName).set(newValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,28 @@
|
|||
package com.pahimar.ee3.configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
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.Configuration;
|
||||
|
||||
public class ItemConfiguration {
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ItemConfiguration
|
||||
{
|
||||
|
||||
private static Configuration itemConfiguration;
|
||||
|
||||
|
||||
private static final String CATEGORY_DURABILITY = "durability";
|
||||
|
||||
protected static void init(File configFile) {
|
||||
|
||||
protected static void init(File configFile)
|
||||
{
|
||||
|
||||
itemConfiguration = new Configuration(configFile);
|
||||
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
itemConfiguration.load();
|
||||
|
||||
/* Item configs */
|
||||
|
@ -36,10 +38,12 @@ public class ItemConfiguration {
|
|||
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) {
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, Reference.MOD_NAME + " has had a problem loading its item configuration");
|
||||
}
|
||||
finally {
|
||||
finally
|
||||
{
|
||||
itemConfiguration.save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
package com.pahimar.ee3.configuration;
|
||||
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import net.minecraftforge.common.Configuration;
|
||||
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
public class TransmutationConfiguration {
|
||||
public class TransmutationConfiguration
|
||||
{
|
||||
|
||||
private static Configuration transmutationConfiguration;
|
||||
|
||||
private static final String CATEGORY_TRANSMUTATION = "transmutation";
|
||||
|
||||
protected static void init(File configFile) {
|
||||
protected static void init(File configFile)
|
||||
{
|
||||
|
||||
transmutationConfiguration = new Configuration(configFile);
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
transmutationConfiguration.load();
|
||||
|
||||
/* Transmutation configs */
|
||||
|
@ -27,10 +28,12 @@ public class TransmutationConfiguration {
|
|||
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) {
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLLog.log(Level.SEVERE, e, Reference.MOD_NAME + " has had a problem loading its transmutation configuration");
|
||||
}
|
||||
finally {
|
||||
finally
|
||||
{
|
||||
transmutationConfiguration.save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
package com.pahimar.ee3.core.handler;
|
||||
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
import com.pahimar.ee3.event.ActionRequestEvent;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ActionRequestHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ActionRequestHandler {
|
||||
public class ActionRequestHandler
|
||||
{
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onModActionEvent(ActionRequestEvent event) {
|
||||
public void onModActionEvent(ActionRequestEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,74 +1,82 @@
|
|||
package com.pahimar.ee3.core.handler;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
||||
import com.pahimar.ee3.core.helper.ItemStackNBTHelper;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* CraftingHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class CraftingHandler implements ICraftingHandler {
|
||||
public class CraftingHandler implements ICraftingHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) {
|
||||
public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix)
|
||||
{
|
||||
|
||||
if (player.worldObj.isRemote) {
|
||||
if (player.worldObj.isRemote)
|
||||
{
|
||||
doPortableCrafting(player, craftMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSmelting(EntityPlayer player, ItemStack item) {
|
||||
public void onSmelting(EntityPlayer player, ItemStack item)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @param player The player that is completing the crafting
|
||||
* @param craftMatrix The contents of the crafting matrix
|
||||
*/
|
||||
private void doPortableCrafting(EntityPlayer player, IInventory craftMatrix) {
|
||||
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)) {
|
||||
for (ItemStack itemStack : player.inventory.mainInventory)
|
||||
{
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN))
|
||||
{
|
||||
openStone = itemStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack itemStack = null;
|
||||
if (openStone != null) {
|
||||
for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
|
||||
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)) {
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN))
|
||||
{
|
||||
openStone = itemStack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (openStone != null) {
|
||||
if (openStone != null)
|
||||
{
|
||||
openStone.damageItem(ConfigurationSettings.TRANSMUTE_COST_ITEM, player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
package com.pahimar.ee3.core.handler;
|
||||
|
||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
||||
import com.pahimar.ee3.core.helper.TransmutationHelper;
|
||||
import com.pahimar.ee3.item.IChargeable;
|
||||
import com.pahimar.ee3.item.ITransmutationStone;
|
||||
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.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.EnumMovingObjectType;
|
||||
|
@ -7,47 +15,42 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
||||
import com.pahimar.ee3.core.helper.TransmutationHelper;
|
||||
import com.pahimar.ee3.item.IChargeable;
|
||||
import com.pahimar.ee3.item.ITransmutationStone;
|
||||
import com.pahimar.ee3.lib.Textures;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* DrawBlockHighlightHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class DrawBlockHighlightHandler {
|
||||
public class DrawBlockHighlightHandler
|
||||
{
|
||||
|
||||
private static int pulse = 0;
|
||||
private static boolean doInc = true;
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event) {
|
||||
public void onDrawBlockHighlightEvent(DrawBlockHighlightEvent event)
|
||||
{
|
||||
|
||||
Minecraft minecraft = FMLClientHandler.instance().getClient();
|
||||
|
||||
if (event.currentItem != null) {
|
||||
if (event.currentItem.getItem() instanceof ITransmutationStone) {
|
||||
if (event.target.typeOfHit == EnumMovingObjectType.TILE) {
|
||||
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) {
|
||||
if (Minecraft.isGuiEnabled() && minecraft.inGameHasFocus)
|
||||
{
|
||||
if (ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION)
|
||||
{
|
||||
drawInWorldTransmutationOverlay(event);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +59,8 @@ public class DrawBlockHighlightHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public void drawInWorldTransmutationOverlay(DrawBlockHighlightEvent event) {
|
||||
public void drawInWorldTransmutationOverlay(DrawBlockHighlightEvent event)
|
||||
{
|
||||
|
||||
double x = event.target.blockX + 0.5F;
|
||||
double y = event.target.blockY + 0.5F;
|
||||
|
@ -74,22 +78,26 @@ public class DrawBlockHighlightHandler {
|
|||
int chargeLevel;
|
||||
int itemChargeLevel = 0;
|
||||
|
||||
if (event.currentItem.getItem() instanceof IChargeable) {
|
||||
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: {
|
||||
switch (sideHit)
|
||||
{
|
||||
case UP:
|
||||
{
|
||||
xScale = chargeLevel + 0.1F;
|
||||
zScale = chargeLevel + 0.1F;
|
||||
xShift = 0;
|
||||
zShift = 0;
|
||||
break;
|
||||
}
|
||||
case DOWN: {
|
||||
case DOWN:
|
||||
{
|
||||
xScale = chargeLevel + 0.1F;
|
||||
zScale = chargeLevel + 0.1F;
|
||||
xShift = 0;
|
||||
|
@ -97,7 +105,8 @@ public class DrawBlockHighlightHandler {
|
|||
zShift = 0;
|
||||
break;
|
||||
}
|
||||
case NORTH: {
|
||||
case NORTH:
|
||||
{
|
||||
xScale = chargeLevel + 0.1F;
|
||||
yScale = chargeLevel + 0.1F;
|
||||
xShift = 0;
|
||||
|
@ -105,21 +114,24 @@ public class DrawBlockHighlightHandler {
|
|||
zShift = -zShift;
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
case SOUTH:
|
||||
{
|
||||
xScale = chargeLevel + 0.1F;
|
||||
yScale = chargeLevel + 0.1F;
|
||||
xShift = 0;
|
||||
yShift = 0;
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
case EAST:
|
||||
{
|
||||
yScale = chargeLevel + 0.1F;
|
||||
zScale = chargeLevel + 0.1F;
|
||||
yShift = 0;
|
||||
zShift = 0;
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
case WEST:
|
||||
{
|
||||
yScale = chargeLevel + 0.1F;
|
||||
zScale = chargeLevel + 0.1F;
|
||||
xShift = -xShift;
|
||||
|
@ -134,7 +146,8 @@ public class DrawBlockHighlightHandler {
|
|||
GL11.glDepthMask(false);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection forgeDir = ForgeDirection.getOrientation(i);
|
||||
int zCorrection = i == 2 ? -1 : 1;
|
||||
GL11.glPushMatrix();
|
||||
|
@ -151,7 +164,8 @@ public class DrawBlockHighlightHandler {
|
|||
GL11.glDepthMask(true);
|
||||
}
|
||||
|
||||
public static void renderPulsingQuad(ResourceLocation texture, float maxTransparency) {
|
||||
public static void renderPulsingQuad(ResourceLocation texture, float maxTransparency)
|
||||
{
|
||||
|
||||
float pulseTransparency = getPulseValue() * maxTransparency / 3000f;
|
||||
|
||||
|
@ -176,20 +190,25 @@ public class DrawBlockHighlightHandler {
|
|||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
|
||||
private static int getPulseValue() {
|
||||
private static int getPulseValue()
|
||||
{
|
||||
|
||||
if (doInc) {
|
||||
if (doInc)
|
||||
{
|
||||
pulse += 8;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
pulse -= 8;
|
||||
}
|
||||
|
||||
if (pulse == 3000) {
|
||||
if (pulse == 3000)
|
||||
{
|
||||
doInc = false;
|
||||
}
|
||||
|
||||
if (pulse == 0) {
|
||||
if (pulse == 0)
|
||||
{
|
||||
doInc = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,38 +1,43 @@
|
|||
package com.pahimar.ee3.core.handler;
|
||||
|
||||
import com.pahimar.ee3.core.helper.ItemHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
|
||||
import com.pahimar.ee3.core.helper.ItemHelper;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* EntityLivingHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class EntityLivingHandler {
|
||||
public class EntityLivingHandler
|
||||
{
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onEntityLivingUpdate(LivingUpdateEvent event) {
|
||||
public void onEntityLivingUpdate(LivingUpdateEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onEntityLivingDeath(LivingDeathEvent event) {
|
||||
public void onEntityLivingDeath(LivingDeathEvent event)
|
||||
{
|
||||
|
||||
if (event.source.getDamageType().equals("player")) {
|
||||
if (event.source.getDamageType().equals("player"))
|
||||
{
|
||||
ItemHelper.dropMiniumShard((EntityPlayer) event.source.getSourceOfDamage(), event.entityLiving);
|
||||
}
|
||||
if (event.source.getSourceOfDamage() instanceof EntityArrow) {
|
||||
if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity != null) {
|
||||
if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity instanceof EntityPlayer) {
|
||||
if (event.source.getSourceOfDamage() instanceof EntityArrow)
|
||||
{
|
||||
if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity != null)
|
||||
{
|
||||
if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity instanceof EntityPlayer)
|
||||
{
|
||||
ItemHelper.dropMiniumShard((EntityPlayer) ((EntityArrow) event.source.getSourceOfDamage()).shootingEntity, event.entityLiving);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,38 +1,40 @@
|
|||
package com.pahimar.ee3.core.handler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.pahimar.ee3.core.helper.GeneralHelper;
|
||||
import com.pahimar.ee3.core.helper.LogHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* EquivalencyHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class EquivalencyHandler {
|
||||
public class EquivalencyHandler
|
||||
{
|
||||
|
||||
private static final EquivalencyHandler instance = new EquivalencyHandler();
|
||||
|
||||
private static ArrayList<ArrayList<ItemStack>> equivalencyList = new ArrayList<ArrayList<ItemStack>>();
|
||||
|
||||
public static EquivalencyHandler instance() {
|
||||
public static EquivalencyHandler instance()
|
||||
{
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ArrayList<ArrayList<ItemStack>> getAllLists() {
|
||||
public ArrayList<ArrayList<ItemStack>> getAllLists()
|
||||
{
|
||||
|
||||
return equivalencyList;
|
||||
}
|
||||
|
||||
public void addObjects(Object obj1, Object obj2) {
|
||||
public void addObjects(Object obj1, Object obj2)
|
||||
{
|
||||
|
||||
ItemStack stack1 = GeneralHelper.convertObjectToItemStack(obj1);
|
||||
ItemStack stack2 = GeneralHelper.convertObjectToItemStack(obj2);
|
||||
|
@ -43,45 +45,58 @@ public class EquivalencyHandler {
|
|||
Integer stack2Index = getIndexInList(stack2);
|
||||
|
||||
if (stack1Index != null && stack2Index != null)
|
||||
return;
|
||||
else if (stack1Index != null && stack2Index == null) {
|
||||
{
|
||||
}
|
||||
else if (stack1Index != null && stack2Index == null)
|
||||
{
|
||||
currentList = equivalencyList.get(stack1Index.intValue());
|
||||
currentList.add(stack2);
|
||||
equivalencyList.set(stack1Index.intValue(), currentList);
|
||||
}
|
||||
else if (stack1Index == null && stack2Index != null) {
|
||||
else if (stack1Index == null && stack2Index != null)
|
||||
{
|
||||
currentList = equivalencyList.get(stack2Index.intValue());
|
||||
currentList.add(stack1);
|
||||
equivalencyList.set(stack2Index.intValue(), currentList);
|
||||
}
|
||||
else if (stack1Index == null && stack2Index == null) {
|
||||
else if (stack1Index == null && stack2Index == null)
|
||||
{
|
||||
currentList.add(stack1);
|
||||
currentList.add(stack2);
|
||||
equivalencyList.add(currentList);
|
||||
}
|
||||
}
|
||||
|
||||
public void addObjects(Object... objList) {
|
||||
public void addObjects(Object... objList)
|
||||
{
|
||||
|
||||
if (objList.length < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < objList.length - 1; i++) {
|
||||
for (int i = 0; i < objList.length - 1; i++)
|
||||
{
|
||||
addObjects(objList[i], objList[i + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getIndexInList(Object obj) {
|
||||
public Integer getIndexInList(Object obj)
|
||||
{
|
||||
|
||||
ItemStack checkStack = GeneralHelper.convertObjectToItemStack(obj);
|
||||
ArrayList<ItemStack> currentList;
|
||||
int i = 0;
|
||||
|
||||
while (i < equivalencyList.size()) {
|
||||
while (i < equivalencyList.size())
|
||||
{
|
||||
currentList = equivalencyList.get(i);
|
||||
for (ItemStack currentStack : currentList) {
|
||||
for (ItemStack currentStack : currentList)
|
||||
{
|
||||
if (ItemStack.areItemStacksEqual(checkStack, currentStack))
|
||||
return new Integer(i);
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
@ -89,16 +104,21 @@ public class EquivalencyHandler {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Integer getIndexInList(int id, int meta) {
|
||||
public Integer getIndexInList(int id, int meta)
|
||||
{
|
||||
|
||||
ArrayList<ItemStack> currentList;
|
||||
int i = 0;
|
||||
|
||||
while (i < equivalencyList.size()) {
|
||||
while (i < equivalencyList.size())
|
||||
{
|
||||
currentList = equivalencyList.get(i);
|
||||
for (ItemStack currentStack : currentList) {
|
||||
for (ItemStack currentStack : currentList)
|
||||
{
|
||||
if (id == currentStack.itemID && meta == currentStack.getItemDamage())
|
||||
return new Integer(i);
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
@ -106,46 +126,62 @@ public class EquivalencyHandler {
|
|||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getEquivalencyList(Object obj) {
|
||||
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) {
|
||||
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) {
|
||||
public ArrayList<ItemStack> getEquivalencyList(int id, int meta)
|
||||
{
|
||||
|
||||
for (ArrayList<ItemStack> list : equivalencyList) {
|
||||
for (ItemStack currentStack : list) {
|
||||
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) {
|
||||
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) {
|
||||
public ItemStack getNextInList(int id, int meta)
|
||||
{
|
||||
|
||||
ArrayList<ItemStack> list = getEquivalencyList(id, meta);
|
||||
|
||||
|
@ -153,14 +189,19 @@ public class EquivalencyHandler {
|
|||
ItemStack returnStack = null;
|
||||
int i = 0;
|
||||
|
||||
if (list != null) {
|
||||
if (list != null)
|
||||
{
|
||||
if (list.size() == 1)
|
||||
{
|
||||
return list.get(i);
|
||||
}
|
||||
|
||||
while (i < list.size()) {
|
||||
while (i < list.size())
|
||||
{
|
||||
currentStack = list.get(i);
|
||||
|
||||
if (id == currentStack.itemID && meta == currentStack.getItemDamage()) {
|
||||
if (id == currentStack.itemID && meta == currentStack.getItemDamage())
|
||||
{
|
||||
returnStack = list.get((i + 1) % list.size());
|
||||
break;
|
||||
}
|
||||
|
@ -172,17 +213,21 @@ public class EquivalencyHandler {
|
|||
return returnStack;
|
||||
}
|
||||
|
||||
public ItemStack getPrevInList(Object obj) {
|
||||
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) {
|
||||
public ItemStack getPrevInList(int id, int meta)
|
||||
{
|
||||
|
||||
ArrayList<ItemStack> list = getEquivalencyList(id, meta);
|
||||
|
||||
|
@ -190,14 +235,19 @@ public class EquivalencyHandler {
|
|||
ItemStack returnStack = null;
|
||||
int i = 0;
|
||||
|
||||
if (list != null) {
|
||||
if (list != null)
|
||||
{
|
||||
if (list.size() == 1)
|
||||
{
|
||||
return list.get(i);
|
||||
}
|
||||
|
||||
while (i < list.size()) {
|
||||
while (i < list.size())
|
||||
{
|
||||
currentStack = list.get(i);
|
||||
|
||||
if (id == currentStack.itemID && meta == currentStack.getItemDamage()) {
|
||||
if (id == currentStack.itemID && meta == currentStack.getItemDamage())
|
||||
{
|
||||
int index = (i - 1 + list.size()) % list.size();
|
||||
returnStack = list.get(index);
|
||||
break;
|
||||
|
@ -210,43 +260,65 @@ public class EquivalencyHandler {
|
|||
return returnStack;
|
||||
}
|
||||
|
||||
public boolean areEquivalent(Object obj1, Object obj2) {
|
||||
public boolean areEquivalent(Object obj1, Object obj2)
|
||||
{
|
||||
|
||||
if (getEquivalencyList(obj1) != null && getEquivalencyList(obj2) != null) {
|
||||
if (getEquivalencyList(obj1) != null && getEquivalencyList(obj2) != null)
|
||||
{
|
||||
// TODO This could be cleaner
|
||||
if (GeneralHelper.convertObjectToItemStack(obj1).itemID == GeneralHelper.convertObjectToItemStack(obj2).itemID && GeneralHelper.convertObjectToItemStack(obj1).getItemDamage() == GeneralHelper.convertObjectToItemStack(obj2).getItemDamage())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return getEquivalencyList(obj1).equals(getEquivalencyList(obj2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Ignores stack size for world transmutation */
|
||||
public boolean areWorldEquivalent(Object obj1, Object obj2) {
|
||||
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) {
|
||||
if (getEquivalencyList(first.itemID, first.getItemDamage()) != null && getEquivalencyList(second.itemID, second.getItemDamage()) != null)
|
||||
{
|
||||
if (first.itemID == second.itemID && first.getItemDamage() == second.getItemDamage())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return getEquivalencyList(first.itemID, first.getItemDamage()).equals(getEquivalencyList(second.itemID, second.getItemDamage()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void debug() {
|
||||
public void debug()
|
||||
{
|
||||
|
||||
int i = 0;
|
||||
for (ArrayList<ItemStack> list : equivalencyList) {
|
||||
for (ArrayList<ItemStack> list : equivalencyList)
|
||||
{
|
||||
LogHelper.info("equivalencyList[" + i + "]: " + list.toString());
|
||||
++i;
|
||||
}
|
||||
|
|
|
@ -1,64 +1,76 @@
|
|||
package com.pahimar.ee3.core.handler;
|
||||
|
||||
import com.pahimar.ee3.core.helper.ItemStackNBTHelper;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||
|
||||
import com.pahimar.ee3.core.helper.ItemStackNBTHelper;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ItemEventHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ItemEventHandler {
|
||||
public class ItemEventHandler
|
||||
{
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onItemPickup(EntityItemPickupEvent event) {
|
||||
public void onItemPickup(EntityItemPickupEvent event)
|
||||
{
|
||||
|
||||
if (ItemStackNBTHelper.hasTag(event.item.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN)) {
|
||||
if (ItemStackNBTHelper.hasTag(event.item.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN))
|
||||
{
|
||||
ItemStackNBTHelper.removeTag(event.item.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN);
|
||||
}
|
||||
else if (ItemStackNBTHelper.hasTag(event.item.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_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)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onItemToss(ItemTossEvent event) {
|
||||
public void onItemToss(ItemTossEvent event)
|
||||
{
|
||||
|
||||
if (ItemStackNBTHelper.hasTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN)) {
|
||||
if (ItemStackNBTHelper.hasTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN))
|
||||
{
|
||||
ItemStackNBTHelper.removeTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN);
|
||||
}
|
||||
else if (ItemStackNBTHelper.hasTag(event.entityItem.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_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)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onPlayerDrop(PlayerDropsEvent event) {
|
||||
public void onPlayerDrop(PlayerDropsEvent event)
|
||||
{
|
||||
|
||||
for (EntityItem entityItem : event.drops) {
|
||||
if (ItemStackNBTHelper.hasTag(entityItem.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN)) {
|
||||
for (EntityItem entityItem : event.drops)
|
||||
{
|
||||
if (ItemStackNBTHelper.hasTag(entityItem.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN))
|
||||
{
|
||||
ItemStackNBTHelper.removeTag(entityItem.getEntityItem(), Strings.NBT_ITEM_CRAFTING_GUI_OPEN);
|
||||
}
|
||||
else if (ItemStackNBTHelper.hasTag(entityItem.getEntityItem(), Strings.NBT_ITEM_TRANSMUTATION_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)) {
|
||||
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,53 +1,61 @@
|
|||
package com.pahimar.ee3.core.handler;
|
||||
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
|
||||
import com.pahimar.ee3.emc.EmcRegistry;
|
||||
import com.pahimar.ee3.emc.EmcType;
|
||||
import com.pahimar.ee3.emc.EmcValue;
|
||||
import com.pahimar.ee3.item.WrappedStack;
|
||||
import com.pahimar.ee3.item.OreStack;
|
||||
import com.pahimar.ee3.item.WrappedStack;
|
||||
import com.pahimar.ee3.item.crafting.RecipeRegistry;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ItemTooltipEventHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ItemTooltipEventHandler {
|
||||
|
||||
public class ItemTooltipEventHandler
|
||||
{
|
||||
|
||||
private static boolean debug = true;
|
||||
|
||||
@ForgeSubscribe
|
||||
public void handleItemTooltipEvent(ItemTooltipEvent event) {
|
||||
public void handleItemTooltipEvent(ItemTooltipEvent event)
|
||||
{
|
||||
|
||||
WrappedStack stack = new WrappedStack(event.itemStack);
|
||||
if (debug) {
|
||||
if (debug)
|
||||
{
|
||||
event.toolTip.add(EnumChatFormatting.AQUA + "ID: " + event.itemStack.itemID + ", Meta: " + event.itemStack.getItemDamage());
|
||||
if (stack.getWrappedStack() instanceof OreStack) {
|
||||
if (stack.getWrappedStack() instanceof OreStack)
|
||||
{
|
||||
event.toolTip.add(EnumChatFormatting.AQUA + "OreDictionary Item");
|
||||
}
|
||||
if (RecipeRegistry.getRecipeMappings().containsKey(stack)) {
|
||||
if (RecipeRegistry.getInstance().getRecipeMappings().containsKey(stack))
|
||||
{
|
||||
event.toolTip.add(EnumChatFormatting.AQUA + "Made from a recipe");
|
||||
}
|
||||
}
|
||||
|
||||
if (EmcRegistry.hasEmcValue(stack)) {
|
||||
|
||||
if (EmcRegistry.hasEmcValue(stack))
|
||||
{
|
||||
EmcValue emcValue = EmcRegistry.getEmcValue(stack);
|
||||
|
||||
event.toolTip.add("");
|
||||
if (emcValue != null) {
|
||||
if (emcValue != null)
|
||||
{
|
||||
event.toolTip.add("EMC: " + String.format("%.3f", stack.getStackSize() * emcValue.getValue()));
|
||||
|
||||
if (debug) {
|
||||
for (EmcType emcType : EmcType.TYPES) {
|
||||
if (emcValue.components[emcType.ordinal()] > 0) {
|
||||
|
||||
if (debug)
|
||||
{
|
||||
for (EmcType emcType : EmcType.TYPES)
|
||||
{
|
||||
if (emcValue.components[emcType.ordinal()] > 0)
|
||||
{
|
||||
event.toolTip.add(" * " + emcType + ": " + String.format("%.3f", stack.getStackSize() * emcValue.components[emcType.ordinal()]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,61 +1,69 @@
|
|||
package com.pahimar.ee3.core.handler;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.pahimar.ee3.core.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.client.registry.KeyBindingRegistry;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
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
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class KeyBindingHandler extends KeyBindingRegistry.KeyHandler {
|
||||
public class KeyBindingHandler extends KeyBindingRegistry.KeyHandler
|
||||
{
|
||||
|
||||
public KeyBindingHandler() {
|
||||
public KeyBindingHandler()
|
||||
{
|
||||
|
||||
super(KeyBindingHelper.gatherKeyBindings(), KeyBindingHelper.gatherIsRepeating());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
public String getLabel()
|
||||
{
|
||||
|
||||
return Reference.MOD_NAME + ": " + this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) {
|
||||
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat)
|
||||
{
|
||||
|
||||
// Only operate at the end of the tick
|
||||
if (tickEnd) {
|
||||
if (tickEnd)
|
||||
{
|
||||
// If we are not in a GUI of any kind, continue execution
|
||||
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
|
||||
if (FMLClientHandler.instance().getClient().inGameHasFocus)
|
||||
{
|
||||
EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
|
||||
if (player != null) {
|
||||
if (player != null)
|
||||
{
|
||||
ItemStack currentItem = FMLClientHandler.instance().getClient().thePlayer.getCurrentEquippedItem();
|
||||
|
||||
if (currentItem != null) {
|
||||
if (currentItem.getItem() instanceof IKeyBound) {
|
||||
if (!KeyBindingHelper.isClientSided(kb.keyDescription)) {
|
||||
if (currentItem != null)
|
||||
{
|
||||
if (currentItem.getItem() instanceof IKeyBound)
|
||||
{
|
||||
if (!KeyBindingHelper.isClientSided(kb.keyDescription))
|
||||
{
|
||||
PacketDispatcher.sendPacketToServer(PacketTypeHandler.populatePacket(new PacketKeyPressed(kb.keyDescription)));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
((IKeyBound) currentItem.getItem()).doKeyBindingAction(player, currentItem, kb.keyDescription);
|
||||
}
|
||||
}
|
||||
|
@ -66,12 +74,14 @@ public class KeyBindingHandler extends KeyBindingRegistry.KeyHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {
|
||||
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks() {
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
|
||||
return EnumSet.of(TickType.CLIENT);
|
||||
}
|
||||
|
|
|
@ -5,17 +5,18 @@ import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
|||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* PlayerDestroyItemHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class PlayerDestroyItemHandler {
|
||||
public class PlayerDestroyItemHandler
|
||||
{
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onPlayerDestroyItemEvent(PlayerDestroyItemEvent event) {
|
||||
public void onPlayerDestroyItemEvent(PlayerDestroyItemEvent event)
|
||||
{
|
||||
|
||||
// TODO Come back and actually do what I want here
|
||||
|
||||
|
|
|
@ -1,59 +1,62 @@
|
|||
package com.pahimar.ee3.core.handler;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
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 com.pahimar.ee3.client.renderer.RenderUtils;
|
||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
||||
import com.pahimar.ee3.core.helper.TransmutationHelper;
|
||||
import com.pahimar.ee3.item.ITransmutationStone;
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
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
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TransmutationTargetOverlayHandler implements ITickHandler {
|
||||
public class TransmutationTargetOverlayHandler implements ITickHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
|
||||
Minecraft minecraft = FMLClientHandler.instance().getClient();
|
||||
EntityPlayer player = minecraft.thePlayer;
|
||||
ItemStack currentItemStack = null;
|
||||
|
||||
if (type.contains(TickType.RENDER)) {
|
||||
if (player != null) {
|
||||
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) {
|
||||
if (Minecraft.isGuiEnabled() && minecraft.inGameHasFocus)
|
||||
{
|
||||
if (currentItemStack != null && currentItemStack.getItem() instanceof ITransmutationStone && ConfigurationSettings.ENABLE_OVERLAY_WORLD_TRANSMUTATION)
|
||||
{
|
||||
renderStoneHUD(minecraft, player, currentItemStack, (Float) tickData[0]);
|
||||
}
|
||||
}
|
||||
|
@ -62,18 +65,21 @@ public class TransmutationTargetOverlayHandler implements ITickHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks() {
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
|
||||
return EnumSet.of(TickType.CLIENT, TickType.RENDER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
public String getLabel()
|
||||
{
|
||||
|
||||
return Reference.MOD_NAME + ": " + this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
private static void renderStoneHUD(Minecraft minecraft, EntityPlayer player, ItemStack stack, float partialTicks) {
|
||||
private static void renderStoneHUD(Minecraft minecraft, EntityPlayer player, ItemStack stack, float partialTicks)
|
||||
{
|
||||
|
||||
float overlayScale = ConfigurationSettings.TARGET_BLOCK_OVERLAY_SCALE;
|
||||
float blockScale = overlayScale / 2;
|
||||
|
@ -101,43 +107,50 @@ public class TransmutationTargetOverlayHandler implements ITickHandler {
|
|||
int hudBlockX = 0;
|
||||
int hudBlockY = 0;
|
||||
|
||||
switch (ConfigurationSettings.TARGET_BLOCK_OVERLAY_POSITION) {
|
||||
case 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: {
|
||||
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: {
|
||||
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: {
|
||||
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: {
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RenderUtils.renderItemIntoGUI(minecraft.fontRenderer, stack, hudOverlayX, hudOverlayY, overlayOpacity, overlayScale);
|
||||
|
||||
if (TransmutationHelper.targetBlockStack != null && TransmutationHelper.targetBlockStack.getItem() instanceof ItemBlock) {
|
||||
if (TransmutationHelper.targetBlockStack != null && TransmutationHelper.targetBlockStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
RenderUtils.renderRotatingBlockIntoGUI(minecraft.fontRenderer, TransmutationHelper.targetBlockStack, hudBlockX, hudBlockY, -90, blockScale);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,50 +1,57 @@
|
|||
package com.pahimar.ee3.core.handler;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraftforge.common.Configuration;
|
||||
|
||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
||||
import com.pahimar.ee3.configuration.GeneralConfiguration;
|
||||
import com.pahimar.ee3.core.helper.VersionHelper;
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* VersionCheckTickHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class VersionCheckTickHandler implements ITickHandler {
|
||||
public class VersionCheckTickHandler implements ITickHandler
|
||||
{
|
||||
|
||||
private static boolean initialized = false;
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
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) {
|
||||
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) {
|
||||
if (VersionHelper.getResult() == VersionHelper.OUTDATED)
|
||||
{
|
||||
FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(VersionHelper.getResultMessageForClient());
|
||||
GeneralConfiguration.set(Configuration.CATEGORY_GENERAL, ConfigurationSettings.DISPLAY_VERSION_RESULT_CONFIGNAME, Strings.FALSE);
|
||||
}
|
||||
|
@ -57,13 +64,15 @@ public class VersionCheckTickHandler implements ITickHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks() {
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
|
||||
return EnumSet.of(TickType.CLIENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
public String getLabel()
|
||||
{
|
||||
|
||||
return Reference.MOD_NAME + ": " + this.getClass().getSimpleName();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
package com.pahimar.ee3.core.handler;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.Event.Result;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
||||
import com.pahimar.ee3.core.helper.TransmutationHelper;
|
||||
import com.pahimar.ee3.event.ActionEvent;
|
||||
|
@ -22,22 +14,29 @@ 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.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.Event.Result;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* WorldTransmutationHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class WorldTransmutationHandler {
|
||||
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) {
|
||||
public static void handleWorldTransmutation(EntityPlayer thePlayer, int originX, int originY, int originZ, byte rangeX, byte rangeY, byte rangeZ, byte sideHit, String data)
|
||||
{
|
||||
|
||||
ActionRequestEvent actionRequestEvent = null;
|
||||
ActionEvent actionEvent = null;
|
||||
|
@ -58,65 +57,82 @@ public class WorldTransmutationHandler {
|
|||
int ySign = 1;
|
||||
int zSign = 1;
|
||||
|
||||
switch (ForgeDirection.getOrientation(sideHit)) {
|
||||
case UP: {
|
||||
switch (ForgeDirection.getOrientation(sideHit))
|
||||
{
|
||||
case UP:
|
||||
{
|
||||
yShift = 1.5D;
|
||||
break;
|
||||
}
|
||||
case DOWN: {
|
||||
case DOWN:
|
||||
{
|
||||
yShift = 0.1D;
|
||||
ySign = -1;
|
||||
break;
|
||||
}
|
||||
case NORTH: {
|
||||
case NORTH:
|
||||
{
|
||||
zShift = 1D;
|
||||
zSign = -1;
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
case SOUTH:
|
||||
{
|
||||
zShift = 1D;
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
case EAST:
|
||||
{
|
||||
xShift = 1D;
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
case WEST:
|
||||
{
|
||||
xShift = 1D;
|
||||
xSign = -1;
|
||||
break;
|
||||
}
|
||||
case UNKNOWN: {
|
||||
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++) {
|
||||
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) {
|
||||
if (actionEvent != null)
|
||||
{
|
||||
actionRequestEvent = new ActionRequestEvent(thePlayer, actionEvent, originX + x, originY + y, originZ + z, sideHit);
|
||||
MinecraftForge.EVENT_BUS.post(actionRequestEvent);
|
||||
|
||||
if (actionRequestEvent.allowEvent != Result.DENY) {
|
||||
if (actionRequestEvent.allowEvent != Result.DENY)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(actionEvent);
|
||||
}
|
||||
|
||||
if (actionEvent.actionResult == ActionResult.SUCCESS) {
|
||||
if (!anySuccess) {
|
||||
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)) {
|
||||
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)));
|
||||
|
@ -127,16 +143,19 @@ public class WorldTransmutationHandler {
|
|||
}
|
||||
}
|
||||
|
||||
if (anySuccess) {
|
||||
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 {
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onWorldTransmutationEvent(WorldTransmutationEvent event) {
|
||||
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);
|
||||
|
@ -144,36 +163,44 @@ public class WorldTransmutationHandler {
|
|||
|
||||
Block currentBlock = Block.blocksList[id];
|
||||
|
||||
if (currentBlock != null) {
|
||||
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()) {
|
||||
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) {
|
||||
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) {
|
||||
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 {
|
||||
else
|
||||
{
|
||||
event.actionResult = ActionResult.FAILURE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ import com.pahimar.ee3.item.OreStack;
|
|||
import com.pahimar.ee3.lib.Reference;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
|
||||
public class AddonEmcValues {
|
||||
public class AddonEmcValues
|
||||
{
|
||||
|
||||
// TODO Clean up these EmcValues and give them some proper breakdowns
|
||||
private static final EmcValue RUBBER_EMC_VALUE = new EmcValue(24);
|
||||
|
@ -31,97 +32,14 @@ public class AddonEmcValues {
|
|||
private static final EmcValue LITHIUM_EMC_VALUE = new EmcValue(256);
|
||||
private static final EmcValue SULFUR_EMC_VALUE = new EmcValue(256);
|
||||
|
||||
public static void init() {
|
||||
public static void init()
|
||||
{
|
||||
|
||||
/**
|
||||
* Pre-Value Assignment Mapping
|
||||
*/
|
||||
|
||||
// Items
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("itemRubber"), RUBBER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crystalCertusQuartz"), CERTUS_QUARTZ_EMC_VALUE));
|
||||
|
||||
// Ores
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("oreCopper"), COPPER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("oreTin"), TIN_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("oreSilver"), SILVER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("oreLead"), LEAD_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("oreUranium"), URANIUM_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("oreApatite"), APATITE_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("oreAluminium"), ALUMINIUM_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("oreCertusQuartz"), CERTUS_QUARTZ_EMC_VALUE));
|
||||
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedCopper"), COPPER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedTin"), TIN_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedIron"), IRON_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedSilver"), SILVER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedLead"), LEAD_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedGold"), GOLD_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedUranium"), URANIUM_EMC_VALUE));
|
||||
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedPurifiedCopper"), COPPER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedPurifiedTin"), TIN_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedPurifiedIron"), IRON_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedPurifiedSilver"), SILVER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedPurifiedLead"), LEAD_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedPurifiedGold"), GOLD_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("crushedPurifiedUranium"), URANIUM_EMC_VALUE));
|
||||
|
||||
// Ingots
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("ingotCopper"), COPPER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("ingotTin"), TIN_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("ingotRefinedIron"), IRON_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("ingotBronze"), BRONZE_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("ingotAluminium"), ALUMINIUM_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("ingotSteel"), STEEL_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("ingotSilver"), SILVER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("ingotLead"), LEAD_EMC_VALUE));
|
||||
|
||||
// Dusts
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustCoal"), COAL_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustClay"), CLAY_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustObsidian"), OBSIDIAN_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustCopper"), COPPER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustTin"), TIN_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustIron"), IRON_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustCertusQuartz"), CERTUS_QUARTZ_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustBronze"), BRONZE_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustSilver"), SILVER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustLapis"), LAPIS_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustLead"), LEAD_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustGold"), GOLD_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustDiamond"), DIAMOND_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustLithium"), LITHIUM_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustSulfur"), SULFUR_EMC_VALUE));
|
||||
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustTinyCopper"), COPPER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustTinyTin"), TIN_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustTinyIron"), IRON_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustTinySilver"), SILVER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustTinyLead"), LEAD_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustTinyGold"), GOLD_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustTinyLithium"), LITHIUM_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("dustTinySulfur"), SULFUR_EMC_VALUE));
|
||||
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateDenseObsidian"), OBSIDIAN_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateDenseCopper"), COPPER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateDenseTin"), TIN_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateDenseIron"), IRON_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateDenseRefinedIron"), IRON_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateDenseBronze"), BRONZE_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateDenseLapis"), LAPIS_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateDenseLead"), LEAD_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateDenseGold"), GOLD_EMC_VALUE));
|
||||
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateObsidian"), OBSIDIAN_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateCopper"), COPPER_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateTin"), TIN_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateIron"), IRON_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateRefinedIron"), IRON_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateBronze"), BRONZE_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateLapis"), LAPIS_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateLead"), LEAD_EMC_VALUE));
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("plateGold"), GOLD_EMC_VALUE));
|
||||
sendPreValueAssignment(new OreStack("dustCopper"), COPPER_EMC_VALUE);
|
||||
sendPreValueAssignment(new OreStack("dustTin"), TIN_EMC_VALUE);
|
||||
|
||||
// Gems
|
||||
sendPreValueAssignment(new StackValueMapping(new OreStack("gemApatite"), APATITE_EMC_VALUE));
|
||||
|
@ -132,15 +50,29 @@ public class AddonEmcValues {
|
|||
*/
|
||||
}
|
||||
|
||||
private static void sendPreValueAssignment(StackValueMapping stackValueMapping) {
|
||||
if (stackValueMapping != null) {
|
||||
private static void sendPreValueAssignment(Object object, EmcValue emcValue)
|
||||
{
|
||||
sendPreValueAssignment(new StackValueMapping(object, emcValue));
|
||||
}
|
||||
|
||||
private static void sendPreValueAssignment(StackValueMapping stackValueMapping)
|
||||
{
|
||||
if (stackValueMapping != null)
|
||||
{
|
||||
FMLInterModComms.sendMessage(Reference.MOD_ID, InterModCommsOperations.EMC_ASSIGN_VALUE_PRE, stackValueMapping.toJson());
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendPostValueAssignment(Object object, EmcValue emcValue)
|
||||
{
|
||||
sendPostValueAssignment(new StackValueMapping(object, emcValue));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void sendPostValueAssignment(StackValueMapping stackValueMapping) {
|
||||
if (stackValueMapping != null) {
|
||||
private static void sendPostValueAssignment(StackValueMapping stackValueMapping)
|
||||
{
|
||||
if (stackValueMapping != null)
|
||||
{
|
||||
FMLInterModComms.sendMessage(Reference.MOD_ID, InterModCommsOperations.EMC_ASSIGN_VALUE_POST, stackValueMapping.toJson());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,16 +2,17 @@ package com.pahimar.ee3.core.handler.addon;
|
|||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* AddonHandler
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class AddonIMCHandler {
|
||||
public class AddonIMCHandler
|
||||
{
|
||||
|
||||
public static void init() {
|
||||
public static void init()
|
||||
{
|
||||
AddonRecipes.init();
|
||||
AddonEmcValues.init();
|
||||
}
|
||||
|
|
|
@ -1,20 +1,36 @@
|
|||
package com.pahimar.ee3.core.handler.addon;
|
||||
|
||||
import com.pahimar.ee3.api.RecipeMapping;
|
||||
import com.pahimar.ee3.imc.InterModCommsOperations;
|
||||
import com.pahimar.ee3.item.OreStack;
|
||||
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/>
|
||||
* AddonVanilla
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class AddonRecipes {
|
||||
public class AddonRecipes
|
||||
{
|
||||
|
||||
public static void init() {
|
||||
public static void init()
|
||||
{
|
||||
|
||||
// TODO Once the API is more solid, add examples here for proper IMC calls
|
||||
// FMLInterModComms.sendMessage(Reference.MOD_ID, InterModComms.ADD_RECIPE, "");
|
||||
sendAddRecipe(new OreStack("dustBronze"), Arrays.asList(new OreStack("dustTin"), new OreStack("dustCopper"), new OreStack("dustCopper"), new OreStack("dustCopper")));
|
||||
sendAddRecipe(new OreStack("dustGold"), Arrays.asList(new OreStack("ingotGold")));
|
||||
}
|
||||
|
||||
private static void sendAddRecipe(Object outputObject, List<?> inputObjects)
|
||||
{
|
||||
FMLInterModComms.sendMessage(Reference.MOD_ID, InterModCommsOperations.RECIPE_ADD, new RecipeMapping(outputObject, inputObjects).toJson());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,84 +1,102 @@
|
|||
package com.pahimar.ee3.core.helper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.pahimar.ee3.emc.EmcRegistry;
|
||||
import com.pahimar.ee3.emc.EmcType;
|
||||
import com.pahimar.ee3.emc.EmcValue;
|
||||
import com.pahimar.ee3.item.WrappedStack;
|
||||
|
||||
public class EmcHelper {
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public static List<WrappedStack> filterStacksByEmc(List<WrappedStack> unfilteredStacks, EmcValue filterValue) {
|
||||
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.hasEmcValue(stack)) {
|
||||
|
||||
|
||||
for (WrappedStack stack : unfilteredStacks)
|
||||
{
|
||||
|
||||
if (EmcRegistry.hasEmcValue(stack))
|
||||
{
|
||||
|
||||
EmcValue value = EmcRegistry.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) {
|
||||
|
||||
for (int i = 0; i < valueSubValues.length; i++)
|
||||
{
|
||||
if (Float.compare(valueSubValues[i], filterValueSubValues[i]) < 0)
|
||||
{
|
||||
satisfiesFilter = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (satisfiesFilter) {
|
||||
|
||||
if (satisfiesFilter)
|
||||
{
|
||||
filteredStacks.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return filteredStacks;
|
||||
}
|
||||
|
||||
public static List<WrappedStack> filterStacksByEmcAndRange(float start, float end, EmcValue filterValue) {
|
||||
|
||||
public static List<WrappedStack> filterStacksByEmcAndRange(float start, float end, EmcValue filterValue)
|
||||
{
|
||||
return filterStacksByEmc(EmcRegistry.getStacksInRange(start, end), filterValue);
|
||||
}
|
||||
|
||||
public static EmcValue computeEmcValueFromList(List<WrappedStack> wrappedStacks) {
|
||||
|
||||
|
||||
public static EmcValue computeEmcValueFromList(List<WrappedStack> wrappedStacks)
|
||||
{
|
||||
|
||||
float[] computedSubValues = new float[EmcType.TYPES.length];
|
||||
|
||||
for (WrappedStack wrappedStack : wrappedStacks) {
|
||||
|
||||
|
||||
for (WrappedStack wrappedStack : wrappedStacks)
|
||||
{
|
||||
|
||||
EmcValue wrappedStackValue = EmcRegistry.getEmcValue(wrappedStack);
|
||||
|
||||
if (wrappedStackValue != null) {
|
||||
for (EmcType emcType : EmcType.TYPES) {
|
||||
|
||||
if (wrappedStackValue != null)
|
||||
{
|
||||
for (EmcType emcType : EmcType.TYPES)
|
||||
{
|
||||
computedSubValues[emcType.ordinal()] += wrappedStackValue.components[emcType.ordinal()] * wrappedStack.getStackSize();
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new EmcValue(computedSubValues);
|
||||
}
|
||||
|
||||
public static EmcValue factorEmcValue(EmcValue emcValue, int factor) {
|
||||
|
||||
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 instanceof EmcValue)) {
|
||||
|
||||
public static EmcValue factorEmcValue(EmcValue emcValue, float factor)
|
||||
{
|
||||
|
||||
if ((Float.compare(factor, 0f) != 0) && (emcValue instanceof EmcValue))
|
||||
{
|
||||
float[] factorSubValues = emcValue.components;
|
||||
|
||||
for (int i = 0; i < factorSubValues.length; i++) {
|
||||
factorSubValues[i] = factorSubValues[i] * 1f / factor;
|
||||
|
||||
for (int i = 0; i < factorSubValues.length; i++)
|
||||
{
|
||||
factorSubValues[i] = factorSubValues[i] * 1f / factor;
|
||||
}
|
||||
|
||||
|
||||
return new EmcValue(factorSubValues);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return emcValue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,68 +1,89 @@
|
|||
package com.pahimar.ee3.core.helper;
|
||||
|
||||
import com.pahimar.ee3.lib.Compare;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.pahimar.ee3.lib.Compare;
|
||||
public class FluidHelper
|
||||
{
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class FluidHelper {
|
||||
|
||||
public static int compare(FluidStack fluidStack1, FluidStack fluidStack2) {
|
||||
public static int compare(FluidStack fluidStack1, FluidStack fluidStack2)
|
||||
{
|
||||
return comparator.compare(fluidStack1, fluidStack2);
|
||||
}
|
||||
|
||||
public static String toString(FluidStack fluidStack) {
|
||||
|
||||
if (fluidStack != null) {
|
||||
|
||||
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) {
|
||||
public static Comparator<FluidStack> comparator = new Comparator<FluidStack>()
|
||||
{
|
||||
|
||||
if (fluidStack1 != null) {
|
||||
if (fluidStack2 != null) {
|
||||
if (fluidStack1.fluidID == fluidStack2.fluidID) {
|
||||
if (fluidStack1.amount == fluidStack2.amount) {
|
||||
if (fluidStack1.tag != null) {
|
||||
if (fluidStack2.tag != null) {
|
||||
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 {
|
||||
else
|
||||
{
|
||||
return Compare.LESSER_THAN;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (fluidStack2.tag != null) {
|
||||
else
|
||||
{
|
||||
if (fluidStack2.tag != null)
|
||||
{
|
||||
return Compare.GREATER_THAN;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return Compare.EQUALS;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return (fluidStack1.amount - fluidStack2.amount);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return (fluidStack1.fluidID - fluidStack2.fluidID);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return Compare.LESSER_THAN;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (fluidStack2 != null) {
|
||||
else
|
||||
{
|
||||
if (fluidStack2 != null)
|
||||
{
|
||||
return Compare.GREATER_THAN;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return Compare.EQUALS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +1,53 @@
|
|||
package com.pahimar.ee3.core.helper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* GeneralHelper
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class GeneralHelper {
|
||||
public class GeneralHelper
|
||||
{
|
||||
|
||||
public static ItemStack convertObjectToItemStack(Object obj) {
|
||||
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) {
|
||||
public static Object[] convertSingleStackToPluralStacks(ItemStack stack)
|
||||
{
|
||||
|
||||
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
|
||||
ItemStack currentStack;
|
||||
|
||||
for (int i = 0; i < stack.stackSize; i++) {
|
||||
for (int i = 0; i < stack.stackSize; i++)
|
||||
{
|
||||
currentStack = new ItemStack(stack.itemID, 1, stack.getItemDamage());
|
||||
list.add(currentStack);
|
||||
}
|
||||
|
@ -44,12 +55,10 @@ public class GeneralHelper {
|
|||
return list.toArray();
|
||||
}
|
||||
|
||||
public static boolean isHostileEntity(EntityLivingBase entity) {
|
||||
public static boolean isHostileEntity(EntityLivingBase entity)
|
||||
{
|
||||
|
||||
if (entity instanceof IMob)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return entity instanceof IMob;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,139 +1,91 @@
|
|||
package com.pahimar.ee3.core.helper;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import com.pahimar.ee3.item.ModItems;
|
||||
import com.pahimar.ee3.lib.Colours;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ItemDropHelper
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ItemHelper {
|
||||
public class ItemHelper
|
||||
{
|
||||
|
||||
private static double rand;
|
||||
|
||||
public static String encodeItemStackAsString(ItemStack itemStack) {
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.append(String.format("%s%s%s", itemStack.itemID, Strings.TOKEN_DELIMITER, itemStack.getItemDamage()));
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
public static ItemStack decodeItemStackFromString(String encodedItemStack) {
|
||||
|
||||
ItemStack decodedItemStack = null;
|
||||
|
||||
final int UNDEFINED = -1;
|
||||
final int ERROR = -2;
|
||||
|
||||
int itemId = UNDEFINED;
|
||||
int meta = UNDEFINED;
|
||||
|
||||
String[] splitString = encodedItemStack.split(Strings.TOKEN_DELIMITER);
|
||||
|
||||
// Grab itemId
|
||||
if (splitString.length >= 1) {
|
||||
|
||||
try {
|
||||
itemId = Integer.parseInt(splitString[0]);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
itemId = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// Grab meta
|
||||
if (splitString.length >= 2) {
|
||||
|
||||
try {
|
||||
meta = Integer.parseInt(splitString[1]);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
meta = ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (meta == UNDEFINED) {
|
||||
meta = OreDictionary.WILDCARD_VALUE;
|
||||
}
|
||||
|
||||
if (itemId != UNDEFINED && itemId != ERROR) {
|
||||
if (meta != ERROR) {
|
||||
decodedItemStack = new ItemStack(itemId, 1, meta);
|
||||
}
|
||||
}
|
||||
|
||||
return decodedItemStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @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) {
|
||||
public static boolean equals(ItemStack first, ItemStack second)
|
||||
{
|
||||
|
||||
return (comparator.compare(first, second) == 0);
|
||||
}
|
||||
|
||||
public static int compare(ItemStack itemStack1, ItemStack itemStack2) {
|
||||
|
||||
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());
|
||||
|
||||
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 "itemStack[null]";
|
||||
}
|
||||
|
||||
public static boolean hasColor(ItemStack itemStack) {
|
||||
public static boolean hasColor(ItemStack itemStack)
|
||||
{
|
||||
|
||||
return !itemStack.hasTagCompound() ? false : !itemStack.getTagCompound().hasKey(Strings.NBT_ITEM_DISPLAY) ? false : itemStack.getTagCompound().getCompoundTag(Strings.NBT_ITEM_DISPLAY).hasKey(Strings.NBT_ITEM_COLOR);
|
||||
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) {
|
||||
public static int getColor(ItemStack itemStack)
|
||||
{
|
||||
|
||||
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
|
||||
|
||||
if (nbtTagCompound == null)
|
||||
{
|
||||
return Integer.parseInt(Colours.PURE_WHITE, 16);
|
||||
else {
|
||||
}
|
||||
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) {
|
||||
public static void setColor(ItemStack itemStack, int color)
|
||||
{
|
||||
|
||||
if (itemStack != null) {
|
||||
if (itemStack != null)
|
||||
{
|
||||
|
||||
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
|
||||
|
||||
if (nbtTagCompound == null) {
|
||||
if (nbtTagCompound == null)
|
||||
{
|
||||
|
||||
nbtTagCompound = new NBTTagCompound();
|
||||
itemStack.setTagCompound(nbtTagCompound);
|
||||
|
@ -141,7 +93,8 @@ public class ItemHelper {
|
|||
|
||||
NBTTagCompound colourTagCompound = nbtTagCompound.getCompoundTag(Strings.NBT_ITEM_DISPLAY);
|
||||
|
||||
if (!nbtTagCompound.hasKey(Strings.NBT_ITEM_DISPLAY)) {
|
||||
if (!nbtTagCompound.hasKey(Strings.NBT_ITEM_DISPLAY))
|
||||
{
|
||||
nbtTagCompound.setCompoundTag(Strings.NBT_ITEM_DISPLAY, colourTagCompound);
|
||||
}
|
||||
|
||||
|
@ -149,64 +102,83 @@ public class ItemHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static void dropMiniumShard(EntityPlayer player, EntityLivingBase entity) {
|
||||
public static void dropMiniumShard(EntityPlayer player, EntityLivingBase entity)
|
||||
{
|
||||
|
||||
if (GeneralHelper.isHostileEntity(entity)) {
|
||||
if (GeneralHelper.isHostileEntity(entity))
|
||||
{
|
||||
rand = Math.random();
|
||||
|
||||
if (rand < 0.15d) {
|
||||
if (rand < 0.15d)
|
||||
{
|
||||
entity.dropItem(ModItems.miniumShard.itemID, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Comparator<ItemStack> comparator = new Comparator<ItemStack>() {
|
||||
public static Comparator<ItemStack> comparator = new Comparator<ItemStack>()
|
||||
{
|
||||
|
||||
public int compare(ItemStack itemStack1, ItemStack itemStack2) {
|
||||
public int compare(ItemStack itemStack1, ItemStack itemStack2)
|
||||
{
|
||||
|
||||
if (itemStack1 != null && itemStack2 != null) {
|
||||
if (itemStack1 != null && itemStack2 != null)
|
||||
{
|
||||
// Sort on itemID
|
||||
if (itemStack1.itemID == itemStack2.itemID) {
|
||||
if (itemStack1.itemID == itemStack2.itemID)
|
||||
{
|
||||
|
||||
// Then sort on meta
|
||||
if (itemStack1.getItemDamage() == itemStack2.getItemDamage()) {
|
||||
if (itemStack1.getItemDamage() == itemStack2.getItemDamage())
|
||||
{
|
||||
|
||||
// Then sort on NBT
|
||||
if (itemStack1.hasTagCompound() && itemStack2.hasTagCompound()) {
|
||||
if (itemStack1.hasTagCompound() && itemStack2.hasTagCompound())
|
||||
{
|
||||
|
||||
// Then sort on stack size
|
||||
if (itemStack1.getTagCompound().equals(itemStack2.getTagCompound())) {
|
||||
if (itemStack1.getTagCompound().equals(itemStack2.getTagCompound()))
|
||||
{
|
||||
return (itemStack1.stackSize - itemStack2.stackSize);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return (itemStack1.getTagCompound().hashCode() - itemStack2.getTagCompound().hashCode());
|
||||
}
|
||||
}
|
||||
else if (!(itemStack1.hasTagCompound()) && itemStack2.hasTagCompound()) {
|
||||
else if (!(itemStack1.hasTagCompound()) && itemStack2.hasTagCompound())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (itemStack1.hasTagCompound() && !(itemStack2.hasTagCompound())) {
|
||||
else if (itemStack1.hasTagCompound() && !(itemStack2.hasTagCompound()))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return (itemStack1.stackSize - itemStack2.stackSize);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return (itemStack1.getItemDamage() - itemStack2.getItemDamage());
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return (itemStack1.itemID - itemStack2.itemID);
|
||||
}
|
||||
}
|
||||
else if (itemStack1 != null && itemStack2 == null) {
|
||||
else if (itemStack1 != null && itemStack2 == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (itemStack1 == null && itemStack2 != null) {
|
||||
else if (itemStack1 == null && itemStack2 != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,57 +5,66 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* NBTHelper
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ItemStackNBTHelper {
|
||||
public class ItemStackNBTHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* Initializes the NBT Tag Compound for the given ItemStack if it is null
|
||||
*
|
||||
* @param itemStack
|
||||
* The ItemStack for which its NBT Tag Compound is being checked
|
||||
* for initialization
|
||||
*
|
||||
* @param itemStack The ItemStack for which its NBT Tag Compound is being checked
|
||||
* for initialization
|
||||
*/
|
||||
private static void initNBTTagCompound(ItemStack itemStack) {
|
||||
private static void initNBTTagCompound(ItemStack itemStack)
|
||||
{
|
||||
|
||||
if (itemStack.stackTagCompound == null) {
|
||||
if (itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasTag(ItemStack itemStack, String keyName) {
|
||||
public static boolean hasTag(ItemStack itemStack, String keyName)
|
||||
{
|
||||
|
||||
if (itemStack.stackTagCompound != null)
|
||||
{
|
||||
return itemStack.stackTagCompound.hasKey(keyName);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void removeTag(ItemStack itemStack, String keyName) {
|
||||
public static void removeTag(ItemStack itemStack, String keyName)
|
||||
{
|
||||
|
||||
if (itemStack.stackTagCompound != null) {
|
||||
if (itemStack.stackTagCompound != null)
|
||||
{
|
||||
itemStack.stackTagCompound.removeTag(keyName);
|
||||
}
|
||||
}
|
||||
|
||||
// String
|
||||
public static String getString(ItemStack itemStack, String keyName) {
|
||||
public static String getString(ItemStack itemStack, String keyName)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName)) {
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName))
|
||||
{
|
||||
setString(itemStack, keyName, "");
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getString(keyName);
|
||||
}
|
||||
|
||||
public static void setString(ItemStack itemStack, String keyName, String keyValue) {
|
||||
public static void setString(ItemStack itemStack, String keyName, String keyValue)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
|
@ -63,18 +72,21 @@ public class ItemStackNBTHelper {
|
|||
}
|
||||
|
||||
// boolean
|
||||
public static boolean getBoolean(ItemStack itemStack, String keyName) {
|
||||
public static boolean getBoolean(ItemStack itemStack, String keyName)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName)) {
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName))
|
||||
{
|
||||
setBoolean(itemStack, keyName, false);
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getBoolean(keyName);
|
||||
}
|
||||
|
||||
public static void setBoolean(ItemStack itemStack, String keyName, boolean keyValue) {
|
||||
public static void setBoolean(ItemStack itemStack, String keyName, boolean keyValue)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
|
@ -82,18 +94,21 @@ public class ItemStackNBTHelper {
|
|||
}
|
||||
|
||||
// byte
|
||||
public static byte getByte(ItemStack itemStack, String keyName) {
|
||||
public static byte getByte(ItemStack itemStack, String keyName)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName)) {
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName))
|
||||
{
|
||||
setByte(itemStack, keyName, (byte) 0);
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getByte(keyName);
|
||||
}
|
||||
|
||||
public static void setByte(ItemStack itemStack, String keyName, byte keyValue) {
|
||||
public static void setByte(ItemStack itemStack, String keyName, byte keyValue)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
|
@ -101,18 +116,21 @@ public class ItemStackNBTHelper {
|
|||
}
|
||||
|
||||
// short
|
||||
public static short getShort(ItemStack itemStack, String keyName) {
|
||||
public static short getShort(ItemStack itemStack, String keyName)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName)) {
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName))
|
||||
{
|
||||
setShort(itemStack, keyName, (short) 0);
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getShort(keyName);
|
||||
}
|
||||
|
||||
public static void setShort(ItemStack itemStack, String keyName, short keyValue) {
|
||||
public static void setShort(ItemStack itemStack, String keyName, short keyValue)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
|
@ -120,18 +138,21 @@ public class ItemStackNBTHelper {
|
|||
}
|
||||
|
||||
// int
|
||||
public static int getInt(ItemStack itemStack, String keyName) {
|
||||
public static int getInt(ItemStack itemStack, String keyName)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName)) {
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName))
|
||||
{
|
||||
setInteger(itemStack, keyName, 0);
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getInteger(keyName);
|
||||
}
|
||||
|
||||
public static void setInteger(ItemStack itemStack, String keyName, int keyValue) {
|
||||
public static void setInteger(ItemStack itemStack, String keyName, int keyValue)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
|
@ -139,18 +160,21 @@ public class ItemStackNBTHelper {
|
|||
}
|
||||
|
||||
// long
|
||||
public static long getLong(ItemStack itemStack, String keyName) {
|
||||
public static long getLong(ItemStack itemStack, String keyName)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName)) {
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName))
|
||||
{
|
||||
setLong(itemStack, keyName, 0);
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getLong(keyName);
|
||||
}
|
||||
|
||||
public static void setLong(ItemStack itemStack, String keyName, long keyValue) {
|
||||
public static void setLong(ItemStack itemStack, String keyName, long keyValue)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
|
@ -158,18 +182,21 @@ public class ItemStackNBTHelper {
|
|||
}
|
||||
|
||||
// float
|
||||
public static float getFloat(ItemStack itemStack, String keyName) {
|
||||
public static float getFloat(ItemStack itemStack, String keyName)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName)) {
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName))
|
||||
{
|
||||
setFloat(itemStack, keyName, 0);
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getFloat(keyName);
|
||||
}
|
||||
|
||||
public static void setFloat(ItemStack itemStack, String keyName, float keyValue) {
|
||||
public static void setFloat(ItemStack itemStack, String keyName, float keyValue)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
|
@ -177,18 +204,21 @@ public class ItemStackNBTHelper {
|
|||
}
|
||||
|
||||
// double
|
||||
public static double getDouble(ItemStack itemStack, String keyName) {
|
||||
public static double getDouble(ItemStack itemStack, String keyName)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName)) {
|
||||
if (!itemStack.stackTagCompound.hasKey(keyName))
|
||||
{
|
||||
setDouble(itemStack, keyName, 0);
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getDouble(keyName);
|
||||
}
|
||||
|
||||
public static void setDouble(ItemStack itemStack, String keyName, double keyValue) {
|
||||
public static void setDouble(ItemStack itemStack, String keyName, double keyValue)
|
||||
{
|
||||
|
||||
initNBTTagCompound(itemStack);
|
||||
|
||||
|
|
|
@ -1,53 +1,59 @@
|
|||
package com.pahimar.ee3.core.helper;
|
||||
|
||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
|
||||
import com.pahimar.ee3.configuration.ConfigurationSettings;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* KeyBindingHelper
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class KeyBindingHelper {
|
||||
public class KeyBindingHelper
|
||||
{
|
||||
|
||||
public static ArrayList<KeyBinding> keyBindingsList;
|
||||
public static ArrayList<Boolean> isRepeatingList;
|
||||
|
||||
public static void addKeyBinding(String name, int value) {
|
||||
public static void addKeyBinding(String name, int value)
|
||||
{
|
||||
|
||||
if (keyBindingsList == null) {
|
||||
if (keyBindingsList == null)
|
||||
{
|
||||
keyBindingsList = new ArrayList<KeyBinding>();
|
||||
}
|
||||
|
||||
keyBindingsList.add(new KeyBinding(name, value));
|
||||
}
|
||||
|
||||
public static void addIsRepeating(boolean value) {
|
||||
public static void addIsRepeating(boolean value)
|
||||
{
|
||||
|
||||
if (isRepeatingList == null) {
|
||||
if (isRepeatingList == null)
|
||||
{
|
||||
isRepeatingList = new ArrayList<Boolean>();
|
||||
}
|
||||
|
||||
isRepeatingList.add(value);
|
||||
}
|
||||
|
||||
public static KeyBinding[] gatherKeyBindings() {
|
||||
public static KeyBinding[] gatherKeyBindings()
|
||||
{
|
||||
|
||||
return keyBindingsList.toArray(new KeyBinding[keyBindingsList.size()]);
|
||||
}
|
||||
|
||||
public static boolean[] gatherIsRepeating() {
|
||||
public static boolean[] gatherIsRepeating()
|
||||
{
|
||||
|
||||
boolean[] isRepeating = new boolean[isRepeatingList.size()];
|
||||
|
||||
for (int x = 0; x < isRepeating.length; x++) {
|
||||
for (int x = 0; x < isRepeating.length; x++)
|
||||
{
|
||||
isRepeating[x] = isRepeatingList.get(x).booleanValue();
|
||||
}
|
||||
|
||||
|
@ -55,11 +61,9 @@ public class KeyBindingHelper {
|
|||
}
|
||||
|
||||
// TODO Still not ideal, won't work for every case. Specifically, make it context sensitive
|
||||
public static boolean isClientSided(String keybinding) {
|
||||
public static boolean isClientSided(String keybinding)
|
||||
{
|
||||
|
||||
if (keybinding.equalsIgnoreCase(ConfigurationSettings.KEYBINDING_TOGGLE))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return keybinding.equalsIgnoreCase(ConfigurationSettings.KEYBINDING_TOGGLE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,71 +1,80 @@
|
|||
package com.pahimar.ee3.core.helper;
|
||||
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* LogHelper
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class LogHelper {
|
||||
public class LogHelper
|
||||
{
|
||||
|
||||
private static Logger eeLogger = Logger.getLogger(Reference.MOD_ID);
|
||||
|
||||
public static void init() {
|
||||
public static void init()
|
||||
{
|
||||
|
||||
eeLogger.setParent(FMLLog.getLogger());
|
||||
}
|
||||
|
||||
public static void log(Level logLevel, Object object) {
|
||||
public static void log(Level logLevel, Object object)
|
||||
{
|
||||
|
||||
eeLogger.log(logLevel, object.toString());
|
||||
}
|
||||
|
||||
public static void severe(Object object) {
|
||||
public static void severe(Object object)
|
||||
{
|
||||
|
||||
log(Level.SEVERE, object.toString());
|
||||
}
|
||||
|
||||
public static void debug(Object object) {
|
||||
public static void debug(Object object)
|
||||
{
|
||||
|
||||
log(Level.WARNING, "[DEBUG] " + object.toString());
|
||||
}
|
||||
|
||||
public static void warning(Object object) {
|
||||
public static void warning(Object object)
|
||||
{
|
||||
|
||||
log(Level.WARNING, object.toString());
|
||||
}
|
||||
|
||||
public static void info(Object object) {
|
||||
public static void info(Object object)
|
||||
{
|
||||
|
||||
log(Level.INFO, object.toString());
|
||||
}
|
||||
|
||||
public static void config(Object object) {
|
||||
public static void config(Object object)
|
||||
{
|
||||
|
||||
log(Level.CONFIG, object.toString());
|
||||
}
|
||||
|
||||
public static void fine(Object object) {
|
||||
public static void fine(Object object)
|
||||
{
|
||||
|
||||
log(Level.FINE, object.toString());
|
||||
}
|
||||
|
||||
public static void finer(Object object) {
|
||||
public static void finer(Object object)
|
||||
{
|
||||
|
||||
log(Level.FINER, object.toString());
|
||||
}
|
||||
|
||||
public static void finest(Object object) {
|
||||
public static void finest(Object object)
|
||||
{
|
||||
|
||||
log(Level.FINEST, object.toString());
|
||||
}
|
||||
|
|
|
@ -4,34 +4,40 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* QualityHelper
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class QualityHelper {
|
||||
public class QualityHelper
|
||||
{
|
||||
|
||||
private static int[][] dustTable = { { 0, 0, 0, 1, 1, 1 }, { 0, 1, 1, 1, 2, 2 }, { 0, 1, 2, 2, 2, 2 }, { 1, 1, 2, 3, 3, 3 }, { 1, 2, 2, 3, 4, 4 }, { 1, 2, 2, 3, 4, 5 }, };
|
||||
private static int[][] dustTable = {{0, 0, 0, 1, 1, 1}, {0, 1, 1, 1, 2, 2}, {0, 1, 2, 2, 2, 2}, {1, 1, 2, 3, 3, 3}, {1, 2, 2, 3, 4, 4}, {1, 2, 2, 3, 4, 5},};
|
||||
|
||||
public static int getItemTierQuality(ItemStack item) {
|
||||
public static int getItemTierQuality(ItemStack item)
|
||||
{
|
||||
|
||||
// TODO Return the 'Tier' level of the given ItemStack
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getFuelTierQuality(ItemStack fuel) {
|
||||
public static int getFuelTierQuality(ItemStack fuel)
|
||||
{
|
||||
|
||||
// TODO Return the 'Tier' level of the given ItemStack
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getDustTierQuality(ItemStack item, ItemStack fuel) {
|
||||
public static int getDustTierQuality(ItemStack item, ItemStack fuel)
|
||||
{
|
||||
|
||||
if (getItemTierQuality(item) >= 0 && getItemTierQuality(item) <= 5) {
|
||||
if (getItemTierQuality(item) >= 0 && getItemTierQuality(item) <= 5)
|
||||
{
|
||||
if (getFuelTierQuality(fuel) >= 0 && getFuelTierQuality(fuel) <= 5)
|
||||
{
|
||||
return dustTable[getItemTierQuality(item)][getFuelTierQuality(fuel)];
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package com.pahimar.ee3.core.helper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.pahimar.ee3.item.EnergyStack;
|
||||
import com.pahimar.ee3.item.OreStack;
|
||||
import com.pahimar.ee3.item.WrappedStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
|
@ -11,44 +10,48 @@ import net.minecraft.item.crafting.ShapelessRecipes;
|
|||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
|
||||
import com.pahimar.ee3.item.WrappedStack;
|
||||
import com.pahimar.ee3.item.EnergyStack;
|
||||
import com.pahimar.ee3.item.OreStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* RecipeHelper
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class RecipeHelper {
|
||||
public class RecipeHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns a list of elements that constitute the input in a crafting recipe
|
||||
*
|
||||
* @param recipe
|
||||
* The IRecipe being examined
|
||||
*
|
||||
* @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
|
||||
* Could be an ItemStack or an Arraylist
|
||||
*/
|
||||
public static ArrayList<WrappedStack> getRecipeInputs(IRecipe recipe) {
|
||||
public static ArrayList<WrappedStack> getRecipeInputs(IRecipe recipe)
|
||||
{
|
||||
|
||||
ArrayList<WrappedStack> recipeInputs = new ArrayList<WrappedStack>();
|
||||
|
||||
if (recipe instanceof ShapedRecipes) {
|
||||
if (recipe instanceof ShapedRecipes)
|
||||
{
|
||||
|
||||
ShapedRecipes shapedRecipe = (ShapedRecipes) recipe;
|
||||
|
||||
for (int i = 0; i < shapedRecipe.recipeItems.length; i++) {
|
||||
for (int i = 0; i < shapedRecipe.recipeItems.length; i++)
|
||||
{
|
||||
|
||||
if (shapedRecipe.recipeItems[i] instanceof ItemStack) {
|
||||
if (shapedRecipe.recipeItems[i] instanceof ItemStack)
|
||||
{
|
||||
|
||||
ItemStack itemStack = shapedRecipe.recipeItems[i].copy();
|
||||
|
||||
if (itemStack.stackSize > 1) {
|
||||
if (itemStack.stackSize > 1)
|
||||
{
|
||||
itemStack.stackSize = 1;
|
||||
}
|
||||
|
||||
|
@ -56,17 +59,21 @@ public class RecipeHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (recipe instanceof ShapelessRecipes) {
|
||||
else if (recipe instanceof ShapelessRecipes)
|
||||
{
|
||||
|
||||
ShapelessRecipes shapelessRecipe = (ShapelessRecipes) recipe;
|
||||
|
||||
for (Object object : shapelessRecipe.recipeItems) {
|
||||
for (Object object : shapelessRecipe.recipeItems)
|
||||
{
|
||||
|
||||
if (object instanceof ItemStack) {
|
||||
if (object instanceof ItemStack)
|
||||
{
|
||||
|
||||
ItemStack itemStack = ((ItemStack) object).copy();
|
||||
|
||||
if (itemStack.stackSize > 1) {
|
||||
if (itemStack.stackSize > 1)
|
||||
{
|
||||
itemStack.stackSize = 1;
|
||||
}
|
||||
|
||||
|
@ -74,27 +81,33 @@ public class RecipeHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (recipe instanceof ShapedOreRecipe) {
|
||||
else if (recipe instanceof ShapedOreRecipe)
|
||||
{
|
||||
|
||||
ShapedOreRecipe shapedOreRecipe = (ShapedOreRecipe) recipe;
|
||||
|
||||
for (int i = 0; i < shapedOreRecipe.getInput().length; i++) {
|
||||
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) {
|
||||
if (shapedOreRecipe.getInput()[i] instanceof ArrayList)
|
||||
{
|
||||
WrappedStack oreStack = new WrappedStack(shapedOreRecipe.getInput()[i]);
|
||||
|
||||
if (oreStack.getWrappedStack() instanceof OreStack) {
|
||||
if (oreStack.getWrappedStack() instanceof OreStack)
|
||||
{
|
||||
recipeInputs.add(new WrappedStack(shapedOreRecipe.getInput()[i]));
|
||||
}
|
||||
}
|
||||
else if (shapedOreRecipe.getInput()[i] instanceof ItemStack) {
|
||||
else if (shapedOreRecipe.getInput()[i] instanceof ItemStack)
|
||||
{
|
||||
|
||||
ItemStack itemStack = ((ItemStack) shapedOreRecipe.getInput()[i]).copy();
|
||||
|
||||
if (itemStack.stackSize > 1) {
|
||||
if (itemStack.stackSize > 1)
|
||||
{
|
||||
itemStack.stackSize = 1;
|
||||
}
|
||||
|
||||
|
@ -102,20 +115,25 @@ public class RecipeHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (recipe instanceof ShapelessOreRecipe) {
|
||||
else if (recipe instanceof ShapelessOreRecipe)
|
||||
{
|
||||
|
||||
ShapelessOreRecipe shapelessOreRecipe = (ShapelessOreRecipe) recipe;
|
||||
|
||||
for (Object object : shapelessOreRecipe.getInput()) {
|
||||
for (Object object : shapelessOreRecipe.getInput())
|
||||
{
|
||||
|
||||
if (object instanceof ArrayList) {
|
||||
if (object instanceof ArrayList)
|
||||
{
|
||||
recipeInputs.add(new WrappedStack(object));
|
||||
}
|
||||
else if (object instanceof ItemStack) {
|
||||
else if (object instanceof ItemStack)
|
||||
{
|
||||
|
||||
ItemStack itemStack = ((ItemStack) object).copy();
|
||||
|
||||
if (itemStack.stackSize > 1) {
|
||||
if (itemStack.stackSize > 1)
|
||||
{
|
||||
itemStack.stackSize = 1;
|
||||
}
|
||||
|
||||
|
@ -130,48 +148,60 @@ public class RecipeHelper {
|
|||
/**
|
||||
* Collates an uncollated, unsorted List of Objects into a sorted, collated
|
||||
* List of WrappedStacks
|
||||
*
|
||||
* @param uncollatedStacks
|
||||
* List of objects for collating
|
||||
*
|
||||
* @param uncollatedStacks List of objects for collating
|
||||
* @return A sorted, collated List of WrappedStacks
|
||||
*/
|
||||
public static List<WrappedStack> collateInputStacks(List<?> uncollatedStacks) {
|
||||
public static List<WrappedStack> collateInputStacks(List<?> uncollatedStacks)
|
||||
{
|
||||
|
||||
List<WrappedStack> collatedStacks = new ArrayList<WrappedStack>();
|
||||
|
||||
WrappedStack stack = null;
|
||||
boolean found = false;
|
||||
|
||||
for (Object object : uncollatedStacks) {
|
||||
for (Object object : uncollatedStacks)
|
||||
{
|
||||
|
||||
found = false;
|
||||
|
||||
if (WrappedStack.canBeWrapped(object)) {
|
||||
if (WrappedStack.canBeWrapped(object))
|
||||
{
|
||||
|
||||
stack = new WrappedStack(object);
|
||||
|
||||
if (collatedStacks.isEmpty()) {
|
||||
if (collatedStacks.isEmpty())
|
||||
{
|
||||
collatedStacks.add(stack);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
|
||||
for (int i = 0; i < collatedStacks.size(); i++) {
|
||||
if (collatedStacks.get(i).getWrappedStack() != null) {
|
||||
if (stack.getWrappedStack() instanceof ItemStack && collatedStacks.get(i).getWrappedStack() instanceof ItemStack) {
|
||||
if (ItemHelper.equals((ItemStack) stack.getWrappedStack(), (ItemStack) collatedStacks.get(i).getWrappedStack())) {
|
||||
for (int i = 0; i < collatedStacks.size(); i++)
|
||||
{
|
||||
if (collatedStacks.get(i).getWrappedStack() != null)
|
||||
{
|
||||
if (stack.getWrappedStack() instanceof ItemStack && collatedStacks.get(i).getWrappedStack() instanceof ItemStack)
|
||||
{
|
||||
if (ItemHelper.equals((ItemStack) stack.getWrappedStack(), (ItemStack) collatedStacks.get(i).getWrappedStack()))
|
||||
{
|
||||
collatedStacks.get(i).setStackSize(collatedStacks.get(i).getStackSize() + stack.getStackSize());
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
else if (stack.getWrappedStack() instanceof OreStack && collatedStacks.get(i).getWrappedStack() instanceof OreStack) {
|
||||
if (OreStack.compareOreNames((OreStack) stack.getWrappedStack(), (OreStack) collatedStacks.get(i).getWrappedStack())) {
|
||||
else if (stack.getWrappedStack() instanceof OreStack && collatedStacks.get(i).getWrappedStack() instanceof OreStack)
|
||||
{
|
||||
if (OreStack.compareOreNames((OreStack) stack.getWrappedStack(), (OreStack) collatedStacks.get(i).getWrappedStack()))
|
||||
{
|
||||
collatedStacks.get(i).setStackSize(collatedStacks.get(i).getStackSize() + stack.getStackSize());
|
||||
found = true;
|
||||
}
|
||||
|
||||
}
|
||||
else if (stack.getWrappedStack() instanceof EnergyStack && collatedStacks.get(i).getWrappedStack() instanceof EnergyStack) {
|
||||
if (EnergyStack.compareEnergyNames((EnergyStack) stack.getWrappedStack(), (EnergyStack) collatedStacks.get(i).getWrappedStack())) {
|
||||
else if (stack.getWrappedStack() instanceof EnergyStack && collatedStacks.get(i).getWrappedStack() instanceof EnergyStack)
|
||||
{
|
||||
if (EnergyStack.compareEnergyNames((EnergyStack) stack.getWrappedStack(), (EnergyStack) collatedStacks.get(i).getWrappedStack()))
|
||||
{
|
||||
collatedStacks.get(i).setStackSize(collatedStacks.get(i).getStackSize() + stack.getStackSize());
|
||||
found = true;
|
||||
}
|
||||
|
@ -179,7 +209,8 @@ public class RecipeHelper {
|
|||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
if (!found)
|
||||
{
|
||||
collatedStacks.add(stack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
package com.pahimar.ee3.core.helper;
|
||||
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
public class ResourceLocationHelper
|
||||
{
|
||||
|
||||
public class ResourceLocationHelper {
|
||||
|
||||
public static ResourceLocation getResourceLocation(String modId, String path) {
|
||||
public static ResourceLocation getResourceLocation(String modId, String path)
|
||||
{
|
||||
|
||||
return new ResourceLocation(modId, path);
|
||||
}
|
||||
|
||||
public static ResourceLocation getResourceLocation(String path) {
|
||||
public static ResourceLocation getResourceLocation(String path)
|
||||
{
|
||||
|
||||
return getResourceLocation(Reference.MOD_ID.toLowerCase(), path);
|
||||
}
|
||||
|
|
|
@ -1,33 +1,34 @@
|
|||
package com.pahimar.ee3.core.helper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.pahimar.ee3.core.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 com.pahimar.ee3.core.handler.EquivalencyHandler;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* TransmutationHelper
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class TransmutationHelper {
|
||||
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) {
|
||||
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) {
|
||||
if (Block.blocksList[targetID] != null)
|
||||
{
|
||||
world.setBlock(x, y, z, targetID, targetMeta, 2);
|
||||
return true;
|
||||
}
|
||||
|
@ -35,32 +36,42 @@ public class TransmutationHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static String formatTargetBlockInfo(ItemStack targetBlock) {
|
||||
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) {
|
||||
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) {
|
||||
if (currentBlock != null)
|
||||
{
|
||||
meta = currentBlock.damageDropped(meta);
|
||||
|
||||
currentBlockStack = new ItemStack(id, 1, meta);
|
||||
|
||||
if (previousBlockStack == null) {
|
||||
if (previousBlockStack == null)
|
||||
{
|
||||
previousBlockStack = currentBlockStack;
|
||||
targetBlockStack = getNextBlock(currentBlockStack.itemID, currentBlockStack.getItemDamage());
|
||||
}
|
||||
else {
|
||||
if (!EquivalencyHandler.instance().areEquivalent(TransmutationHelper.previousBlockStack, currentBlockStack)) {
|
||||
else
|
||||
{
|
||||
if (!EquivalencyHandler.instance().areEquivalent(TransmutationHelper.previousBlockStack, currentBlockStack))
|
||||
{
|
||||
previousBlockStack = currentBlockStack;
|
||||
targetBlockStack = getNextBlock(currentBlockStack.itemID, currentBlockStack.getItemDamage());
|
||||
}
|
||||
|
@ -68,24 +79,29 @@ public class TransmutationHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static ItemStack getNextBlock(int id, int meta) {
|
||||
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) {
|
||||
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) {
|
||||
if (list != null)
|
||||
{
|
||||
nextStack = EquivalencyHandler.instance().getNextInList(id, meta);
|
||||
nextStack.stackSize = 1;
|
||||
|
||||
|
@ -96,12 +112,19 @@ public class TransmutationHelper {
|
|||
* the recursion.
|
||||
*/
|
||||
if (nextStack.itemID == origId && nextStack.getItemDamage() == origMeta)
|
||||
{
|
||||
return nextStack;
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nextStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
return nextStack;
|
||||
}
|
||||
else
|
||||
{
|
||||
return getNextBlock(nextStack.itemID, nextStack.getItemDamage(), origId, origMeta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,33 +132,45 @@ public class TransmutationHelper {
|
|||
return nextStack;
|
||||
}
|
||||
|
||||
public static ItemStack getPreviousBlock(int itemID, int meta) {
|
||||
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) {
|
||||
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) {
|
||||
if (list != null)
|
||||
{
|
||||
prevStack = EquivalencyHandler.instance().getPrevInList(id, meta);
|
||||
prevStack.stackSize = 1;
|
||||
|
||||
if (prevStack.itemID == origId && prevStack.getItemDamage() == origMeta)
|
||||
{
|
||||
return prevStack;
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prevStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
return prevStack;
|
||||
}
|
||||
else
|
||||
{
|
||||
return getPreviousBlock(prevStack.itemID, prevStack.getItemDamage(), origId, origMeta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +1,28 @@
|
|||
package com.pahimar.ee3.core.helper;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
|
||||
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 net.minecraftforge.common.Configuration;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* VersionHelper
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class VersionHelper implements Runnable {
|
||||
public class VersionHelper implements Runnable
|
||||
{
|
||||
|
||||
private static VersionHelper instance = new VersionHelper();
|
||||
|
||||
|
@ -46,155 +44,198 @@ public class VersionHelper implements Runnable {
|
|||
public static String remoteVersion = null;
|
||||
public static String remoteUpdateLocation = null;
|
||||
|
||||
/***
|
||||
/**
|
||||
* 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() {
|
||||
public static void checkVersion()
|
||||
{
|
||||
|
||||
InputStream remoteVersionRepoStream = null;
|
||||
result = UNINITIALIZED;
|
||||
|
||||
try {
|
||||
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) {
|
||||
if (remoteVersionProperty != null)
|
||||
{
|
||||
String[] remoteVersionTokens = remoteVersionProperty.split("\\|");
|
||||
|
||||
if (remoteVersionTokens.length >= 2) {
|
||||
if (remoteVersionTokens.length >= 2)
|
||||
{
|
||||
remoteVersion = remoteVersionTokens[0];
|
||||
remoteUpdateLocation = remoteVersionTokens[1];
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
result = ERROR;
|
||||
}
|
||||
|
||||
if (remoteVersion != null) {
|
||||
if (!ConfigurationSettings.LAST_DISCOVERED_VERSION.equalsIgnoreCase(remoteVersion)) {
|
||||
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())) {
|
||||
if (remoteVersion.equalsIgnoreCase(getVersionForCheck()))
|
||||
{
|
||||
result = CURRENT;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
result = OUTDATED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
result = MC_VERSION_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception e)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
finally {
|
||||
if (result == UNINITIALIZED) {
|
||||
finally
|
||||
{
|
||||
if (result == UNINITIALIZED)
|
||||
{
|
||||
result = ERROR;
|
||||
}
|
||||
|
||||
try {
|
||||
if (remoteVersionRepoStream != null) {
|
||||
try
|
||||
{
|
||||
if (remoteVersionRepoStream != null)
|
||||
{
|
||||
remoteVersionRepoStream.close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
catch (Exception ex)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getVersionForCheck() {
|
||||
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() {
|
||||
public static void logResult()
|
||||
{
|
||||
|
||||
if (result == CURRENT || result == OUTDATED) {
|
||||
if (result == CURRENT || result == OUTDATED)
|
||||
{
|
||||
LogHelper.info(getResultMessage());
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
LogHelper.warning(getResultMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static String getResultMessage() {
|
||||
public static String getResultMessage()
|
||||
{
|
||||
|
||||
if (result == UNINITIALIZED) {
|
||||
if (result == UNINITIALIZED)
|
||||
{
|
||||
return StatCollector.translateToLocal(Strings.UNINITIALIZED_MESSAGE);
|
||||
}
|
||||
else if (result == CURRENT) {
|
||||
else if (result == CURRENT)
|
||||
{
|
||||
return StatCollector.translateToLocalFormatted(Strings.CURRENT_MESSAGE, Reference.MOD_NAME, Loader.instance().getMCVersionString());
|
||||
}
|
||||
else if (result == OUTDATED && remoteVersion != null && remoteUpdateLocation != null) {
|
||||
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) {
|
||||
else if (result == ERROR)
|
||||
{
|
||||
return StatCollector.translateToLocal(Strings.GENERAL_ERROR_MESSAGE);
|
||||
}
|
||||
else if (result == FINAL_ERROR) {
|
||||
else if (result == FINAL_ERROR)
|
||||
{
|
||||
return StatCollector.translateToLocal(Strings.FINAL_ERROR_MESSAGE);
|
||||
}
|
||||
else if (result == MC_VERSION_NOT_FOUND) {
|
||||
else if (result == MC_VERSION_NOT_FOUND)
|
||||
{
|
||||
return StatCollector.translateToLocalFormatted(Strings.MC_VERSION_NOT_FOUND, Reference.MOD_NAME, Loader.instance().getMCVersionString());
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
result = ERROR;
|
||||
return StatCollector.translateToLocal(Strings.GENERAL_ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getResultMessageForClient() {
|
||||
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() {
|
||||
public static byte getResult()
|
||||
{
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
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)) {
|
||||
try
|
||||
{
|
||||
while (count < Reference.VERSION_CHECK_ATTEMPTS - 1 && (result == UNINITIALIZED || result == ERROR))
|
||||
{
|
||||
|
||||
checkVersion();
|
||||
count++;
|
||||
logResult();
|
||||
|
||||
if (result == UNINITIALIZED || result == ERROR) {
|
||||
if (result == UNINITIALIZED || result == ERROR)
|
||||
{
|
||||
Thread.sleep(10000);
|
||||
}
|
||||
}
|
||||
|
||||
if (result == ERROR) {
|
||||
if (result == ERROR)
|
||||
{
|
||||
result = FINAL_ERROR;
|
||||
logResult();
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void execute() {
|
||||
public static void execute()
|
||||
{
|
||||
|
||||
new Thread(instance).start();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
package com.pahimar.ee3.core.proxy;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
import com.pahimar.ee3.client.audio.SoundHandler;
|
||||
import com.pahimar.ee3.client.renderer.item.ItemAlchemicalChestRenderer;
|
||||
|
@ -31,12 +23,7 @@ import com.pahimar.ee3.lib.Colours;
|
|||
import com.pahimar.ee3.lib.RenderIds;
|
||||
import com.pahimar.ee3.network.PacketTypeHandler;
|
||||
import com.pahimar.ee3.network.packet.PacketRequestEvent;
|
||||
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
|
||||
import com.pahimar.ee3.tileentity.TileAludel;
|
||||
import com.pahimar.ee3.tileentity.TileCalcinator;
|
||||
import com.pahimar.ee3.tileentity.TileEE;
|
||||
import com.pahimar.ee3.tileentity.TileGlassBell;
|
||||
|
||||
import com.pahimar.ee3.tileentity.*;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.KeyBindingRegistry;
|
||||
|
@ -44,51 +31,64 @@ import cpw.mods.fml.client.registry.RenderingRegistry;
|
|||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.registry.TickRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ClientProxy
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ClientProxy extends CommonProxy {
|
||||
public class ClientProxy extends CommonProxy
|
||||
{
|
||||
|
||||
@Override
|
||||
public void registerKeyBindingHandler() {
|
||||
public void registerKeyBindingHandler()
|
||||
{
|
||||
|
||||
KeyBindingRegistry.registerKeyBinding(new KeyBindingHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRenderTickHandler() {
|
||||
public void registerRenderTickHandler()
|
||||
{
|
||||
|
||||
TickRegistry.registerTickHandler(new TransmutationTargetOverlayHandler(), Side.CLIENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerDrawBlockHighlightHandler() {
|
||||
public void registerDrawBlockHighlightHandler()
|
||||
{
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new DrawBlockHighlightHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeyBinding(String name, int value) {
|
||||
public void setKeyBinding(String name, int value)
|
||||
{
|
||||
|
||||
KeyBindingHelper.addKeyBinding(name, value);
|
||||
KeyBindingHelper.addIsRepeating(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSoundHandler() {
|
||||
public void registerSoundHandler()
|
||||
{
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new SoundHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initRenderingAndTextures() {
|
||||
public void initRenderingAndTextures()
|
||||
{
|
||||
|
||||
RenderIds.calcinatorRender = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderIds.aludelRender = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
@ -102,7 +102,8 @@ public class ClientProxy extends CommonProxy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void registerTileEntities() {
|
||||
public void registerTileEntities()
|
||||
{
|
||||
|
||||
super.registerTileEntities();
|
||||
|
||||
|
@ -113,18 +114,22 @@ public class ClientProxy extends CommonProxy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendRequestEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data) {
|
||||
public void sendRequestEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data)
|
||||
{
|
||||
|
||||
PacketDispatcher.sendPacketToServer(PacketTypeHandler.populatePacket(new PacketRequestEvent(eventType, originX, originY, originZ, sideHit, rangeX, rangeY, rangeZ, data)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleTileEntityPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName) {
|
||||
public void handleTileEntityPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName)
|
||||
{
|
||||
|
||||
TileEntity tileEntity = FMLClientHandler.instance().getClient().theWorld.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null) {
|
||||
if (tileEntity instanceof TileEE) {
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity instanceof TileEE)
|
||||
{
|
||||
((TileEE) tileEntity).setOrientation(orientation);
|
||||
((TileEE) tileEntity).setState(state);
|
||||
((TileEE) tileEntity).setCustomName(customName);
|
||||
|
@ -133,28 +138,34 @@ public class ClientProxy extends CommonProxy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color) {
|
||||
public void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color)
|
||||
{
|
||||
|
||||
World world = FMLClientHandler.instance().getClient().theWorld;
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
this.handleTileEntityPacket(x, y, z, orientation, state, customName);
|
||||
|
||||
if (tileEntity != null) {
|
||||
if (tileEntity instanceof TileGlassBell) {
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity instanceof TileGlassBell)
|
||||
{
|
||||
|
||||
ItemStack itemStack = new ItemStack(itemID, stackSize, metaData);
|
||||
if (color != Integer.parseInt(Colours.PURE_WHITE, 16)) {
|
||||
if (color != Integer.parseInt(Colours.PURE_WHITE, 16))
|
||||
{
|
||||
ItemHelper.setColor(itemStack, color);
|
||||
}
|
||||
|
||||
((TileGlassBell) tileEntity).setInventorySlotContents(TileGlassBell.DISPLAY_SLOT_INVENTORY_INDEX, itemStack);
|
||||
world.updateAllLightTypes(x, y, z);
|
||||
}
|
||||
else if (tileEntity instanceof TileAludel) {
|
||||
else if (tileEntity instanceof TileAludel)
|
||||
{
|
||||
|
||||
ItemStack itemStack = new ItemStack(itemID, stackSize, metaData);
|
||||
if (color != Integer.parseInt(Colours.PURE_WHITE, 16)) {
|
||||
if (color != Integer.parseInt(Colours.PURE_WHITE, 16))
|
||||
{
|
||||
ItemHelper.setColor(itemStack, color);
|
||||
}
|
||||
|
||||
|
@ -165,47 +176,59 @@ public class ClientProxy extends CommonProxy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit) {
|
||||
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit)
|
||||
{
|
||||
|
||||
if (TransmutationHelper.targetBlockStack != null) {
|
||||
if (itemStack != null) {
|
||||
if (TransmutationHelper.targetBlockStack != null)
|
||||
{
|
||||
if (itemStack != null)
|
||||
{
|
||||
int pnX = 1;
|
||||
int pnY = 1;
|
||||
int pnZ = 1;
|
||||
if (itemStack.getItem() instanceof IChargeable) {
|
||||
if (itemStack.getItem() instanceof IChargeable)
|
||||
{
|
||||
int charge = ((IChargeable) itemStack.getItem()).getCharge(itemStack) * 2;
|
||||
switch (ForgeDirection.getOrientation(sideHit)) {
|
||||
case UP: {
|
||||
switch (ForgeDirection.getOrientation(sideHit))
|
||||
{
|
||||
case UP:
|
||||
{
|
||||
pnX = 1 + charge;
|
||||
pnZ = 1 + charge;
|
||||
break;
|
||||
}
|
||||
case DOWN: {
|
||||
case DOWN:
|
||||
{
|
||||
pnX = 1 + charge;
|
||||
pnZ = 1 + charge;
|
||||
break;
|
||||
}
|
||||
case NORTH: {
|
||||
case NORTH:
|
||||
{
|
||||
pnX = 1 + charge;
|
||||
pnY = 1 + charge;
|
||||
break;
|
||||
}
|
||||
case SOUTH: {
|
||||
case SOUTH:
|
||||
{
|
||||
pnX = 1 + charge;
|
||||
pnY = 1 + charge;
|
||||
break;
|
||||
}
|
||||
case EAST: {
|
||||
case EAST:
|
||||
{
|
||||
pnY = 1 + charge;
|
||||
pnZ = 1 + charge;
|
||||
break;
|
||||
}
|
||||
case WEST: {
|
||||
case WEST:
|
||||
{
|
||||
pnY = 1 + charge;
|
||||
pnZ = 1 + charge;
|
||||
break;
|
||||
}
|
||||
case UNKNOWN: {
|
||||
case UNKNOWN:
|
||||
{
|
||||
pnX = 0;
|
||||
pnY = 0;
|
||||
pnZ = 0;
|
||||
|
|
|
@ -1,70 +1,63 @@
|
|||
package com.pahimar.ee3.core.proxy;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import com.pahimar.ee3.client.gui.inventory.GuiAlchemicalBag;
|
||||
import com.pahimar.ee3.client.gui.inventory.GuiAlchemicalChest;
|
||||
import com.pahimar.ee3.client.gui.inventory.GuiAludel;
|
||||
import com.pahimar.ee3.client.gui.inventory.GuiCalcinator;
|
||||
import com.pahimar.ee3.client.gui.inventory.GuiGlassBell;
|
||||
import com.pahimar.ee3.client.gui.inventory.GuiPortableCrafting;
|
||||
import com.pahimar.ee3.client.gui.inventory.GuiPortableTransmutation;
|
||||
import com.pahimar.ee3.inventory.ContainerAlchemicalBag;
|
||||
import com.pahimar.ee3.inventory.ContainerAlchemicalChest;
|
||||
import com.pahimar.ee3.inventory.ContainerAludel;
|
||||
import com.pahimar.ee3.inventory.ContainerCalcinator;
|
||||
import com.pahimar.ee3.inventory.ContainerGlassBell;
|
||||
import com.pahimar.ee3.inventory.ContainerPortableCrafting;
|
||||
import com.pahimar.ee3.inventory.ContainerPortableTransmutation;
|
||||
import com.pahimar.ee3.client.gui.inventory.*;
|
||||
import com.pahimar.ee3.inventory.*;
|
||||
import com.pahimar.ee3.lib.GuiIds;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
|
||||
import com.pahimar.ee3.tileentity.TileAludel;
|
||||
import com.pahimar.ee3.tileentity.TileCalcinator;
|
||||
import com.pahimar.ee3.tileentity.TileGlassBell;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* CommonProxy
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class CommonProxy implements IGuiHandler {
|
||||
public class CommonProxy implements IGuiHandler
|
||||
{
|
||||
|
||||
public void registerKeyBindingHandler() {
|
||||
public void registerKeyBindingHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void registerRenderTickHandler() {
|
||||
public void registerRenderTickHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void registerDrawBlockHighlightHandler() {
|
||||
public void registerDrawBlockHighlightHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setKeyBinding(String name, int value) {
|
||||
public void setKeyBinding(String name, int value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void registerSoundHandler() {
|
||||
public void registerSoundHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void initRenderingAndTextures() {
|
||||
public void initRenderingAndTextures()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void registerTileEntities() {
|
||||
public void registerTileEntities()
|
||||
{
|
||||
|
||||
GameRegistry.registerTileEntity(TileCalcinator.class, Strings.TE_CALCINATOR_NAME);
|
||||
GameRegistry.registerTileEntity(TileAludel.class, Strings.TE_ALUDEL_NAME);
|
||||
|
@ -72,45 +65,60 @@ public class CommonProxy implements IGuiHandler {
|
|||
GameRegistry.registerTileEntity(TileGlassBell.class, Strings.TE_GLASS_BELL_NAME);
|
||||
}
|
||||
|
||||
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit) {
|
||||
public void transmuteBlock(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int sideHit)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void sendRequestEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data) {
|
||||
public void sendRequestEventPacket(byte eventType, int originX, int originY, int originZ, byte sideHit, byte rangeX, byte rangeY, byte rangeZ, String data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void handleTileEntityPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName) {
|
||||
public void handleTileEntityPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color) {
|
||||
public void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
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.PORTABLE_TRANSMUTATION)
|
||||
{
|
||||
return new ContainerPortableTransmutation();
|
||||
else if (ID == GuiIds.CALCINATOR) {
|
||||
}
|
||||
else if (ID == GuiIds.CALCINATOR)
|
||||
{
|
||||
TileCalcinator tileCalcinator = (TileCalcinator) world.getBlockTileEntity(x, y, z);
|
||||
return new ContainerCalcinator(player.inventory, tileCalcinator);
|
||||
}
|
||||
else if (ID == GuiIds.ALCHEMICAL_CHEST) {
|
||||
else if (ID == GuiIds.ALCHEMICAL_CHEST)
|
||||
{
|
||||
TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) world.getBlockTileEntity(x, y, z);
|
||||
return new ContainerAlchemicalChest(player.inventory, tileAlchemicalChest);
|
||||
}
|
||||
else if (ID == GuiIds.ALCHEMICAL_BAG)
|
||||
// TODO Alchemical Bag inventory work is incomplete
|
||||
// TODO Alchemical Bag inventory work is incomplete
|
||||
{
|
||||
return new ContainerAlchemicalBag(player.inventory);
|
||||
else if (ID == GuiIds.ALUDEL) {
|
||||
}
|
||||
else if (ID == GuiIds.ALUDEL)
|
||||
{
|
||||
TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y, z);
|
||||
return new ContainerAludel(player.inventory, tileAludel);
|
||||
}
|
||||
else if (ID == GuiIds.GLASS_BELL) {
|
||||
else if (ID == GuiIds.GLASS_BELL)
|
||||
{
|
||||
TileGlassBell tileGlassBell = (TileGlassBell) world.getBlockTileEntity(x, y, z);
|
||||
return new ContainerGlassBell(player.inventory, tileGlassBell);
|
||||
}
|
||||
|
@ -119,28 +127,39 @@ public class CommonProxy implements IGuiHandler {
|
|||
}
|
||||
|
||||
@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.PORTABLE_TRANSMUTATION)
|
||||
{
|
||||
return new GuiPortableTransmutation(null);
|
||||
else if (ID == GuiIds.CALCINATOR) {
|
||||
}
|
||||
else if (ID == GuiIds.CALCINATOR)
|
||||
{
|
||||
TileCalcinator tileCalcinator = (TileCalcinator) world.getBlockTileEntity(x, y, z);
|
||||
return new GuiCalcinator(player.inventory, tileCalcinator);
|
||||
}
|
||||
else if (ID == GuiIds.ALCHEMICAL_CHEST) {
|
||||
else if (ID == GuiIds.ALCHEMICAL_CHEST)
|
||||
{
|
||||
TileAlchemicalChest tileAlchemicalChest = (TileAlchemicalChest) world.getBlockTileEntity(x, y, z);
|
||||
return new GuiAlchemicalChest(player.inventory, tileAlchemicalChest);
|
||||
}
|
||||
else if (ID == GuiIds.ALCHEMICAL_BAG)
|
||||
// TODO Alchemical Bag inventory work is incomplete
|
||||
// TODO Alchemical Bag inventory work is incomplete
|
||||
{
|
||||
return new GuiAlchemicalBag(player.inventory);
|
||||
else if (ID == GuiIds.ALUDEL) {
|
||||
}
|
||||
else if (ID == GuiIds.ALUDEL)
|
||||
{
|
||||
TileAludel tileAludel = (TileAludel) world.getBlockTileEntity(x, y, z);
|
||||
return new GuiAludel(player.inventory, tileAludel);
|
||||
}
|
||||
else if (ID == GuiIds.GLASS_BELL) {
|
||||
else if (ID == GuiIds.GLASS_BELL)
|
||||
{
|
||||
TileGlassBell tileGlassBell = (TileGlassBell) world.getBlockTileEntity(x, y, z);
|
||||
return new GuiGlassBell(player.inventory, tileGlassBell);
|
||||
}
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
package com.pahimar.ee3.creativetab;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
||||
import com.pahimar.ee3.lib.ItemIds;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* CreativeTabEE3
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class CreativeTabEE3 extends CreativeTabs {
|
||||
public class CreativeTabEE3 extends CreativeTabs
|
||||
{
|
||||
|
||||
public CreativeTabEE3(int tabID, String tabLabel) {
|
||||
public CreativeTabEE3(int tabID, String tabLabel)
|
||||
{
|
||||
|
||||
super(tabID, tabLabel);
|
||||
}
|
||||
|
@ -28,7 +27,8 @@ public class CreativeTabEE3 extends CreativeTabs {
|
|||
/**
|
||||
* the itemID for the item to be displayed on the tab
|
||||
*/
|
||||
public int getTabIconItemIndex() {
|
||||
public int getTabIconItemIndex()
|
||||
{
|
||||
|
||||
return ItemIds.MINIUM_SHARD;
|
||||
}
|
||||
|
|
|
@ -1,31 +1,38 @@
|
|||
package com.pahimar.ee3.emc;
|
||||
|
||||
public class EmcComponent implements Comparable<EmcComponent> {
|
||||
|
||||
public class EmcComponent implements Comparable<EmcComponent>
|
||||
{
|
||||
|
||||
public final EmcType type;
|
||||
public final int weight;
|
||||
|
||||
public EmcComponent(EmcType type, int weight) {
|
||||
public EmcComponent(EmcType type, int weight)
|
||||
{
|
||||
|
||||
this.type = type;
|
||||
|
||||
if (weight > 0) {
|
||||
|
||||
if (weight > 0)
|
||||
{
|
||||
this.weight = weight;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
this.weight = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public EmcComponent(EmcType type) {
|
||||
|
||||
|
||||
public EmcComponent(EmcType type)
|
||||
{
|
||||
|
||||
this(type, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
public boolean equals(Object object)
|
||||
{
|
||||
|
||||
if (!(object instanceof EmcComponent)) {
|
||||
if (!(object instanceof EmcComponent))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -35,27 +42,28 @@ public class EmcComponent implements Comparable<EmcComponent> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.append(String.format("<EMC Type: %s, Weight: %s>", type, weight));
|
||||
|
||||
return stringBuilder.toString();
|
||||
public String toString()
|
||||
{
|
||||
return String.format("<EMC Type: %s, Weight: %s>", type, weight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(EmcComponent emcComponent) {
|
||||
public int compareTo(EmcComponent emcComponent)
|
||||
{
|
||||
|
||||
if (emcComponent != null) {
|
||||
if (this.type == emcComponent.type) {
|
||||
if (emcComponent != null)
|
||||
{
|
||||
if (this.type == emcComponent.type)
|
||||
{
|
||||
return (this.weight - emcComponent.weight);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return this.type.compareTo(emcComponent.type);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,5 @@
|
|||
package com.pahimar.ee3.emc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.pahimar.ee3.core.helper.EmcHelper;
|
||||
import com.pahimar.ee3.core.helper.LogHelper;
|
||||
|
@ -19,25 +7,33 @@ import com.pahimar.ee3.core.helper.RecipeHelper;
|
|||
import com.pahimar.ee3.item.OreStack;
|
||||
import com.pahimar.ee3.item.WrappedStack;
|
||||
import com.pahimar.ee3.item.crafting.RecipeRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class EmcRegistry {
|
||||
import java.util.*;
|
||||
|
||||
public class EmcRegistry
|
||||
{
|
||||
|
||||
private int MAX_ATTEMPTED_ASSIGNMENT_PASSES = 16;
|
||||
|
||||
|
||||
private static EmcRegistry emcRegistry = null;
|
||||
|
||||
private ImmutableSortedMap<WrappedStack, EmcValue> stackMappings;
|
||||
private ImmutableSortedMap<EmcValue, List<WrappedStack>> valueMappings;
|
||||
|
||||
public static void lazyInit() {
|
||||
public static void lazyInit()
|
||||
{
|
||||
|
||||
if (emcRegistry == null) {
|
||||
if (emcRegistry == null)
|
||||
{
|
||||
emcRegistry = new EmcRegistry();
|
||||
emcRegistry.init();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
private void init()
|
||||
{
|
||||
|
||||
HashMap<WrappedStack, EmcValue> stackValueMap = new HashMap<WrappedStack, EmcValue>();
|
||||
|
||||
|
@ -45,12 +41,16 @@ public class EmcRegistry {
|
|||
* Default values
|
||||
*/
|
||||
Map<WrappedStack, EmcValue> defaultValuesMap = EmcValuesDefault.getDefaultValueMap();
|
||||
for (WrappedStack wrappedStack : defaultValuesMap.keySet()) {
|
||||
if (wrappedStack != null) {
|
||||
if (!stackValueMap.keySet().contains(wrappedStack)) {
|
||||
for (WrappedStack wrappedStack : defaultValuesMap.keySet())
|
||||
{
|
||||
if (wrappedStack != null)
|
||||
{
|
||||
if (!stackValueMap.keySet().contains(wrappedStack))
|
||||
{
|
||||
EmcValue emcValue = defaultValuesMap.get(wrappedStack);
|
||||
|
||||
if (emcValue != null && emcValue.getValue() > 0f) {
|
||||
|
||||
if (emcValue != null && emcValue.getValue() > 0f)
|
||||
{
|
||||
stackValueMap.put(wrappedStack, emcValue);
|
||||
}
|
||||
}
|
||||
|
@ -61,12 +61,16 @@ public class EmcRegistry {
|
|||
* IMC Pre-assigned values
|
||||
*/
|
||||
Map<WrappedStack, EmcValue> preAssignedValuesMap = EmcValuesIMC.getPreAssignedValues();
|
||||
for (WrappedStack wrappedStack : preAssignedValuesMap.keySet()) {
|
||||
if (wrappedStack != null) {
|
||||
if (!stackValueMap.keySet().contains(wrappedStack)) {
|
||||
for (WrappedStack wrappedStack : preAssignedValuesMap.keySet())
|
||||
{
|
||||
if (wrappedStack != null)
|
||||
{
|
||||
if (!stackValueMap.keySet().contains(wrappedStack))
|
||||
{
|
||||
EmcValue emcValue = preAssignedValuesMap.get(wrappedStack);
|
||||
|
||||
if (emcValue != null && emcValue.getValue() > 0f) {
|
||||
|
||||
if (emcValue != null && emcValue.getValue() > 0f)
|
||||
{
|
||||
stackValueMap.put(wrappedStack, emcValue);
|
||||
}
|
||||
}
|
||||
|
@ -80,17 +84,18 @@ public class EmcRegistry {
|
|||
stackMappingsBuilder.putAll(stackValueMap);
|
||||
stackValueMap.clear();
|
||||
stackMappings = stackMappingsBuilder.build();
|
||||
|
||||
|
||||
int passNumber = 0;
|
||||
Map<WrappedStack, EmcValue> computedStackValues = computeStackMappings();
|
||||
|
||||
while ((computedStackValues.size() > 0) && (passNumber < MAX_ATTEMPTED_ASSIGNMENT_PASSES)) {
|
||||
|
||||
while ((computedStackValues.size() > 0) && (passNumber < MAX_ATTEMPTED_ASSIGNMENT_PASSES))
|
||||
{
|
||||
|
||||
passNumber++;
|
||||
computedStackValues = computeStackMappings();
|
||||
|
||||
|
||||
stackMappingsBuilder = ImmutableSortedMap.naturalOrder();
|
||||
stackMappingsBuilder.putAll(stackMappings);
|
||||
stackMappingsBuilder.putAll(stackMappings);
|
||||
stackMappingsBuilder.putAll(computedStackValues);
|
||||
stackMappings = stackMappingsBuilder.build();
|
||||
}
|
||||
|
@ -100,12 +105,15 @@ public class EmcRegistry {
|
|||
*/
|
||||
stackValueMap.putAll(stackMappings);
|
||||
Map<WrappedStack, EmcValue> postAssignedValuesMap = EmcValuesIMC.getPostAssignedValues();
|
||||
for (WrappedStack wrappedStack : postAssignedValuesMap.keySet()) {
|
||||
if (wrappedStack != null) {
|
||||
|
||||
for (WrappedStack wrappedStack : postAssignedValuesMap.keySet())
|
||||
{
|
||||
if (wrappedStack != null)
|
||||
{
|
||||
|
||||
EmcValue emcValue = postAssignedValuesMap.get(wrappedStack);
|
||||
|
||||
if (emcValue != null && emcValue.getValue() > 0f) {
|
||||
|
||||
if (emcValue != null && emcValue.getValue() > 0f)
|
||||
{
|
||||
stackValueMap.put(wrappedStack, emcValue);
|
||||
}
|
||||
}
|
||||
|
@ -119,96 +127,122 @@ public class EmcRegistry {
|
|||
*/
|
||||
SortedMap<EmcValue, List<WrappedStack>> tempValueMappings = new TreeMap<EmcValue, List<WrappedStack>>();
|
||||
|
||||
for (WrappedStack stack : stackMappings.keySet()) {
|
||||
for (WrappedStack stack : stackMappings.keySet())
|
||||
{
|
||||
EmcValue value = stackMappings.get(stack);
|
||||
|
||||
if (tempValueMappings.containsKey(value)) {
|
||||
if (!(tempValueMappings.get(value).contains(stack))) {
|
||||
if (tempValueMappings.containsKey(value))
|
||||
{
|
||||
if (!(tempValueMappings.get(value).contains(stack)))
|
||||
{
|
||||
tempValueMappings.get(value).add(stack);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
tempValueMappings.put(value, new ArrayList<WrappedStack>(Arrays.asList(stack)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
valueMappings = ImmutableSortedMap.copyOf(tempValueMappings);
|
||||
}
|
||||
|
||||
private static Map<WrappedStack, EmcValue> computeStackMappings() {
|
||||
|
||||
|
||||
private static Map<WrappedStack, EmcValue> computeStackMappings()
|
||||
{
|
||||
|
||||
Map<WrappedStack, EmcValue> computedStackMap = new HashMap<WrappedStack, EmcValue>();
|
||||
|
||||
for (WrappedStack recipeOutput : RecipeRegistry.getRecipeMappings().keySet()) {
|
||||
|
||||
if (!hasEmcValue(recipeOutput.getWrappedStack(), false) && !computedStackMap.containsKey(recipeOutput.getWrappedStack())) {
|
||||
|
||||
|
||||
for (WrappedStack recipeOutput : RecipeRegistry.getInstance().getRecipeMappings().keySet())
|
||||
{
|
||||
|
||||
if (!hasEmcValue(recipeOutput.getWrappedStack(), false) && !computedStackMap.containsKey(recipeOutput.getWrappedStack()))
|
||||
{
|
||||
|
||||
EmcValue lowestValue = null;
|
||||
|
||||
for (List<WrappedStack> recipeInputs : RecipeRegistry.getRecipeMappings().get(recipeOutput)) {
|
||||
|
||||
|
||||
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) {
|
||||
|
||||
if (computedValue != null)
|
||||
{
|
||||
if (computedValue.compareTo(lowestValue) < 0)
|
||||
{
|
||||
lowestValue = computedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((lowestValue != null) && (lowestValue.getValue() > 0f)) {
|
||||
|
||||
if ((lowestValue != null) && (lowestValue.getValue() > 0f))
|
||||
{
|
||||
computedStackMap.put(new WrappedStack(recipeOutput.getWrappedStack()), lowestValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return computedStackMap;
|
||||
}
|
||||
|
||||
public static boolean hasEmcValue(Object object, boolean strict) {
|
||||
public static boolean hasEmcValue(Object object, boolean strict)
|
||||
{
|
||||
|
||||
lazyInit();
|
||||
|
||||
if (WrappedStack.canBeWrapped(object)) {
|
||||
|
||||
if (WrappedStack.canBeWrapped(object))
|
||||
{
|
||||
|
||||
WrappedStack stack = new WrappedStack(object);
|
||||
|
||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(stack.getWrappedStack()))) {
|
||||
|
||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(stack.getWrappedStack())))
|
||||
{
|
||||
return emcRegistry.stackMappings.containsKey(new WrappedStack(stack.getWrappedStack()));
|
||||
}
|
||||
else {
|
||||
|
||||
if (!strict) {
|
||||
if (stack.getWrappedStack() instanceof ItemStack) {
|
||||
|
||||
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) {
|
||||
|
||||
if (OreDictionary.getOreID(wrappedItemStack) != -1)
|
||||
{
|
||||
|
||||
OreStack oreStack = new OreStack(wrappedItemStack);
|
||||
|
||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(oreStack))) {
|
||||
|
||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(oreStack)))
|
||||
{
|
||||
return emcRegistry.stackMappings.containsKey(new WrappedStack(oreStack));
|
||||
}
|
||||
else {
|
||||
for (ItemStack itemStack : OreDictionary.getOres(OreDictionary.getOreID(wrappedItemStack))) {
|
||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(itemStack))) {
|
||||
else
|
||||
{
|
||||
for (ItemStack itemStack : OreDictionary.getOres(OreDictionary.getOreID(wrappedItemStack)))
|
||||
{
|
||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(itemStack)))
|
||||
{
|
||||
return emcRegistry.stackMappings.containsKey(new WrappedStack(itemStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Else, scan for if there is a wildcard value for it
|
||||
else {
|
||||
|
||||
for (WrappedStack valuedStack : emcRegistry.stackMappings.keySet()) {
|
||||
|
||||
if (valuedStack.getWrappedStack() instanceof ItemStack) {
|
||||
else
|
||||
{
|
||||
|
||||
for (WrappedStack valuedStack : emcRegistry.stackMappings.keySet())
|
||||
{
|
||||
|
||||
if (valuedStack.getWrappedStack() instanceof ItemStack)
|
||||
{
|
||||
ItemStack valuedItemStack = (ItemStack) valuedStack.getWrappedStack();
|
||||
|
||||
if ((valuedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE || wrappedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) && valuedItemStack.itemID == wrappedItemStack.itemID) {
|
||||
|
||||
if ((valuedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE || wrappedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) && valuedItemStack.itemID == wrappedItemStack.itemID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -221,76 +255,95 @@ public class EmcRegistry {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean hasEmcValue(Object object) {
|
||||
|
||||
public static boolean hasEmcValue(Object object)
|
||||
{
|
||||
return hasEmcValue(object, false);
|
||||
}
|
||||
|
||||
public static EmcValue getEmcValue(Object object, boolean strict) {
|
||||
public static EmcValue getEmcValue(Object object, boolean strict)
|
||||
{
|
||||
|
||||
lazyInit();
|
||||
|
||||
if (hasEmcValue(object, strict)) {
|
||||
|
||||
if (hasEmcValue(object, strict))
|
||||
{
|
||||
|
||||
WrappedStack stack = new WrappedStack(object);
|
||||
|
||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(stack.getWrappedStack()))) {
|
||||
|
||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(stack.getWrappedStack())))
|
||||
{
|
||||
return emcRegistry.stackMappings.get(new WrappedStack(stack.getWrappedStack()));
|
||||
}
|
||||
else {
|
||||
|
||||
if (stack.getWrappedStack() instanceof ItemStack) {
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
if (stack.getWrappedStack() instanceof ItemStack)
|
||||
{
|
||||
|
||||
ItemStack wrappedItemStack = (ItemStack) stack.getWrappedStack();
|
||||
EmcValue lowestValue = null;
|
||||
|
||||
if (OreDictionary.getOreID(wrappedItemStack) != -1) {
|
||||
|
||||
|
||||
if (OreDictionary.getOreID(wrappedItemStack) != -1)
|
||||
{
|
||||
|
||||
OreStack oreStack = new OreStack(wrappedItemStack);
|
||||
|
||||
if (emcRegistry.stackMappings.containsKey(new WrappedStack(oreStack))) {
|
||||
|
||||
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) {
|
||||
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 {
|
||||
else
|
||||
{
|
||||
EmcValue itemValue = emcRegistry.stackMappings.get(new WrappedStack(itemStack));
|
||||
|
||||
if (itemValue.compareTo(lowestValue) < 0) {
|
||||
|
||||
if (itemValue.compareTo(lowestValue) < 0)
|
||||
{
|
||||
lowestValue = itemValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return lowestValue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
for (WrappedStack valuedStack : emcRegistry.stackMappings.keySet()) {
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
for (WrappedStack valuedStack : emcRegistry.stackMappings.keySet())
|
||||
{
|
||||
|
||||
EmcValue stackValue = emcRegistry.stackMappings.get(valuedStack);
|
||||
|
||||
if (valuedStack.getWrappedStack() instanceof ItemStack) {
|
||||
|
||||
|
||||
if (valuedStack.getWrappedStack() instanceof ItemStack)
|
||||
{
|
||||
|
||||
ItemStack valuedItemStack = (ItemStack) valuedStack.getWrappedStack();
|
||||
|
||||
if ((valuedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE || wrappedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) && valuedItemStack.itemID == wrappedItemStack.itemID) {
|
||||
|
||||
if (stackValue.compareTo(lowestValue) < 0) {
|
||||
|
||||
if ((valuedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE || wrappedItemStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) && valuedItemStack.itemID == wrappedItemStack.itemID)
|
||||
{
|
||||
|
||||
if (stackValue.compareTo(lowestValue) < 0)
|
||||
{
|
||||
lowestValue = stackValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return lowestValue;
|
||||
}
|
||||
}
|
||||
|
@ -299,22 +352,26 @@ public class EmcRegistry {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EmcValue getEmcValue(Object object) {
|
||||
|
||||
public static EmcValue getEmcValue(Object object)
|
||||
{
|
||||
return getEmcValue(object, false);
|
||||
}
|
||||
|
||||
public static List<WrappedStack> getStacksInRange(int start, int finish) {
|
||||
public static List<WrappedStack> getStacksInRange(int start, int finish)
|
||||
{
|
||||
|
||||
return getStacksInRange(new EmcValue(start), new EmcValue(finish));
|
||||
}
|
||||
|
||||
public static List<WrappedStack> getStacksInRange(float start, float finish) {
|
||||
public static List<WrappedStack> getStacksInRange(float start, float finish)
|
||||
{
|
||||
|
||||
return getStacksInRange(new EmcValue(start), new EmcValue(finish));
|
||||
}
|
||||
|
||||
public static List<WrappedStack> getStacksInRange(EmcValue start, EmcValue finish) {
|
||||
public static List<WrappedStack> getStacksInRange(EmcValue start, EmcValue finish)
|
||||
{
|
||||
|
||||
lazyInit();
|
||||
|
||||
|
@ -326,19 +383,24 @@ public class EmcRegistry {
|
|||
SortedMap<EmcValue, List<WrappedStack>> smallerMap;
|
||||
SortedMap<EmcValue, List<WrappedStack>> biggerMap;
|
||||
|
||||
if (!tailMap.isEmpty() && !headMap.isEmpty()) {
|
||||
if (!tailMap.isEmpty() && !headMap.isEmpty())
|
||||
{
|
||||
|
||||
if (tailMap.size() <= headMap.size()) {
|
||||
if (tailMap.size() <= headMap.size())
|
||||
{
|
||||
smallerMap = tailMap;
|
||||
biggerMap = headMap;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
smallerMap = headMap;
|
||||
biggerMap = tailMap;
|
||||
}
|
||||
|
||||
for (EmcValue value : smallerMap.keySet()) {
|
||||
if (biggerMap.containsKey(value)) {
|
||||
for (EmcValue value : smallerMap.keySet())
|
||||
{
|
||||
if (biggerMap.containsKey(value))
|
||||
{
|
||||
stacksInRange.addAll(emcRegistry.valueMappings.get(value));
|
||||
}
|
||||
}
|
||||
|
@ -347,58 +409,71 @@ public class EmcRegistry {
|
|||
return stacksInRange;
|
||||
}
|
||||
|
||||
public static void printStackValueMappings() {
|
||||
public static void printStackValueMappings()
|
||||
{
|
||||
|
||||
lazyInit();
|
||||
|
||||
for (WrappedStack stack : emcRegistry.stackMappings.keySet()) {
|
||||
|
||||
for (WrappedStack stack : emcRegistry.stackMappings.keySet())
|
||||
{
|
||||
LogHelper.debug("Stack: " + stack + ", Value: " + emcRegistry.stackMappings.get(stack));
|
||||
}
|
||||
}
|
||||
|
||||
public static void printUnmappedStacks() {
|
||||
|
||||
|
||||
public static void printUnmappedStacks()
|
||||
{
|
||||
|
||||
lazyInit();
|
||||
List<WrappedStack> discoveredStacks = new ArrayList<WrappedStack>(RecipeRegistry.getDiscoveredStacks());
|
||||
List<WrappedStack> discoveredStacks = new ArrayList<WrappedStack>(RecipeRegistry.getInstance().getDiscoveredStacks());
|
||||
Collections.sort(discoveredStacks);
|
||||
for (WrappedStack stack : discoveredStacks) {
|
||||
if (!hasEmcValue(stack)) {
|
||||
if (RecipeRegistry.getRecipeMappings().get(stack).size() > 0) {
|
||||
for (List<WrappedStack> recipeInputs : RecipeRegistry.getRecipeMappings().get(stack)) {
|
||||
for (WrappedStack stack : discoveredStacks)
|
||||
{
|
||||
if (!hasEmcValue(stack))
|
||||
{
|
||||
if (RecipeRegistry.getInstance().getRecipeMappings().get(stack).size() > 0)
|
||||
{
|
||||
for (List<WrappedStack> recipeInputs : RecipeRegistry.getInstance().getRecipeMappings().get(stack))
|
||||
{
|
||||
LogHelper.debug(stack + ": " + RecipeHelper.collateInputStacks(recipeInputs));
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
LogHelper.debug(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void printUnmappedCompoundStacks() {
|
||||
|
||||
|
||||
public static void printUnmappedCompoundStacks()
|
||||
{
|
||||
|
||||
lazyInit();
|
||||
|
||||
|
||||
List<WrappedStack> unmappedStacks = new ArrayList<WrappedStack>();
|
||||
|
||||
for (WrappedStack recipeOutput : RecipeRegistry.getRecipeMappings().keySet()) {
|
||||
|
||||
|
||||
for (WrappedStack recipeOutput : RecipeRegistry.getInstance().getRecipeMappings().keySet())
|
||||
{
|
||||
|
||||
WrappedStack unitStack = new WrappedStack(recipeOutput.getWrappedStack());
|
||||
|
||||
if (!hasEmcValue(unitStack)) {
|
||||
|
||||
if (!hasEmcValue(unitStack))
|
||||
{
|
||||
unmappedStacks.add(recipeOutput);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Collections.sort(unmappedStacks);
|
||||
|
||||
for (WrappedStack recipeOutput : unmappedStacks) {
|
||||
|
||||
for (List<WrappedStack> recipeInputs : RecipeRegistry.getRecipeMappings().get(recipeOutput)) {
|
||||
|
||||
for (WrappedStack recipeOutput : unmappedStacks)
|
||||
{
|
||||
|
||||
for (List<WrappedStack> recipeInputs : RecipeRegistry.getInstance().getRecipeMappings().get(recipeOutput))
|
||||
{
|
||||
LogHelper.debug(String.format("Recipe Output: %s, Recipe Inputs: %s", recipeOutput, RecipeHelper.collateInputStacks(recipeInputs)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package com.pahimar.ee3.emc;
|
||||
|
||||
public enum EmcType {
|
||||
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,79 +1,79 @@
|
|||
package com.pahimar.ee3.emc;
|
||||
|
||||
import com.google.gson.*;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* EMCEntry
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue>, JsonSerializer<EmcValue> {
|
||||
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();
|
||||
|
||||
public final float[] components;
|
||||
|
||||
public EmcValue() {
|
||||
public EmcValue()
|
||||
{
|
||||
|
||||
this(new float[EmcType.TYPES.length]);
|
||||
}
|
||||
|
||||
public EmcValue(int value) {
|
||||
public EmcValue(int value)
|
||||
{
|
||||
|
||||
this((float) value);
|
||||
}
|
||||
|
||||
public EmcValue(float value) {
|
||||
public EmcValue(float value)
|
||||
{
|
||||
|
||||
this(value, EmcType.DEFAULT);
|
||||
}
|
||||
|
||||
public EmcValue(float value, EmcComponent component) {
|
||||
public EmcValue(float value, EmcComponent component)
|
||||
{
|
||||
|
||||
this(value, component.type);
|
||||
}
|
||||
|
||||
public EmcValue(int value, EmcType emcType) {
|
||||
public EmcValue(int value, EmcType emcType)
|
||||
{
|
||||
|
||||
this((float) value, emcType);
|
||||
}
|
||||
|
||||
public EmcValue(float value, EmcType emcType) {
|
||||
public EmcValue(float value, EmcType emcType)
|
||||
{
|
||||
|
||||
this.components = new float[EmcType.TYPES.length];
|
||||
this.components[emcType.ordinal()] = value;
|
||||
}
|
||||
|
||||
public EmcValue(float[] components) {
|
||||
public EmcValue(float[] components)
|
||||
{
|
||||
|
||||
this.components = components;
|
||||
}
|
||||
|
||||
public EmcValue(int value, List<EmcComponent> componentList) {
|
||||
public EmcValue(int value, List<EmcComponent> componentList)
|
||||
{
|
||||
|
||||
this((float) value, componentList);
|
||||
}
|
||||
|
||||
public EmcValue(float value, List<EmcComponent> componentList) {
|
||||
public EmcValue(float value, List<EmcComponent> componentList)
|
||||
{
|
||||
|
||||
this.components = new float[EmcType.TYPES.length];
|
||||
|
||||
|
@ -81,30 +81,39 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
|
|||
|
||||
int totalComponents = 0;
|
||||
|
||||
for (EmcComponent component : collatedComponents) {
|
||||
if (component.weight > 0) {
|
||||
for (EmcComponent component : collatedComponents)
|
||||
{
|
||||
if (component.weight > 0)
|
||||
{
|
||||
totalComponents += component.weight;
|
||||
}
|
||||
}
|
||||
|
||||
if (totalComponents > 0) {
|
||||
for (EmcComponent component : collatedComponents) {
|
||||
if (component.weight > 0) {
|
||||
if (totalComponents > 0)
|
||||
{
|
||||
for (EmcComponent component : collatedComponents)
|
||||
{
|
||||
if (component.weight > 0)
|
||||
{
|
||||
this.components[component.type.ordinal()] = value * (component.weight * 1F / totalComponents);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
this.components[EmcType.DEFAULT.ordinal()] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public float getValue() {
|
||||
public float getValue()
|
||||
{
|
||||
|
||||
float sumSubValues = 0;
|
||||
|
||||
for (float subValue : this.components) {
|
||||
if (subValue > 0) {
|
||||
for (float subValue : this.components)
|
||||
{
|
||||
if (subValue > 0)
|
||||
{
|
||||
sumSubValues += subValue;
|
||||
}
|
||||
}
|
||||
|
@ -113,9 +122,11 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
public boolean equals(Object object)
|
||||
{
|
||||
|
||||
if (!(object instanceof EmcValue)) {
|
||||
if (!(object instanceof EmcValue))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -123,15 +134,18 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString()
|
||||
{
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
// TODO Intelligible output
|
||||
stringBuilder.append("[");
|
||||
|
||||
for (EmcType emcType : EmcType.TYPES) {
|
||||
if (components[emcType.ordinal()] > 0) {
|
||||
for (EmcType emcType : EmcType.TYPES)
|
||||
{
|
||||
if (components[emcType.ordinal()] > 0)
|
||||
{
|
||||
stringBuilder.append(String.format(" %s:%s ", emcType, components[emcType.ordinal()]));
|
||||
}
|
||||
}
|
||||
|
@ -142,12 +156,14 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
|
|||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
public int hashCode()
|
||||
{
|
||||
|
||||
int hashCode = 1;
|
||||
|
||||
hashCode = 37 * hashCode + Float.floatToIntBits(getValue());
|
||||
for (float subValue : components) {
|
||||
for (float subValue : components)
|
||||
{
|
||||
hashCode = 37 * hashCode + Float.floatToIntBits(subValue);
|
||||
}
|
||||
|
||||
|
@ -155,30 +171,35 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
|
|||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(EmcValue emcValue) {
|
||||
public int compareTo(EmcValue emcValue)
|
||||
{
|
||||
|
||||
if (emcValue instanceof EmcValue) {
|
||||
if (emcValue instanceof EmcValue)
|
||||
{
|
||||
return compareComponents(this.components, emcValue.components);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes an EmcValue object from the given serialized json String
|
||||
*
|
||||
* @param jsonEmcValue
|
||||
* Json encoded String representing a EmcValue object
|
||||
*
|
||||
* @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
|
||||
* EmcValue could not be decoded from given String
|
||||
*/
|
||||
public static EmcValue createFromJson(String jsonEmcValue) {
|
||||
public static EmcValue createFromJson(String jsonEmcValue)
|
||||
{
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
return (EmcValue) gsonSerializer.fromJson(jsonEmcValue, EmcValue.class);
|
||||
}
|
||||
catch (JsonSyntaxException exception) {
|
||||
catch (JsonSyntaxException exception)
|
||||
{
|
||||
// TODO Log something regarding the failed parse
|
||||
}
|
||||
|
||||
|
@ -187,32 +208,39 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
|
|||
|
||||
/**
|
||||
* Returns this EmcValue as a json serialized String
|
||||
*
|
||||
*
|
||||
* @return Json serialized String of this EmcValue
|
||||
*/
|
||||
public String toJson() {
|
||||
public String toJson()
|
||||
{
|
||||
|
||||
return gsonSerializer.toJson(this);
|
||||
}
|
||||
|
||||
private static List<EmcComponent> collateComponents(List<EmcComponent> uncollatedComponents) {
|
||||
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()] = new Integer(0);
|
||||
for (EmcComponent emcComponent : uncollatedComponents)
|
||||
{
|
||||
if (componentCount[emcComponent.type.ordinal()] == null)
|
||||
{
|
||||
componentCount[emcComponent.type.ordinal()] = 0;
|
||||
}
|
||||
|
||||
if (emcComponent.weight >= 0) {
|
||||
componentCount[emcComponent.type.ordinal()] = new Integer(componentCount[emcComponent.type.ordinal()].intValue() + emcComponent.weight);
|
||||
if (emcComponent.weight >= 0)
|
||||
{
|
||||
componentCount[emcComponent.type.ordinal()] = componentCount[emcComponent.type.ordinal()].intValue() + emcComponent.weight;
|
||||
}
|
||||
}
|
||||
|
||||
List<EmcComponent> collatedComponents = new ArrayList<EmcComponent>();
|
||||
|
||||
for (int i = 0; i < EmcType.TYPES.length; i++) {
|
||||
if (componentCount[i] != null) {
|
||||
for (int i = 0; i < EmcType.TYPES.length; i++)
|
||||
{
|
||||
if (componentCount[i] != null)
|
||||
{
|
||||
collatedComponents.add(new EmcComponent(EmcType.TYPES[i], componentCount[i].intValue()));
|
||||
}
|
||||
}
|
||||
|
@ -222,29 +250,36 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
|
|||
return collatedComponents;
|
||||
}
|
||||
|
||||
private static int compareComponents(float[] first, float[] second) {
|
||||
private static int compareComponents(float[] first, float[] second)
|
||||
{
|
||||
|
||||
if (first.length == EmcType.TYPES.length && second.length == EmcType.TYPES.length) {
|
||||
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()]) != 0) {
|
||||
for (EmcType emcType : EmcType.TYPES)
|
||||
{
|
||||
if (Float.compare(first[emcType.ordinal()], second[emcType.ordinal()]) != 0)
|
||||
{
|
||||
return Float.compare(first[emcType.ordinal()], second[emcType.ordinal()]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(EmcValue emcValue, Type type, JsonSerializationContext context) {
|
||||
public JsonElement serialize(EmcValue emcValue, Type type, JsonSerializationContext context)
|
||||
{
|
||||
|
||||
JsonObject jsonEmcValue = new JsonObject();
|
||||
|
||||
for (EmcType emcType : EmcType.TYPES) {
|
||||
for (EmcType emcType : EmcType.TYPES)
|
||||
{
|
||||
jsonEmcValue.addProperty(emcType.toString(), emcValue.components[emcType.ordinal()]);
|
||||
}
|
||||
|
||||
|
@ -252,17 +287,22 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
|
|||
}
|
||||
|
||||
@Override
|
||||
public EmcValue deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException {
|
||||
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 {
|
||||
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) {
|
||||
catch (UnsupportedOperationException exception)
|
||||
{
|
||||
// TODO Better logging/handling of the exception
|
||||
exception.printStackTrace(System.err);
|
||||
}
|
||||
|
@ -271,7 +311,8 @@ public class EmcValue implements Comparable<EmcValue>, JsonDeserializer<EmcValue
|
|||
|
||||
EmcValue emcValue = new EmcValue(emcValueComponents);
|
||||
|
||||
if (emcValue.getValue() > 0f) {
|
||||
if (emcValue.getValue() > 0f)
|
||||
{
|
||||
return emcValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,40 +1,45 @@
|
|||
package com.pahimar.ee3.emc;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.pahimar.ee3.item.OreStack;
|
||||
import com.pahimar.ee3.item.WrappedStack;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import com.pahimar.ee3.item.WrappedStack;
|
||||
import com.pahimar.ee3.item.OreStack;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class EmcValuesDefault {
|
||||
public class EmcValuesDefault
|
||||
{
|
||||
|
||||
private static EmcValuesDefault emcDefaultValues = null;
|
||||
private Map<WrappedStack, EmcValue> valueMap;
|
||||
|
||||
private EmcValuesDefault() {
|
||||
private EmcValuesDefault()
|
||||
{
|
||||
|
||||
valueMap = new HashMap<WrappedStack, EmcValue>();
|
||||
}
|
||||
|
||||
private static void lazyInit() {
|
||||
private static void lazyInit()
|
||||
{
|
||||
|
||||
if (emcDefaultValues == null) {
|
||||
if (emcDefaultValues == null)
|
||||
{
|
||||
emcDefaultValues = new EmcValuesDefault();
|
||||
emcDefaultValues.init();
|
||||
}
|
||||
}
|
||||
|
||||
private void 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++) {
|
||||
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, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 4), new EmcComponent(EmcType.ESSENTIA, 1))));
|
||||
|
@ -54,7 +59,7 @@ public class EmcValuesDefault {
|
|||
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, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 4), new EmcComponent(EmcType.ESSENTIA, 1))));
|
||||
valueMap.put(new WrappedStack(new OreStack(new ItemStack(Block.sapling))), new EmcValue(32, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 4), new EmcComponent(EmcType.ESSENTIA, 1))));
|
||||
|
||||
|
||||
// Fluids
|
||||
valueMap.put(new WrappedStack(Block.waterStill), new EmcValue(0.1f, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 1), new EmcComponent(EmcType.AMORPHOUS, 1))));
|
||||
valueMap.put(new WrappedStack(Block.lavaStill), new EmcValue(64, Arrays.asList(new EmcComponent(EmcType.CORPOREAL, 4), new EmcComponent(EmcType.AMORPHOUS, 1))));
|
||||
|
@ -113,7 +118,7 @@ public class EmcValuesDefault {
|
|||
|
||||
/* Miscellaneous */
|
||||
valueMap.put(new WrappedStack(Item.snowball), new EmcValue(0.25f));
|
||||
valueMap.put(new WrappedStack(Item.bucketMilk), new EmcValue(832));
|
||||
valueMap.put(new WrappedStack(Item.bucketMilk), new EmcValue(832));
|
||||
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));
|
||||
|
@ -179,7 +184,8 @@ public class EmcValuesDefault {
|
|||
/* Equivalent Exchange 3 */
|
||||
}
|
||||
|
||||
public static Map<WrappedStack, EmcValue> getDefaultValueMap() {
|
||||
public static Map<WrappedStack, EmcValue> getDefaultValueMap()
|
||||
{
|
||||
|
||||
lazyInit();
|
||||
return emcDefaultValues.valueMap;
|
||||
|
|
|
@ -1,58 +1,70 @@
|
|||
package com.pahimar.ee3.emc;
|
||||
|
||||
import com.pahimar.ee3.item.WrappedStack;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.pahimar.ee3.item.WrappedStack;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* EmcIMCValues
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class EmcValuesIMC {
|
||||
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() {
|
||||
|
||||
public static Map<WrappedStack, EmcValue> getPreAssignedValues()
|
||||
{
|
||||
return preAssignedValueMap;
|
||||
}
|
||||
|
||||
public static Map<WrappedStack, EmcValue> getPostAssignedValues() {
|
||||
|
||||
public static Map<WrappedStack, EmcValue> getPostAssignedValues()
|
||||
{
|
||||
return postAssignedValueMap;
|
||||
}
|
||||
|
||||
public static void addPreAssignedValued(WrappedStack wrappedStack, EmcValue emcValue) {
|
||||
|
||||
if (wrappedStack != null) {
|
||||
if (!preAssignedValueMap.containsKey(wrappedStack)) {
|
||||
public static void addPreAssignedValued(WrappedStack wrappedStack, EmcValue emcValue)
|
||||
{
|
||||
|
||||
if (wrappedStack != null)
|
||||
{
|
||||
if (!preAssignedValueMap.containsKey(wrappedStack))
|
||||
{
|
||||
preAssignedValueMap.put(wrappedStack, emcValue);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Log that we already have a value for that
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Logging
|
||||
}
|
||||
}
|
||||
|
||||
public static void addPostAssignedValued(WrappedStack wrappedStack, EmcValue emcValue) {
|
||||
public static void addPostAssignedValued(WrappedStack wrappedStack, EmcValue emcValue)
|
||||
{
|
||||
|
||||
if (wrappedStack != null) {
|
||||
if (!postAssignedValueMap.containsKey(wrappedStack)) {
|
||||
if (wrappedStack != null)
|
||||
{
|
||||
if (!postAssignedValueMap.containsKey(wrappedStack))
|
||||
{
|
||||
postAssignedValueMap.put(wrappedStack, emcValue);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Log that we already have a value for that
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Logging
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,17 @@ import net.minecraftforge.event.Event;
|
|||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ActionEvent
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ActionEvent extends Event {
|
||||
public class ActionEvent extends Event
|
||||
{
|
||||
|
||||
public enum ActionResult {
|
||||
public enum ActionResult
|
||||
{
|
||||
SUCCESS, DEFAULT, FAILURE
|
||||
}
|
||||
|
||||
|
@ -29,7 +30,8 @@ public class ActionEvent extends Event {
|
|||
public final String data;
|
||||
public ActionResult actionResult;
|
||||
|
||||
public ActionEvent(byte actionType, ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, boolean hasActionOccured, String data) {
|
||||
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;
|
||||
|
|
|
@ -1,29 +1,31 @@
|
|||
package com.pahimar.ee3.event;
|
||||
|
||||
import static net.minecraftforge.event.Event.Result.DEFAULT;
|
||||
import static net.minecraftforge.event.Event.Result.DENY;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.event.Cancelable;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
|
||||
import static net.minecraftforge.event.Event.Result.DEFAULT;
|
||||
import static net.minecraftforge.event.Event.Result.DENY;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ActionRequestEvent
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
@Cancelable
|
||||
public class ActionRequestEvent extends PlayerEvent {
|
||||
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) {
|
||||
public ActionRequestEvent(EntityPlayer player, ActionEvent modEvent, int x, int y, int z, int sideHit)
|
||||
{
|
||||
|
||||
super(player);
|
||||
this.modEvent = modEvent;
|
||||
|
@ -31,13 +33,15 @@ public class ActionRequestEvent extends PlayerEvent {
|
|||
this.y = y;
|
||||
this.z = z;
|
||||
this.sideHit = sideHit;
|
||||
if (sideHit == -1) {
|
||||
if (sideHit == -1)
|
||||
{
|
||||
allowEvent = DENY;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanceled(boolean cancel) {
|
||||
public void setCanceled(boolean cancel)
|
||||
{
|
||||
|
||||
super.setCanceled(cancel);
|
||||
allowEvent = cancel ? DENY : allowEvent == DENY ? DENY : DEFAULT;
|
||||
|
|
|
@ -6,18 +6,19 @@ import net.minecraft.world.World;
|
|||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* WorldTransmutationEvent
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class WorldTransmutationEvent extends ActionEvent {
|
||||
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) {
|
||||
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(":")));
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
package com.pahimar.ee3.imc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.pahimar.ee3.core.helper.LogHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.Gson;
|
||||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
|
@ -17,205 +11,251 @@ import com.pahimar.ee3.emc.EmcValuesIMC;
|
|||
import com.pahimar.ee3.item.WrappedStack;
|
||||
import com.pahimar.ee3.item.crafting.RecipesIMC;
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
|
||||
import cpw.mods.fml.common.IScheduledTickHandler;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
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;
|
||||
|
||||
public class InterModCommsHandler implements ITickHandler, IScheduledTickHandler{
|
||||
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()) {
|
||||
|
||||
public static void processIMCMessages(IMCEvent event)
|
||||
{
|
||||
|
||||
for (IMCMessage imcMessage : event.getMessages())
|
||||
{
|
||||
processIMCMessage(imcMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public static void processIMCMessage(IMCMessage imcMessage) {
|
||||
|
||||
|
||||
public static void processIMCMessage(IMCMessage imcMessage)
|
||||
{
|
||||
|
||||
String requestedOperation = imcMessage.key;
|
||||
|
||||
if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.RECIPE_ADD)) {
|
||||
if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.RECIPE_ADD))
|
||||
{
|
||||
processAddRecipeMessage(imcMessage);
|
||||
}
|
||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_ASSIGN_VALUE_PRE)) {
|
||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_ASSIGN_VALUE_PRE))
|
||||
{
|
||||
processPreAssignEmcValueMessage(imcMessage);
|
||||
}
|
||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_ASSIGN_VALUE_POST)) {
|
||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_ASSIGN_VALUE_POST))
|
||||
{
|
||||
processPostAssignEmcValueMessage(imcMessage);
|
||||
}
|
||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_HAS_VALUE)) {
|
||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_HAS_VALUE))
|
||||
{
|
||||
processHasEmcValueMessage(imcMessage);
|
||||
}
|
||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_GET_VALUE)) {
|
||||
else if (requestedOperation.equalsIgnoreCase(InterModCommsOperations.EMC_GET_VALUE))
|
||||
{
|
||||
processGetEmcValueMessage(imcMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private static void processAddRecipeMessage(IMCMessage imcMessage) {
|
||||
private static void processAddRecipeMessage(IMCMessage imcMessage)
|
||||
{
|
||||
|
||||
if (imcMessage.getMessageType() == String.class)
|
||||
{
|
||||
|
||||
if (imcMessage.getMessageType() == String.class) {
|
||||
|
||||
RecipeMapping recipeMapping = RecipeMapping.createFromJson(imcMessage.getStringValue());
|
||||
|
||||
if (recipeMapping != null) {
|
||||
|
||||
|
||||
if (recipeMapping != null)
|
||||
{
|
||||
|
||||
WrappedStack outputWrappedStack = recipeMapping.outputWrappedStack;
|
||||
List<WrappedStack> inputWrappedStacks = recipeMapping.inputWrappedStacks;
|
||||
|
||||
|
||||
RecipesIMC.addRecipe(outputWrappedStack, inputWrappedStacks);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Log that the message payloads json was invalid
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Log that the message payload is of an invalid type
|
||||
}
|
||||
}
|
||||
|
||||
private static void processPreAssignEmcValueMessage(IMCMessage imcMessage) {
|
||||
private static void processPreAssignEmcValueMessage(IMCMessage imcMessage)
|
||||
{
|
||||
|
||||
if (imcMessage.getMessageType() == String.class)
|
||||
{
|
||||
|
||||
if (imcMessage.getMessageType() == String.class) {
|
||||
|
||||
StackValueMapping stackValueMapping = StackValueMapping.createFromJson(imcMessage.getStringValue());
|
||||
|
||||
if (stackValueMapping != null) {
|
||||
|
||||
|
||||
if (stackValueMapping != null)
|
||||
{
|
||||
|
||||
WrappedStack wrappedStack = stackValueMapping.wrappedStack;
|
||||
EmcValue emcValue = stackValueMapping.emcValue;
|
||||
|
||||
|
||||
EmcValuesIMC.addPreAssignedValued(wrappedStack, emcValue);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Log that the message payloads json was invalid
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Log that the message payload is of an invalid type
|
||||
}
|
||||
}
|
||||
|
||||
private static void processPostAssignEmcValueMessage(IMCMessage imcMessage) {
|
||||
|
||||
if (imcMessage.getMessageType() == String.class) {
|
||||
|
||||
private static void processPostAssignEmcValueMessage(IMCMessage imcMessage)
|
||||
{
|
||||
|
||||
if (imcMessage.getMessageType() == String.class)
|
||||
{
|
||||
|
||||
StackValueMapping stackValueMapping = StackValueMapping.createFromJson(imcMessage.getStringValue());
|
||||
|
||||
if (stackValueMapping != null) {
|
||||
|
||||
|
||||
if (stackValueMapping != null)
|
||||
{
|
||||
|
||||
WrappedStack wrappedStack = stackValueMapping.wrappedStack;
|
||||
EmcValue emcValue = stackValueMapping.emcValue;
|
||||
|
||||
|
||||
EmcValuesIMC.addPostAssignedValued(wrappedStack, emcValue);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Log that the message payloads json was invalid
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Log that the message payload is of an invalid type
|
||||
}
|
||||
}
|
||||
|
||||
private static void processHasEmcValueMessage(IMCMessage imcMessage) {
|
||||
|
||||
if (imcMessage.getMessageType() == String.class) {
|
||||
|
||||
private static void processHasEmcValueMessage(IMCMessage imcMessage)
|
||||
{
|
||||
|
||||
if (imcMessage.getMessageType() == String.class)
|
||||
{
|
||||
|
||||
WrappedStack wrappedStack = WrappedStack.createFromJson(imcMessage.getStringValue());
|
||||
|
||||
if (wrappedStack != null) {
|
||||
|
||||
if (wrappedStack != null)
|
||||
{
|
||||
FMLInterModComms.sendRuntimeMessage(
|
||||
EquivalentExchange3.instance,
|
||||
imcMessage.getSender(),
|
||||
InterModCommsOperations.EMC_RETURN_HAS_VALUE,
|
||||
EquivalentExchange3.instance,
|
||||
imcMessage.getSender(),
|
||||
InterModCommsOperations.EMC_RETURN_HAS_VALUE,
|
||||
String.format("%s==%s", imcMessage.getStringValue(), String.valueOf(EmcRegistry.hasEmcValue(wrappedStack))));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Log that the message payloads json was invalid
|
||||
}
|
||||
}
|
||||
else if (imcMessage.getMessageType() == ItemStack.class) {
|
||||
|
||||
else if (imcMessage.getMessageType() == ItemStack.class)
|
||||
{
|
||||
|
||||
ItemStack itemStack = imcMessage.getItemStackValue();
|
||||
|
||||
if (itemStack != null) {
|
||||
if (itemStack != null)
|
||||
{
|
||||
FMLInterModComms.sendRuntimeMessage(
|
||||
EquivalentExchange3.instance,
|
||||
imcMessage.getSender(),
|
||||
InterModCommsOperations.EMC_RETURN_HAS_VALUE,
|
||||
EquivalentExchange3.instance,
|
||||
imcMessage.getSender(),
|
||||
InterModCommsOperations.EMC_RETURN_HAS_VALUE,
|
||||
String.format("%s==%s", gson.toJson(itemStack), String.valueOf(EmcRegistry.hasEmcValue(itemStack))));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Logging
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Log that the message payload is of an invalid type
|
||||
}
|
||||
}
|
||||
|
||||
private static void processGetEmcValueMessage(IMCMessage imcMessage) {
|
||||
|
||||
if (imcMessage.getMessageType() == String.class) {
|
||||
|
||||
|
||||
private static void processGetEmcValueMessage(IMCMessage imcMessage)
|
||||
{
|
||||
|
||||
if (imcMessage.getMessageType() == String.class)
|
||||
{
|
||||
|
||||
WrappedStack wrappedStack = WrappedStack.createFromJson(imcMessage.getStringValue());
|
||||
|
||||
if (wrappedStack != null) {
|
||||
|
||||
if (wrappedStack != null)
|
||||
{
|
||||
FMLInterModComms.sendRuntimeMessage(
|
||||
EquivalentExchange3.instance,
|
||||
imcMessage.getSender(),
|
||||
InterModCommsOperations.EMC_RETURN_GET_VALUE,
|
||||
EquivalentExchange3.instance,
|
||||
imcMessage.getSender(),
|
||||
InterModCommsOperations.EMC_RETURN_GET_VALUE,
|
||||
String.format("%s==%s", imcMessage.getStringValue(), EmcRegistry.getEmcValue(wrappedStack).toJson()));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Log that the message payloads json was invalid
|
||||
}
|
||||
}
|
||||
else if (imcMessage.getMessageType() == ItemStack.class) {
|
||||
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,
|
||||
EquivalentExchange3.instance,
|
||||
imcMessage.getSender(),
|
||||
InterModCommsOperations.EMC_RETURN_GET_VALUE,
|
||||
String.format("%s==%s", gson.toJson(itemStack), EmcRegistry.getEmcValue(itemStack).toJson()));
|
||||
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
// TODO Log that the message payload is of an invalid type
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runtime fetching and processing of IMC messages
|
||||
*/
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData) {
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
|
||||
for (TickType tickType : type)
|
||||
{
|
||||
|
||||
if (tickType == TickType.SERVER)
|
||||
{
|
||||
|
||||
for (TickType tickType : type) {
|
||||
|
||||
if (tickType == TickType.SERVER) {
|
||||
|
||||
ImmutableList<IMCMessage> runtimeIMCMessages = FMLInterModComms.fetchRuntimeMessages(EquivalentExchange3.instance);
|
||||
|
||||
for (IMCMessage imcMessage : runtimeIMCMessages) {
|
||||
|
||||
for (IMCMessage imcMessage : runtimeIMCMessages)
|
||||
{
|
||||
InterModCommsHandler.processIMCMessage(imcMessage);
|
||||
}
|
||||
}
|
||||
|
@ -223,19 +263,22 @@ public class InterModCommsHandler implements ITickHandler, IScheduledTickHandler
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks() {
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
|
||||
return EnumSet.of(TickType.SERVER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
public String getLabel()
|
||||
{
|
||||
|
||||
return Reference.MOD_NAME + ": " + this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextTickSpacing() {
|
||||
public int nextTickSpacing()
|
||||
{
|
||||
|
||||
return 10;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.pahimar.ee3.imc;
|
||||
|
||||
public class InterModCommsOperations {
|
||||
public class InterModCommsOperations
|
||||
{
|
||||
|
||||
// Interacting with the Recipe Registry
|
||||
public static final String RECIPE_ADD = "recipe-add";
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import com.pahimar.ee3.core.helper.ItemStackNBTHelper;
|
||||
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;
|
||||
|
||||
import com.pahimar.ee3.core.helper.ItemStackNBTHelper;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ContainerAlchemicalBag
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ContainerAlchemicalBag extends Container {
|
||||
public class ContainerAlchemicalBag extends Container
|
||||
{
|
||||
|
||||
private final int BAG_INVENTORY_ROWS = 4;
|
||||
private final int BAG_INVENTORY_COLUMNS = 13;
|
||||
|
@ -26,37 +25,47 @@ public class ContainerAlchemicalBag extends Container {
|
|||
private final int PLAYER_INVENTORY_ROWS = 3;
|
||||
private final int PLAYER_INVENTORY_COLUMNS = 9;
|
||||
|
||||
public ContainerAlchemicalBag(InventoryPlayer inventoryPlayer) {
|
||||
public ContainerAlchemicalBag(InventoryPlayer inventoryPlayer)
|
||||
{
|
||||
|
||||
// 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) {
|
||||
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
|
||||
{
|
||||
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * PLAYER_INVENTORY_COLUMNS + PLAYER_INVENTORY_COLUMNS, 44 + inventoryColumnIndex * 18, 104 + inventoryRowIndex * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Add the player's action bar slots to the container
|
||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) {
|
||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 162));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer var1) {
|
||||
public boolean canInteractWith(EntityPlayer var1)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
public void onContainerClosed(EntityPlayer player)
|
||||
{
|
||||
|
||||
super.onContainerClosed(player);
|
||||
|
||||
if (!player.worldObj.isRemote) {
|
||||
if (!player.worldObj.isRemote)
|
||||
{
|
||||
InventoryPlayer invPlayer = player.inventory;
|
||||
for (ItemStack itemStack : invPlayer.mainInventory) {
|
||||
if (itemStack != null) {
|
||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -65,26 +74,35 @@ public class ContainerAlchemicalBag extends Container {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) {
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
|
||||
{
|
||||
|
||||
ItemStack newItemStack = null;
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemStack = slot.getStack();
|
||||
newItemStack = itemStack.copy();
|
||||
|
||||
if (slotIndex < BAG_INVENTORY_ROWS * BAG_INVENTORY_COLUMNS) {
|
||||
if (slotIndex < BAG_INVENTORY_ROWS * BAG_INVENTORY_COLUMNS)
|
||||
{
|
||||
if (!this.mergeItemStack(itemStack, BAG_INVENTORY_ROWS * BAG_INVENTORY_COLUMNS, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemStack, 0, BAG_INVENTORY_ROWS * BAG_INVENTORY_COLUMNS, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemStack.stackSize == 0) {
|
||||
if (itemStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
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;
|
||||
|
||||
import com.pahimar.ee3.tileentity.TileAlchemicalChest;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ContainerAlchemicalChest
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ContainerAlchemicalChest extends Container {
|
||||
public class ContainerAlchemicalChest extends Container
|
||||
{
|
||||
|
||||
private TileAlchemicalChest tileAlchemicalChest;
|
||||
|
||||
|
@ -27,34 +26,41 @@ public class ContainerAlchemicalChest extends Container {
|
|||
private final int PLAYER_INVENTORY_ROWS = 3;
|
||||
private final int PLAYER_INVENTORY_COLUMNS = 9;
|
||||
|
||||
public ContainerAlchemicalChest(InventoryPlayer inventoryPlayer, TileAlchemicalChest tileAlchemicalChest) {
|
||||
public ContainerAlchemicalChest(InventoryPlayer inventoryPlayer, TileAlchemicalChest tileAlchemicalChest)
|
||||
{
|
||||
|
||||
this.tileAlchemicalChest = tileAlchemicalChest;
|
||||
|
||||
tileAlchemicalChest.openChest();
|
||||
|
||||
// Add the Alchemical Chest slots to the container
|
||||
for (int chestRowIndex = 0; chestRowIndex < CHEST_INVENTORY_ROWS; ++chestRowIndex) {
|
||||
for (int chestColumnIndex = 0; chestColumnIndex < CHEST_INVENTORY_COLUMNS; ++chestColumnIndex) {
|
||||
for (int chestRowIndex = 0; chestRowIndex < CHEST_INVENTORY_ROWS; ++chestRowIndex)
|
||||
{
|
||||
for (int chestColumnIndex = 0; chestColumnIndex < CHEST_INVENTORY_COLUMNS; ++chestColumnIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(tileAlchemicalChest, chestColumnIndex + chestRowIndex * 13, 8 + chestColumnIndex * 18, 18 + 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) {
|
||||
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
|
||||
{
|
||||
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 44 + inventoryColumnIndex * 18, 104 + inventoryRowIndex * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Add the player's action bar slots to the container
|
||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) {
|
||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 44 + actionBarSlotIndex * 18, 162));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer var1) {
|
||||
public boolean canInteractWith(EntityPlayer var1)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -63,33 +69,43 @@ public class ContainerAlchemicalChest extends Container {
|
|||
* Callback for when the crafting gui is closed.
|
||||
*/
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityPlayer) {
|
||||
public void onContainerClosed(EntityPlayer entityPlayer)
|
||||
{
|
||||
|
||||
super.onContainerClosed(entityPlayer);
|
||||
tileAlchemicalChest.closeChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) {
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
|
||||
{
|
||||
|
||||
ItemStack newItemStack = null;
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemStack = slot.getStack();
|
||||
newItemStack = itemStack.copy();
|
||||
|
||||
if (slotIndex < CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS) {
|
||||
if (slotIndex < CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS)
|
||||
{
|
||||
if (!this.mergeItemStack(itemStack, CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemStack, 0, CHEST_INVENTORY_ROWS * CHEST_INVENTORY_COLUMNS, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemStack.stackSize == 0) {
|
||||
if (itemStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import com.pahimar.ee3.item.ItemAlchemicalDust;
|
||||
import com.pahimar.ee3.tileentity.TileAludel;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
@ -7,24 +9,22 @@ import net.minecraft.inventory.Slot;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
|
||||
import com.pahimar.ee3.item.ItemAlchemicalDust;
|
||||
import com.pahimar.ee3.tileentity.TileAludel;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ContainerAludel
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ContainerAludel extends Container {
|
||||
public class ContainerAludel extends Container
|
||||
{
|
||||
|
||||
private final int PLAYER_INVENTORY_ROWS = 3;
|
||||
private final int PLAYER_INVENTORY_COLUMNS = 9;
|
||||
|
||||
public ContainerAludel(InventoryPlayer inventoryPlayer, TileAludel tileAludel) {
|
||||
public ContainerAludel(InventoryPlayer inventoryPlayer, TileAludel tileAludel)
|
||||
{
|
||||
|
||||
this.addSlotToContainer(new Slot(tileAludel, TileAludel.FUEL_INVENTORY_INDEX, 44, 74));
|
||||
this.addSlotToContainer(new Slot(tileAludel, TileAludel.INPUT_INVENTORY_INDEX, 44, 18));
|
||||
|
@ -32,31 +32,37 @@ public class ContainerAludel extends Container {
|
|||
this.addSlotToContainer(new Slot(tileAludel, TileAludel.OUTPUT_INVENTORY_INDEX, 120, 39));
|
||||
|
||||
// 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) {
|
||||
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
|
||||
{
|
||||
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 8 + inventoryColumnIndex * 18, 106 + inventoryRowIndex * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Add the player's action bar slots to the container
|
||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) {
|
||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 164));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer var1) {
|
||||
public boolean canInteractWith(EntityPlayer var1)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) {
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
|
||||
{
|
||||
|
||||
ItemStack itemStack = null;
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
|
||||
ItemStack slotItemStack = slot.getStack();
|
||||
itemStack = slotItemStack.copy();
|
||||
|
@ -66,13 +72,16 @@ public class ContainerAludel extends Container {
|
|||
* attempt to put it in the first available slot in the player's
|
||||
* inventory
|
||||
*/
|
||||
if (slotIndex < TileAludel.INVENTORY_SIZE) {
|
||||
if (slotIndex < TileAludel.INVENTORY_SIZE)
|
||||
{
|
||||
|
||||
if (!this.mergeItemStack(slotItemStack, TileAludel.INVENTORY_SIZE, inventorySlots.size(), false)) {
|
||||
if (!this.mergeItemStack(slotItemStack, TileAludel.INVENTORY_SIZE, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
|
||||
/**
|
||||
* If the stack being shift-clicked into the Aludel's container
|
||||
|
@ -80,8 +89,10 @@ public class ContainerAludel extends Container {
|
|||
* be merged into the fuel slot, try to put it in the input
|
||||
* slot.
|
||||
*/
|
||||
if (TileEntityFurnace.isItemFuel(slotItemStack)) {
|
||||
if (!this.mergeItemStack(slotItemStack, TileAludel.FUEL_INVENTORY_INDEX, TileAludel.INPUT_INVENTORY_INDEX, false)) {
|
||||
if (TileEntityFurnace.isItemFuel(slotItemStack))
|
||||
{
|
||||
if (!this.mergeItemStack(slotItemStack, TileAludel.FUEL_INVENTORY_INDEX, TileAludel.INPUT_INVENTORY_INDEX, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -92,8 +103,10 @@ public class ContainerAludel extends Container {
|
|||
* be merged into the dust slot, try to put it in the input
|
||||
* slot.
|
||||
*/
|
||||
else if (slotItemStack.getItem() instanceof ItemAlchemicalDust) {
|
||||
if (!this.mergeItemStack(slotItemStack, TileAludel.DUST_INVENTORY_INDEX, TileAludel.OUTPUT_INVENTORY_INDEX, false)) {
|
||||
else if (slotItemStack.getItem() instanceof ItemAlchemicalDust)
|
||||
{
|
||||
if (!this.mergeItemStack(slotItemStack, TileAludel.DUST_INVENTORY_INDEX, TileAludel.OUTPUT_INVENTORY_INDEX, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -101,15 +114,18 @@ public class ContainerAludel extends Container {
|
|||
/**
|
||||
* Finally, attempt to put stack into the input slot
|
||||
*/
|
||||
else if (!this.mergeItemStack(slotItemStack, TileAludel.INPUT_INVENTORY_INDEX, TileAludel.DUST_INVENTORY_INDEX, false)) {
|
||||
else if (!this.mergeItemStack(slotItemStack, TileAludel.INPUT_INVENTORY_INDEX, TileAludel.DUST_INVENTORY_INDEX, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (slotItemStack.stackSize == 0) {
|
||||
if (slotItemStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import com.pahimar.ee3.tileentity.TileCalcinator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
@ -7,20 +8,19 @@ import net.minecraft.inventory.Slot;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
|
||||
import com.pahimar.ee3.tileentity.TileCalcinator;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ContainerCalcinator
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ContainerCalcinator extends Container {
|
||||
public class ContainerCalcinator extends Container
|
||||
{
|
||||
|
||||
public ContainerCalcinator(InventoryPlayer inventoryPlayer, TileCalcinator calcinator) {
|
||||
public ContainerCalcinator(InventoryPlayer inventoryPlayer, TileCalcinator calcinator)
|
||||
{
|
||||
|
||||
// Add the fuel slot to the container
|
||||
this.addSlotToContainer(new Slot(calcinator, TileCalcinator.FUEL_INVENTORY_INDEX, 56, 62));
|
||||
|
@ -32,31 +32,37 @@ public class ContainerCalcinator extends Container {
|
|||
this.addSlotToContainer(new SlotCalcinator(calcinator, TileCalcinator.OUTPUT_INVENTORY_INDEX, 116, 35));
|
||||
|
||||
// Add the player's inventory slots to the container
|
||||
for (int inventoryRowIndex = 0; inventoryRowIndex < 3; ++inventoryRowIndex) {
|
||||
for (int inventoryColumnIndex = 0; inventoryColumnIndex < 9; ++inventoryColumnIndex) {
|
||||
for (int inventoryRowIndex = 0; inventoryRowIndex < 3; ++inventoryRowIndex)
|
||||
{
|
||||
for (int inventoryColumnIndex = 0; inventoryColumnIndex < 9; ++inventoryColumnIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 8 + inventoryColumnIndex * 18, 94 + inventoryRowIndex * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Add the player's action bar slots to the container
|
||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < 9; ++actionBarSlotIndex) {
|
||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < 9; ++actionBarSlotIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 152));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) {
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
|
||||
{
|
||||
|
||||
ItemStack itemStack = null;
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
|
||||
ItemStack slotItemStack = slot.getStack();
|
||||
itemStack = slotItemStack.copy();
|
||||
|
@ -66,13 +72,16 @@ public class ContainerCalcinator extends Container {
|
|||
* attempt to put it in the first available slot in the player's
|
||||
* inventory
|
||||
*/
|
||||
if (slotIndex < TileCalcinator.INVENTORY_SIZE) {
|
||||
if (slotIndex < TileCalcinator.INVENTORY_SIZE)
|
||||
{
|
||||
|
||||
if (!this.mergeItemStack(slotItemStack, TileCalcinator.INVENTORY_SIZE, inventorySlots.size(), false)) {
|
||||
if (!this.mergeItemStack(slotItemStack, TileCalcinator.INVENTORY_SIZE, inventorySlots.size(), false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
|
||||
/**
|
||||
* If the stack being shift-clicked into the Aludel's container
|
||||
|
@ -80,8 +89,10 @@ public class ContainerCalcinator extends Container {
|
|||
* be merged into the fuel slot, try to put it in the input
|
||||
* slot.
|
||||
*/
|
||||
if (TileEntityFurnace.isItemFuel(slotItemStack)) {
|
||||
if (!this.mergeItemStack(slotItemStack, TileCalcinator.FUEL_INVENTORY_INDEX, TileCalcinator.OUTPUT_INVENTORY_INDEX, false)) {
|
||||
if (TileEntityFurnace.isItemFuel(slotItemStack))
|
||||
{
|
||||
if (!this.mergeItemStack(slotItemStack, TileCalcinator.FUEL_INVENTORY_INDEX, TileCalcinator.OUTPUT_INVENTORY_INDEX, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -89,15 +100,18 @@ public class ContainerCalcinator extends Container {
|
|||
/**
|
||||
* Finally, attempt to put stack into the input slot
|
||||
*/
|
||||
else if (!this.mergeItemStack(slotItemStack, TileCalcinator.INPUT_INVENTORY_INDEX, TileCalcinator.OUTPUT_INVENTORY_INDEX, false)) {
|
||||
else if (!this.mergeItemStack(slotItemStack, TileCalcinator.INPUT_INVENTORY_INDEX, TileCalcinator.OUTPUT_INVENTORY_INDEX, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (slotItemStack.stackSize == 0) {
|
||||
if (slotItemStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,76 +1,88 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import com.pahimar.ee3.tileentity.TileGlassBell;
|
||||
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;
|
||||
|
||||
import com.pahimar.ee3.tileentity.TileGlassBell;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ContainerGlassBell
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ContainerGlassBell extends Container {
|
||||
public class ContainerGlassBell extends Container
|
||||
{
|
||||
|
||||
private final int PLAYER_INVENTORY_ROWS = 3;
|
||||
private final int PLAYER_INVENTORY_COLUMNS = 9;
|
||||
|
||||
public ContainerGlassBell(InventoryPlayer inventoryPlayer, TileGlassBell tileGlassBell) {
|
||||
public ContainerGlassBell(InventoryPlayer inventoryPlayer, TileGlassBell tileGlassBell)
|
||||
{
|
||||
|
||||
this.addSlotToContainer(new Slot(tileGlassBell, TileGlassBell.DISPLAY_SLOT_INVENTORY_INDEX, 80, 22));
|
||||
|
||||
// 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) {
|
||||
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
|
||||
{
|
||||
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 8 + inventoryColumnIndex * 18, 58 + inventoryRowIndex * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Add the player's action bar slots to the container
|
||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) {
|
||||
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 116));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer var1) {
|
||||
public boolean canInteractWith(EntityPlayer var1)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) {
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
|
||||
{
|
||||
|
||||
ItemStack itemStack = null;
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack slotItemStack = slot.getStack();
|
||||
itemStack = slotItemStack.copy();
|
||||
|
||||
if (slotIndex < TileGlassBell.INVENTORY_SIZE) {
|
||||
if (slotIndex < TileGlassBell.INVENTORY_SIZE)
|
||||
{
|
||||
|
||||
if (!this.mergeItemStack(slotItemStack, 1, inventorySlots.size(), true)) {
|
||||
if (!this.mergeItemStack(slotItemStack, 1, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!this.mergeItemStack(slotItemStack, 0, TileGlassBell.INVENTORY_SIZE, false)) {
|
||||
else
|
||||
{
|
||||
if (!this.mergeItemStack(slotItemStack, 0, TileGlassBell.INVENTORY_SIZE, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (slotItemStack.stackSize == 0) {
|
||||
if (slotItemStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,46 +1,52 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import com.pahimar.ee3.core.helper.ItemStackNBTHelper;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ContainerWorkbench;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.pahimar.ee3.core.helper.ItemStackNBTHelper;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ContainerPortableCrafting
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ContainerPortableCrafting extends ContainerWorkbench {
|
||||
public class ContainerPortableCrafting extends ContainerWorkbench
|
||||
{
|
||||
|
||||
public ContainerPortableCrafting(InventoryPlayer inventoryPlayer, World world, int x, int y, int z) {
|
||||
public ContainerPortableCrafting(InventoryPlayer inventoryPlayer, World world, int x, int y, int z)
|
||||
{
|
||||
|
||||
super(inventoryPlayer, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer var1) {
|
||||
public boolean canInteractWith(EntityPlayer var1)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
public void onContainerClosed(EntityPlayer player)
|
||||
{
|
||||
|
||||
super.onContainerClosed(player);
|
||||
|
||||
if (!player.worldObj.isRemote) {
|
||||
if (!player.worldObj.isRemote)
|
||||
{
|
||||
InventoryPlayer invPlayer = player.inventory;
|
||||
for (ItemStack itemStack : invPlayer.mainInventory) {
|
||||
if (itemStack != null) {
|
||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_CRAFTING_GUI_OPEN)) {
|
||||
for (ItemStack itemStack : invPlayer.mainInventory)
|
||||
{
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_CRAFTING_GUI_OPEN))
|
||||
{
|
||||
ItemStackNBTHelper.removeTag(itemStack, Strings.NBT_ITEM_CRAFTING_GUI_OPEN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,41 +1,46 @@
|
|||
package com.pahimar.ee3.inventory;
|
||||
|
||||
import com.pahimar.ee3.core.helper.ItemStackNBTHelper;
|
||||
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.item.ItemStack;
|
||||
|
||||
import com.pahimar.ee3.core.helper.ItemStackNBTHelper;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ContainerPortableTransmutation
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ContainerPortableTransmutation extends Container {
|
||||
public class ContainerPortableTransmutation extends Container
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer var1) {
|
||||
public boolean canInteractWith(EntityPlayer var1)
|
||||
{
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
public void onContainerClosed(EntityPlayer player)
|
||||
{
|
||||
|
||||
super.onContainerClosed(player);
|
||||
|
||||
if (!player.worldObj.isRemote) {
|
||||
if (!player.worldObj.isRemote)
|
||||
{
|
||||
InventoryPlayer invPlayer = player.inventory;
|
||||
for (ItemStack itemStack : invPlayer.mainInventory) {
|
||||
if (itemStack != null) {
|
||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN)) {
|
||||
for (ItemStack itemStack : invPlayer.mainInventory)
|
||||
{
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN))
|
||||
{
|
||||
ItemStackNBTHelper.removeTag(itemStack, Strings.NBT_ITEM_TRANSMUTATION_GUI_OPEN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,22 +6,24 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* SlotCalcinator
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class SlotCalcinator extends Slot {
|
||||
public class SlotCalcinator extends Slot
|
||||
{
|
||||
|
||||
public SlotCalcinator(IInventory inventory, int x, int y, int z) {
|
||||
public SlotCalcinator(IInventory inventory, int x, int y, int z)
|
||||
{
|
||||
|
||||
super(inventory, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||
public boolean isItemValid(ItemStack par1ItemStack)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.pahimar.ee3.lib.Compare;
|
||||
|
||||
public class EnergyStack implements Comparable<EnergyStack> {
|
||||
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;
|
||||
|
@ -12,36 +13,44 @@ public class EnergyStack implements Comparable<EnergyStack> {
|
|||
public String energyName;
|
||||
public int stackSize;
|
||||
|
||||
public EnergyStack(String energyName, int stackSize) {
|
||||
public EnergyStack(String energyName, int stackSize)
|
||||
{
|
||||
|
||||
this.energyName = energyName;
|
||||
this.stackSize = stackSize;
|
||||
}
|
||||
|
||||
public EnergyStack(String energyName) {
|
||||
public EnergyStack(String energyName)
|
||||
{
|
||||
|
||||
this(energyName, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString()
|
||||
{
|
||||
return String.format("%dxenergyStack.%s", stackSize, energyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
public boolean equals(Object object)
|
||||
{
|
||||
|
||||
if (!(object instanceof EnergyStack)) {
|
||||
if (!(object instanceof EnergyStack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (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)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -50,42 +59,54 @@ public class EnergyStack implements Comparable<EnergyStack> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(EnergyStack energyStack) {
|
||||
public int compareTo(EnergyStack energyStack)
|
||||
{
|
||||
|
||||
return comparator.compare(this, energyStack);
|
||||
}
|
||||
|
||||
public static int compare(EnergyStack energyStack1, EnergyStack energyStack2) {
|
||||
|
||||
public static int compare(EnergyStack energyStack1, EnergyStack energyStack2)
|
||||
{
|
||||
return comparator.compare(energyStack1, energyStack2);
|
||||
}
|
||||
|
||||
public static Comparator<EnergyStack> comparator = new Comparator<EnergyStack>() {
|
||||
public static Comparator<EnergyStack> comparator = new Comparator<EnergyStack>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare(EnergyStack energyStack1, EnergyStack energyStack2) {
|
||||
public int compare(EnergyStack energyStack1, EnergyStack energyStack2)
|
||||
{
|
||||
|
||||
if (energyStack1 != null) {
|
||||
if (energyStack2 != null) {
|
||||
if (energyStack1.energyName.equalsIgnoreCase(energyStack2.energyName)) {
|
||||
if (energyStack1 != null)
|
||||
{
|
||||
if (energyStack2 != null)
|
||||
{
|
||||
if (energyStack1.energyName.equalsIgnoreCase(energyStack2.energyName))
|
||||
{
|
||||
return energyStack1.stackSize - energyStack2.stackSize;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return energyStack1.energyName.compareToIgnoreCase(energyStack2.energyName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return Compare.LESSER_THAN;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (energyStack2 != null) {
|
||||
else
|
||||
{
|
||||
if (energyStack2 != null)
|
||||
{
|
||||
return Compare.GREATER_THAN;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return Compare.EQUALS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,14 +4,14 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* IChargeable
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public interface IChargeable {
|
||||
public interface IChargeable
|
||||
{
|
||||
|
||||
public abstract short getCharge(ItemStack stack);
|
||||
|
||||
|
|
|
@ -5,14 +5,14 @@ import net.minecraft.item.ItemStack;
|
|||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* IKeyBound
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public interface IKeyBound {
|
||||
public interface IKeyBound
|
||||
{
|
||||
|
||||
public abstract void doKeyBindingAction(EntityPlayer thePlayer, ItemStack itemStack, String keyBinding);
|
||||
|
||||
|
|
|
@ -6,14 +6,14 @@ import net.minecraft.world.World;
|
|||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ITransmutationStone
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public interface ITransmutationStone {
|
||||
public interface ITransmutationStone
|
||||
{
|
||||
|
||||
public abstract void openPortableCraftingGUI(EntityPlayer thePlayer, ItemStack itemStack);
|
||||
|
||||
|
|
|
@ -1,39 +1,38 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
import com.pahimar.ee3.core.helper.ItemHelper;
|
||||
import com.pahimar.ee3.core.helper.ItemStackNBTHelper;
|
||||
import com.pahimar.ee3.lib.Colours;
|
||||
import com.pahimar.ee3.lib.GuiIds;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ItemAlchemicalBag
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ItemAlchemicalBag extends ItemEE {
|
||||
public class ItemAlchemicalBag extends ItemEE
|
||||
{
|
||||
|
||||
private static final String[] ALCHEMICAL_BAG_SUBTYPES = new String[] { "Open", "OpenDrawString", "Closed", "ClosedDrawString" };
|
||||
private static final String[] ALCHEMICAL_BAG_SUBTYPES = new String[] {"Open", "OpenDrawString", "Closed", "ClosedDrawString"};
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Icon[] icons;
|
||||
|
||||
public ItemAlchemicalBag(int id) {
|
||||
public ItemAlchemicalBag(int id)
|
||||
{
|
||||
|
||||
super(id);
|
||||
this.setUnlocalizedName(Strings.RESOURCE_PREFIX + Strings.ALCHEMICAL_BAG_NAME);
|
||||
|
@ -42,19 +41,23 @@ public class ItemAlchemicalBag extends ItemEE {
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister) {
|
||||
public void registerIcons(IconRegister iconRegister)
|
||||
{
|
||||
|
||||
icons = new Icon[ALCHEMICAL_BAG_SUBTYPES.length];
|
||||
|
||||
for (int i = 0; i < ALCHEMICAL_BAG_SUBTYPES.length; ++i) {
|
||||
for (int i = 0; i < ALCHEMICAL_BAG_SUBTYPES.length; ++i)
|
||||
{
|
||||
icons[i] = iconRegister.registerIcon(Strings.RESOURCE_PREFIX + Strings.ALCHEMICAL_BAG_NAME + ALCHEMICAL_BAG_SUBTYPES[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) {
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)
|
||||
{
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (!world.isRemote)
|
||||
{
|
||||
ItemStackNBTHelper.setBoolean(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN, true);
|
||||
entityPlayer.openGui(EquivalentExchange3.instance, GuiIds.ALCHEMICAL_BAG, entityPlayer.worldObj, (int) entityPlayer.posX, (int) entityPlayer.posY, (int) entityPlayer.posZ);
|
||||
}
|
||||
|
@ -63,47 +66,65 @@ public class ItemAlchemicalBag extends ItemEE {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean getShareTag() {
|
||||
public boolean getShareTag()
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
public boolean requiresMultipleRenderPasses()
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(ItemStack itemStack, int renderPass) {
|
||||
public Icon getIcon(ItemStack itemStack, int renderPass)
|
||||
{
|
||||
|
||||
// If the bag is open
|
||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN)) {
|
||||
if (ItemStackNBTHelper.hasTag(itemStack, Strings.NBT_ITEM_ALCHEMICAL_BAG_GUI_OPEN))
|
||||
{
|
||||
if (renderPass != 1)
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[1];
|
||||
}
|
||||
}
|
||||
// Else, the bag is closed
|
||||
else {
|
||||
else
|
||||
{
|
||||
if (renderPass != 1)
|
||||
{
|
||||
return icons[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
return icons[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getColorFromItemStack(ItemStack itemStack, int renderPass) {
|
||||
public int getColorFromItemStack(ItemStack itemStack, int renderPass)
|
||||
{
|
||||
|
||||
if (renderPass == 1)
|
||||
{
|
||||
return Integer.parseInt(Colours.PURE_WHITE, 16);
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
int bagColor = this.getColor(itemStack);
|
||||
|
||||
if (bagColor < 0) {
|
||||
if (bagColor < 0)
|
||||
{
|
||||
bagColor = Integer.parseInt(Colours.PURE_WHITE, 16);
|
||||
}
|
||||
|
||||
|
@ -111,39 +132,50 @@ public class ItemAlchemicalBag extends ItemEE {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean hasColor(ItemStack itemStack) {
|
||||
public boolean hasColor(ItemStack itemStack)
|
||||
{
|
||||
|
||||
return ItemHelper.hasColor(itemStack);
|
||||
}
|
||||
|
||||
public int getColor(ItemStack itemStack) {
|
||||
public int getColor(ItemStack itemStack)
|
||||
{
|
||||
|
||||
return ItemHelper.getColor(itemStack);
|
||||
}
|
||||
|
||||
public void setColor(ItemStack itemStack, int color) {
|
||||
public void setColor(ItemStack itemStack, int color)
|
||||
{
|
||||
|
||||
if (itemStack != null) {
|
||||
if (itemStack != null)
|
||||
{
|
||||
if (!(itemStack.getItem() instanceof ItemAlchemicalBag))
|
||||
// TODO Localize
|
||||
// TODO Localize
|
||||
{
|
||||
throw new UnsupportedOperationException("Cannot dye non-bags!");
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemHelper.setColor(itemStack, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeColor(ItemStack itemStack) {
|
||||
public void removeColor(ItemStack itemStack)
|
||||
{
|
||||
|
||||
if (itemStack != null) {
|
||||
if (itemStack != null)
|
||||
{
|
||||
|
||||
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
|
||||
|
||||
if (nbtTagCompound != null) {
|
||||
if (nbtTagCompound != null)
|
||||
{
|
||||
|
||||
NBTTagCompound displayTagCompound = nbtTagCompound.getCompoundTag(Strings.NBT_ITEM_DISPLAY);
|
||||
|
||||
if (displayTagCompound.hasKey(Strings.NBT_ITEM_COLOR)) {
|
||||
if (displayTagCompound.hasKey(Strings.NBT_ITEM_COLOR))
|
||||
{
|
||||
|
||||
displayTagCompound.removeTag(Strings.NBT_ITEM_COLOR);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,11 @@ package com.pahimar.ee3.item;
|
|||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
|
||||
public class ItemAlchemicalChalk extends ItemEE {
|
||||
public class ItemAlchemicalChalk extends ItemEE
|
||||
{
|
||||
|
||||
public ItemAlchemicalChalk(int id) {
|
||||
public ItemAlchemicalChalk(int id)
|
||||
{
|
||||
|
||||
super(id);
|
||||
this.setUnlocalizedName(Strings.RESOURCE_PREFIX + Strings.ALCHEMICAL_CHALK_NAME);
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -9,29 +11,26 @@ import net.minecraft.util.EnumChatFormatting;
|
|||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import com.pahimar.ee3.EquivalentExchange3;
|
||||
import com.pahimar.ee3.lib.Strings;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ItemAlchemicalDust
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ItemAlchemicalDust extends ItemEE {
|
||||
public class ItemAlchemicalDust extends ItemEE
|
||||
{
|
||||
|
||||
private static final String[] ALCHEMICAL_DUST_NAMES = new String[] { "Ash", "Minium", "Verdant", "Azure", "Amaranthine", "Iridescent" };
|
||||
private static final String[] ALCHEMICAL_DUST_NAMES = new String[] {"Ash", "Minium", "Verdant", "Azure", "Amaranthine", "Iridescent"};
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Icon[] icons;
|
||||
|
||||
public ItemAlchemicalDust(int id) {
|
||||
public ItemAlchemicalDust(int id)
|
||||
{
|
||||
|
||||
super(id);
|
||||
this.setHasSubtypes(true);
|
||||
|
@ -40,7 +39,8 @@ public class ItemAlchemicalDust extends ItemEE {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack) {
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
|
||||
StringBuilder unlocalizedName = new StringBuilder();
|
||||
int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, 5);
|
||||
|
@ -58,7 +58,8 @@ public class ItemAlchemicalDust extends ItemEE {
|
|||
/**
|
||||
* Gets an icon index based on an item's damage value
|
||||
*/
|
||||
public Icon getIconFromDamage(int meta) {
|
||||
public Icon getIconFromDamage(int meta)
|
||||
{
|
||||
|
||||
int j = MathHelper.clamp_int(meta, 0, 5);
|
||||
return icons[j];
|
||||
|
@ -66,33 +67,35 @@ public class ItemAlchemicalDust extends ItemEE {
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister) {
|
||||
public void registerIcons(IconRegister iconRegister)
|
||||
{
|
||||
|
||||
icons = new Icon[ALCHEMICAL_DUST_NAMES.length];
|
||||
|
||||
for (int i = 0; i < ALCHEMICAL_DUST_NAMES.length; ++i) {
|
||||
for (int i = 0; i < ALCHEMICAL_DUST_NAMES.length; ++i)
|
||||
{
|
||||
icons[i] = iconRegister.registerIcon(Strings.RESOURCE_PREFIX + Strings.ALCHEMICAL_DUST_NAME + ALCHEMICAL_DUST_NAMES[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean hasEffect(ItemStack stack) {
|
||||
public boolean hasEffect(ItemStack stack)
|
||||
{
|
||||
|
||||
int meta = MathHelper.clamp_int(stack.getItemDamage(), 0, 5);
|
||||
|
||||
if (meta == 5)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return meta == 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemDisplayName(ItemStack itemStack) {
|
||||
public String getItemDisplayName(ItemStack itemStack)
|
||||
{
|
||||
|
||||
int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, 5);
|
||||
|
||||
switch (meta) {
|
||||
switch (meta)
|
||||
{
|
||||
case 0:
|
||||
return EnumChatFormatting.WHITE + super.getItemDisplayName(itemStack);
|
||||
case 1:
|
||||
|
@ -111,11 +114,13 @@ public class ItemAlchemicalDust extends ItemEE {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(int id, CreativeTabs creativeTab, List list) {
|
||||
public void getSubItems(int id, CreativeTabs creativeTab, List list)
|
||||
{
|
||||
|
||||
for (int meta = 0; meta < 6; ++meta) {
|
||||
for (int meta = 0; meta < 6; ++meta)
|
||||
{
|
||||
list.add(new ItemStack(id, 1, meta));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
package com.pahimar.ee3.item;
|
||||
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import com.pahimar.ee3.lib.Reference;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ItemEE
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ItemEE extends Item {
|
||||
public class ItemEE extends Item
|
||||
{
|
||||
|
||||
public ItemEE(int id) {
|
||||
public ItemEE(int id)
|
||||
{
|
||||
|
||||
super(id - Reference.SHIFTED_ID_RANGE_CORRECTION);
|
||||
maxStackSize = 1;
|
||||
|
@ -28,7 +27,8 @@ public class ItemEE extends Item {
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister) {
|
||||
public void registerIcons(IconRegister iconRegister)
|
||||
{
|
||||
|
||||
itemIcon = iconRegister.registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1));
|
||||
}
|
||||
|
|
|
@ -5,16 +5,17 @@ import com.pahimar.ee3.lib.Strings;
|
|||
|
||||
/**
|
||||
* Equivalent-Exchange-3
|
||||
*
|
||||
* <p/>
|
||||
* ItemInertStone
|
||||
*
|
||||
*
|
||||
* @author pahimar
|
||||
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
||||
*
|
||||
*/
|
||||
public class ItemInertStone extends ItemEE {
|
||||
public class ItemInertStone extends ItemEE
|
||||
{
|
||||
|
||||
public ItemInertStone(int id) {
|
||||
public ItemInertStone(int id)
|
||||
{
|
||||
|
||||
super(id);
|
||||
this.setUnlocalizedName(Strings.RESOURCE_PREFIX + Strings.INERT_STONE_NAME);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue