More fixes of API

Fixed most of files
This commit is contained in:
TheDarkDnKTv 2020-08-11 23:51:02 +03:00
parent 364b220925
commit 43f6e8dad8
8 changed files with 123 additions and 239 deletions

View file

@ -52,7 +52,7 @@ public class GT_FoodStat implements IFoodStat {
public void onEaten(GT_MetaGenerated_Item aItem, ItemStack aStack, EntityPlayer aPlayer) { public void onEaten(GT_MetaGenerated_Item aItem, ItemStack aStack, EntityPlayer aPlayer) {
aStack.stackSize--; aStack.stackSize--;
ItemStack tStack = GT_OreDictUnificator.get(GT_Utility.copy(mEmptyContainer)); ItemStack tStack = GT_OreDictUnificator.get(GT_Utility.copy(mEmptyContainer));
if (tStack != null && !aPlayer.inventory.addItemStackToInventory(tStack)) aPlayer.dropPlayerItem(tStack); if (tStack != null && !aPlayer.inventory.addItemStackToInventory(tStack)) aPlayer.entityDropItem(tStack, 0);
aPlayer.worldObj.playSoundAtEntity(aPlayer, "random.burp", 0.5F, aPlayer.worldObj.rand.nextFloat() * 0.1F + 0.9F); aPlayer.worldObj.playSoundAtEntity(aPlayer, "random.burp", 0.5F, aPlayer.worldObj.rand.nextFloat() * 0.1F + 0.9F);
if (!aPlayer.worldObj.isRemote) { if (!aPlayer.worldObj.isRemote) {
for (int i = 3; i < mPotionEffects.length; i+=4) { for (int i = 3; i < mPotionEffects.length; i+=4) {

View file

@ -5,17 +5,21 @@ import gregtechmod.api.enums.GT_ConfigCategories;
import gregtechmod.api.enums.GT_Items; import gregtechmod.api.enums.GT_Items;
import gregtechmod.api.enums.Materials; import gregtechmod.api.enums.Materials;
import gregtechmod.api.enums.OrePrefixes; import gregtechmod.api.enums.OrePrefixes;
import gregtechmod.api.items.GT_Tool_Item;
import ic2.api.item.IBoxable; import ic2.api.item.IBoxable;
import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItem;
import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.IRecipeInput;
import ic2.api.recipe.RecipeOutput; import ic2.api.recipe.RecipeOutput;
import java.lang.reflect.Method;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -30,7 +34,7 @@ import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe;
import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
/** /**
@ -147,7 +151,7 @@ public class GT_ModHandler {
public static ItemStack getIC2Item(String aItem, long aAmount, ItemStack aReplacement) { public static ItemStack getIC2Item(String aItem, long aAmount, ItemStack aReplacement) {
if (GT_Utility.isStringInvalid(aItem) || !GregTech_API.sPreloadStarted) return null; if (GT_Utility.isStringInvalid(aItem) || !GregTech_API.sPreloadStarted) return null;
//if (GregTech_API.DEBUG_MODE) GT_Log.out.println("Requested the Item '" + aItem + "' from the IC2-API"); //if (GregTech_API.DEBUG_MODE) GT_Log.out.println("Requested the Item '" + aItem + "' from the IC2-API");
if (!sIC2ItemMap.containsKey(aItem)) try {sIC2ItemMap.put(aItem, ic2.api.item.Items.getItem(aItem));} catch (Throwable e) {/*Do nothing*/} if (!sIC2ItemMap.containsKey(aItem)) try {sIC2ItemMap.put(aItem, ic2.api.item.IC2Items.getItem(aItem));} catch (Throwable e) {/*Do nothing*/}
return GT_Utility.copyAmount(aAmount, sIC2ItemMap.get(aItem), aReplacement); return GT_Utility.copyAmount(aAmount, sIC2ItemMap.get(aItem), aReplacement);
} }
@ -157,7 +161,7 @@ public class GT_ModHandler {
public static ItemStack getIC2Item(String aItem, long aAmount, int aMeta, ItemStack aReplacement) { public static ItemStack getIC2Item(String aItem, long aAmount, int aMeta, ItemStack aReplacement) {
ItemStack rStack = getIC2Item(aItem, aAmount, aReplacement); ItemStack rStack = getIC2Item(aItem, aAmount, aReplacement);
if (rStack == null) return null; if (rStack == null) return null;
Item.feather.setDamage(rStack, aMeta); Items.feather.setDamage(rStack, aMeta);
return rStack; return rStack;
} }
@ -196,7 +200,7 @@ public class GT_ModHandler {
public static ItemStack getRCItem(String aItem, long aAmount, int aMeta) { public static ItemStack getRCItem(String aItem, long aAmount, int aMeta) {
ItemStack rStack = getRCItem(aItem, aAmount); ItemStack rStack = getRCItem(aItem, aAmount);
if (rStack == null) return null; if (rStack == null) return null;
Item.feather.setDamage(rStack, aMeta); Items.feather.setDamage(rStack, aMeta);
return rStack; return rStack;
} }
@ -206,7 +210,7 @@ public class GT_ModHandler {
public static ItemStack getRCItem(String aItem, long aAmount, int aMeta, ItemStack aReplacement) { public static ItemStack getRCItem(String aItem, long aAmount, int aMeta, ItemStack aReplacement) {
ItemStack rStack = getRCItem(aItem, aAmount, aReplacement); ItemStack rStack = getRCItem(aItem, aAmount, aReplacement);
if (rStack == null) return null; if (rStack == null) return null;
Item.feather.setDamage(rStack, aMeta); Items.feather.setDamage(rStack, aMeta);
return rStack; return rStack;
} }
@ -224,7 +228,7 @@ public class GT_ModHandler {
public static ItemStack getTEItem(String aItem, long aAmount, int aMeta) { public static ItemStack getTEItem(String aItem, long aAmount, int aMeta) {
ItemStack rStack = getTEItem(aItem, aAmount); ItemStack rStack = getTEItem(aItem, aAmount);
if (rStack == null) return null; if (rStack == null) return null;
Item.feather.setDamage(rStack, aMeta); Items.feather.setDamage(rStack, aMeta);
return rStack; return rStack;
} }
@ -241,7 +245,7 @@ public class GT_ModHandler {
public static ItemStack getTEItem(String aItem, long aAmount, int aMeta, ItemStack aReplacement) { public static ItemStack getTEItem(String aItem, long aAmount, int aMeta, ItemStack aReplacement) {
ItemStack rStack = getTEItem(aItem, aAmount, aReplacement); ItemStack rStack = getTEItem(aItem, aAmount, aReplacement);
if (rStack == null) return null; if (rStack == null) return null;
Item.feather.setDamage(rStack, aMeta); Items.feather.setDamage(rStack, aMeta);
return rStack; return rStack;
} }
@ -295,7 +299,7 @@ public class GT_ModHandler {
aOutput = GT_OreDictUnificator.get(true, aOutput); aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aOutput == null || aChance <= 0) return false; if (aOutput == null || aChance <= 0) return false;
aOutput.stackSize = 1; aOutput.stackSize = 1;
if (GT_Config.system && !GT_Utility.areStacksEqual(aOutput, new ItemStack(Item.hoeWood, 1, 0))) return false; if (GT_Config.system && !GT_Utility.areStacksEqual(aOutput, new ItemStack(Items.wooden_hoe, 1, 0))) return false;
aChance = (float)GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.scrapboxdrops, aOutput, aChance); aChance = (float)GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.scrapboxdrops, aOutput, aChance);
if (aChance <= 0) return false; if (aChance <= 0) return false;
try { try {
@ -311,19 +315,25 @@ public class GT_ModHandler {
public static boolean addToRecyclerBlackList(ItemStack aRecycledStack) { public static boolean addToRecyclerBlackList(ItemStack aRecycledStack) {
if (aRecycledStack == null) return false; if (aRecycledStack == null) return false;
try { try {
ic2.api.recipe.Recipes.recyclerBlacklist.add(GT_Utility.copy(aRecycledStack)); Class<?> recipeInputStack = Class.forName("ic2.api.recipe.RecipeInputItemStack");
} catch (Throwable e) {/*Do nothing*/} Class<?> iRecipeInput = Class.forName("ic2.api.recipe.IRecipeInput");
Method add = Class.forName("ic2.api.recipe.IListRecipeManager").getMethod("add", iRecipeInput);
Object o = recipeInputStack.getConstructor(ItemStack.class).newInstance(aRecycledStack.copy());
add.invoke(ic2.api.recipe.Recipes.recyclerBlacklist, o);
} catch (Throwable e) {}
return true; return true;
} }
/** /**
* Just simple Furnace smelting. Unbelievable how Minecraft fails at making a simple ItemStack->ItemStack mapping... * Just simple Furnace smelting. Unbelievable how Minecraft fails at making a simple ItemStack->ItemStack mapping...
*/ */
@SuppressWarnings("deprecation")
public static boolean addSmeltingRecipe(ItemStack aInput, ItemStack aOutput) { public static boolean addSmeltingRecipe(ItemStack aInput, ItemStack aOutput) {
aOutput = GT_OreDictUnificator.get(true, aOutput); aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null || GT_Utility.getContainerItem(aInput) != null) return false; if (aInput == null || aOutput == null) return false;
if (aInput.getItem().hasContainerItem()) return false;
if (!GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.smelting, aInput, true)) return false; if (!GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.smelting, aInput, true)) return false;
FurnaceRecipes.smelting().addSmelting(aInput.itemID, aInput.getItemDamage(), GT_Utility.copy(aOutput), 0.0F); FurnaceRecipes.smelting().func_151394_a(aInput.copy(), aOutput.copy(), 0.0F);
return true; return true;
} }
@ -356,12 +366,12 @@ public class GT_ModHandler {
/** /**
* LiquidTransposer Recipe for both directions * LiquidTransposer Recipe for both directions
*/ */
public static boolean addLiquidTransposerRecipe(ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aMJ) { public static boolean addLiquidTransposerRecipe(ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aRF) {
aFullContainer = GT_OreDictUnificator.get(true, aFullContainer); aFullContainer = GT_OreDictUnificator.get(true, aFullContainer);
if (aEmptyContainer == null || aFullContainer == null || aLiquid == null) return false; if (aEmptyContainer == null || aFullContainer == null || aLiquid == null) return false;
if (!GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.liquidtransposer, aFullContainer, true)) return false; if (!GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.liquidtransposer, aFullContainer, true)) return false;
try { try {
ThermalExpansion.addTransposerFill(aMJ, aEmptyContainer, aFullContainer, aLiquid, true); cofh.thermalexpansion.api.crafting.CraftingHandlers.transposer.addFillRecipe(aRF, aEmptyContainer, aFullContainer, aLiquid, true, true);
} catch(Throwable e) {/*Do nothing*/} } catch(Throwable e) {/*Do nothing*/}
return true; return true;
} }
@ -369,12 +379,12 @@ public class GT_ModHandler {
/** /**
* LiquidTransposer Recipe for filling Containers * LiquidTransposer Recipe for filling Containers
*/ */
public static boolean addLiquidTransposerFillRecipe(ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aMJ) { public static boolean addLiquidTransposerFillRecipe(ItemStack aEmptyContainer, FluidStack aLiquid, ItemStack aFullContainer, int aRF) {
aFullContainer = GT_OreDictUnificator.get(true, aFullContainer); aFullContainer = GT_OreDictUnificator.get(true, aFullContainer);
if (aEmptyContainer == null || aFullContainer == null || aLiquid == null) return false; if (aEmptyContainer == null || aFullContainer == null || aLiquid == null) return false;
if (!GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.liquidtransposerfilling, aFullContainer, true)) return false; if (!GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.liquidtransposerfilling, aFullContainer, true)) return false;
try { try {
ThermalExpansion.addTransposerFill(aMJ, aEmptyContainer, aFullContainer, aLiquid, false); cofh.thermalexpansion.api.crafting.CraftingHandlers.transposer.addFillRecipe(aRF, aEmptyContainer, aFullContainer, aLiquid, false, true);
} catch(Throwable e) {/*Do nothing*/} } catch(Throwable e) {/*Do nothing*/}
return true; return true;
} }
@ -382,12 +392,12 @@ public class GT_ModHandler {
/** /**
* LiquidTransposer Recipe for emptying Containers * LiquidTransposer Recipe for emptying Containers
*/ */
public static boolean addLiquidTransposerEmptyRecipe(ItemStack aFullContainer, FluidStack aLiquid, ItemStack aEmptyContainer, int aMJ) { public static boolean addLiquidTransposerEmptyRecipe(ItemStack aFullContainer, FluidStack aLiquid, ItemStack aEmptyContainer, int aRF) {
aEmptyContainer = GT_OreDictUnificator.get(true, aEmptyContainer); aEmptyContainer = GT_OreDictUnificator.get(true, aEmptyContainer);
if (aFullContainer == null || aEmptyContainer == null || aLiquid == null) return false; if (aFullContainer == null || aEmptyContainer == null || aLiquid == null) return false;
if (!GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.liquidtransposeremptying, aFullContainer, true)) return false; if (!GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.liquidtransposeremptying, aFullContainer, true)) return false;
try { try {
ThermalExpansion.addTransposerExtract(aMJ, aFullContainer, aEmptyContainer, aLiquid, 100, false); cofh.thermalexpansion.api.crafting.CraftingHandlers.transposer.addExtractionRecipe(aRF, aFullContainer, aEmptyContainer, aLiquid, 100, false, true);
} catch(Throwable e) {/*Do nothing*/} } catch(Throwable e) {/*Do nothing*/}
return true; return true;
} }
@ -434,7 +444,7 @@ public class GT_ModHandler {
} }
ItemStack tInput = GT_Utility.copy(aInput); ItemStack tInput = GT_Utility.copy(aInput);
Item.feather.setDamage(tInput, GregTech_API.ITEM_WILDCARD_DAMAGE); Items.feather.setDamage(tInput, GregTech_API.ITEM_WILDCARD_DAMAGE);
tObject = sPulverizerRecipes.get(GT_Utility.stackToInt(tInput)); tObject = sPulverizerRecipes.get(GT_Utility.stackToInt(tInput));
if (tObject != null) { if (tObject != null) {
return tObject; return tObject;
@ -493,14 +503,14 @@ public class GT_ModHandler {
if (Materials.Wood.contains(aOutput1)) { if (Materials.Wood.contains(aOutput1)) {
if (GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.pulverization, aInput, true)) { if (GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.pulverization, aInput, true)) {
if (aOutput2 == null) if (aOutput2 == null)
ThermalExpansion.addSawmillRecipe(80, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1)); addSawmillRecipe(GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), null, 80);
else else
ThermalExpansion.addSawmillRecipe(80, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), GT_Utility.copy(aOutput2), aChance<=0?10:aChance); addSawmillRecipe(GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), GT_Utility.copy(aOutput2), 80, aChance<=0?10:aChance);
} }
} else { } else {
if (GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.rockcrushing, aInput, true)) { if (GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.rockcrushing, aInput, true)) {
try { try {
if (aInput.itemID != Block.obsidian.blockID) { if (Block.getBlockFromItem(aInput.getItem()) != Blocks.obsidian) {
mods.railcraft.api.crafting.IRockCrusherRecipe tRecipe = mods.railcraft.api.crafting.RailcraftCraftingManager.rockCrusher.createNewRecipe(GT_Utility.copyAmount(1, aInput), aInput.getItemDamage() != GregTech_API.ITEM_WILDCARD_DAMAGE, false); mods.railcraft.api.crafting.IRockCrusherRecipe tRecipe = mods.railcraft.api.crafting.RailcraftCraftingManager.rockCrusher.createNewRecipe(GT_Utility.copyAmount(1, aInput), aInput.getItemDamage() != GregTech_API.ITEM_WILDCARD_DAMAGE, false);
tRecipe.addOutput(GT_Utility.copy(aOutput1), 1.0F/aInput.stackSize); tRecipe.addOutput(GT_Utility.copy(aOutput1), 1.0F/aInput.stackSize);
tRecipe.addOutput(GT_Utility.copy(aOutput2), (0.01F*(aChance<=0?10:aChance))/aInput.stackSize); tRecipe.addOutput(GT_Utility.copy(aOutput2), (0.01F*(aChance<=0?10:aChance))/aInput.stackSize);
@ -509,9 +519,9 @@ public class GT_ModHandler {
} }
if (GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.pulverization, aInput, true)) { if (GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.pulverization, aInput, true)) {
if (aOutput2 == null) if (aOutput2 == null)
ThermalExpansion.addPulverizerRecipe(80, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1)); addSawmillRecipe(GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), null, 80);
else else
ThermalExpansion.addPulverizerRecipe(80, GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), GT_Utility.copy(aOutput2), aChance<=0?10:aChance); addSawmillRecipe(GT_Utility.copy(aInput), GT_Utility.copy(aOutput1), GT_Utility.copy(aOutput2), 80, aChance<=0?10:aChance);
} }
} }
} }
@ -523,12 +533,20 @@ public class GT_ModHandler {
* Adds a Recipe to the Sawmills of GregTech and ThermalCraft * Adds a Recipe to the Sawmills of GregTech and ThermalCraft
*/ */
public static boolean addSawmillRecipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2) { public static boolean addSawmillRecipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2) {
return addSawmillRecipe(aInput1, aOutput1, aOutput2, 160);
}
public static boolean addSawmillRecipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, int aRF) {
return addSawmillRecipe(aInput1, aOutput1, aOutput2, aRF, 100);
}
public static boolean addSawmillRecipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, int aRF, int aChance) {
aOutput1 = GT_OreDictUnificator.get(true, aOutput1); aOutput1 = GT_OreDictUnificator.get(true, aOutput1);
aOutput2 = GT_OreDictUnificator.get(true, aOutput2); aOutput2 = GT_OreDictUnificator.get(true, aOutput2);
if (aInput1 == null || aOutput1 == null) return false; if (aInput1 == null || aOutput1 == null) return false;
if (!GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.sawmill, aInput1, true)) return false; if (!GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.sawmill, aInput1, true)) return false;
try { try {
ThermalExpansion.addSawmillRecipe(160, aInput1, aOutput1, aOutput2, 100); cofh.thermalexpansion.api.crafting.CraftingHandlers.sawmill.addRecipe(aRF, aInput1, aOutput1, aOutput2, aChance, true);
} catch(Throwable e) {/*Do nothing*/} } catch(Throwable e) {/*Do nothing*/}
GregTech_API.sRecipeAdder.addSawmillRecipe(aInput1, GT_Items.Cell_Water.get(1), aOutput1, aOutput2, GT_Items.Cell_Empty.get(1)); GregTech_API.sRecipeAdder.addSawmillRecipe(aInput1, GT_Items.Cell_Water.get(1), aOutput1, aOutput2, GT_Items.Cell_Empty.get(1));
return true; return true;
@ -555,7 +573,7 @@ public class GT_ModHandler {
if (aInput1 == null || aOutput1 == null || GT_Utility.getContainerItem(aInput1) != null) return false; if (aInput1 == null || aOutput1 == null || GT_Utility.getContainerItem(aInput1) != null) return false;
if (!GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.inductionsmelter, aInput2==null?aInput1:aOutput1, true)) return false; if (!GregTech_API.sRecipeFile.get(GT_ConfigCategories.Machines.inductionsmelter, aInput2==null?aInput1:aOutput1, true)) return false;
try { try {
ThermalExpansion.addSmelterRecipe(aEnergy, GT_Utility.copy(aInput1), aInput2==null?new ItemStack(Block.sand, 1, 0):aInput2, aOutput1, aOutput2, aChance); cofh.thermalexpansion.api.crafting.CraftingHandlers.smelter.addRecipe(aEnergy, GT_Utility.copy(aInput1), aInput2==null?new ItemStack(Blocks.sand, 1, 0):aInput2, aOutput1, aOutput2, aChance, true);
} catch(Throwable e) {/*Do nothing*/} } catch(Throwable e) {/*Do nothing*/}
return true; return true;
} }
@ -574,7 +592,7 @@ public class GT_ModHandler {
public static boolean addOreToIngotSmeltingRecipe(ItemStack aInput, ItemStack aOutput) { public static boolean addOreToIngotSmeltingRecipe(ItemStack aInput, ItemStack aOutput) {
aOutput = GT_OreDictUnificator.get(true, aOutput); aOutput = GT_OreDictUnificator.get(true, aOutput);
if (aInput == null || aOutput == null) return false; if (aInput == null || aOutput == null) return false;
FurnaceRecipes.smelting().addSmelting(aInput.itemID, aInput.getItemDamage(), GT_Utility.copy(aOutput), 0.0F); addSmeltingRecipe(aInput, GT_Utility.copy(aOutput));
return true; return true;
} }
@ -735,7 +753,7 @@ public class GT_ModHandler {
*/ */
public static boolean addCraftingRecipe(ItemStack aResult, boolean aUseIC2Handler, boolean aMirrored, boolean aBuffered, boolean aKeepNBT, Object[] aRecipe) { public static boolean addCraftingRecipe(ItemStack aResult, boolean aUseIC2Handler, boolean aMirrored, boolean aBuffered, boolean aKeepNBT, Object[] aRecipe) {
aResult = GT_OreDictUnificator.get(true, aResult); aResult = GT_OreDictUnificator.get(true, aResult);
if (aResult != null && aResult.getItemDamage() == GregTech_API.ITEM_WILDCARD_DAMAGE) Item.feather.setDamage(aResult, 0); if (aResult != null && aResult.getItemDamage() == GregTech_API.ITEM_WILDCARD_DAMAGE) Items.feather.setDamage(aResult, 0);
if (aRecipe == null || aRecipe.length <= 0) return false; if (aRecipe == null || aRecipe.length <= 0) return false;
for (byte i = 0; i < aRecipe.length; i++) { for (byte i = 0; i < aRecipe.length; i++) {
if (aRecipe[i] instanceof Enum) aRecipe[i] = aRecipe[i].toString(); if (aRecipe[i] instanceof Enum) aRecipe[i] = aRecipe[i].toString();
@ -759,7 +777,7 @@ public class GT_ModHandler {
itemMap.put(' ', null); itemMap.put(' ', null);
for (; idx < aRecipe.length; idx += 2) { for (; idx < aRecipe.length; idx += 2) {
if (aRecipe[idx] == null || aRecipe[idx + 1] == null) { if (aRecipe[idx] == null || aRecipe[idx + 1] == null) {
if (GregTech_API.DEBUG_MODE) GT_Log.err.println("WARNING: Missing Item for shaped Recipe: " + (aResult==null?"null":aResult.getDisplayName())); if (GregTech_API.DEBUG_MODE) GT_Log.log.warn("WARNING: Missing Item for shaped Recipe: " + (aResult==null?"null":aResult.getDisplayName()));
return false; return false;
} }
Character chr = (Character)aRecipe[idx]; Character chr = (Character)aRecipe[idx];
@ -780,11 +798,11 @@ public class GT_ModHandler {
tRecipe[++x] = itemMap.get(chr); tRecipe[++x] = itemMap.get(chr);
if (tRecipe[x] != null) if (tRecipe[x] != null)
if (tRecipe[x].getItemDamage() == GregTech_API.ITEM_WILDCARD_DAMAGE) if (tRecipe[x].getItemDamage() == GregTech_API.ITEM_WILDCARD_DAMAGE)
Item.feather.setDamage(tRecipe[x], 0); Items.feather.setDamage(tRecipe[x], 0);
} }
removeRecipe(tRecipe); removeRecipe(tRecipe);
break; break;
}} catch(Throwable e) {e.printStackTrace(GT_Log.err);} }} catch(Throwable e) {GT_Log.log.catching(e);}
if (aResult == null || aResult.stackSize <= 0) return false; if (aResult == null || aResult.stackSize <= 0) return false;
@ -844,7 +862,7 @@ public class GT_ModHandler {
int i = 0; int i = 0;
for (Object tObject : aRecipe) { for (Object tObject : aRecipe) {
if (tObject == null) { if (tObject == null) {
if (GregTech_API.DEBUG_MODE) GT_Log.err.println("WARNING: Missing Item for shapeless Recipe: " + (aResult==null?"null":aResult.getDisplayName())); if (GregTech_API.DEBUG_MODE) GT_Log.log.warn("WARNING: Missing Item for shapeless Recipe: " + (aResult==null?"null":aResult.getDisplayName()));
return false; return false;
} }
if (tObject instanceof ItemStack) { if (tObject instanceof ItemStack) {
@ -852,14 +870,14 @@ public class GT_ModHandler {
} else if (tObject instanceof String) { } else if (tObject instanceof String) {
tRecipe[i] = GT_OreDictUnificator.getFirstOre(tObject, 1); tRecipe[i] = GT_OreDictUnificator.getFirstOre(tObject, 1);
} else if (tObject instanceof Boolean) { } else if (tObject instanceof Boolean) {
// // TODO
} else { } else {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
i++; i++;
} }
removeRecipe(tRecipe); removeRecipe(tRecipe);
} catch(Throwable e) {e.printStackTrace(GT_Log.err);} } catch(Throwable e) {GT_Log.log.catching(e);}
if (aResult == null || aResult.stackSize <= 0) return false; if (aResult == null || aResult.stackSize <= 0) return false;
@ -887,8 +905,7 @@ public class GT_ModHandler {
*/ */
public static boolean removeFurnaceSmelting(ItemStack aInput) { public static boolean removeFurnaceSmelting(ItemStack aInput) {
if (aInput != null) { if (aInput != null) {
FurnaceRecipes.smelting().getMetaSmeltingList().remove(Arrays.asList(aInput.itemID, aInput.getItemDamage())); FurnaceRecipes.smelting().getSmeltingList().remove(aInput);
FurnaceRecipes.smelting().getSmeltingList().remove(aInput.itemID);
return true; return true;
} }
return false; return false;
@ -912,6 +929,7 @@ public class GT_ModHandler {
ItemStack rReturn = null; ItemStack rReturn = null;
InventoryCrafting aCrafting = new InventoryCrafting(new Container() {@Override public boolean canInteractWith(EntityPlayer var1) {return false;}}, 3, 3); InventoryCrafting aCrafting = new InventoryCrafting(new Container() {@Override public boolean canInteractWith(EntityPlayer var1) {return false;}}, 3, 3);
for (int i = 0; i < aRecipe.length && i < 9; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]); for (int i = 0; i < aRecipe.length && i < 9; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]);
@SuppressWarnings("unchecked")
ArrayList<IRecipe> tList = (ArrayList<IRecipe>)CraftingManager.getInstance().getRecipeList(); ArrayList<IRecipe> tList = (ArrayList<IRecipe>)CraftingManager.getInstance().getRecipeList();
for (int i = 0; i < tList.size(); i++) { for (int i = 0; i < tList.size(); i++) {
try { try {
@ -919,7 +937,7 @@ public class GT_ModHandler {
rReturn = tList.get(i).getCraftingResult(aCrafting); rReturn = tList.get(i).getCraftingResult(aCrafting);
tList.remove(i--); tList.remove(i--);
} }
} catch(Throwable e) {e.printStackTrace(GT_Log.err);} } catch(Throwable e) {GT_Log.log.catching(e);}
} }
for (int i = 0; i < sBufferRecipeList.size(); i++) { for (int i = 0; i < sBufferRecipeList.size(); i++) {
try { try {
@ -927,7 +945,7 @@ public class GT_ModHandler {
rReturn = sBufferRecipeList.get(i).getCraftingResult(aCrafting); rReturn = sBufferRecipeList.get(i).getCraftingResult(aCrafting);
sBufferRecipeList.remove(i--); sBufferRecipeList.remove(i--);
} }
} catch(Throwable e) {e.printStackTrace(GT_Log.err);} } catch(Throwable e) {GT_Log.log.catching(e);}
} }
return rReturn; return rReturn;
} }
@ -940,6 +958,7 @@ public class GT_ModHandler {
public static boolean removeRecipeByOutput(ItemStack aOutput) { public static boolean removeRecipeByOutput(ItemStack aOutput) {
if (aOutput == null) return false; if (aOutput == null) return false;
boolean rReturn = false; boolean rReturn = false;
@SuppressWarnings("unchecked")
ArrayList<IRecipe> tList = (ArrayList<IRecipe>)CraftingManager.getInstance().getRecipeList(); ArrayList<IRecipe> tList = (ArrayList<IRecipe>)CraftingManager.getInstance().getRecipeList();
aOutput = GT_OreDictUnificator.get(aOutput); aOutput = GT_OreDictUnificator.get(aOutput);
for (int i = 0; i < tList.size(); i++) { for (int i = 0; i < tList.size(); i++) {
@ -967,6 +986,7 @@ public class GT_ModHandler {
if (!temp) return null; if (!temp) return null;
InventoryCrafting aCrafting = new InventoryCrafting(new Container() {@Override public boolean canInteractWith(EntityPlayer var1) {return false;}}, 3, 3); InventoryCrafting aCrafting = new InventoryCrafting(new Container() {@Override public boolean canInteractWith(EntityPlayer var1) {return false;}}, 3, 3);
for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]); for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]);
@SuppressWarnings("unchecked")
List<IRecipe> tList = CraftingManager.getInstance().getRecipeList(); List<IRecipe> tList = CraftingManager.getInstance().getRecipeList();
synchronized(sAllRecipeList) { synchronized(sAllRecipeList) {
if (sAllRecipeList.size() != tList.size()) { if (sAllRecipeList.size() != tList.size()) {
@ -1000,7 +1020,7 @@ public class GT_ModHandler {
assert tStack1 != null && tStack2 != null; assert tStack1 != null && tStack2 != null;
if (tStack1.getItem() == tStack2.getItem() && tStack1.stackSize == 1 && tStack2.stackSize == 1 && tStack1.getItem().isRepairable()) { if (tStack1.getItem() == tStack2.getItem() && tStack1.stackSize == 1 && tStack2.stackSize == 1 && tStack1.getItem().isRepairable()) {
int tNewDamage = tStack1.getMaxDamage() + tStack1.getItemDamage() - tStack2.getItemDamage() + tStack1.getMaxDamage() / 20; int tNewDamage = tStack1.getMaxDamage() + tStack1.getItemDamage() - tStack2.getItemDamage() + tStack1.getMaxDamage() / 20;
return new ItemStack(tStack1.itemID, 1, tNewDamage<0?0:tNewDamage); return new ItemStack(tStack1.getItem(), 1, tNewDamage<0?0:tNewDamage);
} }
} }
@ -1032,11 +1052,12 @@ public class GT_ModHandler {
InventoryCrafting aCrafting = new InventoryCrafting(new Container() {@Override InventoryCrafting aCrafting = new InventoryCrafting(new Container() {@Override
public boolean canInteractWith(EntityPlayer var1) {return false;}}, 3, 3); public boolean canInteractWith(EntityPlayer var1) {return false;}}, 3, 3);
for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]); for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]);
@SuppressWarnings("unchecked")
ArrayList<IRecipe> tList = (ArrayList<IRecipe>)CraftingManager.getInstance().getRecipeList(); ArrayList<IRecipe> tList = (ArrayList<IRecipe>)CraftingManager.getInstance().getRecipeList();
for (int i = 0; i < tList.size(); i++) {temp = false; for (int i = 0; i < tList.size(); i++) {temp = false;
try { try {
temp = tList.get(i).matches(aCrafting, GregTech_API.sDummyWorld); temp = tList.get(i).matches(aCrafting, GregTech_API.sDummyWorld);
} catch(Throwable e) {e.printStackTrace(GT_Log.err);} } catch(Throwable e) {GT_Log.log.catching(e);}
if (temp) { if (temp) {
ItemStack tOutput = aUncopiedStack?tList.get(i).getRecipeOutput():tList.get(i).getCraftingResult(aCrafting); ItemStack tOutput = aUncopiedStack?tList.get(i).getRecipeOutput():tList.get(i).getCraftingResult(aCrafting);
if (tOutput == null || tOutput.stackSize <= 0) { if (tOutput == null || tOutput.stackSize <= 0) {
@ -1056,6 +1077,7 @@ public class GT_ModHandler {
* If you have multiple Mods, which add Bronze Armor for example * If you have multiple Mods, which add Bronze Armor for example
* This also removes old Recipes from the List. * This also removes old Recipes from the List.
*/ */
@SuppressWarnings("unchecked")
public static ArrayList<ItemStack> getVanillyToolRecipeOutputs(ItemStack... aRecipe) { public static ArrayList<ItemStack> getVanillyToolRecipeOutputs(ItemStack... aRecipe) {
if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) sSingleNonBlockDamagableRecipeList.clear(); if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) sSingleNonBlockDamagableRecipeList.clear();
if (sSingleNonBlockDamagableRecipeList.isEmpty()) { if (sSingleNonBlockDamagableRecipeList.isEmpty()) {
@ -1087,7 +1109,7 @@ public class GT_ModHandler {
} }
} }
} }
GT_Log.out.println("GT_Mod: Created a List of Tool Recipes containing " + sSingleNonBlockDamagableRecipeList.size() + " Recipes for recycling." + (sSingleNonBlockDamagableRecipeList.size()>2048?" Scanning all these Recipes is the reason for the startup Lag you receive right now.":"")); GT_Log.log.info("GT_Mod: Created a List of Tool Recipes containing " + sSingleNonBlockDamagableRecipeList.size() + " Recipes for recycling." + (sSingleNonBlockDamagableRecipeList.size()>2048?" Scanning all these Recipes is the reason for the startup Lag you receive right now.":""));
} }
ArrayList<ItemStack> rList = getRecipeOutputs(sSingleNonBlockDamagableRecipeList, true, aRecipe); ArrayList<ItemStack> rList = getRecipeOutputs(sSingleNonBlockDamagableRecipeList, true, aRecipe);
if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) sSingleNonBlockDamagableRecipeList.clear(); if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) sSingleNonBlockDamagableRecipeList.clear();
@ -1098,6 +1120,7 @@ public class GT_ModHandler {
* Gives you a list of the Outputs from a Crafting Recipe * Gives you a list of the Outputs from a Crafting Recipe
* If you have multiple Mods, which add Bronze Armor for example * If you have multiple Mods, which add Bronze Armor for example
*/ */
@SuppressWarnings("unchecked")
public static ArrayList<ItemStack> getRecipeOutputs(ItemStack... aRecipe) { public static ArrayList<ItemStack> getRecipeOutputs(ItemStack... aRecipe) {
return getRecipeOutputs(CraftingManager.getInstance().getRecipeList(), false, aRecipe); return getRecipeOutputs(CraftingManager.getInstance().getRecipeList(), false, aRecipe);
} }
@ -1124,7 +1147,7 @@ public class GT_ModHandler {
temp = false; temp = false;
try { try {
temp = aList.get(i).matches(aCrafting, GregTech_API.sDummyWorld); temp = aList.get(i).matches(aCrafting, GregTech_API.sDummyWorld);
} catch(Throwable e) {e.printStackTrace(GT_Log.err);} } catch(Throwable e) {GT_Log.log.catching(e);}
if (temp) { if (temp) {
ItemStack tOutput = aList.get(i).getCraftingResult(aCrafting); ItemStack tOutput = aList.get(i).getCraftingResult(aCrafting);
if (tOutput == null || tOutput.stackSize <= 0) { if (tOutput == null || tOutput.stackSize <= 0) {
@ -1206,7 +1229,7 @@ public class GT_ModHandler {
} }
} }
} catch(Throwable e) { } catch(Throwable e) {
if (GregTech_API.DEBUG_MODE) e.printStackTrace(GT_Log.err); if (GregTech_API.DEBUG_MODE) GT_Log.log.catching(e);
} }
return new ItemStack[aOutputSlots.length]; return new ItemStack[aOutputSlots.length];
} }
@ -1243,14 +1266,11 @@ public class GT_ModHandler {
try { try {
Object temp = GT_Utility.callPublicMethod(aTileEntity, "isAddedToEnergyNet"); Object temp = GT_Utility.callPublicMethod(aTileEntity, "isAddedToEnergyNet");
if (aTileEntity instanceof ic2.api.energy.tile.IEnergyTile && temp != null && temp instanceof Boolean && !((Boolean)temp)) { if (aTileEntity instanceof ic2.api.energy.tile.IEnergyTile && temp != null && temp instanceof Boolean && !((Boolean)temp)) {
net.minecraftforge.event.Event tEvent = (net.minecraftforge.event.Event)Class.forName("ic2.api.energy.event.EnergyTileLoadEvent").getConstructors()[0].newInstance((ic2.api.energy.tile.IEnergyTile)aTileEntity); Event tEvent = (Event)Class.forName("ic2.api.energy.event.EnergyTileLoadEvent").getConstructors()[0].newInstance((ic2.api.energy.tile.IEnergyTile)aTileEntity);
MinecraftForge.EVENT_BUS.post(tEvent); MinecraftForge.EVENT_BUS.post(tEvent);
return true; return true;
} }
} catch(Throwable e) { } catch(Throwable e) {}
GT_Log.err.println("E-net Error. Please report to GregTech ASAP!");
e.printStackTrace(GT_Log.err);
}
return false; return false;
} }
@ -1261,14 +1281,11 @@ public class GT_ModHandler {
try { try {
Object temp = GT_Utility.callPublicMethod(aTileEntity, "isAddedToEnergyNet"); Object temp = GT_Utility.callPublicMethod(aTileEntity, "isAddedToEnergyNet");
if (aTileEntity instanceof ic2.api.energy.tile.IEnergyTile && temp != null && temp instanceof Boolean && (Boolean)temp) { if (aTileEntity instanceof ic2.api.energy.tile.IEnergyTile && temp != null && temp instanceof Boolean && (Boolean)temp) {
net.minecraftforge.event.Event tEvent = (net.minecraftforge.event.Event)Class.forName("ic2.api.energy.event.EnergyTileUnloadEvent").getConstructors()[0].newInstance((ic2.api.energy.tile.IEnergyTile)aTileEntity); Event tEvent = (Event)Class.forName("ic2.api.energy.event.EnergyTileUnloadEvent").getConstructors()[0].newInstance((ic2.api.energy.tile.IEnergyTile)aTileEntity);
MinecraftForge.EVENT_BUS.post(tEvent); MinecraftForge.EVENT_BUS.post(tEvent);
return true; return true;
} }
} catch(Throwable e) { } catch(Throwable e) {}
GT_Log.err.println("E-net Error. Please report to GregTech ASAP!");
e.printStackTrace(GT_Log.err);
}
return false; return false;
} }
@ -1304,7 +1321,7 @@ public class GT_ModHandler {
* Charges an Electric Item. Only if it's a valid Electric Item of course. * Charges an Electric Item. Only if it's a valid Electric Item of course.
* @return the actually used Energy. * @return the actually used Energy.
*/ */
public static int chargeElectricItem(ItemStack aStack, int aCharge, int aTier, boolean aIgnoreLimit, boolean aSimulate) { public static double chargeElectricItem(ItemStack aStack, double aCharge, int aTier, boolean aIgnoreLimit, boolean aSimulate) {
try { try {
if (isElectricItem(aStack)) { if (isElectricItem(aStack)) {
return ic2.api.item.ElectricItem.manager.charge(aStack, aCharge, aTier, aIgnoreLimit, aSimulate); return ic2.api.item.ElectricItem.manager.charge(aStack, aCharge, aTier, aIgnoreLimit, aSimulate);
@ -1317,11 +1334,11 @@ public class GT_ModHandler {
* Discharges an Electric Item. Only if it's a valid Electric Item for that of course. * Discharges an Electric Item. Only if it's a valid Electric Item for that of course.
* @return the Energy got from the Item. * @return the Energy got from the Item.
*/ */
public static int dischargeElectricItem(ItemStack aStack, int aCharge, int aTier, boolean aIgnoreLimit, boolean aSimulate, boolean aIgnoreDischargability) { public static double dischargeElectricItem(ItemStack aStack, double aCharge, int aTier, boolean aIgnoreLimit, boolean externally, boolean aSimulate, boolean aIgnoreDischargability) {
try { try {
if (isElectricItem(aStack)) { if (isElectricItem(aStack)) {
if (aIgnoreDischargability || ((ic2.api.item.IElectricItem)aStack.getItem()).canProvideEnergy(aStack)) { if (aIgnoreDischargability || ((ic2.api.item.IElectricItem)aStack.getItem()).canProvideEnergy(aStack)) {
return ic2.api.item.ElectricItem.manager.discharge(aStack, aCharge, aTier, aIgnoreLimit, aSimulate); return ic2.api.item.ElectricItem.manager.discharge(aStack, aCharge, aTier, aIgnoreLimit, externally, aSimulate);
} }
} }
} catch (Throwable e) {/*Do nothing*/} } catch (Throwable e) {/*Do nothing*/}
@ -1332,7 +1349,7 @@ public class GT_ModHandler {
* Gets the max Charge Level of an Electric Item. Only if it's a valid Electric Item for that of course. * Gets the max Charge Level of an Electric Item. Only if it's a valid Electric Item for that of course.
* @return the Energy got from the Item. * @return the Energy got from the Item.
*/ */
public static int getMaxElectricCharge(ItemStack aStack) { public static double getMaxElectricCharge(ItemStack aStack) {
try { try {
if (isElectricItem(aStack)) { if (isElectricItem(aStack)) {
return ((ic2.api.item.IElectricItem)aStack.getItem()).getMaxCharge(aStack); return ((ic2.api.item.IElectricItem)aStack.getItem()).getMaxCharge(aStack);
@ -1373,6 +1390,7 @@ public class GT_ModHandler {
/** /**
* Uses an Item. Tries to discharge in case of Electric Items * Uses an Item. Tries to discharge in case of Electric Items
*/ */
@SuppressWarnings("deprecation")
public static boolean damageOrDechargeItem(ItemStack aStack, int aDamage, int aDecharge, EntityLivingBase aPlayer) { public static boolean damageOrDechargeItem(ItemStack aStack, int aDamage, int aDecharge, EntityLivingBase aPlayer) {
if (GT_Utility.isStackInvalid(aStack) || (aStack.getMaxStackSize() <= 1 && aStack.stackSize > 1)) return false; if (GT_Utility.isStackInvalid(aStack) || (aStack.getMaxStackSize() <= 1 && aStack.stackSize > 1)) return false;
if (aPlayer != null && aPlayer instanceof EntityPlayer && ((EntityPlayer)aPlayer).capabilities.isCreativeMode) return true; if (aPlayer != null && aPlayer instanceof EntityPlayer && ((EntityPlayer)aPlayer).capabilities.isCreativeMode) return true;
@ -1380,8 +1398,9 @@ public class GT_ModHandler {
if (canUseElectricItem(aStack, aDecharge)) { if (canUseElectricItem(aStack, aDecharge)) {
if (aPlayer != null && aPlayer instanceof EntityPlayer) { if (aPlayer != null && aPlayer instanceof EntityPlayer) {
return GT_ModHandler.useElectricItem(aStack, aDecharge, (EntityPlayer)aPlayer); return GT_ModHandler.useElectricItem(aStack, aDecharge, (EntityPlayer)aPlayer);
} else {
return GT_ModHandler.dischargeElectricItem(aStack, aDecharge, Integer.MAX_VALUE, true, false, false, true) >= aDecharge;
} }
return GT_ModHandler.dischargeElectricItem(aStack, aDecharge, Integer.MAX_VALUE, true, false, true) >= aDecharge;
} }
} else if (aStack.getItem().isDamageable()) { } else if (aStack.getItem().isDamageable()) {
if (aPlayer == null) { if (aPlayer == null) {
@ -1390,15 +1409,10 @@ public class GT_ModHandler {
aStack.damageItem(aDamage, aPlayer); aStack.damageItem(aDamage, aPlayer);
} }
if (aStack.getItemDamage() >= aStack.getMaxDamage()) { if (aStack.getItemDamage() >= aStack.getMaxDamage()) {
aStack.setItemDamage(aStack.getMaxDamage()+1); aStack.setItemDamage(aStack.getMaxDamage() + 1);
if (GT_Utility.getContainerItem(aStack) != null) { if (aStack.getItem().hasContainerItem() && aStack.getItem() instanceof GT_Tool_Item) {
ItemStack tStack = aStack.getItem().getContainerItemStack(aStack); GT_Tool_Item item = (GT_Tool_Item) aStack.getItem();
if (tStack != null) { item.getEmptyItem(aStack);
aStack.itemID = tStack.itemID;
aStack.setItemDamage(tStack.getItemDamage());
aStack.stackSize = tStack.stackSize;
aStack.setTagCompound(tStack.getTagCompound());
}
} }
} }
return true; return true;
@ -1478,16 +1492,13 @@ public class GT_ModHandler {
return false; return false;
} }
public static boolean acceptsMJ(TileEntity aTileEntity) { public static boolean acceptsRF(TileEntity aTileEntity) {
try { try {
return aTileEntity instanceof buildcraft.api.power.IPowerReceptor; Class<?> api = Class.forName("cofh.api.energy.IEnergyReceiver");
} catch (Throwable e) {/*Do nothing*/} if (api != null && api.isAssignableFrom(aTileEntity.getClass())) {
return false; return true;
} }
public static boolean acceptsUE(TileEntity aTileEntity) {
try {
return aTileEntity instanceof universalelectricity.core.block.IElectricalStorage;
} catch (Throwable e) {/*Do nothing*/} } catch (Throwable e) {/*Do nothing*/}
return false; return false;
} }
@ -1520,148 +1531,4 @@ public class GT_ModHandler {
if (GT_Utility.areStacksEqual(aStack, getIC2Item("hydratedCoalCell", 1, GregTech_API.ITEM_WILDCARD_DAMAGE))) return 1; if (GT_Utility.areStacksEqual(aStack, getIC2Item("hydratedCoalCell", 1, GregTech_API.ITEM_WILDCARD_DAMAGE))) return 1;
return 0; return 0;
} }
/**
* Copy of the original Helper Class of Thermal Expansion, just to make sure it works even when other Mods include TE-APIs
*/
public static class ThermalExpansion {
public static void addFurnaceRecipe(int energy, ItemStack input, ItemStack output) {
NBTTagCompound toSend = new NBTTagCompound();
toSend.setInteger("energy", energy);
toSend.setCompoundTag("input", new NBTTagCompound());
toSend.setCompoundTag("output", new NBTTagCompound());
input.writeToNBT(toSend.getCompoundTag("input"));
output.writeToNBT(toSend.getCompoundTag("output"));
FMLInterModComms.sendMessage("ThermalExpansion", "FurnaceRecipe", toSend);
}
public static void addPulverizerRecipe(int energy, ItemStack input, ItemStack primaryOutput) {
addPulverizerRecipe(energy, input, primaryOutput, null, 0);
}
public static void addPulverizerRecipe(int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput) {
addPulverizerRecipe(energy, input, primaryOutput, secondaryOutput, 100);
}
public static void addPulverizerRecipe(int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance) {
NBTTagCompound toSend = new NBTTagCompound();
toSend.setInteger("energy", energy);
toSend.setCompoundTag("input", new NBTTagCompound());
toSend.setCompoundTag("primaryOutput", new NBTTagCompound());
toSend.setCompoundTag("secondaryOutput", new NBTTagCompound());
input.writeToNBT(toSend.getCompoundTag("input"));
primaryOutput.writeToNBT(toSend.getCompoundTag("primaryOutput"));
if (secondaryOutput != null) secondaryOutput.writeToNBT(toSend.getCompoundTag("secondaryOutput"));
toSend.setInteger("secondaryChance", secondaryChance);
FMLInterModComms.sendMessage("ThermalExpansion", "PulverizerRecipe", toSend);
}
public static void addSawmillRecipe(int energy, ItemStack input, ItemStack primaryOutput) {
addSawmillRecipe(energy, input, primaryOutput, null, 0);
}
public static void addSawmillRecipe(int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput) {
addSawmillRecipe(energy, input, primaryOutput, secondaryOutput, 100);
}
public static void addSawmillRecipe(int energy, ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance) {
NBTTagCompound toSend = new NBTTagCompound();
toSend.setInteger("energy", energy);
toSend.setCompoundTag("input", new NBTTagCompound());
toSend.setCompoundTag("primaryOutput", new NBTTagCompound());
toSend.setCompoundTag("secondaryOutput", new NBTTagCompound());
input.writeToNBT(toSend.getCompoundTag("input"));
primaryOutput.writeToNBT(toSend.getCompoundTag("primaryOutput"));
if (secondaryOutput != null) secondaryOutput.writeToNBT(toSend.getCompoundTag("secondaryOutput"));
toSend.setInteger("secondaryChance", secondaryChance);
FMLInterModComms.sendMessage("ThermalExpansion", "SawmillRecipe", toSend);
}
public static void addSmelterRecipe(int energy, ItemStack primaryInput, ItemStack secondaryInput, ItemStack primaryOutput) {
addSmelterRecipe(energy, primaryInput, secondaryInput, primaryOutput, null, 0);
}
public static void addSmelterRecipe(int energy, ItemStack primaryInput, ItemStack secondaryInput, ItemStack primaryOutput, ItemStack secondaryOutput) {
addSmelterRecipe(energy, primaryInput, secondaryInput, primaryOutput, secondaryOutput, 100);
}
public static void addSmelterRecipe(int energy, ItemStack primaryInput, ItemStack secondaryInput, ItemStack primaryOutput, ItemStack secondaryOutput, int secondaryChance) {
NBTTagCompound toSend = new NBTTagCompound();
toSend.setInteger("energy", energy);
toSend.setCompoundTag("primaryInput", new NBTTagCompound());
toSend.setCompoundTag("secondaryInput", new NBTTagCompound());
toSend.setCompoundTag("primaryOutput", new NBTTagCompound());
toSend.setCompoundTag("secondaryOutput", new NBTTagCompound());
primaryInput.writeToNBT(toSend.getCompoundTag("primaryInput"));
secondaryInput.writeToNBT(toSend.getCompoundTag("secondaryInput"));
primaryOutput.writeToNBT(toSend.getCompoundTag("primaryOutput"));
if (secondaryOutput != null) secondaryOutput.writeToNBT(toSend.getCompoundTag("secondaryOutput"));
toSend.setInteger("secondaryChance", secondaryChance);
FMLInterModComms.sendMessage("ThermalExpansion", "SmelterRecipe", toSend);
}
public static void addSmelterBlastOre(Materials aMaterial) {
NBTTagCompound toSend = new NBTTagCompound();
toSend.setString("oreType", aMaterial.toString());
FMLInterModComms.sendMessage("ThermalExpansion", "SmelterBlastOreType", toSend);
}
public static void addCrucibleRecipe(int energy, ItemStack input, FluidStack output) {
NBTTagCompound toSend = new NBTTagCompound();
toSend.setInteger("energy", energy);
toSend.setCompoundTag("input", new NBTTagCompound());
toSend.setCompoundTag("output", new NBTTagCompound());
input.writeToNBT(toSend.getCompoundTag("input"));
output.writeToNBT(toSend.getCompoundTag("output"));
FMLInterModComms.sendMessage("ThermalExpansion", "CrucibleRecipe", toSend);
}
public static void addTransposerFill(int energy, ItemStack input, ItemStack output, FluidStack fluid, boolean reversible) {
NBTTagCompound toSend = new NBTTagCompound();
toSend.setInteger("energy", energy);
toSend.setCompoundTag("input", new NBTTagCompound());
toSend.setCompoundTag("output", new NBTTagCompound());
toSend.setCompoundTag("fluid", new NBTTagCompound());
input.writeToNBT(toSend.getCompoundTag("input"));
output.writeToNBT(toSend.getCompoundTag("output"));
toSend.setBoolean("reversible", reversible);
fluid.writeToNBT(toSend.getCompoundTag("fluid"));
FMLInterModComms.sendMessage("ThermalExpansion", "TransposerFillRecipe", toSend);
}
public static void addTransposerExtract(int energy, ItemStack input, ItemStack output, FluidStack fluid, int chance, boolean reversible) {
NBTTagCompound toSend = new NBTTagCompound();
toSend.setInteger("energy", energy);
toSend.setCompoundTag("input", new NBTTagCompound());
toSend.setCompoundTag("output", new NBTTagCompound());
toSend.setCompoundTag("fluid", new NBTTagCompound());
input.writeToNBT(toSend.getCompoundTag("input"));
output.writeToNBT(toSend.getCompoundTag("output"));
toSend.setBoolean("reversible", reversible);
toSend.setInteger("chance", chance);
fluid.writeToNBT(toSend.getCompoundTag("fluid"));
FMLInterModComms.sendMessage("ThermalExpansion", "TransposerExtractRecipe", toSend);
}
public static void addMagmaticFuel(String fluidName, int energy) {
NBTTagCompound toSend = new NBTTagCompound();
toSend.setString("fluidName", fluidName);
toSend.setInteger("energy", energy);
FMLInterModComms.sendMessage("ThermalExpansion", "MagmaticFuel", toSend);
}
public static void addCompressionFuel(String fluidName, int energy) {
NBTTagCompound toSend = new NBTTagCompound();
toSend.setString("fluidName", fluidName);
toSend.setInteger("energy", energy);
FMLInterModComms.sendMessage("ThermalExpansion", "CompressionFuel", toSend);
}
public static void addCoolant(String fluidName, int energy) {
NBTTagCompound toSend = new NBTTagCompound();
toSend.setString("fluidName", fluidName);
toSend.setInteger("energy", energy);
FMLInterModComms.sendMessage("ThermalExpansion", "Coolant", toSend);
}
}
} }

View file

@ -72,7 +72,7 @@ public class GT_OreDictUnificator {
public static ItemStack getFirstOre(Object aName, long aAmount) { public static ItemStack getFirstOre(Object aName, long aAmount) {
if (GT_Utility.isStringInvalid(aName)) return null; if (GT_Utility.isStringInvalid(aName)) return null;
if (GT_Utility.isStackValid(sName2OreMap.get(aName.toString()))) return GT_Utility.copyAmount(aAmount, sName2OreMap.get(aName.toString())); if (GT_Utility.isStackValid(sName2OreMap.get(aName.toString()))) return GT_Utility.copyAmount(aAmount, sName2OreMap.get(aName.toString()));
return GT_Utility.copyAmount(aAmount, getOres(aName).toArray()); return GT_Utility.copyAmount(aAmount, getOres(aName).toArray(new ItemStack[0]));
} }
public static ItemStack get(Object aName, long aAmount) { public static ItemStack get(Object aName, long aAmount) {
@ -104,7 +104,7 @@ public class GT_OreDictUnificator {
public static ItemStack[] getStackArray(boolean aUseBlackList, Object... aStacks) { public static ItemStack[] getStackArray(boolean aUseBlackList, Object... aStacks) {
ItemStack[] rStacks = new ItemStack[aStacks.length]; ItemStack[] rStacks = new ItemStack[aStacks.length];
for (int i = 0; i < aStacks.length; i++) rStacks[i] = get(aUseBlackList, GT_Utility.copy(aStacks[i])); for (int i = 0; i < aStacks.length; i++) rStacks[i] = get(aUseBlackList, GT_Utility.copy((ItemStack)aStacks[i]));
return rStacks; return rStacks;
} }

View file

@ -14,7 +14,7 @@ public class GT_Shaped_Recipe extends ShapedOreRecipe {
ItemStack rStack = super.getCraftingResult(aGrid); ItemStack rStack = super.getCraftingResult(aGrid);
if (rStack != null) { if (rStack != null) {
int tCharge = 0; int tCharge = 0;
for (int i = 0; i < aGrid.getSizeInventory(); i++) tCharge += GT_ModHandler.dischargeElectricItem(aGrid.getStackInSlot(i), Integer.MAX_VALUE, Integer.MAX_VALUE - 1, true, true, true); for (int i = 0; i < aGrid.getSizeInventory(); i++) tCharge += GT_ModHandler.dischargeElectricItem(aGrid.getStackInSlot(i), Integer.MAX_VALUE, Integer.MAX_VALUE - 1, true, false, true, true);
GT_ModHandler.chargeElectricItem(rStack, tCharge, Integer.MAX_VALUE, true, false); GT_ModHandler.chargeElectricItem(rStack, tCharge, Integer.MAX_VALUE, true, false);
} }
return rStack; return rStack;

View file

@ -14,7 +14,7 @@ public class GT_Shapeless_Recipe extends ShapelessOreRecipe {
ItemStack rStack = super.getCraftingResult(aGrid); ItemStack rStack = super.getCraftingResult(aGrid);
if (rStack != null) { if (rStack != null) {
int tCharge = 0; int tCharge = 0;
for (int i = 0; i < aGrid.getSizeInventory(); i++) tCharge += GT_ModHandler.dischargeElectricItem(aGrid.getStackInSlot(i), Integer.MAX_VALUE, Integer.MAX_VALUE - 1, true, true, true); for (int i = 0; i < aGrid.getSizeInventory(); i++) tCharge += GT_ModHandler.dischargeElectricItem(aGrid.getStackInSlot(i), Integer.MAX_VALUE, Integer.MAX_VALUE - 1, true, false, true, true);
GT_ModHandler.chargeElectricItem(rStack, tCharge, Integer.MAX_VALUE, true, false); GT_ModHandler.chargeElectricItem(rStack, tCharge, Integer.MAX_VALUE, true, false);
} }
return rStack; return rStack;

View file

@ -960,6 +960,16 @@ public class GT_Utility {
return null; return null;
} }
public static ItemStack copy(int amount, ItemStack stack) {
if (amount >= 0 && stack != null) {
ItemStack copy = stack.copy();
copy.stackSize = amount;
return copy;
}
return null;
}
public static ItemStack copyAmount(long aAmount, ItemStack... aStacks) { public static ItemStack copyAmount(long aAmount, ItemStack... aStacks) {
ItemStack rStack = copy(aStacks); ItemStack rStack = copy(aStacks);
if (isStackInvalid(rStack)) return null; if (isStackInvalid(rStack)) return null;

View file

@ -78,7 +78,7 @@ public class GT_Debug_Item extends GT_Generic_Item implements IElectricItem {
public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ) { public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ) {
if (aPlayer.isSneaking()) { if (aPlayer.isSneaking()) {
if (aWorld.isRemote) { if (aWorld.isRemote) {
GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(108), 1.0F, aX, aY, aZ); GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(108), 1, 1.0F, aX, aY, aZ);
this.debug(aStack, aPlayer, aX, aY, aZ, aSide, aClickX, aClickY, aClickZ, Side.CLIENT); this.debug(aStack, aPlayer, aX, aY, aZ, aSide, aClickX, aClickY, aClickZ, Side.CLIENT);
return true; return true;
} else return false; } else return false;
@ -87,7 +87,7 @@ public class GT_Debug_Item extends GT_Generic_Item implements IElectricItem {
this.debug(aStack, aPlayer, aX, aY, aZ, aSide, aClickX, aClickY, aClickZ, Side.SERVER); this.debug(aStack, aPlayer, aX, aY, aZ, aSide, aClickX, aClickY, aClickZ, Side.SERVER);
return true; return true;
} else { } else {
GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(108), 1.0F, aX, aY, aZ); GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(108), 1, 1.0F, aX, aY, aZ);
return false; return false;
} }
} }
@ -96,7 +96,7 @@ public class GT_Debug_Item extends GT_Generic_Item implements IElectricItem {
private void debug(ItemStack aStack, EntityPlayer aPlayer, int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ, Side side) { private void debug(ItemStack aStack, EntityPlayer aPlayer, int aX, int aY, int aZ, int aSide, float aClickX, float aClickY, float aClickZ, Side side) {
ArrayList<String> tList = new ArrayList<String>(); ArrayList<String> tList = new ArrayList<String>();
tList.add("====================="); tList.add("=====================");
tList.add(String.format("%s-sided info", side.isClient() ? "§aCLIENT" : "§cSERVER")); tList.add(String.format("%s-sided info", side.isClient() ? "<EFBFBD>aCLIENT" : "<EFBFBD>cSERVER"));
GT_ModHandler.useElectricItem(aStack, GT_Utility.getCoordinateScan(tList, aPlayer, aPlayer.worldObj, 1, aX, aY, aZ, aSide, aClickX, aClickY, aClickZ), aPlayer); GT_ModHandler.useElectricItem(aStack, GT_Utility.getCoordinateScan(tList, aPlayer, aPlayer.worldObj, 1, aX, aY, aZ, aSide, aClickX, aClickY, aClickZ), aPlayer);
for (int i = 0; i < tList.size(); i++) GT_Utility.sendChatToPlayer(aPlayer, tList.get(i)); for (int i = 0; i < tList.size(); i++) GT_Utility.sendChatToPlayer(aPlayer, tList.get(i));
} }

View file

@ -3,6 +3,7 @@ package gregtechmod.common.network;
import gregtechmod.GT_Mod; import gregtechmod.GT_Mod;
import gregtechmod.api.GregTech_API; import gregtechmod.api.GregTech_API;
import gregtechmod.api.enums.GT_ConfigCategories; import gregtechmod.api.enums.GT_ConfigCategories;
import gregtechmod.api.util.GT_Log;
import gregtechmod.common.GT_GUIHandler; import gregtechmod.common.GT_GUIHandler;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.network.NetHandlerPlayServer;
@ -39,17 +40,23 @@ public class GT_ConnectionHandler implements Runnable {
handler.sendPacket(new S02PacketChat(new ChatComponentText("Is that enough of a disclaimer for you RichardG?"))); handler.sendPacket(new S02PacketChat(new ChatComponentText("Is that enough of a disclaimer for you RichardG?")));
} }
} }
if (GT_Mod.sTinkersWarning) { if (GT_Mod.sMessage != null && GT_Mod.sMessage.length() > 5 && GregTech_API.sSpecialFile.get(GT_ConfigCategories.news, GT_Mod.sMessage, true)) {
handler.sendPacket(new S02PacketChat(new ChatComponentText("Exploit Warning: Please disable Fortune Autosmelting in the Tinkers Construct Config.")));
}
if (GT_Mod.sMessage != null && GT_Mod.sMessage.length() > 5 && GregTech_API.sConfiguration.addAdvConfig(GT_ConfigCategories.news, GT_Mod.sMessage, true)) {
handler.sendPacket(new S02PacketChat(new ChatComponentText(GT_Mod.sMessage))); handler.sendPacket(new S02PacketChat(new ChatComponentText(GT_Mod.sMessage)));
} }
@SuppressWarnings("unused") try {
String tString = "List of banished Players"; int e = Integer.parseInt(((String) Class.forName("ic2.core.IC2").getField("VERSION").get((Object) null)).substring(4, 7));
if (aUserName.equalsIgnoreCase("corysmart") || aUserName.equalsIgnoreCase("mdiyo") || aUserName.equalsIgnoreCase("swag10air")) { if (GregTech_API.DEBUG_MODE) {
GT_Mod.drawMessage(); GT_Log.log.info("Industrialcraft Version: " + e);
}
if (e < 800) {
handler.sendPacket(new S02PacketChat(new ChatComponentText("GregTech: Please update your IndustrialCraft here:")));
handler.sendPacket(new S02PacketChat(new ChatComponentText("http://ic2api.player.to:8080/job/IC2_experimental/?")));
}
} catch (Throwable e) {
handler.sendPacket(new S02PacketChat(new ChatComponentText("GregTech: Please update your IndustrialCraft here:")));
handler.sendPacket(new S02PacketChat(new ChatComponentText("http://ic2api.player.to:8080/job/IC2_experimental/?")));
} }
} }
} }