diff options
Diffstat (limited to 'src/Java')
213 files changed, 14086 insertions, 2469 deletions
diff --git a/src/Java/gregtech/api/util/FishPondFakeRecipe.java b/src/Java/gregtech/api/util/FishPondFakeRecipe.java index 9e0a65a6cc..5d74329135 100644 --- a/src/Java/gregtech/api/util/FishPondFakeRecipe.java +++ b/src/Java/gregtech/api/util/FishPondFakeRecipe.java @@ -27,7 +27,7 @@ public class FishPondFakeRecipe { junk = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "junk").get(null); treasure = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "treasure").get(null); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + catch (IllegalArgumentException | IllegalAccessException e) { Logger.INFO("Error generating Fish Pond Recipes. [1]"); e.printStackTrace(); } @@ -46,7 +46,7 @@ public class FishPondFakeRecipe { ItemStack t = (ItemStack) ReflectionUtils.getField(WeightedRandomFishable.class, "field_150711_b").get(u); addNewFishPondLoot(mType, new ItemStack[]{t}, new int[] {10000}); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e1) { + catch (IllegalArgumentException | IllegalAccessException e1) { Logger.INFO("Error generating Fish Pond Recipes. [2]"); e1.printStackTrace(); } diff --git a/src/Java/gregtech/api/util/SemiFluidFuelHandler.java b/src/Java/gregtech/api/util/SemiFluidFuelHandler.java index f1c56c4e95..1414b3beb3 100644 --- a/src/Java/gregtech/api/util/SemiFluidFuelHandler.java +++ b/src/Java/gregtech/api/util/SemiFluidFuelHandler.java @@ -13,12 +13,58 @@ import net.minecraftforge.fluids.FluidStack; public class SemiFluidFuelHandler { + + public static boolean addSemiFluidFuel(ItemStack aFuelItem, int aFuelValue) { + FluidStack p = FluidContainerRegistry.getFluidForFilledItem(aFuelItem); + if (p != null && aFuelValue > 0) { + return addSemiFluidFuel(p, aFuelValue); + } else { + Logger.INFO("Fuel value for " + aFuelItem.getDisplayName() + " is <= 0, ignoring."); + } + return false; + } + + + public static boolean addSemiFluidFuel(FluidStack aFuel, int aFuelValue) { + FluidStack p = aFuel; + if (p != null && aFuelValue > 0) { + GT_Recipe aRecipe = + new Recipe_GT(true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {}, + new FluidStack[] { p }, + null, + 0, + 0, + aFuelValue); + if (aRecipe.mSpecialValue > 0) { + Logger.INFO("Added " + aRecipe.mFluidInputs[0].getLocalizedName() + " to the Semi-Fluid Generator fuel map. Fuel Produces "+(aRecipe.mSpecialValue*1000)+"EU per 1000L."); + sSemiFluidLiquidFuels.add(aRecipe); + return true; + } + } else { + Logger.INFO("Fuel value for " + p != null ? p.getLocalizedName() : "NULL Fluid" + " is <= 0, ignoring."); + } + return false; + } + + + + + + public static boolean generateFuels() { final FluidStack aCreosote = FluidUtils.getFluidStack("creosote", 1000); final FluidStack aHeavyFuel = FluidUtils.getFluidStack("liquid_heavy_fuel", 1000); final HashMap<Integer, Pair<FluidStack, Integer>> aFoundFluidsFromItems = new HashMap<Integer, Pair<FluidStack, Integer>>(); // Find Fluids From items - for (GT_Recipe g : gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDenseLiquidFuels.mRecipeList) { + for (final GT_Recipe r : gregtech.api.util.GT_Recipe.GT_Recipe_Map.sDenseLiquidFuels.mRecipeList) { + + GT_Recipe g = r.copy(); + + if (g != null && g.mEnabled && g.mInputs.length > 0 && g.mInputs[0] != null) { for (ItemStack i : g.mInputs) { FluidStack f = FluidContainerRegistry.getFluidForFilledItem(i); diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 79a3bee7ba..e10369abe3 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -74,7 +74,9 @@ public class GTplusplus implements ActionListener { SUPER(null), PRE_INIT(SUPER), INIT(PRE_INIT), - POST_INIT(INIT); + POST_INIT(INIT), + SERVER_START(POST_INIT), + STARTED(SERVER_START); protected boolean mIsPhaseActive = false; private final INIT_PHASE mPrev; @@ -220,18 +222,15 @@ public class GTplusplus implements ActionListener { } @EventHandler - public void load(FMLInitializationEvent event) { - - } - - @EventHandler public synchronized void serverStarting(final FMLServerStartingEvent event) { + INIT_PHASE.SERVER_START.setPhaseActive(true); mChunkLoading.serverStarting(event); event.registerServerCommand(new CommandMath()); event.registerServerCommand(new CommandDebugChunks()); if (LoadedMods.Thaumcraft) { event.registerServerCommand(new CommandDumpAspects()); } + INIT_PHASE.STARTED.setPhaseActive(true); } @Mod.EventHandler @@ -302,6 +301,9 @@ public class GTplusplus implements ActionListener { if (CORE.RA.addMultiblockCentrifugeRecipe(x.mInputs, x.mFluidInputs, x.mFluidOutputs, x.mOutputs, x.mChances, x.mDuration, x.mEUt, x.mSpecialValue)) { mValidCount[0]++; } + else { + mInvalidCount[0]++; + } } else { Logger.INFO("[Recipe] Error generating Large Centrifuge recipe."); @@ -330,6 +332,9 @@ public class GTplusplus implements ActionListener { if (CORE.RA.addMultiblockElectrolyzerRecipe(x.mInputs, x.mFluidInputs, x.mFluidOutputs, x.mOutputs, x.mChances, x.mDuration, x.mEUt, x.mSpecialValue)) { mValidCount[1]++; } + else { + mInvalidCount[1]++; + } } else { Logger.INFO("[Recipe] Error generating Large Electrolyzer recipe."); @@ -371,11 +376,19 @@ public class GTplusplus implements ActionListener { mValidCount[2]++; } } + else { + mInvalidCount[2]++; + } } else { mInvalidCount[2]++; } } + + //Redo plasma recipes in Adv. Vac. + //Meta_GT_Proxy.generatePlasmaRecipesForAdvVacFreezer(); + + String[] machineName = new String[] {"Centrifuge", "Electrolyzer", "Vacuum Freezer"}; for (int i=0;i<3;i++) { Logger.INFO("[Recipe] Generated "+mValidCount[i]+" recipes for the Industrial "+machineName[i]+". The original machine can process "+mOriginalCount[i]+" recipes, meaning "+mInvalidCount[i]+" are invalid for this Multiblock's processing in some way."); diff --git a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java index ca231dbd63..4663229514 100644 --- a/src/Java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java @@ -3,7 +3,7 @@ package gtPlusPlus.api.objects.data; import java.io.Serializable; import java.util.*; -public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable { +public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable, Collection<V>, Queue<V> { /** * The Internal Map @@ -47,6 +47,10 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable { return set(object); } + public synchronized boolean add(V object){ + return set(object) != null; + } + public synchronized V set(V object){ if (object == null) { return null; @@ -83,33 +87,129 @@ public class AutoMap<V> implements Iterable<V>, Cloneable, Serializable { return mInternalMap.isEmpty(); } - public synchronized boolean clear(){ + public synchronized void clear(){ this.mInternalID = 0; this.mInternalMap.clear(); this.mInternalNameMap.clear(); - return true; + return; } + @SuppressWarnings("unchecked") public synchronized V[] toArray() { - Collection<V> col = this.mInternalMap.values(); - V[] val = (V[]) new Object[col.size()]; - int counter = 0; - for (V i : col) { - val[counter] = i; - counter++; + Collection<V> col = this.mInternalMap.values(); + List<V> abcList = new ArrayList<V>(); + for (V g : col) { + abcList.add(g); } - return val; + return (V[]) abcList.toArray(); + //return (V[]) new AutoArray(this).getGenericArray(); } public synchronized final int getInternalID() { return mInternalID; - } + } - public synchronized final boolean remove(V value) { + public synchronized final boolean remove(Object value) { + value.getClass(); if (this.mInternalMap.containsValue(value)) { return this.mInternalMap.remove(mInternalNameMap.get(""+value.hashCode()), value); } return false; + } + + @Override + public boolean contains(Object o) { + for (V g : this.mInternalMap.values()) { + if (g.equals(o)) { + return true; + } + } + return false; + } + + @SuppressWarnings("unchecked") + @Override + public <V> V[] toArray(V[] a) { + return (V[]) toArray(); + } + + @Override + public boolean containsAll(Collection<?> c) { + boolean aTrue = true; + for (Object g : c) { + if (!this.contains(g)) { + aTrue = false; + } + } + return aTrue; + } + + @Override + public boolean addAll(Collection<? extends V> c) { + boolean aTrue = true; + for (V g : c) { + if (!this.add(g)) { + aTrue = false; + } + } + return aTrue; + } + + @Override + public boolean removeAll(Collection<?> c) { + boolean aTrue = true; + for (Object g : c) { + if (!this.remove(g)) { + aTrue = false; + } + } + return aTrue; + } + + @Override + public boolean retainAll(Collection<?> c) { + AutoMap<?> aTempAllocation = new AutoMap(); + boolean aTrue = false; + aTempAllocation = this; + aTempAllocation.removeAll(c); + aTrue = this.removeAll(aTempAllocation); + aTempAllocation.clear(); + return aTrue; + } + + @Override + public boolean offer(V e) { + return add(e); + } + + @Override + public V remove() { + V y = this.get(0); + if (remove(y)) + return y; + else + return null; + } + + @Override + public V poll() { + if (this.mInternalMap.isEmpty()) { + return null; + } + return remove(); + } + + @Override + public V element() { + if (this.mInternalMap.isEmpty()) { + return null; + } + return this.get(0); + } + + @Override + public V peek() { + return element(); } } diff --git a/src/Java/gtPlusPlus/api/objects/data/ReverseAutoMap.java b/src/Java/gtPlusPlus/api/objects/data/ReverseAutoMap.java index 73858e8d43..72ec0bc293 100644 --- a/src/Java/gtPlusPlus/api/objects/data/ReverseAutoMap.java +++ b/src/Java/gtPlusPlus/api/objects/data/ReverseAutoMap.java @@ -151,11 +151,11 @@ public class ReverseAutoMap<N> extends AutoMap<N> { } @Override - public synchronized boolean clear(){ + public synchronized void clear(){ this.mInternalID = 0; this.mInternalMap.clear(); this.mInternalMapReverseLookup.clear(); - return true; + return; } @Override diff --git a/src/Java/gtPlusPlus/api/objects/data/TypeCounter.java b/src/Java/gtPlusPlus/api/objects/data/TypeCounter.java index 3d562bf76e..601a51392f 100644 --- a/src/Java/gtPlusPlus/api/objects/data/TypeCounter.java +++ b/src/Java/gtPlusPlus/api/objects/data/TypeCounter.java @@ -17,7 +17,7 @@ public class TypeCounter<V> implements Set<V> { private final Class mClass; public TypeCounter(Class o) { - Logger.INFO("Created new TypeCounter for "+o.getName()); + Logger.WARNING("Created new TypeCounter for "+o.getName()); mClass = o; } @@ -56,17 +56,17 @@ public class TypeCounter<V> implements Set<V> { InternalTypeCounterObject<V> aValue = mInternalMap.get(aKey); if (aValue == null) { aValue = new InternalTypeCounterObject<V>((V) arg0); - Logger.INFO("Adding new key to map: "+aKey); + Logger.WARNING("Adding new key to map: "+aKey); } aValue.add(); int a = aValue.count(); if (a > mHighestValue) { mHighestValue = a; mHighestValueKey = aKey; - Logger.INFO("New Highest Count - "+aKey+":"+a); + Logger.WARNING("New Highest Count - "+aKey+":"+a); } mInternalMap.put(aKey, aValue); - Logger.INFO(aKey+":"+a); + Logger.WARNING(aKey+":"+a); return true; } diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java index 25968f1908..04ce0dff19 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/BTF_Inventory.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.tileentities.base.TileEntityBase; +import gtPlusPlus.core.util.data.ArrayUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -19,6 +20,7 @@ public class BTF_Inventory implements ISidedInventory{ } public ItemStack[] getRealInventory() { + purgeNulls(); return this.mInventory; } @@ -139,6 +141,7 @@ public class BTF_Inventory implements ISidedInventory{ public void markDirty() { if (mTile != null) { + purgeNulls(); mTile.markDirty(); } } @@ -160,5 +163,66 @@ public class BTF_Inventory implements ISidedInventory{ return this.mTile != null ? mTile.getInventoryName() : ""; } + public boolean isFull() { + for (int s=0;s<this.getSizeInventory();s++) { + ItemStack slot = mInventory[s]; + if (slot == null || slot.stackSize != slot.getMaxStackSize()) { + return false; + } + } + return true; + } + + public boolean isEmpty() { + for (int s=0;s<this.getSizeInventory();s++) { + ItemStack slot = mInventory[s]; + if (slot == null) { + continue; + } + else { + return false; + } + } + return true; + } + + public boolean addItemStack(ItemStack aInput) { + if (aInput != null & (isEmpty() || !isFull())) { + for (int s = 0; s < this.getSizeInventory(); s++) { + if (mInventory != null && mInventory[s] != null) { + ItemStack slot = mInventory[s]; + if (slot == null || (slot != null && GT_Utility.areStacksEqual(aInput, slot) && slot.stackSize != slot.getItem().getItemStackLimit(slot))) { + if (slot == null) { + slot = aInput.copy(); + } else { + slot.stackSize++; + } + this.setInventorySlotContents(s, slot); + return true; + } + } + } + } + return false; + } + + public final void purgeNulls() { + ItemStack[] aTemp = ArrayUtils.removeNulls(this.mInventory); + for (int g=0;g<this.getSizeInventory();g++) { + if (aTemp.length < this.getSizeInventory()) { + if (g <= aTemp.length-1) { + this.mInventory[g] = aTemp[g]; + } + else { + this.mInventory[g] = null; + } + } + else { + this.mInventory[g] = aTemp[g]; + } + } + + } + } diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java b/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java index 8c940baba3..9ab0f2eefb 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java @@ -6,6 +6,7 @@ import java.util.Set; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import gtPlusPlus.api.objects.data.AutoMap; @@ -48,6 +49,10 @@ public class BlockPos implements Serializable{ public BlockPos(IGregTechTileEntity b) { this (b.getXCoord(), b.getYCoord(), b.getZCoord(), b.getWorld()); } + + public BlockPos(TileEntity b) { + this (b.xCoord, b.yCoord, b.zCoord, b.getWorldObj()); + } public String getLocationString() { return "[X: "+this.xPos+"][Y: "+this.yPos+"][Z: "+this.zPos+"][Dim: "+this.dim+"]"; diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java b/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java new file mode 100644 index 0000000000..fa85f23cf3 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ItemPackage.java @@ -0,0 +1,58 @@ +package gtPlusPlus.api.objects.minecraft; + +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import gtPlusPlus.api.interfaces.RunnableWithInfo; +import gtPlusPlus.core.handler.COMPAT_HANDLER; + +public abstract class ItemPackage implements RunnableWithInfo<String> { + + public ItemPackage() { + this(false); + } + + public ItemPackage(boolean hasExtraLateRun) { + // Register for late run + COMPAT_HANDLER.mObjectsToRunInPostInit.put(this); + if (hasExtraLateRun) { + COMPAT_HANDLER.mObjectsToRunInOnLoadComplete.put(this); + } + init(); + } + + @Override + public final void run() { + generateRecipes(); + } + + @Override + public final String getInfoData() { + return errorMessage(); + } + + public abstract String errorMessage(); + + public abstract boolean generateRecipes(); + + private final void init() { + items(); + blocks(); + fluids(); + } + + public abstract void items(); + + public abstract void blocks(); + + public abstract void fluids(); + + /** + * Override this to handle GT Recipe map manipulation after they're Baked. + * @param event - the {@link FMLLoadCompleteEvent}. + * @return - Did we do anything? + */ + public boolean onLoadComplete(FMLLoadCompleteEvent event) { + return false; + }; + + +} diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java b/src/Java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java new file mode 100644 index 0000000000..a5f466b19f --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ThreadPooCollector.java @@ -0,0 +1,111 @@ +package gtPlusPlus.api.objects.minecraft; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.GTplusplus.INIT_PHASE; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.tileentities.machines.TileEntityPooCollector; +import gtPlusPlus.core.util.Utils; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +public class ThreadPooCollector extends Thread { + + public boolean canRun = true; + public boolean isRunning = false; + + private static final long INIT_TIME; + private static long internalTickCounter = 0; + + private static final ThreadPooCollector mThread; + private static final HashMap<String, Pair<BlockPos, TileEntityPooCollector>> mPooCollectors = new LinkedHashMap<String, Pair<BlockPos, TileEntityPooCollector>>(); + + + static { + mThread = new ThreadPooCollector(); + INIT_TIME = (System.currentTimeMillis()); + } + + public ThreadPooCollector() { + setName("gtpp.handler.poop"); + run(); + } + + public static ThreadPooCollector getInstance() { + return mThread; + } + + public static void addTask(TileEntityPooCollector aTile) { + BlockPos aTempPos = new BlockPos(aTile); + mPooCollectors.put(aTempPos.getUniqueIdentifier(), new Pair<BlockPos, TileEntityPooCollector>(aTempPos, aTile)); + } + + public static void stopThread() { + mThread.canRun = false; + } + + + @Override + public void run() { + + if (!isRunning) { + isRunning = true; + } + else { + return; + } + + while (canRun) { + if (mPooCollectors.isEmpty() || GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED) { + continue; + } else { + internalTickCounter = Utils.getTicksFromSeconds( + Utils.getSecondsFromMillis(Utils.getMillisSince(INIT_TIME, System.currentTimeMillis()))); + if (internalTickCounter % 100 == 0) { + for (Pair<BlockPos, TileEntityPooCollector> pair : mPooCollectors.values()) { + if (pair != null) { + BlockPos p = pair.getKey(); + if (p != null) { + if (p.world != null) { + World w = p.world; + if (w == null) { + continue; + } + Chunk c = w.getChunkFromBlockCoords(p.xPos, p.zPos); + if (c != null) { + if (c.isChunkLoaded) { + int startX = p.xPos - 2; + int startY = p.yPos; + int startZ = p.zPos - 2; + int endX = p.xPos + 3; + int endY = p.yPos + 5; + int endZ = p.zPos + 3; + AxisAlignedBB box = AxisAlignedBB.getBoundingBox(startX, startY, startZ, + endX, endY, endZ); + if (box != null) { + @SuppressWarnings("unchecked") + List<EntityAnimal> animals = w.getEntitiesWithinAABB(EntityAnimal.class, box); + if (animals != null && !animals.isEmpty()) { + pair.getValue().onPostTick(animals); + } + } else { + continue; + } + } + } + } + } + } + } + } + } + } + } + + +} diff --git a/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java index bbaa7ef008..a5e5f8b245 100644 --- a/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java +++ b/src/Java/gtPlusPlus/australia/gen/gt/WorldGen_GT_Australia_Ore_Layer.java @@ -72,7 +72,7 @@ extends WorldGen_GT_Australia { Field temp = ReflectionUtils.getField(GregTech_API.class, "sBlockStones"); tempBlock = temp.get(null); } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} mStoneTypes = (Block) tempBlock; } else { diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index f95f8814a9..2b04356f52 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -1,23 +1,32 @@ package gtPlusPlus.core.block; -import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockJukebox; -import net.minecraft.block.material.Material; - import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; -import gtPlusPlus.core.block.base.BlockBaseOre; -import gtPlusPlus.core.block.general.*; +import gtPlusPlus.core.block.general.BlockCompressedObsidian; +import gtPlusPlus.core.block.general.BlockNet; +import gtPlusPlus.core.block.general.BlockTankXpConverter; +import gtPlusPlus.core.block.general.FirePit; +import gtPlusPlus.core.block.general.FluidTankInfinite; +import gtPlusPlus.core.block.general.HellFire; +import gtPlusPlus.core.block.general.LightGlass; +import gtPlusPlus.core.block.general.MiningExplosives; +import gtPlusPlus.core.block.general.PlayerDoors; import gtPlusPlus.core.block.general.antigrief.BlockWitherProof; -import gtPlusPlus.core.block.machine.*; +import gtPlusPlus.core.block.machine.CircuitProgrammer; +import gtPlusPlus.core.block.machine.DecayablesChest; +import gtPlusPlus.core.block.machine.FishTrap; +import gtPlusPlus.core.block.machine.HeliumGenerator; +import gtPlusPlus.core.block.machine.Machine_ModularityTable; +import gtPlusPlus.core.block.machine.Machine_PooCollector; +import gtPlusPlus.core.block.machine.Machine_ProjectTable; +import gtPlusPlus.core.block.machine.Machine_SuperJukebox; +import gtPlusPlus.core.block.machine.Machine_TradeTable; +import gtPlusPlus.core.block.machine.Machine_Workbench; +import gtPlusPlus.core.block.machine.Machine_WorkbenchAdvanced; import gtPlusPlus.core.block.machine.bedrock.Mining_Head_Fake; import gtPlusPlus.core.block.machine.bedrock.Mining_Pipe_Fake; import gtPlusPlus.core.fluids.FluidRegistryHandler; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.plugin.villagers.block.BlockGenericSpawner; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraftforge.fluids.Fluid; public final class ModBlocks { @@ -78,6 +87,8 @@ public final class ModBlocks { public static Block blockCustomMobSpawner; public static Block blockCustomSuperLight; public static Block blockCustomJukebox; + + public static Block blockPooCollector; public static void init() { Logger.INFO("Initializing Blocks."); @@ -127,6 +138,8 @@ public final class ModBlocks { //blockCustomSuperLight = new BlockSuperLight(); blockCustomJukebox = new Machine_SuperJukebox(); + + blockPooCollector = new Machine_PooCollector(); } diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java index 4d7478dbdd..e1bc3462be 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -113,7 +113,7 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { hiddenTextureArray = new IIconContainer[6]; } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + catch (IllegalArgumentException | IllegalAccessException e) { hiddenTextureArray = new IIconContainer[6]; } } @@ -216,7 +216,7 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { hiddenTextureArray = new IIconContainer[6]; } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + catch (IllegalArgumentException | IllegalAccessException e) { hiddenTextureArray = new IIconContainer[6]; } } diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_PooCollector.java b/src/Java/gtPlusPlus/core/block/machine/Machine_PooCollector.java new file mode 100644 index 0000000000..23fdfe9733 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_PooCollector.java @@ -0,0 +1,180 @@ +package gtPlusPlus.core.block.machine; + +import java.util.List; +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityAdvPooCollector; +import gtPlusPlus.core.tileentities.machines.TileEntityBaseFluidCollector; +import gtPlusPlus.core.tileentities.machines.TileEntityPooCollector; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class Machine_PooCollector extends BlockContainer { + + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureTop2; + @SideOnly(Side.CLIENT) + private IIcon textureSide; + @SideOnly(Side.CLIENT) + private IIcon textureSide2; + + public Machine_PooCollector() { + super(Material.iron); + this.setBlockName("blockPooCollector"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockMeta.class,"blockPooCollector"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int aSide, final int aMeta) { + if (aMeta <= 7) { + blockIcon = textureSide; + return aSide <= 1 ? this.textureTop : this.textureSide; + } + else { + blockIcon = textureSide2; + return aSide <= 1 ? this.textureTop2 : this.textureSide2; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_top"); + this.textureTop2 = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_adv_top"); + this.textureSide = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_sides"); + this.textureSide2 = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_adv_sides"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int side, final float lx, final float ly, final float lz) { + if (world.isRemote) { + return true; + } else { + TileEntityBaseFluidCollector tank = (TileEntityBaseFluidCollector) world.getTileEntity(x, y, z); + if (tank != null) { + Item handItem; + try { + handItem = player.getHeldItem().getItem(); + } catch (Throwable t) { + handItem = null; + } + + //Fluid container code + /*if (handItem != null + && (handItem instanceof IFluidContainerItem || handItem instanceof ItemFluidContainer + || FluidContainerRegistry.isFilledContainer(player.getHeldItem()))) { + if (tank.tank.getFluid() == null) { + try { + if (!FluidContainerRegistry.isFilledContainer(player.getHeldItem())) { + ItemStack handItemStack = player.getHeldItem(); + IFluidContainerItem container = (IFluidContainerItem) handItem; + FluidStack containerFluid = container.getFluid(handItemStack); + container.drain(handItemStack, container.getFluid(handItemStack).amount, true); + tank.tank.setFluid(containerFluid); + } else { + ItemStack handItemStack = player.getHeldItem(); + FluidContainerRegistry.drainFluidContainer(handItemStack); + FluidStack containerFluid = FluidContainerRegistry.getFluidForFilledItem(handItemStack); + ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(handItemStack); + player.setItemInUse(emptyContainer, 0); + + tank.tank.setFluid(containerFluid); + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + }*/ + + if (!tank.mInventory.isEmpty()) { + PlayerUtils.messagePlayer(player, "Inventory contains:"); + PlayerUtils.messagePlayer(player, ItemUtils.getArrayStackNames(tank.mInventory.getRealInventory())); + } + else { + PlayerUtils.messagePlayer(player, "No solids collected yet."); + } + if (tank.tank.getFluid() != null) { + PlayerUtils.messagePlayer(player, "Tank contains " + tank.tank.getFluidAmount() + "L of " + + tank.tank.getFluid().getLocalizedName()); + } + } + } + return true; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public boolean isOpaqueCube() { + return super.isOpaqueCube(); + } + + @Override + public TileEntity createNewTileEntity(final World world, final int aMeta) { + return aMeta <= 7 ? new TileEntityPooCollector() : new TileEntityAdvPooCollector(); + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public int getBlockColor() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int damageDropped(final int damage) { + return damage; + } + + @Override + public Item getItemDropped(final int meta, final Random rand, final int fortune) { + return Item.getItemFromBlock(this); + } + + @Override + public int getRenderColor(int aMeta) { + return super.getRenderColor(aMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { + aList.add(new ItemStack(aItem, 1, 0)); + aList.add(new ItemStack(aItem, 1, 8)); + } + +} diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java b/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java index eecc379290..fdb6b1a0a8 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java @@ -133,34 +133,24 @@ public class Machine_ProjectTable extends BlockContainer implements ITileTooltip } @Optional.Method(modid = "EnderIO") - private static boolean checkEnderIOWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")){ + private static boolean checkEnderIOWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")) { Class<?> wrenchClass; - try { - wrenchClass = Class.forName("crazypants.enderio.api.tool.ITool"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; } @Optional.Method(modid = "Buildcraft") - private static boolean checkBuildcraftWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")){ + private static boolean checkBuildcraftWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")) { Class<?> wrenchClass; - try { - wrenchClass = Class.forName("buildcraft.api.tools.IToolWrench"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java index 675aeaaf2b..5c08612042 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java @@ -121,34 +121,24 @@ public class Machine_Workbench extends BlockContainer } @Optional.Method(modid = "EnderIO") - private static boolean checkEnderIOWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")){ + private static boolean checkEnderIOWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")) { Class<?> wrenchClass; - try { - wrenchClass = Class.forName("crazypants.enderio.api.tool.ITool"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; } @Optional.Method(modid = "Buildcraft") - private static boolean checkBuildcraftWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")){ + private static boolean checkBuildcraftWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")) { Class<?> wrenchClass; - try { - wrenchClass = Class.forName("buildcraft.api.tools.IToolWrench"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; diff --git a/src/Java/gtPlusPlus/core/client/renderer/RenderGiantChicken.java b/src/Java/gtPlusPlus/core/client/renderer/RenderGiantChicken.java index 59621ef830..cc1249280b 100644 --- a/src/Java/gtPlusPlus/core/client/renderer/RenderGiantChicken.java +++ b/src/Java/gtPlusPlus/core/client/renderer/RenderGiantChicken.java @@ -4,40 +4,12 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderChicken; -import net.minecraft.entity.passive.EntityChicken; -import net.minecraft.util.ResourceLocation; - -import gtPlusPlus.core.util.reflect.ReflectionUtils; @SideOnly(Side.CLIENT) public class RenderGiantChicken extends RenderChicken { - - /** - * Fancy reflective handling of nabbing the original chicken texture object, should save reload the texture to memory. :) - */ - private static final ResourceLocation chickenTexturesEx; - static { - ResourceLocation mChicken; - try { - mChicken = (ResourceLocation) ReflectionUtils.getField(RenderGiantChicken.class, "chickenTextures").get(null); - } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { - mChicken = new ResourceLocation("textures/entity/chicken.png"); - } - chickenTexturesEx = mChicken; - } public RenderGiantChicken(ModelBase p_i1252_1_, float p_i1252_2_) { super(p_i1252_1_, p_i1252_2_); } - - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. - */ - @Override - protected ResourceLocation getEntityTexture(EntityChicken p_110775_1_) - { - return chickenTexturesEx; - } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 9176dcc720..301ca992a4 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -18,11 +18,13 @@ import gtPlusPlus.core.entity.InternalEntityRegistry; import gtPlusPlus.core.entity.monster.EntityGiantChickenBase; import gtPlusPlus.core.entity.monster.EntitySickBlaze; import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; +import gtPlusPlus.core.fluids.FluidFactory; import gtPlusPlus.core.handler.BookHandler; import gtPlusPlus.core.handler.BurnableFuelHandler; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.handler.COMPAT_IntermodStaging; import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.handler.StopAnnoyingFuckingAchievements; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.handler.events.GeneralTooltipEventHandler; import gtPlusPlus.core.handler.events.PickaxeBlockBreakEventHandler; @@ -80,8 +82,8 @@ public class CommonProxy { ModItems.init(); ModBlocks.init(); CI.preInit(); - - COMPAT_IntermodStaging.preInit(); + FluidFactory.preInit(); + COMPAT_IntermodStaging.preInit(e); BookHandler.run(); // Registration of entities and renderers Logger.INFO("[Proxy] Calling Entity registrator."); @@ -116,6 +118,7 @@ public class CommonProxy { Logger.ERROR("[ERROR] Did not generate fluids at all."); } CI.init(); + FluidFactory.init(); /** * Register the Event Handlers. @@ -130,6 +133,10 @@ public class CommonProxy { Utils.registerEvent(new HandlerTooltip_EIO()); // Handles Custom Tooltips for GC Utils.registerEvent(new HandlerTooltip_GC()); + + if (CORE.DEVENV) { + Utils.registerEvent(new StopAnnoyingFuckingAchievements()); + } // Register Chunkloader ForgeChunkManager.setForcedChunkLoadingCallback(GTplusplus.instance, ChunkManager.getInstance()); @@ -147,12 +154,13 @@ public class CommonProxy { // Compat Handling COMPAT_HANDLER.registerMyModsOreDictEntries(); COMPAT_HANDLER.intermodOreDictionarySupport(); - COMPAT_IntermodStaging.init(); + COMPAT_IntermodStaging.init(e); } public void postInit(final FMLPostInitializationEvent e) { Logger.INFO("Cleaning up, doing postInit."); PlayerCache.initCache(); + FluidFactory.postInit(); // Make Burnables burnable if (!CORE.burnables.isEmpty()) { @@ -165,7 +173,7 @@ public class CommonProxy { COMPAT_HANDLER.RemoveRecipesFromOtherMods(); COMPAT_HANDLER.InitialiseHandlerThenAddRecipes(); COMPAT_HANDLER.startLoadingGregAPIBasedRecipes(); - COMPAT_IntermodStaging.postInit(); + COMPAT_IntermodStaging.postInit(e); COMPAT_HANDLER.runQueuedRecipes(); } @@ -175,6 +183,7 @@ public class CommonProxy { public void onLoadComplete(FMLLoadCompleteEvent event) { COMPAT_IntermodStaging.onLoadComplete(event); + COMPAT_HANDLER.onLoadComplete(event); } public void registerNetworkStuff() { diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java index a5d0768e72..cd5d36b653 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_CompactWindmills.java @@ -40,17 +40,17 @@ public class COMPAT_CompactWindmills { public static ItemStack evWindmill = ItemUtils.simpleMetaStack("CompactWindmills:blockCompactWindmill", 4, 1); //Compact Rotors - public static ItemStack rotor2 = ItemUtils.getItemStack("CompactWindmills:WOOL", 1); - public static ItemStack rotor1 = ItemUtils.getItemStack("CompactWindmills:WOOD", 1); - public static ItemStack rotor3 = ItemUtils.getItemStack("CompactWindmills:ALLOY", 1); - public static ItemStack rotor4 = ItemUtils.getItemStack("CompactWindmills:CARBON", 1); - public static ItemStack rotor5 = ItemUtils.getItemStack("CompactWindmills:IRIDIUM", 1); + public static ItemStack rotor2 = ItemUtils.getItemStackFromFQRN("CompactWindmills:WOOL", 1); + public static ItemStack rotor1 = ItemUtils.getItemStackFromFQRN("CompactWindmills:WOOD", 1); + public static ItemStack rotor3 = ItemUtils.getItemStackFromFQRN("CompactWindmills:ALLOY", 1); + public static ItemStack rotor4 = ItemUtils.getItemStackFromFQRN("CompactWindmills:CARBON", 1); + public static ItemStack rotor5 = ItemUtils.getItemStackFromFQRN("CompactWindmills:IRIDIUM", 1); //IC2 Rotors - public static ItemStack rotorIC1 = ItemUtils.getItemStack("IC2:itemwoodrotor", 1); - public static ItemStack rotorIC2 = ItemUtils.getItemStack("IC2:itemironrotor", 1); - public static ItemStack rotorIC3 = ItemUtils.getItemStack("IC2:itemsteelrotor", 1); - public static ItemStack rotorIC4 = ItemUtils.getItemStack("IC2:itemwcarbonrotor", 1); + public static ItemStack rotorIC1 = ItemUtils.getItemStackFromFQRN("IC2:itemwoodrotor", 1); + public static ItemStack rotorIC2 = ItemUtils.getItemStackFromFQRN("IC2:itemironrotor", 1); + public static ItemStack rotorIC3 = ItemUtils.getItemStackFromFQRN("IC2:itemsteelrotor", 1); + public static ItemStack rotorIC4 = ItemUtils.getItemStackFromFQRN("IC2:itemwcarbonrotor", 1); public static ItemStack rotorBlade1 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 7, 1); public static ItemStack rotorBlade2 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 8, 1); public static ItemStack rotorBlade3 = ItemUtils.simpleMetaStack("IC2:itemRecipePart", 10, 1); diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java index 45a70997e4..4d736e1362 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_ExtraUtils.java @@ -10,7 +10,7 @@ import gtPlusPlus.core.util.minecraft.RecipeUtils; public class COMPAT_ExtraUtils { public static void OreDict(){ - RECIPES_Tools.RECIPE_DivisionSigil = new ItemStack(ItemUtils.getItem("ExtraUtilities:divisionSigil")); + RECIPES_Tools.RECIPE_DivisionSigil = new ItemStack(ItemUtils.getItemFromFQRN("ExtraUtilities:divisionSigil")); run(); } diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java index c7b90b780c..6381a6705e 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_OpenBlocks.java @@ -13,7 +13,7 @@ public class COMPAT_OpenBlocks { private static final void run(){ - Item aGraveItem = ItemUtils.getItem("OpenBlocks:grave"); + Item aGraveItem = ItemUtils.getItemFromFQRN("OpenBlocks:grave"); if (aGraveItem == null) { return; } diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Railcraft.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Railcraft.java new file mode 100644 index 0000000000..f6c8e86808 --- /dev/null +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Railcraft.java @@ -0,0 +1,14 @@ +package gtPlusPlus.core.common.compat; + +public class COMPAT_Railcraft { + + public static void OreDict(){ + run(); + } + + private static final void run(){ + + + } + +} diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java index 6247face1d..b78c10c8ce 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Thaumcraft.java @@ -20,9 +20,9 @@ public class COMPAT_Thaumcraft { for(int i=0; i<=6; i++){ //Utils.LOG_INFO(""+i); ItemUtils.getItemForOreDict("Thaumcraft:ItemShard", "shardAny", "TC Shard "+i, i); - GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStack("Thaumcraft:ItemShard:"+i, 1)); + GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStackFromFQRN("Thaumcraft:ItemShard:"+i, 1)); ItemUtils.getItemForOreDict("Thaumcraft:ItemShard", "gemInfusedAnything", "TC Shard "+i, i); - GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStack("Thaumcraft:ItemShard:"+i, 1)); + GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("Thaumcraft:ItemShard:"+i, 1)); //System.out.println("TC Shard registration count is: "+i); } @@ -30,15 +30,15 @@ public class COMPAT_Thaumcraft { for(int i=0; i<=6; i++){ //Utils.LOG_INFO(""+i); ItemUtils.getItemForOreDict("ForbiddenMagic:NetherShard", "shardAny", "FM Shard "+i, i); - GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStack("ForbiddenMagic:NetherShard:"+i, 1)); + GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:NetherShard:"+i, 1)); ItemUtils.getItemForOreDict("ForbiddenMagic:NetherShard", "gemInfusedAnything", "FM Shard "+i, i); - GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStack("ForbiddenMagic:NetherShard:"+i, 1)); + GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:NetherShard:"+i, 1)); //System.out.println("TC Shard registration count is: "+i); } ItemUtils.getItemForOreDict("ForbiddenMagic:GluttonyShard", "shardAny", "FM Gluttony Shard", 0); - GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStack("ForbiddenMagic:GluttonyShard", 1)); + GT_OreDictUnificator.registerOre("shardAny", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:GluttonyShard", 1)); ItemUtils.getItemForOreDict("ForbiddenMagic:GluttonyShard", "gemInfusedAnything", "FM Gluttony Shard", 0); - GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStack("ForbiddenMagic:GluttonyShard", 1)); + GT_OreDictUnificator.registerOre("gemInfusedAnything", ItemUtils.getItemStackFromFQRN("ForbiddenMagic:GluttonyShard", 1)); } } diff --git a/src/Java/gtPlusPlus/core/config/ConfigHandler.java b/src/Java/gtPlusPlus/core/config/ConfigHandler.java index 2fbd3f60c2..64c8b74b33 100644 --- a/src/Java/gtPlusPlus/core/config/ConfigHandler.java +++ b/src/Java/gtPlusPlus/core/config/ConfigHandler.java @@ -46,7 +46,9 @@ public class ConfigHandler { enableAlternativeDivisionSigilRecipe = config.getBoolean("enableAlternativeDivisionSigilRecipe", "machines", false, "Utilizes Neutronium instead."); boilerSteamPerSecond = config.getInt("boilerSteamPerSecond", "machines", 750, 0, 10000, "Sets the steam per second value in LV,MV,HV boilers (respectively 1x,2x,3x this number for the tiers)"); - requireControlCores = config.getBoolean("requireControlCores", "machines", true, "Multiblocks Require Control Cores"); + + //requireControlCores + boolean temp = config.getBoolean("requireControlCores", "machines", true, "Multiblocks Require Control Cores"); diff --git a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java index 36f5b86184..e5c779adcf 100644 --- a/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java +++ b/src/Java/gtPlusPlus/core/entity/InternalEntityRegistry.java @@ -14,6 +14,7 @@ import gtPlusPlus.core.entity.monster.EntitySickBlaze; import gtPlusPlus.core.entity.monster.EntityStaballoyConstruct; import gtPlusPlus.core.entity.projectile.EntityHydrofluoricAcidPotion; import gtPlusPlus.core.entity.projectile.EntitySulfuricAcidPotion; +import gtPlusPlus.core.entity.projectile.EntityThrowableBomb; import gtPlusPlus.core.entity.projectile.EntityToxinballSmall; import gtPlusPlus.core.util.Utils; @@ -51,6 +52,8 @@ public class InternalEntityRegistry { //EntityRegistry.registerGlobalEntityID(EntityTeslaTowerLightning.class, "plasmaBolt", EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(125, 125, 125)); EntityRegistry.registerModEntity(EntityTeslaTowerLightning.class, "plasmaBolt", mEntityID++, GTplusplus.instance, 64, 5, true); + EntityRegistry.registerModEntity(EntityThrowableBomb.class, "EntityThrowableBomb", mEntityID++, GTplusplus.instance, 64, 10, true); + /** * Globals, which generate spawn eggs. (Currently required for Giant chicken spawning) */ diff --git a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java index bdc239b9ce..f6f397f59e 100644 --- a/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java +++ b/src/Java/gtPlusPlus/core/entity/monster/EntityStaballoyConstruct.java @@ -363,18 +363,15 @@ public class EntityStaballoyConstruct extends EntityIronGolem { } //Get a private field from a super class if it exists. - try { - if (mFirstUpdateField == null) { - mFirstUpdateField = ReflectionUtils.getField(Class.forName("net.minecraft.entity.Entity"), "firstUpdate"); - } - if (mFirstUpdateField != null && mReflectFirstUpdate == true){ - try { - this.mReflectFirstUpdate = (boolean) mFirstUpdateField.get(this); - } - catch (IllegalArgumentException | IllegalAccessException e) {} + if (mFirstUpdateField == null) { + mFirstUpdateField = ReflectionUtils.getField(this.getClass(), "firstUpdate"); + } + if (mFirstUpdateField != null && mReflectFirstUpdate == true){ + try { + this.mReflectFirstUpdate = (boolean) mFirstUpdateField.get(this); } + catch (IllegalArgumentException | IllegalAccessException e) {} } - catch (NoSuchFieldException | ClassNotFoundException e) {} } super.onEntityUpdate(); } diff --git a/src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java b/src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java new file mode 100644 index 0000000000..9e72daf687 --- /dev/null +++ b/src/Java/gtPlusPlus/core/entity/projectile/EntityThrowableBomb.java @@ -0,0 +1,115 @@ +package gtPlusPlus.core.entity.projectile; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.init.Blocks; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +import gregtech.api.util.GT_Utility; + +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.EntityUtils; + +public class EntityThrowableBomb extends EntityThrowable { + + public EntityThrowableBomb(World world) { + super(world); + } + + public EntityThrowableBomb(World world, EntityLivingBase entity) { + super(world, entity); + } + + public EntityThrowableBomb(World world, double posX, double posY, double posZ) { + super(world, posX, posY, posZ); + } + + /** + * Called when this EntityThrowable hits a block or entity. + */ + @Override + protected void onImpact(MovingObjectPosition object) { + int xBlock = object.blockX; + int yBlock = object.blockY; + int zBlock = object.blockZ; + if (object.entityHit != null) { + byte b0 = 6; + if (!GT_Utility.isWearingFullRadioHazmat((EntityLivingBase) object.entityHit)){ + object.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), b0); + EntityUtils.setEntityOnFire(object.entityHit, 10); + object.entityHit.fireResistance = 0; + ravage(EntityUtils.findBlockPosUnderEntity(object.entityHit)); + } + } + if (object.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK){ + ravage(new BlockPos(xBlock, yBlock, zBlock)); + } + + String mParticleType = "reddust"; + int e=0; + for (int i = 0; i < 24; ++i) { + if ((e = MathUtils.randInt(0, 5)) <= 1){ + if (e==0) + mParticleType = "largesmoke"; + if (e==1) + mParticleType = "flame"; + } + this.worldObj.spawnParticle(mParticleType, this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); + } + + if (!this.worldObj.isRemote) { + this.setDead(); + } + } + + private boolean ravage(BlockPos blockpos){ + + int radius = 1; + + for (int i=(blockpos.xPos-radius);i<(blockpos.xPos+radius);i++){ + for (int j=(blockpos.yPos-radius);j<(blockpos.yPos+radius);j++){ + for (int h=(blockpos.zPos-radius);h<(blockpos.zPos+radius);h++){ + + int mChance = MathUtils.randInt(1, 10); + if (mChance <= 3){ + Block mBlockhit = worldObj.getBlock(i, j, h); + this.worldObj.spawnParticle("flame", this.posX+MathUtils.randDouble(-2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); + this.worldObj.spawnParticle("largesmoke", this.posX+MathUtils.randDouble(2, 2), this.posY+MathUtils.randDouble(-2, 2), this.posZ+MathUtils.randDouble(-2, 2), 0.0D, 0.0D, 0.0D); + + //GT_Pollution.addPollution(worldObj.getChunkFromBlockCoords(blockpos.xPos, blockpos.zPos), mPol); + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 0.01f, true); + if (mBlockhit == Blocks.grass || mBlockhit == Blocks.mycelium){ + worldObj.setBlock(i, j+1, h, Blocks.fire); + worldObj.setBlock(i, j, h, Blocks.dirt); + } + else if (mBlockhit == Blocks.leaves || mBlockhit == Blocks.leaves2){ + worldObj.setBlock(i, j, h, Blocks.fire); + } + else if (mBlockhit == Blocks.tallgrass){ + worldObj.setBlock(i, j, h, Blocks.fire); + if (worldObj.getBlock(i, j-1, h) == Blocks.grass){ + worldObj.setBlock(i, j-1, h, Blocks.dirt); + } + } + else if (mBlockhit == Blocks.carrots || mBlockhit == Blocks.melon_block || mBlockhit == Blocks.pumpkin || mBlockhit == Blocks.potatoes){ + worldObj.setBlock(i, j+1, h, Blocks.fire); + worldObj.setBlock(i, j, h, Blocks.dirt); + } + else if (mBlockhit == Blocks.air){ + worldObj.setBlock(i, j, h, Blocks.fire); + } + } + } + } + } + + + return true; + } + + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/fluids/BlockFluidBase.java b/src/Java/gtPlusPlus/core/fluids/BlockFluidBase.java index 9a3958a908..dc7c9c2e78 100644 --- a/src/Java/gtPlusPlus/core/fluids/BlockFluidBase.java +++ b/src/Java/gtPlusPlus/core/fluids/BlockFluidBase.java @@ -1,113 +1,104 @@ package gtPlusPlus.core.fluids; -import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; - -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.math.MathUtils; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; public class BlockFluidBase extends BlockFluidClassic { @SideOnly(Side.CLIENT) - protected IIcon stillIcon; + protected static IIcon stillIcon; @SideOnly(Side.CLIENT) - protected IIcon flowingIcon; - - protected int colour; - protected Material fluidMaterial; - final String displayName; - - @SuppressWarnings("deprecation") - public BlockFluidBase(final Fluid fluid, final Material material) { - super(fluid, net.minecraft.block.material.Material.lava); - final short[] tempColour = material.getRGBA(); - this.colour = Utils.rgbtoHexValue(tempColour[0], tempColour[1], tempColour[2]); - this.fluidMaterial = material; - this.setCreativeTab(AddToCreativeTab.tabOther); - this.displayName = material.getLocalizedName(); - LanguageRegistry.addName(this, "Molten "+this.displayName+" ["+MathUtils.celsiusToKelvin(this.fluidMaterial.getBoilingPointC())+"K]"); - this.setBlockName(this.GetProperName()); + protected static IIcon flowingIcon; + + protected final short[] mRGB; + + + public BlockFluidBase(Fluid fluid, short[] aRGB) { + this(fluid, Material.water, aRGB); } - @SuppressWarnings("deprecation") - public BlockFluidBase(final String fluidName, final Fluid fluid, final short[] colour) { - super(fluid, net.minecraft.block.material.Material.lava); - final short[] tempColour = colour; - this.colour = Utils.rgbtoHexValue(tempColour[0], tempColour[1], tempColour[2]); - this.setCreativeTab(AddToCreativeTab.tabOther); - this.displayName = fluidName; - LanguageRegistry.addName(this, "Molten "+this.displayName); - this.setBlockName(this.GetProperName()); + public BlockFluidBase(Fluid fluid, Material material, short[] aRGB) { + super(fluid, material); + mRGB = aRGB; + this.setHardness(100.0F); + this.setLightOpacity(3); + this.disableStats(); } @Override - public IIcon getIcon(final int side, final int meta) { - return ((side == 0) || (side == 1))? this.stillIcon : this.flowingIcon; + public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity ent) { + if (!(ent instanceof EntityLivingBase)) { + return; + } + /*EntityLivingBase player = (EntityLivingBase) ent; + int pot = world.rand.nextInt(Potion.potionTypes.length); + Potion.potionTypes[pot].performEffect(player, 40);*/ } - @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(final IIconRegister register) { - this.stillIcon = register.registerIcon(CORE.MODID+":fluids/fluid.molten.autogenerated"); - this.flowingIcon = register.registerIcon(CORE.MODID+":fluids/fluid.molten.autogenerated"); + public IIcon getIcon(int side, int meta) { + return (side == 0 || side == 1) ? stillIcon : flowingIcon; } + @SideOnly(Side.CLIENT) @Override - public boolean canDisplace(final IBlockAccess world, final int x, final int y, final int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) { - return false; + public void registerBlockIcons(IIconRegister register) { + if (stillIcon == null) { + stillIcon = register.registerIcon(CORE.MODID+ ":" + "fluids/fluid.fluid.autogenerated.still"); } - return super.canDisplace(world, x, y, z); + if (flowingIcon == null) { + flowingIcon = register.registerIcon(CORE.MODID+ ":" + "fluids/fluid.fluid.autogenerated.flowing"); + } } @Override - public boolean displaceIfPossible(final World world, final int x, final int y, final int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) { - return false; - } - return super.displaceIfPossible(world, x, y, z); + public int getBlockColor() { + if (mRGB != null && mRGB.length >= 3) { + return Utils.rgbtoHexValue(mRGB[0], mRGB[1], mRGB[2]); + } + return super.getBlockColor(); } @Override - public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ - - if (this.colour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - - return this.colour; + public int getRenderColor(int aMeta) { + if (mRGB != null && mRGB.length >= 3) { + return Utils.rgbtoHexValue(mRGB[0], mRGB[1], mRGB[2]); + } + return super.getRenderColor(aMeta); } @Override - public int getRenderColor(final int aMeta) { - if (this.colour == 0){ - return MathUtils.generateSingularRandomHexValue(); - } - - return this.colour; + public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) { + // TODO Auto-generated method stub + return super.recolourBlock(world, x, y, z, side, colour); } - public String GetProperName() { - String tempIngot; - - tempIngot = "Molten "+this.displayName; - - return tempIngot; + @Override + public boolean canDisplace(IBlockAccess world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.canDisplace(world, x, y, z); } - public Material getFluidMaterial(){ - return this.fluidMaterial; + @Override + public boolean displaceIfPossible(World world, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial().isLiquid()) { + return false; + } + return super.displaceIfPossible(world, x, y, z); } } diff --git a/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java b/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java new file mode 100644 index 0000000000..3359f18f7d --- /dev/null +++ b/src/Java/gtPlusPlus/core/fluids/FactoryFluid.java @@ -0,0 +1,49 @@ +package gtPlusPlus.core.fluids; +import gregtech.api.GregTech_API; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.Block; +import net.minecraft.item.EnumRarity; +import net.minecraftforge.fluids.Fluid; + +public class FactoryFluid extends Fluid implements Runnable { + + private final String mTextureName; + private final short[] mRGBa; + + public FactoryFluid(String fluidName, final short[] aRGBa) { + this(fluidName, null, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, false, EnumRarity.common, aRGBa); + } + + public FactoryFluid(String fluidName, int luminosity, int density, int temp, int viscosity, final short[] aRGBa) { + this(fluidName, null, luminosity, density, temp, viscosity, (density == Short.MIN_VALUE || density >= 0 ? false : true), EnumRarity.common, aRGBa); + } + + public FactoryFluid(String fluidName, Block aBlock, int luminosity, int density, int temp, int viscosity, boolean gas, EnumRarity aRarity, final short[] aRGBa) { + super(fluidName); + this.mRGBa = aRGBa; + this.setBlock(aBlock); + if (luminosity != Short.MIN_VALUE) + this.setLuminosity(luminosity); + if (density != Short.MIN_VALUE) + this.setDensity(density); + if (temp != Short.MIN_VALUE) + this.setTemperature(temp); + if (viscosity != Short.MIN_VALUE) + this.setViscosity(viscosity); + this.setGaseous(gas); + this.setRarity(aRarity); + this.mTextureName = CORE.MODID+":fluids/fluid.fluid.autogenerated"; + GregTech_API.sGTBlockIconload.add(this); + } + + @Override + public int getColor() { + return (Math.max(0, Math.min(255, this.mRGBa[0])) << 16) | (Math.max(0, Math.min(255, this.mRGBa[1])) << 8) | Math.max(0, Math.min(255, this.mRGBa[2])); + } + + @Override + public void run() { + this.setIcons(GregTech_API.sBlockIcons.registerIcon(CORE.MODID+ ":" + "fluids/fluid." + this.mTextureName)); + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/fluids/FluidFactory.java b/src/Java/gtPlusPlus/core/fluids/FluidFactory.java new file mode 100644 index 0000000000..dffd7f55e9 --- /dev/null +++ b/src/Java/gtPlusPlus/core/fluids/FluidFactory.java @@ -0,0 +1,213 @@ +package gtPlusPlus.core.fluids; + +import java.util.LinkedHashMap; +import java.util.Map; + +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.GTplusplus.INIT_PHASE; +import gtPlusPlus.api.objects.GregtechException; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.base.itemblock.FluidItemBlock; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.player.FillBucketEvent; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; + +public class FluidFactory { + + public static final Map<String, Fluid> mNameToFluidMap = new LinkedHashMap<String, Fluid>(); + public static final Map<String, ItemStack> mNameToBucketMap = new LinkedHashMap<String, ItemStack>(); + public static final Map<String, Block> mNameToBlockMap = new LinkedHashMap<String, Block>(); + public static final Map<String, Integer> mNameToMetaMap = new LinkedHashMap<String, Integer>(); + + public static final Map<Fluid, String> mFluidToNameMap = new LinkedHashMap<Fluid, String>(); + public static final Map<Fluid, ItemStack> mFluidToBucketMap = new LinkedHashMap<Fluid, ItemStack>(); + public static final Map<Fluid, Block> mFluidToBlockMap = new LinkedHashMap<Fluid, Block>(); + public static final Map<Fluid, Integer> mFluidToMetaMap = new LinkedHashMap<Fluid, Integer>(); + + public static final Map<ItemStack, Fluid> mBucketToFluidMap = new LinkedHashMap<ItemStack, Fluid>(); + public static final Map<ItemStack, String> mBucketToNameMap = new LinkedHashMap<ItemStack, String>(); + public static final Map<ItemStack, Block> mBucketToBlockMap = new LinkedHashMap<ItemStack, Block>(); + public static final Map<ItemStack, Integer> mBucketToMetaMap = new LinkedHashMap<ItemStack, Integer>(); + + public static final Map<Block, String> mBlockToNameMap = new LinkedHashMap<Block, String>(); + public static final Map<Block, Fluid> mBlockToFluidMap = new LinkedHashMap<Block, Fluid>(); + public static final Map<Block, ItemStack> mBlockToBucketMap = new LinkedHashMap<Block, ItemStack>(); + public static final Map<Block, Integer> mBlockToMetaMap = new LinkedHashMap<Block, Integer>(); + + public static final Map<Integer, String> mMetaToNameMap = new LinkedHashMap<Integer, String>(); + public static final Map<Integer, Fluid> mMetaToFluidMap = new LinkedHashMap<Integer, Fluid>(); + public static final Map<Integer, ItemStack> mMetaToBucketMap = new LinkedHashMap<Integer, ItemStack>(); + public static final Map<Integer, Block> mMetaToBlockMap = new LinkedHashMap<Integer, Block>(); + + + //Special Colour Handling + public static final Map<Integer, Integer> mMetaToColourMap = new LinkedHashMap<Integer, Integer>(); + + + public static Item mGenericBucket; + private static FluidPackage mErrorFluid; + private static AutoMap<FluidPackage> mGeneratedFluids = new AutoMap<FluidPackage>(); + + public static void preInit() { + + } + + public static void init() { + mGenericBucket = new ItemGenericFluidBucket(Blocks.air); + GameRegistry.registerItem(mGenericBucket, "gtpp.bucket.generic"); + for (FluidPackage y : mGeneratedFluids) { + if (!y.valid()) { + continue; + } + GameRegistry.registerBlock(y.mBlock, FluidItemBlock.class, "gtpp_" + y.mName); + FluidContainerRegistry.registerFluidContainer(y.get(), y.mBucket, new ItemStack(Items.bucket)); + } + Utils.registerEvent(BucketHandler.INSTANCE); + } + + public static void postInit() { + + } + + /** + * Generates a 'Water' type fluid. + * @param aID - The Fluid ID (Must be unique) + * @param aUnlocalName - Unlocalized Fluid Name + * @param aRGB - a {@link Short[]} containing the RGB of the FluidPackage. + * @return - A fully constructed & registered {@linkplain FluidPackage} + */ + public static FluidPackage generate(int aID, String aUnlocalName, short[] aRGB) { + return generate(aID, aUnlocalName, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, Short.MIN_VALUE, aRGB); + } + + /** + * Generate a {@link FluidPackage} from the data provided. This FluidPackage is automatically registered and handled internally. + * Pass in {@link Short}.MIN_VALUE for any of the Fluid Fields (Besides ID, Name or RGB) and it will default to water values. + * @param aID - The Fluid ID (Must be unique) + * @param aUnlocalName - Unlocalized Fluid Name + * @param luminosity - How bright is the fluid. + * @param density - completely arbitrary; negative density indicates that the fluid is + * lighter than air. Default value is approximately the real-life density of water in kg/m^3. + * @param temp - completely arbitrary; higher temperature indicates that the fluid is + * hotter than air. Default value is approximately the real-life room temperature of water in degrees Kelvin + * @param viscosity - completely arbitrary; negative values are not + * permissible. Default value is approximately the real-life density of water in m/s^2 (x10^-3). * + * Higher viscosity means that a fluid flows more slowly, like molasses. + * Lower viscosity means that a fluid flows more quickly, like helium. + * @param aRGB - a {@link Short[]} containing the RGB of the FluidPackage. + * @return - A fully constructed & registered {@linkplain FluidPackage} + */ + public static FluidPackage generate(int aID, String aUnlocalName, int luminosity, int density, int temp, + int viscosity, short[] aRGB) { + + FluidPackage aFluidToGenerate = null; + + // Check Load Phase for some Safety, only allow this to be called in Pre-Init. + if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.PRE_INIT) { + try { + throw new GregtechException("Cannot generate Fluid Packages outside of Pre-Init!"); + } catch (GregtechException e) { + System.exit(0); + } + } + + Fluid aGenFluid = fluid(aUnlocalName, luminosity, density, temp, viscosity, aRGB); + Block aGenBlock = block(aGenFluid, aRGB); + ItemStack aGenBucket = bucket(aID); + + aFluidToGenerate = new FluidPackage(aID, aUnlocalName, aGenFluid, aGenBucket, aGenBlock); + + if (aFluidToGenerate != null && aFluidToGenerate.valid()) { + FluidRegistry.registerFluid(aFluidToGenerate.get()); + mGeneratedFluids.put(aFluidToGenerate); + } + else { + // Handle Bad generation + if (mErrorFluid == null) { + mErrorFluid = new FluidPackage(0, "", FluidUtils.getWater(1).getFluid(), ItemUtils.getSimpleStack(Items.water_bucket), Blocks.water); + } + return mErrorFluid; + } + + + return aFluidToGenerate; + } + + + + private static Fluid fluid(String aUnlocalName, int luminosity, int density, int temp, + int viscosity, short[] aRGB) { + return new FactoryFluid(aUnlocalName, luminosity, density, temp, viscosity, aRGB); + } + + private static ItemStack bucket(int aID) { + return ItemGenericFluidBucket.registerFluidForBucket(aID); + } + + private static Block block(Fluid aFluidForBlock, short[] aRGB) { + if (aFluidForBlock != null) { + FluidRegistry.registerFluid(aFluidForBlock); + return new BlockFluidBase(aFluidForBlock, aRGB); + } + return Blocks.dirt; + } + + /** + * Copyright © SpaceToad, 2011 http://www.mod-buildcraft.com BuildCraft is + * distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. + * Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + * + * Modified version of the BC BucketHandler, except using ItemStacks > Items + * (Why?) + * + * @author Alkalus + */ + + public static class BucketHandler { + + public static BucketHandler INSTANCE = new BucketHandler(); + + private BucketHandler() { + + } + + @SubscribeEvent + public void onBucketFill(FillBucketEvent event) { + ItemStack result = fillCustomBucket(event.world, event.target); + if (result == null) { + return; + } + event.result = result; + event.setResult(Result.ALLOW); + } + + private ItemStack fillCustomBucket(World world, MovingObjectPosition pos) { + Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ); + ItemStack bucket = mBlockToBucketMap.get(block); + if (bucket != null && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) { + world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ); + return ItemUtils.getSimpleStack(bucket, 1); + } else { + return null; + } + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/fluids/FluidPackage.java b/src/Java/gtPlusPlus/core/fluids/FluidPackage.java new file mode 100644 index 0000000000..29f831776b --- /dev/null +++ b/src/Java/gtPlusPlus/core/fluids/FluidPackage.java @@ -0,0 +1,83 @@ +package gtPlusPlus.core.fluids; + +import static gtPlusPlus.core.fluids.FluidFactory.mBlockToBucketMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBlockToFluidMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBlockToMetaMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBlockToNameMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBucketToBlockMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBucketToFluidMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBucketToMetaMap; +import static gtPlusPlus.core.fluids.FluidFactory.mBucketToNameMap; +import static gtPlusPlus.core.fluids.FluidFactory.mFluidToBlockMap; +import static gtPlusPlus.core.fluids.FluidFactory.mFluidToBucketMap; +import static gtPlusPlus.core.fluids.FluidFactory.mFluidToMetaMap; +import static gtPlusPlus.core.fluids.FluidFactory.mFluidToNameMap; +import static gtPlusPlus.core.fluids.FluidFactory.mMetaToBlockMap; +import static gtPlusPlus.core.fluids.FluidFactory.mMetaToBucketMap; +import static gtPlusPlus.core.fluids.FluidFactory.mMetaToColourMap; +import static gtPlusPlus.core.fluids.FluidFactory.mMetaToFluidMap; +import static gtPlusPlus.core.fluids.FluidFactory.mMetaToNameMap; +import static gtPlusPlus.core.fluids.FluidFactory.mNameToBlockMap; +import static gtPlusPlus.core.fluids.FluidFactory.mNameToBucketMap; +import static gtPlusPlus.core.fluids.FluidFactory.mNameToFluidMap; +import static gtPlusPlus.core.fluids.FluidFactory.mNameToMetaMap; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; + +public class FluidPackage { + + + public final int mID; + public final String mName; + private final Fluid mFluid; + public final ItemStack mBucket; + public final Block mBlock; + + public FluidPackage(int aID, String aName, Fluid aFluid, ItemStack aBucket, Block aBlock) { + + mNameToFluidMap.put(aName, aFluid); + mNameToBucketMap.put(aName, aBucket); + mNameToBlockMap.put(aName, aBlock); + mNameToMetaMap.put(aName, aID); + + mFluidToNameMap.put(aFluid, aName); + mFluidToBucketMap.put(aFluid, aBucket); + mFluidToBlockMap.put(aFluid, aBlock); + mFluidToMetaMap.put(aFluid, aID); + + mBucketToFluidMap.put(aBucket, aFluid); + mBucketToNameMap.put(aBucket, aName); + mBucketToBlockMap.put(aBucket, aBlock); + mBucketToMetaMap.put(aBucket, aID); + + mBlockToNameMap.put(aBlock, aName); + mBlockToFluidMap.put(aBlock, aFluid); + mBlockToBucketMap.put(aBlock, aBucket); + mBlockToMetaMap.put(aBlock, aID); + + mMetaToNameMap.put(aID, aName); + mMetaToFluidMap.put(aID, aFluid); + mMetaToBucketMap.put(aID, aBucket); + mMetaToBlockMap.put(aID, aBlock); + + mMetaToColourMap.put(aID, aFluid.getColor()); + + mID = aID; + mName = aName; + mFluid = aFluid; + mBucket = aBucket; + mBlock = aBlock; + + } + + public Fluid get() { + return mFluid; + } + + public boolean valid() { + return mName != null && mName.length() > 0 && mFluid != null && mBucket != null && mBlock != null; + } + +} diff --git a/src/Java/gtPlusPlus/core/fluids/GenericFluid.java b/src/Java/gtPlusPlus/core/fluids/GenericFluid.java deleted file mode 100644 index 4f1f5df006..0000000000 --- a/src/Java/gtPlusPlus/core/fluids/GenericFluid.java +++ /dev/null @@ -1,70 +0,0 @@ -package gtPlusPlus.core.fluids; - -import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.block.Block; - -import gtPlusPlus.core.item.base.itemblock.ItemBlockFluid; -import gtPlusPlus.core.material.Material; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; - -public class GenericFluid extends Fluid{ - - protected final String fluidName; - protected final Fluid fluidFactory; - protected final Block blockFactory; - protected final short[] rgba; - - public GenericFluid(final String displayName, final String fluidName, final int luminosity, final int density, final int temperature, final int viscosity, final boolean isGas, final short[] rgba) { - super(fluidName); - this.fluidFactory = this; - this.rgba = rgba; - this.fluidName = fluidName; - this.fluidFactory.setLuminosity(luminosity); - this.fluidFactory.setDensity(density); - this.fluidFactory.setTemperature(temperature); - this.fluidFactory.setViscosity(viscosity); - this.fluidFactory.setGaseous(isGas); - this.fluidFactory.setUnlocalizedName("fluid"+fluidName); - FluidRegistry.registerFluid(this.fluidFactory); - this.blockFactory = new BlockFluidBase(displayName, this.fluidFactory, rgba).setBlockName("fluidblock"+fluidName); - GameRegistry.registerBlock(this.blockFactory, ItemBlockFluid.class, this.blockFactory.getUnlocalizedName().substring(5)); - this.fluidFactory.setBlock(this.blockFactory); - - //fluidFactory.setUnlocalizedName(blockFactory.getUnlocalizedName()); - - } - - public GenericFluid(final Material fluidMaterial, final int luminosity, final int density, final int temperature, final int viscosity, final boolean isGas) { - - super(fluidMaterial.getUnlocalizedName()); - //IC2_ItemFluidCell fullFluidCell = emptyCell.fill(emptyCell, FluidUtils.getFluidStack(getUnlocalizedName(), 1), true); - - this.fluidFactory = this; - this.rgba = fluidMaterial.getRGBA(); - this.fluidName = fluidMaterial.getUnlocalizedName(); - this.fluidFactory.setLuminosity(luminosity); - this.fluidFactory.setDensity(density); - this.fluidFactory.setTemperature(temperature); - this.fluidFactory.setViscosity(viscosity); - this.fluidFactory.setGaseous(isGas); - this.fluidFactory.setUnlocalizedName("fluid"+this.fluidName); - FluidRegistry.registerFluid(this.fluidFactory); - this.blockFactory = new BlockFluidBase(this.fluidFactory, fluidMaterial).setBlockName("fluidblock"+this.fluidName); - GameRegistry.registerBlock(this.blockFactory, ItemBlockFluid.class, this.blockFactory.getUnlocalizedName().substring(5)); - this.fluidFactory.setBlock(this.blockFactory); - //IC2_ItemFluidCell emptyCell = new IC2_ItemFluidCell(fluidName); - /*if (aFullContainer != null && aEmptyContainer != null && !FluidContainerRegistry.registerFluidContainer(new FluidStack(rFluid, aFluidAmount), aFullContainer, aEmptyContainer)) { - GT_Values.RA.addFluidCannerRecipe(aFullContainer, container(aFullContainer, false), null, new FluidStack(rFluid, aFluidAmount)); - }*/ - //fluidFactory.setUnlocalizedName(blockFactory.getUnlocalizedName()); - - } - - @Override - public int getColor() { - return (Math.max(0, Math.min(255, this.rgba[0])) << 16) | (Math.max(0, Math.min(255, this.rgba[1])) << 8) | Math.max(0, Math.min(255, this.rgba[2])); - } - -} diff --git a/src/Java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java b/src/Java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java new file mode 100644 index 0000000000..d41fccb3ed --- /dev/null +++ b/src/Java/gtPlusPlus/core/fluids/ItemGenericFluidBucket.java @@ -0,0 +1,318 @@ +package gtPlusPlus.core.fluids; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import cpw.mods.fml.common.eventhandler.Event; +import gtPlusPlus.api.objects.GregtechException; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBucket; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.FillBucketEvent; + +public class ItemGenericFluidBucket extends ItemBucket { + + private static IIcon mBaseBucketTexture; + private static IIcon mOverlayBucketTexture; + private static AutoMap<Block> mInternalFluidCache = new AutoMap<Block>(); + + public ItemGenericFluidBucket(Block aFluid) { + super(aFluid); + this.setContainerItem(Items.bucket); + this.maxStackSize = 1; + mInternalFluidCache.put(aFluid); + } + + public static ItemStack registerFluidForBucket(int aID) { + + if (FluidFactory.mMetaToBucketMap.containsKey(aID)) { + try { + throw new GregtechException(""+aID+" is already registered! Unable to register fluid: "+FluidFactory.mMetaToFluidMap.get(aID).getLocalizedName()); + } catch (GregtechException e) { + System.exit(0); + } + } + mInternalFluidCache.put(FluidFactory.mMetaToBlockMap.get(aID)); + return ItemUtils.simpleMetaStack(FluidFactory.mGenericBucket, aID, 1); + } + + Map<Integer, IIcon> mIconCache = new LinkedHashMap<Integer, IIcon>(); + + /** + * Called whenever this item is equipped and the right mouse button is pressed. + * Args: itemStack, world, entityPlayer + */ + public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + + Block isFull = FluidFactory.mMetaToBlockMap.get(aStack.getItemDamage()); + + boolean flag = isFull == Blocks.air; + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(aWorld, aPlayer, flag); + + if (movingobjectposition == null || isFull == null) { + return aStack; + } else { + FillBucketEvent event = new FillBucketEvent(aPlayer, aStack, aWorld, movingobjectposition); + if (MinecraftForge.EVENT_BUS.post(event)) { + return aStack; + } + + if (event.getResult() == Event.Result.ALLOW) { + if (aPlayer.capabilities.isCreativeMode) { + return aStack; + } + + if (--aStack.stackSize <= 0) { + return event.result; + } + + if (!aPlayer.inventory.addItemStackToInventory(event.result)) { + aPlayer.dropPlayerItemWithRandomChoice(event.result, false); + } + + return aStack; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!aWorld.canMineBlock(aPlayer, i, j, k)) { + return aStack; + } + + if (flag) { + if (!aPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, aStack)) { + return aStack; + } + + Material material = aWorld.getBlock(i, j, k).getMaterial(); + int l = aWorld.getBlockMetadata(i, j, k); + + if (material == Material.water && l == 0) { + aWorld.setBlockToAir(i, j, k); + return this.func_150910_a(aStack, aPlayer, Items.water_bucket); + } + + if (material == Material.lava && l == 0) { + aWorld.setBlockToAir(i, j, k); + return this.func_150910_a(aStack, aPlayer, Items.lava_bucket); + } + } else { + if (isFull == Blocks.air) { + return new ItemStack(Items.bucket); + } + + if (movingobjectposition.sideHit == 0) { + --j; + } + + if (movingobjectposition.sideHit == 1) { + ++j; + } + + if (movingobjectposition.sideHit == 2) { + --k; + } + + if (movingobjectposition.sideHit == 3) { + ++k; + } + + if (movingobjectposition.sideHit == 4) { + --i; + } + + if (movingobjectposition.sideHit == 5) { + ++i; + } + + if (!aPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, aStack)) { + return aStack; + } + + if (this.tryPlaceContainedLiquid(isFull, aWorld, i, j, k) && !aPlayer.capabilities.isCreativeMode) { + return new ItemStack(Items.bucket); + } + } + } + + return aStack; + } + } + + private ItemStack func_150910_a(ItemStack p_150910_1_, EntityPlayer p_150910_2_, Item p_150910_3_) { + if (p_150910_2_.capabilities.isCreativeMode) { + return p_150910_1_; + } else if (--p_150910_1_.stackSize <= 0) { + return new ItemStack(p_150910_3_); + } else { + if (!p_150910_2_.inventory.addItemStackToInventory(new ItemStack(p_150910_3_))) { + p_150910_2_.dropPlayerItemWithRandomChoice(new ItemStack(p_150910_3_, 1, 0), false); + } + + return p_150910_1_; + } + } + + /** + * Attempts to place the liquid contained inside the bucket. + */ + public boolean tryPlaceContainedLiquid(Block isFull, World aWorld, int aX, int aY, int aZ) { + if (isFull == Blocks.air) { + return false; + } else { + Material material = aWorld.getBlock(aX, aY, aZ).getMaterial(); + boolean flag = !material.isSolid(); + + if (!aWorld.isAirBlock(aX, aY, aZ) && !flag) { + return false; + } else { + + if (!aWorld.isRemote && flag && !material.isLiquid()) { + aWorld.func_147480_a(aX, aY, aZ, true); + } + + aWorld.setBlock(aX, aY, aZ, isFull, 0, 3); + + return true; + } + } + } + + @Override + public IIcon getIconFromDamage(int aMeta) { + IIcon aTemp = mIconCache.get(aMeta); + return aTemp != null ? aTemp : super.getIconFromDamage(aMeta); + } + + @Override + public boolean getHasSubtypes() { + return mInternalFluidCache.size() > 0; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + list.add(new ItemStack(item, 1, 0)); + for (Block f : mInternalFluidCache) { + Integer aMeta; + if (f != null) { + aMeta = FluidFactory.mBlockToMetaMap.get(f); + if (aMeta != null) { + list.add(new ItemStack(item, 1, aMeta)); + } + } + } + } + + @Override + public int getMaxDamage() { + return 512; + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { + // TODO Auto-generated method stub + super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + if (stack != null && renderPass == 1) { + return mOverlayBucketTexture; + } + else { + return mBaseBucketTexture; + } + /*IIcon aTemp = mIconCache.get(stack.getItemDamage()); + return aTemp != null ? aTemp : super.getIcon(stack, renderPass, player, usingItem, useRemaining);*/ + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public int getMaxDamage(ItemStack stack) { + return 512; + } + + @Override + public boolean isDamaged(ItemStack stack) { + return false; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } + + @Override + public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { + if (pass == 1) { + return mOverlayBucketTexture; + } + else { + return mBaseBucketTexture; + } + } + + @Override + public void registerIcons(final IIconRegister i) { + mBaseBucketTexture = i.registerIcon("bucket_empty"); + mOverlayBucketTexture = i.registerIcon(CORE.MODID+":bucket.generic.overlay"); + } + + @Override + public boolean tryPlaceContainedLiquid(World p_77875_1_, int p_77875_2_, int p_77875_3_, int p_77875_4_) { + return tryPlaceContainedLiquid(Blocks.air, p_77875_1_, p_77875_2_, p_77875_3_, p_77875_4_); + } + + @Override + public int getColorFromItemStack(ItemStack aStack, int aPass) { + if (aPass == 0) { + return super.getColorFromItemStack(aStack, aPass); + } + else { + return FluidFactory.mMetaToColourMap.get(aStack.getItemDamage()); + } + } + + @Override + public boolean requiresMultipleRenderPasses() { + return true; + } + + +} diff --git a/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java index f4669bfe35..ed347e8d30 100644 --- a/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java +++ b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java @@ -331,7 +331,7 @@ public class GuiBaseGrindle extends GuiContainer { try { r = (ResourceLocation) ReflectionUtils.getField(GuiScreenBook.class, "bookGuiTextures").get(null); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { r = new ResourceLocation("textures/gui/book.png"); } mBookTexture = r; diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java index 7a3a01b27c..8a1f7c3fe9 100644 --- a/src/Java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java +++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_ScrollTest.java @@ -16,6 +16,7 @@ import com.google.common.collect.Lists; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiOptionButton; import net.minecraft.client.gui.GuiResourcePackAvailable; @@ -145,9 +146,9 @@ public class GUI_ScrollTest extends GuiScreen try { - Class<?> oclass = Class.forName("java.awt.Desktop"); - Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); - oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {file1.toURI()}); + Class<?> oclass = ReflectionUtils.getClass("java.awt.Desktop"); + Object object = ReflectionUtils.getMethod(oclass, "getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + ReflectionUtils.getMethod(oclass, "browse", new Class[] {URI.class}).invoke(object, new Object[] {file1.toURI()}); } catch (Throwable throwable) { diff --git a/src/Java/gtPlusPlus/core/handler/AchievementHandler.java b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java new file mode 100644 index 0000000000..482ca66f09 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/AchievementHandler.java @@ -0,0 +1,417 @@ +package gtPlusPlus.core.handler; + +import java.util.concurrent.ConcurrentHashMap; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemSmeltedEvent; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Log; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.Achievement; +import net.minecraft.stats.StatBase; +import net.minecraftforge.common.AchievementPage; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; + +public class AchievementHandler { + + public ConcurrentHashMap<String, Achievement> achievementList = new ConcurrentHashMap<String, Achievement>(); + public ConcurrentHashMap<String, Boolean> issuedAchievements = new ConcurrentHashMap<String, Boolean>(); + + public int adjX = 5; + public int adjY = 9; + + private static final String aBaseAchievementName = "gtpp.start"; + + public AchievementHandler() { + + Logger.INFO("Initializing GT++ achievements"); + GT_Log.out.println("Initializing GT++ achievements"); + + //register first + this.registerAchievement(aBaseAchievementName, 0, 0, GT_MetaGenerated_Tool_01.INSTANCE.getToolWithStats(GT_MetaGenerated_Tool_01.HARDHAMMER, 1, Materials.Neutronium, Materials.Osmium, null), "", true); + + //Useful Info + boolean cores = CORE.ConfigSwitches.requireControlCores; + if (cores || GregtechMeta_MultiBlockBase.DEBUG_DISABLE_CORES_TEMPORARILY) { + this.registerAchievement("hatch.control", -2, -2, GregtechItemList.Hatch_Control_Core.get(1), aBaseAchievementName, false); + } + this.registerAchievement("hatch.dynamo.buffered", 2, -2, GregtechItemList.Hatch_Buffer_Dynamo_IV.get(1), aBaseAchievementName, false); + //First multi anyone really needs + this.registerAchievement("multi.abs", -4, -2, GregtechItemList.Industrial_AlloyBlastSmelter.get(1), cores ? "hatch.control" : aBaseAchievementName, true); + + //Material Advancement + this.registerAchievement("dust.potin", 0, 2, ALLOY.POTIN.getDust(1), aBaseAchievementName, false); + this.registerAchievement("dust.eglin", 0, 4, ALLOY.EGLIN_STEEL.getDust(1), "dust.potin", false); + this.registerAchievement("dust.staballoy", 0, 6, ALLOY.STABALLOY.getDust(1), "dust.eglin", false); + this.registerAchievement("dust.quantum", 0, 8, ALLOY.QUANTUM.getDust(1), "dust.staballoy", true); + this.registerAchievement("dust.hypogen", 0, 10, ELEMENT.STANDALONE.HYPOGEN.getDust(1), "dust.quantum", true); + + + //Blocks + this.registerAchievement("block.fishtrap", -2, 2, ItemUtils.getSimpleStack(ModBlocks.blockFishTrap), "dust.potin", false); + this.registerAchievement("block.withercage", -2, 4, ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard), "dust.eglin", false); + + + //Machines (-10/-8/-6) + this.registerAchievement("rtg", -16, -10, GregtechItemList.RTG.get(1), aBaseAchievementName, false); + this.registerAchievement("dehydrate", -15, -10, GregtechItemList.GT_Dehydrator_HV.get(1), aBaseAchievementName, false); + this.registerAchievement("semifluid", -14, -10, GregtechItemList.Generator_SemiFluid_HV.get(1), aBaseAchievementName, false); + this.registerAchievement("earlywasher", -13, -10, GregtechItemList.SimpleDustWasher.get(1), aBaseAchievementName, false); + this.registerAchievement("advancedsteam", -12, -10, GregtechItemList.Boiler_Advanced_MV.get(1), aBaseAchievementName, false); + this.registerAchievement("pollutionremoval", -11, -10, GregtechItemList.Pollution_Cleaner_IV.get(1), aBaseAchievementName, false); + this.registerAchievement("hiampxform", -10, -10, GregtechItemList.Transformer_HA_HV_MV.get(1), aBaseAchievementName, false); + + + //Multis (-4/-2/0) + this.registerAchievement("multi.pss", -16, -7, GregtechItemList.PowerSubStation.get(1), "multi.abs", false); + this.registerAchievement("multi.cyclo", -15, -7, GregtechItemList.COMET_Cyclotron.get(1), "multi.abs", false); + this.registerAchievement("multi.sifter", -14, -7, GregtechItemList.Industrial_Sifter.get(1), "dust.eglin", false); + this.registerAchievement("multi.cokeoven", -13, -7, GregtechItemList.Industrial_CokeOven.get(1), "multi.abs", false); + this.registerAchievement("multi.boiler.thermal", -12, -7, GregtechItemList.GT4_Thermal_Boiler.get(1), "multi.abs", false); + this.registerAchievement("multi.zhuhai", -11, -7, GregtechItemList.Industrial_FishingPond.get(1), aBaseAchievementName, false); + //this.registerAchievement("rtg", -4, -4, GregtechItemList.RTG.get(1), aBaseAchievementName, false); + + //Casings + this.registerAchievement("casing.abs", 2, -10, GregtechItemList.Casing_Coil_BlastSmelter.get(1), aBaseAchievementName, false); + this.registerAchievement("casing.cyclotron.coil", 3, -10, GregtechItemList.Casing_Cyclotron_Coil.get(1), aBaseAchievementName, false); + this.registerAchievement("casing.multiuse", 4, -10, GregtechItemList.Casing_Multi_Use.get(1), aBaseAchievementName, false); + this.registerAchievement("casing.containment", 5, -10, GregtechItemList.Casing_Containment.get(1), aBaseAchievementName, false); + + + + + + + + + //Radioactive + this.registerAchievement("decay.neptunium238", 11, 8, ItemUtils.getSimpleStack(ModItems.dustNeptunium238), "multi.cyclo", false); + this.registerAchievement("decay.radium226", 12, 8, ItemUtils.getSimpleStack(ModItems.dustRadium226), "multi.cyclo", false); + this.registerAchievement("decay.molybdenum99", 13, 8, ItemUtils.getSimpleStack(ModItems.dustMolybdenum99), "multi.cyclo", false); + this.registerAchievement("decay.technetium99m", 14, 8, ItemUtils.getSimpleStack(ModItems.dustTechnetium99M), "multi.cyclo", false); + this.registerAchievement("decay.technetium99", 15, 8, ItemUtils.getSimpleStack(ModItems.dustTechnetium99), "multi.cyclo", false); + + + + + + + + + + + + + AchievementPage.registerAchievementPage( + new AchievementPage("GT++", (Achievement[]) ((Achievement[]) this.achievementList.values() + .toArray(new Achievement[this.achievementList.size()])))); + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + + + } + + public Achievement registerAchievement(String textId, int x, int y, ItemStack icon, Achievement requirement, + boolean special) { + Achievement achievement = new Achievement(textId, textId, this.adjX + x, this.adjY + y, icon, requirement); + if (special) { + achievement.setSpecial(); + } + + achievement.registerStat(); + if (CORE.DEVENV) { + GT_Log.out.println("achievement." + textId + "="); + GT_Log.out.println("achievement." + textId + ".desc="); + } + + this.achievementList.put(textId, achievement); + return achievement; + } + + public Achievement registerAchievement(String textId, int x, int y, ItemStack icon, String requirement, + boolean special) { + Achievement achievement = new Achievement(textId, textId, this.adjX + x, this.adjY + y, icon, + this.getAchievement(requirement)); + if (special) { + achievement.setSpecial(); + } + + achievement.registerStat(); + if (CORE.DEVENV) { + GT_Log.out.println("achievement." + textId + "="); + GT_Log.out.println("achievement." + textId + ".desc="); + } + + this.achievementList.put(textId, achievement); + return achievement; + } + + public void issueAchievement(EntityPlayer entityplayer, String textId) { + if (entityplayer != null) { + entityplayer.triggerAchievement((StatBase) this.achievementList.get(textId)); + } + } + + public Achievement getAchievement(String textId) { + return this.achievementList.containsKey(textId) ? (Achievement) this.achievementList.get(textId) : null; + } + + + /** + * A generic handler that will give an achievement for an item. + * Useful to only write this once, then call it from all handlers. + * @param aStack - The Itemstack to check for achievements. + * @param aPlayer - The player to unlock for. + */ + private void handleAchivement(ItemStack aStack, EntityPlayer aPlayer) { + + if (aPlayer != null && aStack != null) { + /* + * Copy this to all events because I am lazy - Alk 2019 + */ + + //Safe name + String aUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + + + boolean isValid = false; + //Check if valid name // mod + String aModID = ItemUtils.getModId(aStack); + + if (aModID == null || aModID.length() <= 0 || aModID.isEmpty()) { + return; + } + + if (aModID != null && (ItemUtils.getModId(aStack).equals(CORE.MODID) || ItemUtils.getModId(aStack).equalsIgnoreCase("gregtech"))) { + isValid = true; + } + if (!isValid) { + return; + } + + //Should unlock base achievement from *ANY* GT++ item. (Too lazy to special case GT machineBlocks though) + if (ItemUtils.getModId(aStack).equals(CORE.MODID)) { + this.issueAchievement(aPlayer, aBaseAchievementName); + } + + if (aUnlocalName.contains("item.")) { + aUnlocalName = aUnlocalName.substring(5); + } + else if (aUnlocalName.contains("tile.")) { + aUnlocalName = aUnlocalName.substring(5); + } + + //Logger.INFO("Picked up "+aUnlocalName); + + + /** + * Misc Blocks + */ + + if (aUnlocalName.equals("blockFishTrap")) { + this.issueAchievement(aPlayer, "block.fishtrap"); + } + if (aUnlocalName.equals("blockBlackGate")) { + this.issueAchievement(aPlayer, "block.withercage"); + } + + + /** + * Decayables + */ + if (aUnlocalName.equals("dustNeptunium238")) { + this.issueAchievement(aPlayer, "decay.neptunium238"); + } + else if (aUnlocalName.equals("dustRadium226")) { + this.issueAchievement(aPlayer, "decay.radium226"); + } + else if (aUnlocalName.equals("dustMolybdenum99")) { + this.issueAchievement(aPlayer, "decay.molybdenum99"); + } + else if (aUnlocalName.equals("dustTechnetium99M")) { + this.issueAchievement(aPlayer, "decay.technetium99m"); + } + else if (aUnlocalName.equals("dustTechnetium99")) { + this.issueAchievement(aPlayer, "decay.technetium99"); + } + + /** + * Random Materials worthy of Achievements + */ + else if (aUnlocalName.equals("itemDustPotin")) { + this.issueAchievement(aPlayer, "dust.potin"); + } + else if (aUnlocalName.equals("itemDustEglinSteel")) { + this.issueAchievement(aPlayer, "dust.eglin"); + } + else if (aUnlocalName.equals("itemDustStaballoy")) { + this.issueAchievement(aPlayer, "dust.staballoy"); + } + else if (aUnlocalName.equals("itemDustQuantum")) { + this.issueAchievement(aPlayer, "dust.quantum"); + } + else if (aUnlocalName.equals("itemDustHypogen")) { + this.issueAchievement(aPlayer, "dust.hypogen"); + } + + + + /** + * Machines + */ + + else if (aUnlocalName.startsWith("gt.blockmachines.")) { + + //Readability + String aStartsWith = "gt.blockmachines."; + + /** + * Single Blocks + */ + + //RTG + if (aUnlocalName.startsWith(aStartsWith + "basicgenerator.rtg")) { + this.issueAchievement(aPlayer, "rtg"); + } + //Dehydrator + else if (aUnlocalName.startsWith(aStartsWith + "machine.dehydrator.tier.")) { + this.issueAchievement(aPlayer, "dehydrate"); + } + //SemiFluids + else if (aUnlocalName.startsWith(aStartsWith + "basicgenerator.semifluid.tier.")) { + this.issueAchievement(aPlayer, "semifluid"); + } + //Simple Washer + else if (aUnlocalName.startsWith(aStartsWith + "simplewasher.01.tier.")) { + this.issueAchievement(aPlayer, "earlywasher"); + } + //Advanced Boilers + else if (aUnlocalName.startsWith(aStartsWith + "electricboiler.")) { + this.issueAchievement(aPlayer, "advancedsteam"); + } + //Scrubers + else if (aUnlocalName.startsWith(aStartsWith + "pollutioncleaner.01.tier.")) { + this.issueAchievement(aPlayer, "pollutionremoval"); + } + //High-amp xformers + else if (aUnlocalName.startsWith(aStartsWith + "transformer.ha.tier.")) { + this.issueAchievement(aPlayer, "hiampxform"); + } + //Buffered Dynamos + else if (aUnlocalName.startsWith(aStartsWith + "hatch.dynamo.buffer.tier.")) { + this.issueAchievement(aPlayer, "hatch.dynamo.buffered"); + } + //Control Core Hatch + else if (aUnlocalName.startsWith(aStartsWith + "hatch.control.adv")) { + this.issueAchievement(aPlayer, "hatch.control"); + } + + + + /** + * Multis + */ + + //ABS + else if (aUnlocalName.equals(aStartsWith + "industrialsalloyamelter.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.abs"); + } + //PSS + else if (aUnlocalName.equals(aStartsWith + "substation.01.input.single")) { + this.issueAchievement(aPlayer, "multi.pss"); + } + //Cyclotron + else if (aUnlocalName.startsWith(aStartsWith + "cyclotron.tier.single")) { + this.issueAchievement(aPlayer, "multi.cyclo"); + } + //Sifter + else if (aUnlocalName.equals(aStartsWith + "industrialsifter.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.sifter"); + } + //Coke Oven + else if (aUnlocalName.equals(aStartsWith + "industrialcokeoven.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.cokeoven"); + } + //Thermal Boiler + else if (aUnlocalName.equals(aStartsWith + "gtplusplus.thermal.boiler")) { + this.issueAchievement(aPlayer, "multi.boiler.thermal"); + } + //Zhuhai + else if (aUnlocalName.equals(aStartsWith + "industrial.fishpond.controller.tier.single")) { + this.issueAchievement(aPlayer, "multi.zhuhai"); + } + + } + + /** + * Casings + */ + + else if (aUnlocalName.equals("gtplusplus.blockcasings.14")) { + this.issueAchievement(aPlayer, "casing.abs"); + } + + else if (aUnlocalName.equals("gtplusplus.blockcasings.2.9")) { + this.issueAchievement(aPlayer, "casing.cyclotron.coil"); + } + + else if (aUnlocalName.equals("gtplusplus.blockcasings.3.2")) { + this.issueAchievement(aPlayer, "casing.multiuse"); + } + else if (aUnlocalName.equals("gtplusplus.blockcasings.3.15")) { + this.issueAchievement(aPlayer, "casing.containment"); + } + } + } + + + + + /* + * Handle achievements for all vanilla types of obtianment. + */ + + + + @SubscribeEvent + public void onCrafting(ItemCraftedEvent event) { + EntityPlayer player = event.player; + ItemStack stack = event.crafting; + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } + + @SubscribeEvent + public void onSmelting(ItemSmeltedEvent event) { + EntityPlayer player = event.player; + ItemStack stack = event.smelting; + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } + + @SubscribeEvent + public void onItemPickup(EntityItemPickupEvent event) { + EntityPlayer player = event.entityPlayer; + ItemStack stack = event.item.getEntityItem(); + if (player != null && stack != null) { + handleAchivement(stack, player); + } + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index f6735de8e4..1e3cb0ffbb 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -4,11 +4,13 @@ import static gtPlusPlus.core.lib.LoadedMods.Gregtech; import java.util.*; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.common.compat.*; import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; @@ -19,6 +21,7 @@ import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.recipe.*; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; import gtPlusPlus.xmod.gregtech.registration.gregtech.*; import net.minecraft.item.ItemStack; @@ -39,7 +42,7 @@ public class COMPAT_HANDLER { GT_OreDictUnificator.registerOre("craftingToolSandHammer", new ItemStack(ModItems.itemSandstoneHammer)); for(int i=1; i<=10; i++){ - GT_OreDictUnificator.registerOre("bufferCore_"+GT_Values.VN[i-1], new ItemStack(ItemUtils.getItem("miscutils:item.itemBufferCore"+i))); + GT_OreDictUnificator.registerOre("bufferCore_"+GT_Values.VN[i-1], new ItemStack(ItemUtils.getItemFromFQRN("miscutils:item.itemBufferCore"+i))); } } @@ -204,11 +207,21 @@ public class COMPAT_HANDLER { } } } - RecipeGen_Recycling.executeGenerators(); + RecipeGen_Recycling.executeGenerators(); + runQueuedMisc(); + } + + + + public static void onLoadComplete(FMLLoadCompleteEvent event) { + runQueuedOnLoadComplete(event); } public static final AutoMap<RunnableWithInfo<String>> mRecipesToGenerate = new AutoMap<RunnableWithInfo<String>>(); - public static final AutoMap<RunnableWithInfo<String>> mGtRecipesToGenerate = new AutoMap<RunnableWithInfo<String>>(); + public static final AutoMap<RunnableWithInfo<String>> mGtRecipesToGenerate = new AutoMap<RunnableWithInfo<String>>(); + + public static final AutoMap<RunnableWithInfo<String>> mObjectsToRunInPostInit = new AutoMap<RunnableWithInfo<String>>(); + public static final AutoMap<ItemPackage> mObjectsToRunInOnLoadComplete = new AutoMap<ItemPackage>(); public static void runQueuedRecipes() { //Add autogenerated Recipes from Item Components @@ -233,4 +246,33 @@ public class COMPAT_HANDLER { } } + + public static void runQueuedMisc() { + for (RunnableWithInfo<String> m : mObjectsToRunInPostInit) { + try { + m.run(); + } + catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] "+m.getInfoData()); + } + + } + } + + /** + * Generally used to register GT recipe map changes after they've been populated. + */ + public static void runQueuedOnLoadComplete(FMLLoadCompleteEvent event) { + for (ItemPackage m : mObjectsToRunInOnLoadComplete) { + try { + m.onLoadComplete(event); + } + catch (Throwable t) { + t.printStackTrace(); + Logger.INFO("[ERROR] "+m.getInfoData()); + } + + } + } } diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java index 79a2d2a6c0..0f689325a3 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -1,6 +1,10 @@ package gtPlusPlus.core.handler; +import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gtPlusPlus.xmod.bartcrops.HANDLER_CropsPlusPlus; import gtPlusPlus.xmod.bop.HANDLER_BiomesOPlenty; import gtPlusPlus.xmod.computronics.HANDLER_Computronics; import gtPlusPlus.xmod.forestry.HANDLER_FR; @@ -15,7 +19,7 @@ import gtPlusPlus.xmod.tinkers.HANDLER_Tinkers; public class COMPAT_IntermodStaging { - public static void preInit(){ + public static void preInit(FMLPreInitializationEvent preinit){ HANDLER_GT.preInit(); HANDLER_GC.preInit(); HANDLER_TF.preInit(); @@ -28,9 +32,10 @@ public class COMPAT_IntermodStaging { HANDLER_Tinkers.preInit(); HANDLER_SC2.preInit(); HANDLER_GalactiCraft.preInit(); + HANDLER_CropsPlusPlus.preInit(preinit); } - public static void init(){ + public static void init(FMLInitializationEvent init){ HANDLER_GT.init(); HANDLER_GC.init(); HANDLER_TF.init(); @@ -43,9 +48,10 @@ public class COMPAT_IntermodStaging { HANDLER_Tinkers.init(); HANDLER_SC2.init(); HANDLER_GalactiCraft.init(); + HANDLER_CropsPlusPlus.init(init); } - public static void postInit(){ + public static void postInit(FMLPostInitializationEvent postinit){ HANDLER_GT.postInit(); HANDLER_GC.postInit(); HANDLER_TF.postInit(); @@ -58,6 +64,7 @@ public class COMPAT_IntermodStaging { HANDLER_Tinkers.postInit(); HANDLER_SC2.postInit(); HANDLER_GalactiCraft.postInit(); + HANDLER_CropsPlusPlus.postInit(postinit); } public static void onLoadComplete(FMLLoadCompleteEvent event) { diff --git a/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java b/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java new file mode 100644 index 0000000000..b10e67aeaf --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/StopAnnoyingFuckingAchievements.java @@ -0,0 +1,24 @@ +package gtPlusPlus.core.handler; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.stats.AchievementList; +import net.minecraftforge.event.entity.player.AchievementEvent; + +public class StopAnnoyingFuckingAchievements { + + /** + * Stops me getting fireworks every fucking time I open my inventory upon first loading a dev client. + * @param event + */ + @SubscribeEvent + public void FUCK_OFF(AchievementEvent event) { + if (event.achievement.equals(AchievementList.openInventory)) { + if (MathUtils.randInt(0, 10) >= 9) + PlayerUtils.messagePlayer(event.entityPlayer, "Bang! Nah, Just joking, there's no fireworks. :)"); + event.setCanceled(true); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java index 6c940371b3..ef91647c1a 100644 --- a/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/GeneralTooltipEventHandler.java @@ -3,10 +3,16 @@ package gtPlusPlus.core.handler.events; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.GTplusplus.INIT_PHASE; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -22,8 +28,15 @@ public class GeneralTooltipEventHandler { @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event){ + + if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED && GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.SERVER_START) { + return; + } + if (event.itemStack == null) { + return; + } if (CORE.ConfigSwitches.chanceToDropFluoriteOre > 0) { - if (!BlockEventHandler.blockLimestone.isEmpty()) { + if (BlockEventHandler.blockLimestone != null && !BlockEventHandler.blockLimestone.isEmpty()) { for (ItemStack h : BlockEventHandler.blockLimestone) { if (h != null && Block.getBlockFromItem(h.getItem()) == Block.getBlockFromItem(event.itemStack.getItem())) { if (ItemUtils.getModId(h) != null && !ItemUtils.getModId(h).toLowerCase().contains("biomesoplenty")) { @@ -32,7 +45,7 @@ public class GeneralTooltipEventHandler { } } } - if (!BlockEventHandler.oreLimestone.isEmpty()) { + if (BlockEventHandler.oreLimestone != null && !BlockEventHandler.oreLimestone.isEmpty()) { for (ItemStack h : BlockEventHandler.oreLimestone) { if (h != null && Block.getBlockFromItem(h.getItem()) == Block.getBlockFromItem(event.itemStack.getItem())) { if (ItemUtils.getModId(h) != null && !ItemUtils.getModId(h).toLowerCase().contains("biomesoplenty")) { @@ -43,6 +56,26 @@ public class GeneralTooltipEventHandler { } } + //Material Collector Tooltips + if (ModBlocks.blockPooCollector != null && Block.getBlockFromItem(event.itemStack.getItem()) == ModBlocks.blockPooCollector) { + //Normal + if (event.itemStack.getItemDamage() == 0) { + event.toolTip.add("Used to collect animal waste"); + event.toolTip.add("Collects in a 5x4x5 area starting at Y+1"); + event.toolTip.add("Use Hoppers/Pipes to empty"); + event.toolTip.add(EnumChatFormatting.GOLD+"Capacity: "+EnumChatFormatting.AQUA+"8000L"); + } + //Advanced + else { + event.toolTip.add("Used to collect waste (Works on more than animals)"); + event.toolTip.add("Significantly faster than the simple version"); + event.toolTip.add("Collects in a 5x4x5 area starting at Y+1"); + event.toolTip.add("Use Hoppers/Pipes to empty"); + event.toolTip.add(EnumChatFormatting.GOLD+"Capacity: "+EnumChatFormatting.AQUA+"128000L"); + } + } + + if (CORE.ConfigSwitches.enableAnimatedTurbines) { boolean shift = false; diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index 8d7db4f40a..e8f0e31458 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -32,11 +32,14 @@ import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble; import gtPlusPlus.core.item.bauble.BatteryPackBaseBauble; import gtPlusPlus.core.item.bauble.HealthBoostBauble; import gtPlusPlus.core.item.bauble.ModularBauble; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; import gtPlusPlus.core.item.chemistry.CoalTar; +import gtPlusPlus.core.item.chemistry.GenericChem; import gtPlusPlus.core.item.chemistry.IonParticles; import gtPlusPlus.core.item.chemistry.NuclearChem; import gtPlusPlus.core.item.chemistry.RocketFuels; import gtPlusPlus.core.item.chemistry.StandardBaseParticles; +import gtPlusPlus.core.item.crafting.ItemDummyResearch; import gtPlusPlus.core.item.effects.RarityUncommon; import gtPlusPlus.core.item.general.BaseItemGrindle; import gtPlusPlus.core.item.general.BufferCore; @@ -59,8 +62,10 @@ import gtPlusPlus.core.item.general.chassis.ItemDehydratorCoil; import gtPlusPlus.core.item.general.chassis.ItemDehydratorCoilWire; import gtPlusPlus.core.item.general.throwables.ItemHydrofluoricAcidPotion; import gtPlusPlus.core.item.general.throwables.ItemSulfuricAcidPotion; +import gtPlusPlus.core.item.general.throwables.ItemThrowableBomb; import gtPlusPlus.core.item.init.ItemsFoods; import gtPlusPlus.core.item.materials.DustDecayable; +import gtPlusPlus.core.item.tool.misc.DebugScanner; import gtPlusPlus.core.item.tool.misc.GregtechPump; import gtPlusPlus.core.item.tool.misc.SandstoneHammer; import gtPlusPlus.core.item.tool.misc.box.AutoLunchBox; @@ -87,6 +92,7 @@ import gtPlusPlus.core.util.data.StringUtils; import gtPlusPlus.core.util.debug.DEBUG_INIT; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.everglades.GTplusplus_Everglades; import gtPlusPlus.xmod.eio.material.MaterialEIO; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; @@ -217,6 +223,8 @@ public final class ModItems { public static Item dustCalciumCarbonate; public static Item dustLi2CO3CaOH2; public static Item dustLi2BeF4; + + public static Item dustTumbagaMix; public static Item dustAer; public static Item dustIgnis; @@ -304,7 +312,7 @@ public final class ModItems { public static GregtechPump toolGregtechPump; - public static Item itemGenericToken; + public static ItemGenericToken itemGenericToken; public static Item itemControlCore; @@ -328,6 +336,15 @@ public final class ModItems { public static BatteryPackBaseBauble itemChargePack3; public static BatteryPackBaseBauble itemChargePack4; + public static DebugScanner itemDebugScanner; + + public static ItemDummyResearch itemDummyResearch; + + public static CoreItem itemBombCasing; + public static CoreItem itemBombUnf; + public static CoreItem itemDetCable; + public static ItemThrowableBomb itemBomb; + static { Logger.INFO("Items!"); //Default item used when recipes fail, handy for debugging. Let's make sure they exist when this class is called upon. @@ -336,9 +353,13 @@ public final class ModItems { } public static final void init(){ + + itemDebugScanner = new DebugScanner(); + itemAlkalusDisk = new BaseItemDamageable("itemAlkalusDisk", AddToCreativeTab.tabMisc, 1, 0, "Unknown Use", EnumRarity.rare, EnumChatFormatting.AQUA, false, null); itemBigEgg = new ItemGiantEgg("itemBigEgg", "Ginourmous Chicken Egg", tabMisc, 64, 0, "I had best try disassemble this.. for science!", "fuelLargeChickenEgg", 5000, 0).setTextureName(CORE.MODID + ":itemBigEgg"); itemGenericToken = new ItemGenericToken(); + itemDummyResearch = new ItemDummyResearch(); //Debug Loading if (CORE.DEBUG){ @@ -353,7 +374,7 @@ public final class ModItems { //Some Simple forms of materials itemStickyRubber = new Item().setUnlocalizedName("itemStickyRubber").setCreativeTab(tabMachines).setTextureName(CORE.MODID + ":itemStickyRubber"); GameRegistry.registerItem(itemStickyRubber, "itemStickyRubber"); - GT_OreDictUnificator.registerOre("ingotRubber", ItemUtils.getItemStack(CORE.MODID+":itemStickyRubber", 1)); + GT_OreDictUnificator.registerOre("ingotRubber", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemStickyRubber", 1)); itemCoalCoke = new BaseItemBurnable("itemCoalCoke", "Coking Coal", tabMisc, 64, 0, "Used for metallurgy.", "fuelCoke", 3200, 0).setTextureName(CORE.MODID + ":itemCoalCoke"); @@ -689,7 +710,8 @@ public final class ModItems { GT_OreDictUnificator.registerOre("pelletZirconium", new ItemStack(itemZirconiumChlorideCinterPellet)); //Zirconium Chloride dustZrCl4 = ItemUtils.generateSpecialUseDusts("ZrCl4", "ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[0]; //http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf - dustCookedZrCl4 = ItemUtils.generateSpecialUseDusts("CookedZrCl4", "Cooked ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[0]; //http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf + dustCookedZrCl4 = ItemUtils.generateSpecialUseDusts("CookedZrCl4", "Cooked ZrCl4", "ZrCl4", Utils.rgbtoHexValue(180, 180, 180))[0]; //http://www.iaea.org/inis/collection/NCLCollectionStore/_Public/39/036/39036750.pdf + //Zirconium Tetrafluoride /*GT_OreDictUnificator.registerOre("cellZrF4", ItemUtils.getItemStackOfAmountFromOreDict("cellZirconiumTetrafluoride", 1)); GT_OreDictUnificator.registerOre("dustZrF4", ItemUtils.getItemStackOfAmountFromOreDict("dustZirconiumTetrafluoride", 1));*/ @@ -830,7 +852,9 @@ public final class ModItems { if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDoubleEuropium", 1) == null) && CORE.ConfigSwitches.enableCustom_Pipes){ itemDoublePlateEuropium = new BaseItemPlateDouble(ELEMENT.getInstance().EUROPIUM); } - + + //Tumbaga Mix (For Simple Crafting) + dustTumbagaMix = ItemUtils.generateSpecialUseDusts("MixTumbaga", "Tumbaga Mix", "Au2Cu", Utils.rgbtoHexValue(255, 150, 80))[0]; /* * Decayable Materials @@ -863,12 +887,28 @@ public final class ModItems { itemControlCore = new ItemControlCore(); //Chemistry - CoalTar.run(); - RocketFuels.run(); + new CoalTar(); + new RocketFuels(); //Nuclear Processing - NuclearChem.run(); - + new NuclearChem(); + + //Farm Animal Fun + new AgriculturalChem(); + + //General Chemistry + new GenericChem(); + + + //Bombs + itemBombCasing = new CoreItem("itemBombCasing", "Bomb Casing", tabMisc); + itemBombCasing.setTextureName(CORE.MODID + ":bomb_casing"); + itemBombUnf = new CoreItem("itemBombUnf", "Bomb (unf)", tabMisc); + itemBombUnf.setTextureName(CORE.MODID + ":bomb_casing"); + itemDetCable = new CoreItem("itemDetCable", "Det. Cable", tabMisc); + itemDetCable.setTextureName("string"); + itemBomb = new ItemThrowableBomb(); + //Only used for debugging. /*if (CORE.DEVENV) { new ConnectedBlockFinder(); @@ -1002,7 +1042,7 @@ public final class ModItems { //Baubles Mod Test try { - final Class<?> baublesTest = Class.forName("baubles.api.IBauble"); + final Class<?> baublesTest = ReflectionUtils.getClass("baubles.api.IBauble"); if (baublesTest != null){ COMPAT_Baubles.run(); } @@ -1064,10 +1104,10 @@ public final class ModItems { } public static void registerCustomTokens() { - ItemGenericToken.register(0, "BitCoin", 16, "Can be used on the dark web"); - ItemGenericToken.register(1, "Hand Pump Trade Token I", 1, "Craft into a Tier I Hand pump"); - ItemGenericToken.register(2, "Hand Pump Trade Token II", 1, "Craft into a Tier II Hand pump"); - ItemGenericToken.register(3, "Hand Pump Trade Token III", 1, "Craft into a Tier III Hand pump"); - ItemGenericToken.register(4, "Hand Pump Trade Token IV", 1, "Craft into a Tier IV Hand pump"); + itemGenericToken.register(0, "BitCoin", 16, "Can be used on the dark web"); + itemGenericToken.register(1, "Hand Pump Trade Token I", 1, "Craft into a Tier I Hand pump"); + itemGenericToken.register(2, "Hand Pump Trade Token II", 1, "Craft into a Tier II Hand pump"); + itemGenericToken.register(3, "Hand Pump Trade Token III", 1, "Craft into a Tier III Hand pump"); + itemGenericToken.register(4, "Hand Pump Trade Token IV", 1, "Craft into a Tier IV Hand pump"); } } diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java index 4dbb5851f2..ceeff7e655 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -8,6 +8,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.TextureSet; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.objects.Logger; @@ -17,11 +18,12 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.data.StringUtils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; @@ -66,9 +68,9 @@ public class BaseItemComponent extends Item{ GT_OreDictUnificator.registerOre(componentType.getOreDictName()+material.getUnlocalizedName(), ItemUtils.getSimpleStack(this)); if (LoadedMods.Thaumcraft) { - ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), GTPP_Aspects.METALLUM, 1); + ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), TC_Aspect_Wrapper.generate(TC_Aspects.METALLUM.mAspect), 1); if (componentMaterial.isRadioactive) { - ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), GTPP_Aspects.RADIO, 2); + ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), TC_Aspect_Wrapper.generate(TC_Aspects.RADIO.mAspect), componentMaterial.vRadiationLevel); } } registerComponent(); @@ -76,18 +78,28 @@ public class BaseItemComponent extends Item{ //For Cell Generation public BaseItemComponent(final String unlocalName, final String localName, final short[] RGBA) { + + // Handles .'s from fluid internal names. + String aFormattedNameForFluids; + if (unlocalName.contains(".")) { + aFormattedNameForFluids = StringUtils.splitAndUppercase(unlocalName, "."); + } + else { + aFormattedNameForFluids = unlocalName; + } + this.componentMaterial = null; - this.unlocalName = "itemCell"+unlocalName; + this.unlocalName = "itemCell"+aFormattedNameForFluids; this.materialName = localName; this.componentType = ComponentTypes.CELL; this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(unlocalName); + this.setUnlocalizedName(aFormattedNameForFluids); this.setMaxStackSize(64); this.componentColour = MathUtils.getRgbAsHex(RGBA); this.extraData = RGBA; this.setTextureName(CORE.MODID + ":" + "item"+ComponentTypes.CELL.COMPONENT_NAME); - GameRegistry.registerItem(this, unlocalName); - GT_OreDictUnificator.registerOre(ComponentTypes.CELL.getOreDictName()+unlocalName, ItemUtils.getSimpleStack(this)); + GameRegistry.registerItem(this, aFormattedNameForFluids); + GT_OreDictUnificator.registerOre(ComponentTypes.CELL.getOreDictName()+aFormattedNameForFluids, ItemUtils.getSimpleStack(this)); registerComponent(); } diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockFluid.java b/src/Java/gtPlusPlus/core/item/base/itemblock/FluidItemBlock.java index 84fae41bb0..96b5425437 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockFluid.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/FluidItemBlock.java @@ -13,38 +13,30 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; -public class ItemBlockFluid extends ItemBlock{ +public class FluidItemBlock extends ItemBlock{ protected final int blockColour; - protected final int sRadiation; - protected Material thisFluid; final BlockFluidBase baseBlock; String name; - public ItemBlockFluid(final Block block) { + public FluidItemBlock(final Block block) { super(block); this.baseBlock = (BlockFluidBase) block; this.blockColour = this.baseBlock.getRenderColor(1); - this.thisFluid = this.baseBlock.getFluidMaterial(); - this.sRadiation=ItemUtils.getRadioactivityLevel(this.baseBlock.getUnlocalizedName()); this.name = this.baseBlock.getLocalizedName().replace("tile", "").replace("fluid", "").replace("name", "").replace("block", "").replace(".", ""); //GT_OreDictUnificator.registerOre("frameGt"+block.getUnlocalizedName().replace("tile.", "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox", ""), UtilsItems.getSimpleStack(this)); } - public final Material setFluidMaterial(final Material M){ - return this.thisFluid=M; - } - public int getRenderColor(final int aMeta) { return this.blockColour; } @Override public String getItemStackDisplayName(final ItemStack iStack) { - if (this.thisFluid != null){ + /*if (this.thisFluid != null){ this.name = "Molten "+this.thisFluid.getLocalizedName(); return this.name; - } + }*/ this.name = "Molten "+this.baseBlock.getLocalizedName().replace("tile", "").replace("fluid", "").replace("name", "").replace("block", "").replace(".", ""); return this.name; } @@ -55,24 +47,15 @@ public class ItemBlockFluid extends ItemBlock{ return MathUtils.generateSingularRandomHexValue(); } return this.blockColour; - } @Override public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - list.add("Temperature: "+MathUtils.celsiusToKelvin(this.thisFluid.getMeltingPointC())+"K"); + /*list.add("Temperature: "+MathUtils.celsiusToKelvin(this.thisFluid.getMeltingPointC())+"K"); if (this.sRadiation > 0){ list.add(CORE.GT_Tooltip_Radioactive); - } + }*/ super.addInformation(stack, aPlayer, list, bool); } - public String GetProperName() { - String tempIngot; - - tempIngot = "Molten "+this.baseBlock.getLocalizedName(); - - return tempIngot; - } - } diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java index 517e3f7c1f..396689ef63 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtBlock.java @@ -15,6 +15,7 @@ import gtPlusPlus.core.block.base.BlockBaseOre; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.sys.KeyboardUtils; @@ -44,7 +45,16 @@ public class ItemBlockGtBlock extends ItemBlock { this.blockColour = block.getBlockColor(); } else { this.blockColour = block.getBlockColor(); + } + + if (block instanceof BlockBaseModular){ + BlockBaseModular g = (BlockBaseModular) block; + this.mMaterial = g.getMaterialEx(); + } + else { + this.mMaterial = null; } + // GT_OreDictUnificator.registerOre("block"+block.getUnlocalizedName().replace("tile.block", // "").replace("tile.", "").replace("of", "").replace("Of", "").replace("Block", // "").replace("-", "").replace("_", "").replace(" ", ""), @@ -59,24 +69,32 @@ public class ItemBlockGtBlock extends ItemBlock { public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { if (this.mMaterial != null) { - list.add(this.mMaterial.vChemicalFormula); - if (this.mMaterial.vRadiationLevel > 0) { - list.add(CORE.GT_Tooltip_Radioactive); - } + list.add(this.mMaterial.vChemicalFormula); } else { - list.add("Material is Null."); + + try { + BlockBaseModular g = (BlockBaseModular) thisBlock; + this.mMaterial = g.getMaterialEx(); + } + catch (Throwable t) { + + } + + + //list.add("Material is Null."); } + if (this.isOre) { if (KeyboardUtils.isCtrlKeyDown()) { Block b = Block.getBlockFromItem(stack.getItem()); if (b != null) { String aTool = b.getHarvestTool(stack.getItemDamage()); int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); - list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); if (this.mMaterial != null) { - list.add("Ore contains: "); + list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); + list.add("Contains: "); if (mMaterial.getComposites().isEmpty()) { list.add("- " + mMaterial.getLocalizedName()); } else { @@ -89,6 +107,22 @@ public class ItemBlockGtBlock extends ItemBlock { } else { list.add(EnumChatFormatting.DARK_GRAY + "Hold Ctrl to show additional info."); } + } + else { + Block b = Block.getBlockFromItem(stack.getItem()); + if (b != null) { + String aTool = b.getHarvestTool(stack.getItemDamage()); + int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); + list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); + } + } + + if (this.mMaterial != null) { + if (this.mMaterial.vRadiationLevel > 0) { + list.add(CORE.GT_Tooltip_Radioactive); + } + } + super.addInformation(stack, aPlayer, list, bool); } diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java index 74dd2f196c..0dd125bf7b 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java @@ -1,18 +1,45 @@ package gtPlusPlus.core.item.base.itemblock; import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; + +import java.util.List; import gtPlusPlus.core.block.base.BlockBaseModular; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; public class ItemBlockGtFrameBox extends ItemBlock{ protected int blockColour; + private Material mMaterial; + private int sRadiation; public ItemBlockGtFrameBox(final Block block) { super(block); final BlockBaseModular baseBlock = (BlockBaseModular) block; this.blockColour = baseBlock.getRenderColor(1); + + + + if (block instanceof BlockBaseModular){ + BlockBaseModular g = (BlockBaseModular) block; + this.mMaterial = g.getMaterialEx(); + sRadiation = mMaterial.vRadiationLevel; + } + else { + this.mMaterial = null; + sRadiation = 0; + } + //GT_OreDictUnificator.registerOre("frameGt"+block.getUnlocalizedName().replace("tile.", "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox", ""), ItemUtils.getSimpleStack(this)); } @@ -20,4 +47,48 @@ public class ItemBlockGtFrameBox extends ItemBlock{ return this.blockColour; } + @SuppressWarnings("unchecked") + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if (this.mMaterial != null) { + list.add(this.mMaterial.vChemicalFormula); + if (this.mMaterial.vRadiationLevel > 0) { + list.add(CORE.GT_Tooltip_Radioactive); + } + } else { + list.add("Material is Null."); + } + if (KeyboardUtils.isCtrlKeyDown()) { + Block b = Block.getBlockFromItem(stack.getItem()); + if (b != null) { + String aTool = b.getHarvestTool(stack.getItemDamage()); + int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); + list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); + if (this.mMaterial != null) { + list.add("Contains: "); + if (mMaterial.getComposites().isEmpty()) { + list.add("- " + mMaterial.getLocalizedName()); + } else { + for (MaterialStack m : mMaterial.getComposites()) { + list.add("- " + m.getStackMaterial().getLocalizedName() + " x" + m.getPartsPerOneHundred()); + } + } + } + } + } else { + list.add(EnumChatFormatting.DARK_GRAY + "Hold Ctrl to show additional info."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, + final boolean p_77663_5_) { + + if (this.sRadiation > 0) { + EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding); + } + } + + } diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java index 1d48bbbbf9..b26ac67225 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java @@ -1,8 +1,14 @@ package gtPlusPlus.core.item.base.itemblock; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.api.objects.data.AutoMap; import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlockWithMetadata; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; @@ -10,13 +16,36 @@ import net.minecraft.util.IIcon; public class ItemBlockMeta extends ItemBlockWithMetadata { private final Block mBlock; + private HashMap<Integer, AutoMap<String>> aTooltips = new LinkedHashMap<Integer, AutoMap<String>>(); - public ItemBlockMeta(final Block p_i45326_1_) + public ItemBlockMeta(final Block aBlock) { - super(p_i45326_1_, p_i45326_1_); - this.mBlock = p_i45326_1_; + super(aBlock, aBlock); + this.mBlock = aBlock; this.setMaxDamage(0); this.setHasSubtypes(true); + if (aBlock instanceof ITileTooltip) { + ITileTooltip aTooltip = (ITileTooltip) aBlock; + //aTooltips.put(aTooltip.getTooltipID(), aTooltip.getTooltipMap()); + } + } + + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + Block aThis = Block.getBlockFromItem(stack.getItem()); + if (aThis != null) { + if (!aTooltips.isEmpty()) { + AutoMap<String> h = aTooltips.get(stack.getItemDamage()); + if (h != null && !h.isEmpty()) { + for (String s : h) { + list.add(s); + } + } + } + } + super.addInformation(stack, aPlayer, list, bool); } /** @@ -42,4 +71,44 @@ public class ItemBlockMeta extends ItemBlockWithMetadata public String getUnlocalizedName(final ItemStack stack) { return this.getUnlocalizedName() + "." + stack.getItemDamage(); } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public int getItemEnchantability() { + return 0; + } + + @Override + public boolean getIsRepairable(ItemStack p_82789_1_, ItemStack p_82789_2_) { + return false; + } + + @Override + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return false; + } + + @Override + public int getDisplayDamage(ItemStack stack) { + return 0; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return false; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 0; + } + + @Override + public int getItemEnchantability(ItemStack stack) { + return 0; + } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java index 2b3f477c56..de47ed8225 100644 --- a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java @@ -16,6 +16,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TC_Aspects; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.creative.AddToCreativeTab; @@ -26,7 +27,7 @@ import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; public class BaseOreComponent extends Item{ @@ -57,9 +58,9 @@ public class BaseOreComponent extends Item{ registerComponent(); GT_OreDictUnificator.registerOre(componentType.getComponent()+material.getUnlocalizedName(), ItemUtils.getSimpleStack(this)); if (LoadedMods.Thaumcraft) { - ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), GTPP_Aspects.METALLUM, 2); + ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), TC_Aspect_Wrapper.generate(TC_Aspects.METALLUM.mAspect), 1); if (componentMaterial.isRadioactive) { - ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), GTPP_Aspects.RADIO, 4); + ThaumcraftUtils.addAspectToItem(ItemUtils.getSimpleStack(this), TC_Aspect_Wrapper.generate(TC_Aspects.RADIO.mAspect), componentMaterial.vRadiationLevel); } } diff --git a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java index b6a5dff2ac..eaa0905c93 100644 --- a/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java +++ b/src/Java/gtPlusPlus/core/item/base/rods/BaseItemRod.java @@ -14,22 +14,36 @@ public class BaseItemRod extends BaseItemComponent{ public BaseItemRod(final Material material) { super(material, BaseItemComponent.ComponentTypes.ROD); this.addExtruderRecipe(); + this.addLatheRecipe(); } private void addExtruderRecipe(){ Logger.WARNING("Adding cutter recipe for "+this.materialName+" Rods"); - final ItemStack stackStick = this.componentMaterial.getRod(1); final ItemStack stackBolt = this.componentMaterial.getBolt(4); - + if (ItemUtils.checkForInvalidItems(new ItemStack[] {stackStick, stackBolt})) - GT_Values.RA.addCutterRecipe( - stackStick, - stackBolt, - null, - (int) Math.max(this.componentMaterial.getMass() * 2L, 1L), - 4); + GT_Values.RA.addCutterRecipe( + stackStick, + stackBolt, + null, + (int) Math.max(this.componentMaterial.getMass() * 2L, 1L), + 4); + } + + + private void addLatheRecipe(){ + Logger.WARNING("Adding recipe for "+this.materialName+" Rod"); + ItemStack boltStack = this.componentMaterial.getIngot(1); + if (ItemUtils.checkForInvalidItems(boltStack)){ + GT_Values.RA.addLatheRecipe( + boltStack, + ItemUtils.getSimpleStack(this), + null, + (int) Math.max(this.componentMaterial.getMass() / 8L, 1L), + 4); + } } } diff --git a/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java b/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java index af74c1d535..29e525ed10 100644 --- a/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java +++ b/src/Java/gtPlusPlus/core/item/base/screws/BaseItemScrew.java @@ -18,8 +18,8 @@ public class BaseItemScrew extends BaseItemComponent{ private void addLatheRecipe(){ Logger.WARNING("Adding recipe for "+this.materialName+" Screws"); - final ItemStack boltStack = ItemUtils.getItemStackOfAmountFromOreDict(this.unlocalName.replace("itemScrew", "bolt"), 1); - if (null != boltStack){ + ItemStack boltStack = this.componentMaterial.getBolt(1); + if (ItemUtils.checkForInvalidItems(boltStack)){ GT_Values.RA.addLatheRecipe( boltStack, ItemUtils.getSimpleStack(this), diff --git a/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java new file mode 100644 index 0000000000..0c2bdaa3ef --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java @@ -0,0 +1,408 @@ +package gtPlusPlus.core.item.chemistry; + +import java.util.ArrayList; + +import forestry.plugins.PluginCore; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.ItemPackage; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +public class AgriculturalChem extends ItemPackage { + + private static boolean aBOP; + private static boolean aTiCon; + + private static AutoMap<FluidStack> mBloodFluids = new AutoMap<FluidStack>(); + + /** + * Fluids + */ + + // Poop Juice + public static Fluid PoopJuice; + // Manure Slurry + public static Fluid ManureSlurry; + // Fertile Manure Slurry + public static Fluid FertileManureSlurry; + // Blood + public static Fluid CustomBlood; + + /** + * Items + */ + + // Manure Byproducts + public static Item dustManureByproducts; + // Organic Fertilizer + public static Item dustOrganicFertilizer; + // Dirt + public static Item dustDirt; + + // Poop Juice + // vv - Centrifuge + // Manure Slurry && Manure Byproducts -> (Elements) Centrifuge to several tiny + // piles + // vv - Chem Reactor - Add Peat, Meat + // Organic Fertilizer + // vv - Dehydrate + // Fertilizer + + // Poop Juice + // vv - Mixer - Add Blood, Bone, Meat (1000L Poo, 200L Blood, x2 Bone, x3 Meat) + // Fertile Manure Slurry + // vv - Chem Reactor - Add Peat x1.5 + // Organic Fertilizer x3 + // vv - Dehydrate + // Fertilizer + + + @Override + public void items() { + // Nitrogen, Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon + dustManureByproducts = ItemUtils.generateSpecialUseDusts("ManureByproducts", "Manure Byproduct", + "(N2H4O3)N2P2Ca3CuC8", Utils.rgbtoHexValue(110, 75, 25))[0]; + + // Basically Guano + dustOrganicFertilizer = ItemUtils.generateSpecialUseDusts("OrganicFertilizer", "Organic Fertilizer", + "Ca5(PO4)3(OH)", Utils.rgbtoHexValue(240, 240, 240))[0]; + + // Dirt Dust :) + dustDirt = ItemUtils.generateSpecialUseDusts("Dirt", "Dried Earth", Utils.rgbtoHexValue(65, 50, 15))[0]; + } + + @Override + public void blocks() { + // None yet + } + + @Override + public void fluids() { + // Sewage + PoopJuice = FluidUtils.generateFluidNonMolten("raw.waste", "Raw Animal Waste", 32 + 175, + new short[] { 100, 70, 30, 100 }, null, null, 0, true); + + // Sewage + ManureSlurry = FluidUtils.generateFluidNonMolten("manure.slurry", "Manure Slurry", 39 + 175, + new short[] { 75, 45, 15, 100 }, null, null, 0, true); + + // Sewage + FertileManureSlurry = FluidUtils.generateFluidNonMolten("fertile.manure.slurry", "Fertile Manure Slurry", + 45 + 175, new short[] { 65, 50, 15, 100 }, null, null, 0, true); + } + + + + public AgriculturalChem() { + super(); + + aBOP = LoadedMods.BiomesOPlenty; + aTiCon = LoadedMods.TiCon; + + Logger.INFO("Adding Agrochemical content"); + + FluidStack aBlood; + if (aBOP) { + aBlood = FluidUtils.getFluidStack("hell_blood", 100); + if (aBlood != null) { + Logger.INFO("Found Biome's o Plenty, enabled Blood support."); + CustomBlood = aBlood.getFluid(); + mBloodFluids.put(aBlood); + } + } + + if (aTiCon) { + aBlood = FluidUtils.getFluidStack("hell_blood", 100); + if (aBlood != null) { + Logger.INFO("Found Tinker's Construct, enabled Blood support."); + CustomBlood = aBlood.getFluid(); + mBloodFluids.put(FluidUtils.getFluidStack("blood", 100)); + } + } + + // Handle Blood Internally, Create if required. + if (mBloodFluids.isEmpty() || CustomBlood == null) { + Logger.INFO( + "Did not find any existing Blood fluids. Trying to wildcard search the fluid registry, then generate our own if that fails."); + FluidStack aTempBlood = FluidUtils.getWildcardFluidStack("blood", 100); + if (aTempBlood != null) { + CustomBlood = aTempBlood.getFluid(); + } else { + aTempBlood = FluidUtils.getWildcardFluidStack("hell_blood", 100); + if (aTempBlood == null) { + CustomBlood = FluidUtils.generateFluidNoPrefix("blood", "Blood", 32 + 175, + new short[] { 175, 25, 25, 100 }, true); + } else { + CustomBlood = aTempBlood.getFluid(); + } + } + Logger.INFO("Using " + CustomBlood.getName()); + mBloodFluids.put(FluidUtils.getFluidStack(CustomBlood, 100)); + } + + } + + private static AutoMap<ItemStack> mMeats = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mFish = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mFruits = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mVege = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mNuts = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mSeeds = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mPeat = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mBones = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mBoneMeal = new AutoMap<ItemStack>(); + + private static AutoMap<ItemStack> mList_Master_Meats = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mList_Master_FruitVege = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mList_Master_Bones = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mList_Master_Seeds = new AutoMap<ItemStack>(); + + private static void processAllOreDict() { + processOreDict("listAllmeatraw", mMeats); + processOreDict("listAllfishraw", mFish); + processOreDict("listAllfruit", mFruits); + processOreDict("listAllVeggie", mVege); + processOreDict("listAllnut", mNuts); + processOreDict("listAllSeed", mSeeds); + processOreDict("brickPeat", mPeat); + processOreDict("bone", mBones); + processOreDict("dustBone", mBoneMeal); + // Just make a mega list, makes life easier. + if (!mMeats.isEmpty()) { + for (ItemStack g : mMeats) { + mList_Master_Meats.put(g); + } + } + if (!mFish.isEmpty()) { + for (ItemStack g : mFish) { + mList_Master_Meats.put(g); + } + } + if (!mFruits.isEmpty()) { + for (ItemStack g : mFruits) { + mList_Master_FruitVege.put(g); + } + } + if (!mVege.isEmpty()) { + for (ItemStack g : mVege) { + mList_Master_FruitVege.put(g); + } + } + if (!mNuts.isEmpty()) { + for (ItemStack g : mNuts) { + mList_Master_FruitVege.put(g); + } + } + if (!mSeeds.isEmpty()) { + for (ItemStack g : mSeeds) { + mList_Master_Seeds.put(g); + } + } + if (!mBoneMeal.isEmpty()) { + for (ItemStack g : mBoneMeal) { + mList_Master_Bones.put(g); + } + } + if (!mBones.isEmpty()) { + for (ItemStack g : mBones) { + mList_Master_Bones.put(g); + } + } + } + + private static void processOreDict(String aOreName, AutoMap<ItemStack> aMap) { + ArrayList<ItemStack> aTemp = OreDictionary.getOres(aOreName); + if (!aTemp.isEmpty()) { + for (ItemStack stack : aTemp) { + aMap.put(stack); + } + } + } + + private static void addBasicSlurryRecipes() { + + ItemStack aManureByprod1 = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); + ItemStack aManureByprod2 = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + ItemStack aDirtDust = ItemUtils.getSimpleStack(dustDirt, 1); + + // Poop Juice to Basic Slurry + GT_Values.RA.addCentrifugeRecipe(CI.getNumberedCircuit(10), null, FluidUtils.getFluidStack(PoopJuice, 1000), // In + // Fluid + FluidUtils.getFluidStack(ManureSlurry, 250), // Out Fluid + aDirtDust, aDirtDust, aManureByprod1, aManureByprod1, aManureByprod1, aManureByprod1, + new int[] { 2000, 2000, 500, 500, 250, 250 }, // Chances + 10 * 20, // Time + 30); // EU + + // More Efficient way to get byproducts, less Slurry + GT_Values.RA.addCentrifugeRecipe(CI.getNumberedCircuit(20), null, FluidUtils.getFluidStack(PoopJuice, 1000), // In + // Fluid + FluidUtils.getFluidStack(ManureSlurry, 50), // Out Fluid + aDirtDust, aDirtDust, aManureByprod1, aManureByprod1, aManureByprod2, aManureByprod2, + new int[] { 4000, 3000, 1250, 1250, 675, 675 }, // Chances + 20 * 20, // Time + 60); // EU + + } + + private static void addAdvancedSlurryRecipes() { + + ItemStack aCircuit = CI.getNumberedCircuit(10); + ItemStack aBone; + ItemStack aMeat; + ItemStack aEmptyCells = CI.emptyCells(2); + ItemStack aInputCells = ItemUtils.getItemStackOfAmountFromOreDict("cellRawWaste", 2); + FluidStack aOutput = FluidUtils.getFluidStack(FertileManureSlurry, 1000); + + for (FluidStack aBloodStack : mBloodFluids) { + for (ItemStack aBoneStack : mList_Master_Bones) { + aBone = ItemUtils.getSimpleStack(aBoneStack, 2); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); + // Poop Juice to Fertile Slurry + GT_Values.RA.addMixerRecipe(aCircuit, aBone, aMeat, aInputCells, aBloodStack, // Input Fluid + aOutput, // Output Fluid + aEmptyCells, // Output Item + 20 * 8, // Time? + 60 // Eu? + ); + } + } + } + } + + private static void addBasicOrganiseFertRecipes() { + FluidStack aInputFluid = FluidUtils.getFluidStack(ManureSlurry, 1000); + ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 3); + ItemStack aPeat; + ItemStack aMeat; + for (ItemStack aPeatStack : mPeat) { + aPeat = ItemUtils.getSimpleStack(aPeatStack, 3); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 5); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 20 * 20, 120); + } + + aPeat = ItemUtils.getSimpleStack(aPeatStack, 2); + for (ItemStack aMeatStack : mList_Master_FruitVege) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 9); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 10 * 20, 120); + } + } + } + + private static void addAdvancedOrganiseFertRecipes() { + FluidStack aInputFluid = FluidUtils.getFluidStack(FertileManureSlurry, 1000); + ItemStack aOutputDust = ItemUtils.getSimpleStack(dustOrganicFertilizer, 7); + ItemStack aPeat; + ItemStack aMeat; + for (ItemStack aPeatStack : mPeat) { + aPeat = ItemUtils.getSimpleStack(aPeatStack, 5); + for (ItemStack aMeatStack : mList_Master_Meats) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 7); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 10 * 20, 140); + } + aPeat = ItemUtils.getSimpleStack(aPeatStack, 3); + for (ItemStack aMeatStack : mList_Master_FruitVege) { + aMeat = ItemUtils.getSimpleStack(aMeatStack, 12); + CORE.RA.addChemicalRecipe(aPeat, aMeat, aInputFluid, null, aOutputDust, 5 * 20, 140); + } + } + } + + private static void addMiscRecipes() { + + ItemStack aDustOrganicFert = ItemUtils.getSimpleStack(dustOrganicFertilizer, 1); + ItemStack aManureByprod = ItemUtils.getSimpleStack(dustManureByproducts, 1); + + // Dehydrate Organise Fert to Normal Fert. + + /** + * Forestry Support + */ + if (LoadedMods.Forestry) { + + Item aForestryFert = PluginCore.items.fertilizerCompound; + + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedCircuit(11), ItemUtils.getSimpleStack(aDustOrganicFert, 4) }, null, + null, new ItemStack[] { ItemUtils.getSimpleStack(aForestryFert, 3), aManureByprod, aManureByprod }, + new int[] { 10000, 2000, 2000 }, 20 * 20, 240); + } + + /** + * IC2 Support + */ + if (LoadedMods.IndustrialCraft2) { + CORE.RA.addDehydratorRecipe( + new ItemStack[] { CI.getNumberedCircuit(12), ItemUtils.getSimpleStack(aDustOrganicFert, 4) }, null, + null, new ItemStack[] { ItemUtils.getItemStackFromFQRN("IC2:itemFertilizer", 3), aManureByprod, + aManureByprod }, + new int[] { 10000, 2000, 2000 }, 20 * 20, 240); + } + + // Dirt Production + CORE.RA.addCompressorRecipe(ItemUtils.getSimpleStack(dustDirt, 9), ItemUtils.getSimpleStack(Blocks.dirt), + 20 * 2, 8); + + // Centrifuge Byproducts + + // Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon + GT_Values.RA.addCentrifugeRecipe(CI.getNumberedCircuit(20), ItemUtils.getSimpleStack(aManureByprod, 4), + FluidUtils.getFluidStack("sulfuricacid", 250), // In Fluid + FluidUtils.getFluidStack("sulfuricapatite", 50), // Out Fluid + Materials.Phosphorus.getDustSmall(2), Materials.Calcium.getDustSmall(2), + Materials.Copper.getDustTiny(1), Materials.Carbon.getDust(1), ItemUtils.getSimpleStack(dustDirt, 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyAmmoniumNitrate", 1), + new int[] { 2500, 2500, 750, 1000, 5000, 250 }, // Chances + 20 * 20, // Time + 60); // EU + + // Add Fuel Usages + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(PoopJuice, 1000), 12); + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(ManureSlurry, 1000), 24); + CORE.RA.addSemifluidFuel(FluidUtils.getFluidStack(FertileManureSlurry, 1000), 32); + + } + + @Override + public String errorMessage() { + // TODO Auto-generated method stub + return "Failed to generate recipes for AgroChem."; + } + + @Override + public boolean generateRecipes() { + if (mBloodFluids.isEmpty()) { + Logger.INFO("Could not find, nor create Blood fluid. Unable to add recipes."); + return false; + } + + // Organise OreDict + processAllOreDict(); + + // Slurry Production + addBasicSlurryRecipes(); + addAdvancedSlurryRecipes(); + + // Organic Fert. Production + addBasicOrganiseFertRecipes(); + addAdvancedOrganiseFertRecipes(); + + addMiscRecipes(); + return true; + } +} diff --git a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java index eea1aed49f..e060723afd 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/CoalTar.java @@ -8,7 +8,7 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; - +import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.lib.CORE; @@ -21,9 +21,10 @@ import gtPlusPlus.core.util.reflect.AddGregtechRecipe; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -public class CoalTar { +public class CoalTar extends ItemPackage { public static Fluid Coal_Gas; + public static Fluid Coal_Oil; public static Fluid Ethylene; public static Fluid Benzene; public static Fluid Ethylbenzene; @@ -39,116 +40,6 @@ public class CoalTar { public static Fluid Hydrogen_Peroxide; public static Fluid Lithium_Peroxide; - public static void run(){ - - //Special Compatibility for Coke - ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(ModItems.itemCoalCoke, 1), "fuelCoke"); - //Create Coal Gas - Coal_Gas = FluidUtils.generateFluidNonMolten("CoalGas", "Coal Gas", 500, new short[]{48, 48, 48, 100}, null, null); - //Ethanol - // v - Dehydrate cells to remove water - - - //Create Ethylene - if (!FluidUtils.doesFluidExist("Ethylene")){ - Ethylene = FluidUtils.generateFluidNonMolten("Ethylene", "Ethylene", -103, new short[]{255, 255, 255, 100}, null, null); - } - else { - Ethylene = FluidUtils.getWildcardFluidStack("Ethylene", 1).getFluid(); - } - - //Create Benzene - (Toluene + Hydrogen | 95% Benzene / 5% methane) - if (!FluidUtils.doesFluidExist("NitrousOxide")){ - Benzene = FluidUtils.generateFluidNonMolten("Benzene", "Benzene", 81, new short[]{150, 75, 0, 100}, null, null); - } - else { - Benzene = FluidUtils.getWildcardFluidStack("Benzene", 1).getFluid(); - } - - //Create Ethylbenzene - Ethylbenzene is produced in on a large scale by combining benzene and ethylene in an acid-catalyzed chemical reaction - //Use Chemical Reactor - Ethylbenzene = FluidUtils.generateFluidNonMolten("Ethylbenzene", "Ethylbenzene", 136, new short[]{255, 255, 255, 100}, null, null); - //Create Anthracene - Anthracene = FluidUtils.generateFluidNonMolten("Anthracene", "Anthracene", 340, new short[]{255, 255, 255, 100}, null, null); - //Toluene - if (!FluidUtils.doesFluidExist("Toluene")){ - Toluene = FluidUtils.generateFluidNonMolten("Toluene", "Toluene", -95, new short[]{140, 70, 20, 100}, null, null); - } - else { - Toluene = FluidUtils.getWildcardFluidStack("Toluene", 1).getFluid(); - Item itemCellToluene = new BaseItemComponent("Toluene", "Toluene", new short[]{140, 70, 20, 100}); - MaterialGenerator.addFluidCannerRecipe(ItemUtils.getEmptyCell(), ItemUtils.getSimpleStack(itemCellToluene), FluidUtils.getFluidStack(Toluene, 1000), null); - } - - //Create Coal Tar - Coal_Tar = FluidUtils.generateFluidNonMolten("CoalTar", "Coal Tar", 450, new short[]{32, 32, 32, 100}, null, null); - // v - Distill (60% Tar oil/15% Naphtha/20% Ethylbenzene/5% Anthracene) - //Create Coal Tar Oil - Coal_Tar_Oil = FluidUtils.generateFluidNonMolten("CoalTarOil", "Coal Tar Oil", 240, new short[]{240, 240, 150, 100}, null, null); - // v - Wash With Sulfuric Acid - //Create Sulfuric Coal Tar Oil - Sulfuric_Coal_Tar_Oil = FluidUtils.generateFluidNonMolten("SulfuricCoalTarOil", "Sulfuric Coal Tar Oil", 240, new short[]{250, 170, 12, 100}, null, null); - // v - Distill (No loss, just time consuming) - //Create Naphthalene - Naphthalene = FluidUtils.generateFluidNonMolten("Naphthalene", "Naphthalene", 115, new short[]{210, 185, 135, 100}, null, null); - // v - Oxidize with mercury and nitric acid - //Create Phthalic Acid - Phthalic_Acid = FluidUtils.generateFluidNonMolten("PhthalicAcid", "Phthalic Acid", 207, new short[]{210, 220, 210, 100}, null, null); - // v - Dehydrate at 180C+ - //Create Phthalic Anhydride - ItemUtils.generateSpecialUseDusts("PhthalicAnhydride", "Phthalic Anhydride", "C6H4(CO)2O", Utils.rgbtoHexValue(175, 175, 175)); - - - - //Create 2-Ethylanthraquinone - //2-Ethylanthraquinone is prepared from the reaction of phthalic anhydride and ethylbenzene - Ethylanthraquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthraquinone", "2-Ethylanthraquinone", 415, new short[]{227, 255, 159, 100}, null, null); - //Create 2-Ethylanthrahydroquinone - //Palladium plate + Hydrogen(250) + 2-Ethylanthraquinone(500) = 600 Ethylanthrahydroquinone - Ethylanthrahydroquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthrahydroquinone", "2-Ethylanthrahydroquinone", 415, new short[]{207, 225, 129, 100}, null, null); - //Create Hydrogen Peroxide - //Compressed Air(1500) + Ethylanthrahydroquinone(500) + Anthracene(5) = 450 Ethylanthraquinone && 200 Peroxide - Hydrogen_Peroxide = FluidUtils.generateFluidNonMolten("HydrogenPeroxide", "Hydrogen Peroxide", 150, new short[]{210, 255, 255, 100}, null, null); - - - - //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O - ItemUtils.generateSpecialUseDusts("LithiumHydroperoxide", "Lithium Hydroperoxide", "HLiO2", Utils.rgbtoHexValue(125, 125, 125)); - // v - Dehydrate - //Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O - Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new short[]{135, 135, 135, 100}, null, null); - - //Burn the coal gas! - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalGas", 1), null, 96, 1); - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 1), null, 32, 3); - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 1), null, 64, 3); - GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTar", 1), null, 128, 3); - createRecipes(); - - - } - - private static void createRecipes() { - recipeCreateEthylene(); - recipeCreateBenzene(); - recipeCreateEthylbenzene(); - - recipeCoalToCoalTar(); - recipeCoalTarToCoalTarOil(); - recipeCoalTarOilToSulfuricOilToNaphthalene(); - recipeNaphthaleneToPhthalicAcid(); - recipePhthalicAcidToPhthalicAnhydride(); - recipe2Ethylanthraquinone(); - recipe2Ethylanthrahydroquinone(); - recipeHydrogenPeroxide(); - recipeLithiumHydroperoxide(); - recipeLithiumPeroxide(); - - recipeEthylBenzineFuelsIntoHeavyFuel(); - } - - - private static void recipeEthylBenzineFuelsIntoHeavyFuel() { CORE.RA.addChemicalRecipe( ItemUtils.getItemStackOfAmountFromOreDict("cellFuel", 9), @@ -228,6 +119,15 @@ public class CoalTar { public static void recipeCoalToCoalTar(){ + //Charcoal + AddGregtechRecipe.addCokeAndPyrolyseRecipes( + GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 32L), + 8, + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallDirt", 2), + FluidUtils.getFluidStack("fluid.coaltar", 800), + 15, + 120); //Lignite AddGregtechRecipe.addCokeAndPyrolyseRecipes( GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Lignite, 16L), @@ -235,7 +135,7 @@ public class CoalTar { GT_Values.NF, ItemUtils.getItemStackOfAmountFromOreDict("dustSmallDarkAsh", 2), FluidUtils.getFluidStack("fluid.coaltar", 800), - 90, + 45, 60); //Coal @@ -245,7 +145,7 @@ public class CoalTar { GT_Values.NF, ItemUtils.getItemStackOfAmountFromOreDict("dustSmallDarkAsh", 2), FluidUtils.getFluidStack("fluid.coaltar", 2200), - 60, + 30, 120); //Coke @@ -255,7 +155,7 @@ public class CoalTar { GT_Values.NF, ItemUtils.getItemStackOfAmountFromOreDict("dustSmallAsh", 3), FluidUtils.getFluidStack("fluid.coaltar", 3400), - 30, + 15, 240); } @@ -295,14 +195,24 @@ public class CoalTar { 900, //aDuration 30,//aEUt false //Hidden? - ); + ); + GT_Values.RA.addDistilleryRecipe( + CI.getNumberedCircuit(5), //Circuit + FluidUtils.getFluidStack("fluid.coaltar", 1500), //aInput + FluidUtils.getFluidStack("fluid.kerosene", 400), //aOutput + 300, //aDuration + 64,//aEUt + false //Hidden? + ); + GT_Values.RA.addDistillationTowerRecipe( FluidUtils.getFluidStack("fluid.coaltar", 1000), new FluidStack[]{ - FluidUtils.getFluidStack("fluid.coaltaroil", 600), //aOutput - FluidUtils.getFluidStack("liquid_naphtha", 150), //aOutput - FluidUtils.getFluidStack("fluid.ethylbenzene", 200), //aOutput + FluidUtils.getFluidStack("fluid.coaltaroil", 500), //aOutput + FluidUtils.getFluidStack("liquid_naphtha", 100), //aOutput + FluidUtils.getFluidStack("fluid.ethylbenzene", 150), //aOutput FluidUtils.getFluidStack("fluid.anthracene", 50), //aOutput + FluidUtils.getFluidStack("fluid.kerosene", 200), //aOutput }, null, 900, @@ -430,4 +340,141 @@ public class CoalTar { 240); } + @Override + public String errorMessage() { + // TODO Auto-generated method stub + return "Bad Coal Science!"; + } + + @Override + public boolean generateRecipes() { + recipeCreateEthylene(); + recipeCreateBenzene(); + recipeCreateEthylbenzene(); + + recipeCoalToCoalTar(); + recipeCoalTarToCoalTarOil(); + recipeCoalTarOilToSulfuricOilToNaphthalene(); + recipeNaphthaleneToPhthalicAcid(); + recipePhthalicAcidToPhthalicAnhydride(); + recipe2Ethylanthraquinone(); + recipe2Ethylanthrahydroquinone(); + recipeHydrogenPeroxide(); + recipeLithiumHydroperoxide(); + recipeLithiumPeroxide(); + + recipeEthylBenzineFuelsIntoHeavyFuel(); + + //Burn the coal gas! + GT_Values.RA.addFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalGas", 1), null, 96, 1); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellSulfuricCoalTarOil", 1), 64); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTarOil", 1), 32); + CORE.RA.addSemifluidFuel(ItemUtils.getItemStackOfAmountFromOreDict("cellCoalTar", 1), 16); + + return true; + } + + @Override + public void items() { + //Phthalic_Acid = FluidUtils.generateFluidNonMolten("PhthalicAcid", "Phthalic Acid", 207, new short[]{210, 220, 210, 100}, null, null); + // v - Dehydrate at 180C+ + //Create Phthalic Anhydride + ItemUtils.generateSpecialUseDusts("PhthalicAnhydride", "Phthalic Anhydride", "C6H4(CO)2O", Utils.rgbtoHexValue(175, 175, 175)); + + //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O + ItemUtils.generateSpecialUseDusts("LithiumHydroperoxide", "Lithium Hydroperoxide", "HLiO2", Utils.rgbtoHexValue(125, 125, 125)); + // v - Dehydrate + //Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O + //Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new short[]{135, 135, 135, 100}, null, null); + } + + @Override + public void blocks() { + // TODO Auto-generated method stub + + } + + @Override + public void fluids() { + + + //Special Compatibility for Coke + ItemUtils.addItemToOreDictionary(ItemUtils.getSimpleStack(ModItems.itemCoalCoke, 1), "fuelCoke"); + //Create Coal Gas + Coal_Gas = FluidUtils.generateFluidNonMolten("CoalGas", "Coal Gas", 500, new short[]{48, 48, 48, 100}, null, null); + //Ethanol + // v - Dehydrate cells to remove water + + + //Create Ethylene + if (!FluidUtils.doesFluidExist("Ethylene")){ + Ethylene = FluidUtils.generateFluidNonMolten("Ethylene", "Ethylene", -103, new short[]{255, 255, 255, 100}, null, null); + } + else { + Ethylene = FluidUtils.getWildcardFluidStack("Ethylene", 1).getFluid(); + } + + //Create Benzene - (Toluene + Hydrogen | 95% Benzene / 5% methane) + if (!FluidUtils.doesFluidExist("NitrousOxide")){ + Benzene = FluidUtils.generateFluidNonMolten("Benzene", "Benzene", 81, new short[]{150, 75, 0, 100}, null, null); + } + else { + Benzene = FluidUtils.getWildcardFluidStack("Benzene", 1).getFluid(); + } + + //Create Ethylbenzene - Ethylbenzene is produced in on a large scale by combining benzene and ethylene in an acid-catalyzed chemical reaction + //Use Chemical Reactor + Ethylbenzene = FluidUtils.generateFluidNonMolten("Ethylbenzene", "Ethylbenzene", 136, new short[]{255, 255, 255, 100}, null, null); + //Create Anthracene + Anthracene = FluidUtils.generateFluidNonMolten("Anthracene", "Anthracene", 340, new short[]{255, 255, 255, 100}, null, null); + //Toluene + if (!FluidUtils.doesFluidExist("Toluene")){ + Toluene = FluidUtils.generateFluidNonMolten("Toluene", "Toluene", -95, new short[]{140, 70, 20, 100}, null, null); + } + else { + Toluene = FluidUtils.getWildcardFluidStack("Toluene", 1).getFluid(); + Item itemCellToluene = new BaseItemComponent("Toluene", "Toluene", new short[]{140, 70, 20, 100}); + MaterialGenerator.addFluidCannerRecipe(ItemUtils.getEmptyCell(), ItemUtils.getSimpleStack(itemCellToluene), FluidUtils.getFluidStack(Toluene, 1000), null); + } + + //Create Coal Tar + Coal_Tar = FluidUtils.generateFluidNonMolten("CoalTar", "Coal Tar", 450, new short[]{32, 32, 32, 100}, null, null); + // v - Distill (60% Tar oil/15% Naphtha/20% Ethylbenzene/5% Anthracene) + //Create Coal Tar Oil + Coal_Tar_Oil = FluidUtils.generateFluidNonMolten("CoalTarOil", "Coal Tar Oil", 240, new short[]{240, 240, 150, 100}, null, null); + // v - Wash With Sulfuric Acid + //Create Sulfuric Coal Tar Oil + Sulfuric_Coal_Tar_Oil = FluidUtils.generateFluidNonMolten("SulfuricCoalTarOil", "Sulfuric Coal Tar Oil", 240, new short[]{250, 170, 12, 100}, null, null); + // v - Distill (No loss, just time consuming) + //Create Naphthalene + Naphthalene = FluidUtils.generateFluidNonMolten("Naphthalene", "Naphthalene", 115, new short[]{210, 185, 135, 100}, null, null); + // v - Oxidize with mercury and nitric acid + //Create Phthalic Acid + Phthalic_Acid = FluidUtils.generateFluidNonMolten("PhthalicAcid", "Phthalic Acid", 207, new short[]{210, 220, 210, 100}, null, null); + // v - Dehydrate at 180C+ + //Create Phthalic Anhydride + //ItemUtils.generateSpecialUseDusts("PhthalicAnhydride", "Phthalic Anhydride", "C6H4(CO)2O", Utils.rgbtoHexValue(175, 175, 175)); + + + + //Create 2-Ethylanthraquinone + //2-Ethylanthraquinone is prepared from the reaction of phthalic anhydride and ethylbenzene + Ethylanthraquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthraquinone", "2-Ethylanthraquinone", 415, new short[]{227, 255, 159, 100}, null, null); + //Create 2-Ethylanthrahydroquinone + //Palladium plate + Hydrogen(250) + 2-Ethylanthraquinone(500) = 600 Ethylanthrahydroquinone + Ethylanthrahydroquinone2 = FluidUtils.generateFluidNonMolten("2Ethylanthrahydroquinone", "2-Ethylanthrahydroquinone", 415, new short[]{207, 225, 129, 100}, null, null); + //Create Hydrogen Peroxide + //Compressed Air(1500) + Ethylanthrahydroquinone(500) + Anthracene(5) = 450 Ethylanthraquinone && 200 Peroxide + Hydrogen_Peroxide = FluidUtils.generateFluidNonMolten("HydrogenPeroxide", "Hydrogen Peroxide", 150, new short[]{210, 255, 255, 100}, null, null); + + + + //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O + //ItemUtils.generateSpecialUseDusts("LithiumHydroperoxide", "Lithium Hydroperoxide", "HLiO2", Utils.rgbtoHexValue(125, 125, 125)); + // v - Dehydrate + //Lithium Peroxide - 2 LiOOH → Li2O2 + H2O2 + 2 H2O + Lithium_Peroxide = FluidUtils.generateFluidNonMolten("LithiumPeroxide", "Lithium Peroxide", 446, new short[]{135, 135, 135, 100}, null, null); + + } + } diff --git a/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java b/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java new file mode 100644 index 0000000000..02afada849 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/chemistry/GenericChem.java @@ -0,0 +1,108 @@ +package gtPlusPlus.core.item.chemistry; + +import gregtech.api.enums.TextureSet; +import gtPlusPlus.api.objects.minecraft.ItemPackage; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.material.MaterialGenerator; +import gtPlusPlus.core.material.state.MaterialState; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.Item; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +public class GenericChem extends ItemPackage { + + /** + * Materials + */ + + public static final Material BAKELITE = new Material("Bakelite", MaterialState.SOLID, TextureSet.SET_DULL, new short[]{90, 140, 140}, 120, 240, 23, 24, true, "", 0);//Not a GT Inherited Material + public static final Material NYLON = new Material("Nylon", MaterialState.SOLID, TextureSet.SET_SHINY, new short[]{45, 45, 45}, 300, 600, 44, 48, true, "", 0);//Not a GT Inherited Material + public static final Material TEFLON = new Material("Teflon", MaterialState.SOLID, TextureSet.SET_SHINY, new short[]{75, 45, 75}, 300, 600, 44, 48, true, "", 0);//Not a GT Inherited Material + + //public static final Material HYPOGEN = new Material("Hypogen", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{220, 120, 75}, 12255, 19377, 240, 251, true, "Hy⚶", 0);//Not a GT Inherited Material + //public static final Material HYPOGEN = new Material("Hypogen", MaterialState.SOLID, TextureSets.NUCLEAR.get(), new short[]{220, 120, 75}, 12255, 19377, 240, 251, true, "Hy⚶", 0);//Not a GT Inherited Material + //public static final Material Nylon = new Material(); + + /** + * Fluids + */ + + public Fluid Benzene; + public Fluid NitroBenzene; + public Fluid Aniline; + public Fluid Polyurethane; + public Fluid Phenol; //https://en.wikipedia.org/wiki/Phenol#Uses + public Fluid Cyclohexane; //https://en.wikipedia.org/wiki/Cyclohexane + public Fluid Cyclohexanone; //https://en.wikipedia.org/wiki/Cyclohexanone + + public Fluid Cadaverine; //https://en.wikipedia.org/wiki/Cadaverine + public Fluid Putrescine; //https://en.wikipedia.org/wiki/Putrescine + + + /** + * Items + */ + + // Phenol Byproducts + public Item PhenolicResins; //https://en.wikipedia.org/wiki/Phenol_formaldehyde_resin + + + + @Override + public void items() { + PhenolicResins = ItemUtils.generateSpecialUseDusts("phenolicresins", "Phenolic Resin", "HOC6H4CH2OH", Utils.rgbtoHexValue(80, 40, 40))[0]; + MaterialGenerator.generate(BAKELITE, false); + MaterialGenerator.generate(NYLON, false); + MaterialGenerator.generate(TEFLON, false); + } + + @Override + public void blocks() {} + + @Override + public void fluids() { + + if (!FluidRegistry.isFluidRegistered("benzene")) { + Benzene = FluidUtils.generateFluidNoPrefix("benzene", "Benzene", 278, new short[] { 100, 70, 30, 100 }, true); + } + else { + Benzene = FluidRegistry.getFluid("benzene"); + } + + NitroBenzene = FluidUtils.generateFluidNoPrefix("nitrobenzene", "NitroBenzene", 278, new short[] { 70, 50, 40, 100 }, true); + + Aniline = FluidUtils.generateFluidNoPrefix("aniline", "Aniline", 266, new short[] { 100, 100, 30, 100 }, true); + + Polyurethane = FluidUtils.generateFluidNoPrefix("polyurethane", "Polyurethane", 350, new short[] { 100, 70, 100, 100 }, true); + + if (!FluidRegistry.isFluidRegistered("phenol")) { + Phenol = FluidUtils.generateFluidNoPrefix("phenol", "Phenol", 313, new short[] { 100, 70, 30, 100 }, true); + } + else { + Phenol = FluidRegistry.getFluid("phenol"); + } + + Cyclohexane = FluidUtils.generateFluidNoPrefix("cyclohexane", "Cyclohexane", 32 + 175, new short[] { 100, 70, 30, 100 }, true); + Cyclohexanone = FluidUtils.generateFluidNoPrefix("cyclohexanone", "Cyclohexanone", 32 + 175, new short[] { 100, 70, 30, 100 }, true); + + Cadaverine = FluidUtils.generateFluidNoPrefix("cadaverine", "Cadaverine", 32 + 175, new short[] { 100, 70, 30, 100 }, true); + Putrescine = FluidUtils.generateFluidNoPrefix("putrescine", "Putrescine", 32 + 175, new short[] { 100, 70, 30, 100 }, true); + + } + + @Override + public String errorMessage() { + // TODO Auto-generated method stub + return "Failed to generate recipes for AgroChem."; + } + + @Override + public boolean generateRecipes() { + + + return true; + } +} diff --git a/src/Java/gtPlusPlus/core/item/chemistry/IonParticles.java b/src/Java/gtPlusPlus/core/item/chemistry/IonParticles.java index 517a698e80..e08a509436 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/IonParticles.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/IonParticles.java @@ -6,6 +6,7 @@ import java.util.List; import gregtech.api.enums.Materials; import gtPlusPlus.core.item.base.misc.BaseItemParticle; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.util.Utils; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -22,18 +23,16 @@ public class IonParticles extends BaseItemParticle { public IonParticles() { - super("Ion", aElements.length, EnumRarity.rare); + super("Ion", ELEMENT.NAMES.length, EnumRarity.rare); } - private static final String[] aElements = new String[]{"Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminum", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; - - public static IIcon[] overlays = new IIcon[aElements.length]; + public static IIcon[] overlays = new IIcon[ELEMENT.NAMES.length]; public static IIcon baseTexture; static { //Generate Ions int key = 0; - for (String s : aElements) { + for (String s : ELEMENT.NAMES) { //Map names to Meta NameToMetaMap.put(Utils.sanitizeString(s.toLowerCase()), key); MetaToNameMap.put(key, Utils.sanitizeString(s.toLowerCase())); @@ -62,7 +61,7 @@ public class IonParticles extends BaseItemParticle { @Override public String getUnlocalizedName(final ItemStack itemStack) { - return "item.particle.ion" + "." + aElements[itemStack.getItemDamage()]; + return "item.particle.ion" + "." + ELEMENT.NAMES[itemStack.getItemDamage()]; } private static boolean createNBT(ItemStack rStack){ diff --git a/src/Java/gtPlusPlus/core/item/chemistry/NuclearChem.java b/src/Java/gtPlusPlus/core/item/chemistry/NuclearChem.java index 1d45dec183..25beb6d9b5 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/NuclearChem.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/NuclearChem.java @@ -3,7 +3,7 @@ package gtPlusPlus.core.item.chemistry; import net.minecraft.init.Items; import gregtech.api.enums.GT_Values; - +import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; @@ -11,18 +11,40 @@ import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraftforge.fluids.Fluid; -public class NuclearChem { +public class NuclearChem extends ItemPackage { public static Fluid Burnt_LiFBeF2ThF4UF4; public static Fluid Burnt_LiFBeF2ZrF4UF4; public static Fluid Burnt_LiFBeF2ZrF4U235; public static Fluid GeneticMutagen; - private static boolean generateMutagenRecipe = false; + private static boolean generateMutagenRecipe = false; + + @Override + public String errorMessage() { + return "bad Nuclear Chemistry Recipes."; + } - public static void run(){ + @Override + public boolean generateRecipes() { + if (generateMutagenRecipe) { + chemReator_CreateMutagen(); + } + chemReactor_MutagenWithEggs(); + return true; + } + + @Override + public void items() { + } + + @Override + public void blocks() { + } - //Create Coal Gas + @Override + public void fluids() { + //Create Used Nuclear Fuels Burnt_LiFBeF2ThF4UF4 = FluidUtils.generateFluidNonMolten("BurntLiFBeF2ThF4UF4", "Burnt LiFBeF2ThF4UF4 Salt", 545, new short[]{48, 175, 48, 100}, null, null); Burnt_LiFBeF2ZrF4UF4 = FluidUtils.generateFluidNonMolten("BurntLiFBeF2ZrF4UF4", "Burnt LiFBeF2ZrF4UF4 Salt", 520, new short[]{48, 168, 68, 100}, null, null); Burnt_LiFBeF2ZrF4U235 = FluidUtils.generateFluidNonMolten("BurntLiFBeF2ZrF4U235", "Burnt LiFBeF2ZrF4U235 Salt", 533, new short[]{68, 185, 48, 100}, null, null); @@ -34,18 +56,6 @@ public class NuclearChem { else { GeneticMutagen = FluidUtils.getFluidStack("fluid.Mutagen", 1).getFluid(); } - - createRecipes(); - - - } - - private static void createRecipes() { - - if (generateMutagenRecipe) - chemReator_CreateMutagen(); - - chemReactor_MutagenWithEggs(); } private static void chemReator_CreateMutagen() { diff --git a/src/Java/gtPlusPlus/core/item/chemistry/OilChem.java b/src/Java/gtPlusPlus/core/item/chemistry/OilChem.java new file mode 100644 index 0000000000..cb7e32eaf0 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/chemistry/OilChem.java @@ -0,0 +1,201 @@ +package gtPlusPlus.core.item.chemistry; + +import java.util.ArrayList; + +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.ItemPackage; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.oredict.OreDictionary; + +public class OilChem extends ItemPackage { + + /** + * Fluids + */ + + // Poop Juice + public static Fluid PoopJuice; + // Manure Slurry + public static Fluid ManureSlurry; + // Fertile Manure Slurry + public static Fluid FertileManureSlurry; + + /** + * Items + */ + + // Manure Byproducts + public static Item dustManureByproducts; + // Organic Fertilizer + public static Item dustOrganicFertilizer; + // Dirt + public static Item dustDirt; + + // Poop Juice + // vv - Centrifuge + // Manure Slurry && Manure Byproducts -> (Elements) Centrifuge to several tiny + // piles + // vv - Chem Reactor - Add Peat, Meat + // Organic Fertilizer + // vv - Dehydrate + // Fertilizer + + // Poop Juice + // vv - Mixer - Add Blood, Bone, Meat (1000L Poo, 200L Blood, x2 Bone, x3 Meat) + // Fertile Manure Slurry + // vv - Chem Reactor - Add Peat x1.5 + // Organic Fertilizer x3 + // vv - Dehydrate + // Fertilizer + + + @Override + public void items() { + // Nitrogen, Ammonium Nitrate, Phosphates, Calcium, Copper, Carbon + dustManureByproducts = ItemUtils.generateSpecialUseDusts("ManureByproducts", "Manure Byproduct", + "(N2H4O3)N2P2Ca3CuC8", Utils.rgbtoHexValue(110, 75, 25))[0]; + + // Basically Guano + dustOrganicFertilizer = ItemUtils.generateSpecialUseDusts("OrganicFertilizer", "Organic Fertilizer", + "Ca5(PO4)3(OH)", Utils.rgbtoHexValue(240, 240, 240))[0]; + + // Dirt Dust :) + dustDirt = ItemUtils.generateSpecialUseDusts("Dirt", "Dried Earth", Utils.rgbtoHexValue(65, 50, 15))[0]; + } + + @Override + public void blocks() { + // None yet + } + + @Override + public void fluids() { + // Sewage + PoopJuice = FluidUtils.generateFluidNonMolten("raw.waste", "Raw Animal Waste", 32 + 175, + new short[] { 100, 70, 30, 100 }, null, null, 0, true); + + // Sewage + ManureSlurry = FluidUtils.generateFluidNonMolten("manure.slurry", "Manure Slurry", 39 + 175, + new short[] { 75, 45, 15, 100 }, null, null, 0, true); + + // Sewage + FertileManureSlurry = FluidUtils.generateFluidNonMolten("fertile.manure.slurry", "Fertile Manure Slurry", + 45 + 175, new short[] { 65, 50, 15, 100 }, null, null, 0, true); + } + + private static AutoMap<ItemStack> mMeats = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mFish = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mFruits = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mVege = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mNuts = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mSeeds = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mPeat = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mBones = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mBoneMeal = new AutoMap<ItemStack>(); + + private static AutoMap<ItemStack> mList_Master_Meats = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mList_Master_FruitVege = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mList_Master_Bones = new AutoMap<ItemStack>(); + private static AutoMap<ItemStack> mList_Master_Seeds = new AutoMap<ItemStack>(); + + private static void processAllOreDict() { + processOreDict("listAllmeatraw", mMeats); + processOreDict("listAllfishraw", mFish); + processOreDict("listAllfruit", mFruits); + processOreDict("listAllVeggie", mVege); + processOreDict("listAllnut", mNuts); + processOreDict("listAllSeed", mSeeds); + processOreDict("brickPeat", mPeat); + processOreDict("bone", mBones); + processOreDict("dustBone", mBoneMeal); + // Just make a mega list, makes life easier. + if (!mMeats.isEmpty()) { + for (ItemStack g : mMeats) { + mList_Master_Meats.put(g); + } + } + if (!mFish.isEmpty()) { + for (ItemStack g : mFish) { + mList_Master_Meats.put(g); + } + } + if (!mFruits.isEmpty()) { + for (ItemStack g : mFruits) { + mList_Master_FruitVege.put(g); + } + } + if (!mVege.isEmpty()) { + for (ItemStack g : mVege) { + mList_Master_FruitVege.put(g); + } + } + if (!mNuts.isEmpty()) { + for (ItemStack g : mNuts) { + mList_Master_FruitVege.put(g); + } + } + if (!mSeeds.isEmpty()) { + for (ItemStack g : mSeeds) { + mList_Master_Seeds.put(g); + } + } + if (!mBoneMeal.isEmpty()) { + for (ItemStack g : mBoneMeal) { + mList_Master_Bones.put(g); + } + } + if (!mBones.isEmpty()) { + for (ItemStack g : mBones) { + mList_Master_Bones.put(g); + } + } + } + + private static void processOreDict(String aOreName, AutoMap<ItemStack> aMap) { + ArrayList<ItemStack> aTemp = OreDictionary.getOres(aOreName); + if (!aTemp.isEmpty()) { + for (ItemStack stack : aTemp) { + aMap.put(stack); + } + } + } + + private static void addBasicSlurryRecipes() {} + + private static void addAdvancedSlurryRecipes() {} + + private static void addBasicOrganiseFertRecipes() {} + + private static void addAdvancedOrganiseFertRecipes() {} + + private static void addMiscRecipes() {} + + @Override + public String errorMessage() { + // TODO Auto-generated method stub + return "Failed to generate recipes for AgroChem."; + } + + @Override + public boolean generateRecipes() { + + // Organise OreDict + processAllOreDict(); + + // Slurry Production + addBasicSlurryRecipes(); + addAdvancedSlurryRecipes(); + + // Organic Fert. Production + addBasicOrganiseFertRecipes(); + addAdvancedOrganiseFertRecipes(); + + addMiscRecipes(); + return true; + } +} diff --git a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java index a516cb0639..f2b5d0683c 100644 --- a/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java +++ b/src/Java/gtPlusPlus/core/item/chemistry/RocketFuels.java @@ -1,31 +1,37 @@ package gtPlusPlus.core.item.chemistry; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.Recipe_GT; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.api.objects.minecraft.ItemPackage; import gtPlusPlus.core.item.base.BaseItemComponent; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -public class RocketFuels { +public class RocketFuels extends ItemPackage { public static HashSet<String> mValidRocketFuelNames = new HashSet<String>(); public static HashMap<Integer, Fluid> mValidRocketFuels = new HashMap<Integer, Fluid>(); - public static Fluid Kerosene; + public static Fluid Oil_Heavy; + public static Fluid Diesel; + public static Fluid Kerosene; public static Fluid RP1; public static Fluid Nitrogen_Tetroxide; public static Fluid Hydrazine; @@ -45,117 +51,23 @@ public class RocketFuels { public static Item Ammonium_Nitrate_Dust; public static Item Formaldehyde_Catalyst; - - public static void run(){ - - //Create Kerosene - Kerosene = FluidUtils.generateFluidNonMolten("Kerosene", "Kerosene", 500, new short[]{150, 40, 150, 100}, null, null); - - //RP! Focket Fuel - RP1 = FluidUtils.generateFluidNonMolten("RP1Fuel", "RP-1 Rocket Fuel", 500, new short[]{210, 50, 50, 100}, null, null); - - //Create Nitrogen Tetroxide - Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten("NitrogenTetroxide", "Nitrogen Tetroxide", -11, new short[]{170, 170, 0, 100}, null, null); - - //Create Hydrazine - Hydrazine = FluidUtils.generateFluidNonMolten("Hydrazine", "Hydrazine", 2, new short[]{250, 250, 250, 100}, null, null); - - //Create Monomethylhydrazine - Monomethylhydrazine = FluidUtils.generateFluidNonMolten("Monomethylhydrazine", "Monomethylhydrazine", -52, new short[]{125, 125, 125, 100}, null, null); - - //Create Anthracene - Nitrous_Oxide = FluidUtils.generateFluidNonMolten("NitrousOxide", "Nitrous Oxide", -91, new short[]{255, 255, 255, 100}, null, null); - - //Nos - if (!FluidUtils.doesFluidExist("NitrousOxide")){ - Nitrous_Oxide = FluidUtils.generateFluidNoPrefix("NitrousOxide", "Nitrous Oxide", -91, new short[]{255, 255, 255, 100}); - } - else { - Nitrous_Oxide = FluidUtils.getWildcardFluidStack("NitrousOxide", 1).getFluid(); - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellNitrousOxide", 1) == null){ - new BaseItemComponent("NitrousOxide", "Nitrous Oxide", new short[] {10, 10, 175}); - } - } - - //Unsymmetrical_Dimethylhydrazine - if (FluidUtils.getFluidStack("1,1dimethylhydrazine", 1) == null){ - Unsymmetrical_Dimethylhydrazine = FluidUtils.generateFluidNonMolten("UnsymmetricalDimethylhydrazine", "Unsymmetrical Dimethylhydrazine", -57, new short[]{70, 210, 20, 100}, null, null); - } - else { - Unsymmetrical_Dimethylhydrazine = FluidUtils.getFluidStack("1,1dimethylhydrazine", 1000).getFluid(); - } - - //Create Hydrated_Ammonium_Nitrate_Slurry - Hydrated_Ammonium_Nitrate_Slurry = FluidUtils.generateFluidNonMolten("AmmoniumNitrateSlurry", "Hydrated Ammonium Nitrate Slurry", 450, new short[]{150, 75, 150, 100}, null, null); - - //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O - Ammonium_Nitrate_Dust = ItemUtils.generateSpecialUseDusts("AmmoniumNitrate", "Ammonium Nitrate", "N2H4O3", Utils.rgbtoHexValue(150, 75, 150))[0]; - - //Create Liquid_Oxygen - if (FluidUtils.getFluidStack("LiquidOxygen", 1) == null && FluidUtils.getFluidStack("liquidoxygen", 1) == null){ - Liquid_Oxygen = FluidUtils.generateFluidNonMolten("LiquidOxygen", "Liquid Oxygen", -240, new short[]{75, 75, 220, 100}, null, null); - } - else { - if (FluidUtils.getFluidStack("LiquidOxygen", 1) != null ) { - Liquid_Oxygen = FluidUtils.getFluidStack("LiquidOxygen", 1).getFluid(); - } - else { - Liquid_Oxygen = FluidUtils.getFluidStack("liquidoxygen", 1).getFluid(); - } - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellLiquidOxygen", 1) == null){ - new BaseItemComponent("LiquidOxygen", "Liquid Oxygen", new short[] {10, 10, 175}); - } - } - - Formaldehyde = FluidUtils.generateFluidNonMolten("Formaldehyde", "Formaldehyde", -92, new short[]{150, 75, 150, 100}, null, null); - Formaldehyde_Catalyst = ItemUtils.generateSpecialUseDusts("FormaldehydeCatalyst", "Formaldehyde Catalyst", "Fe16V1", Utils.rgbtoHexValue(25, 5, 25))[0]; - - - Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten("RocketFuelMixA", "H8N4C2O4 Rocket Fuel", -185, new short[]{50, 220, 50, 100}, null, null); - RP1_Plus_Liquid_Oxygen = FluidUtils.generateFluidNonMolten("RocketFuelMixB", "Rp-1 Fuel Mixture", -250, new short[]{250, 50, 50, 100}, null, null); - Monomethylhydrazine_Plus_Nitric_Acid = FluidUtils.generateFluidNonMolten("RocketFuelMixC", "CN3H7O3 Rocket Fuel", -300, new short[]{125, 75, 180, 100}, null, null); - Dense_Hydrazine_Mix = FluidUtils.generateFluidNonMolten("RocketFuelMixD", "Dense Hydrazine Fuel Mixture", -250, new short[]{175, 80, 120, 100}, null, null); - - - - createRecipes(); - - - } - - private static void createRecipes() { - createKerosene(); - createRP1(); - createNitrogenTetroxide(); - createHydrazine(); - createMonomethylhydrazine(); - - if (!CORE.GTNH) { - createLOX(); - } - - - createHydratedAmmoniumNitrateSlurry(); - createAmmoniumNitrateDust(); - createFormaldehyde(); - createFormaldehydeCatalyst(); - createUnsymmetricalDimethylhydrazine(); - - createRocketFuels(); - addRocketFuelsToMap(); - - } - + public static void createKerosene(){ - FluidStack fuelA = FluidUtils.getFluidStack("diesel", 400); - FluidStack fuelB = FluidUtils.getFluidStack("fuel", 400); + + + + FluidStack fuelA = FluidUtils.getFluidStack("diesel", 300); + FluidStack fuelB = FluidUtils.getFluidStack("fuel", 300); + + + if (fuelA != null){ //GT_Values.RA.addDistilleryRecipe(23, fuelA, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); - GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelA, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); + GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelA, FluidUtils.getFluidStack(Kerosene, 100), 200, 64, false); } if (fuelA == null && fuelB != null){ //GT_Values.RA.addDistilleryRecipe(23, fuelB, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); - GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelB, FluidUtils.getFluidStack(Kerosene, 50), 200, 64, false); + GT_Values.RA.addDistilleryRecipe(CI.getNumberedCircuit(23), fuelB, FluidUtils.getFluidStack(Kerosene, 100), 200, 64, false); } } @@ -288,9 +200,9 @@ public class RocketFuels { } - private static void addRocketFuelsToMap() { - AutoMap<Recipe_GT> mRocketFuels = new AutoMap<Recipe_GT>(); - mRocketFuels.put(new Recipe_GT( + private static void addRocketFuelsToMap() { + HashMap<Integer, Recipe_GT> mRocketFuels = new LinkedHashMap<Integer, Recipe_GT>(); + mRocketFuels.put(0, new Recipe_GT( true, new ItemStack[] {}, new ItemStack[] {}, @@ -302,7 +214,7 @@ public class RocketFuels { 0, 256)); //Fuel Value - mRocketFuels.put(new Recipe_GT( + mRocketFuels.put(1, new Recipe_GT( true, new ItemStack[] {}, new ItemStack[] {}, @@ -314,7 +226,7 @@ public class RocketFuels { 0, 512)); //Fuel Value - mRocketFuels.put(new Recipe_GT( + mRocketFuels.put(2, new Recipe_GT( true, new ItemStack[] {}, new ItemStack[] {}, @@ -326,7 +238,7 @@ public class RocketFuels { 0, 768)); //Fuel Value - mRocketFuels.put(new Recipe_GT( + mRocketFuels.put(3, new Recipe_GT( true, new ItemStack[] {}, new ItemStack[] {}, @@ -340,15 +252,15 @@ public class RocketFuels { //Add in default Diesel for the Buggy - mValidRocketFuelNames.add(Materials.Fuel.getFluid(1).getFluid().getName()); - mValidRocketFuels.put(-1, Materials.Fuel.getFluid(1).getFluid()); - - int mID = 0; - for (Recipe_GT r : mRocketFuels) { - if (r != null) { - mValidRocketFuelNames.add(r.mFluidInputs[0].getFluid().getName()); - mValidRocketFuels.put(mID++, r.mFluidInputs[0].getFluid()); - Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.add(r); + mValidRocketFuels.put(-1, Diesel); + + mValidRocketFuelNames.add(FluidRegistry.getFluidName(Diesel)); + for (int mID : mRocketFuels.keySet()) { + Recipe_GT aFuelRecipe = mRocketFuels.get(mID); + if (aFuelRecipe != null) { + mValidRocketFuelNames.add(FluidRegistry.getFluidName(aFuelRecipe.mFluidInputs[0].getFluid())); + mValidRocketFuels.put(mID, aFuelRecipe.mFluidInputs[0].getFluid()); + Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.add(aFuelRecipe); } } @@ -500,6 +412,333 @@ public class RocketFuels { } + @Override + public String errorMessage() { + // TODO Auto-generated method stub + return "Bad Rocket Fuel Science!"; + } + + @Override + public boolean generateRecipes() { + createKerosene(); + createRP1(); + createNitrogenTetroxide(); + createHydrazine(); + createMonomethylhydrazine(); + + if (!CORE.GTNH) { + createLOX(); + } + + + createHydratedAmmoniumNitrateSlurry(); + createAmmoniumNitrateDust(); + createFormaldehyde(); + createFormaldehydeCatalyst(); + createUnsymmetricalDimethylhydrazine(); + + createRocketFuels(); + addRocketFuelsToMap(); + + return true; + } + + @Override + public boolean onLoadComplete(FMLLoadCompleteEvent event) { + + + if (MathUtils.randInt(1, 2) > 0) { + return false; + } + + + Materials aMaterial_Chloramine = MaterialUtils.getMaterial("Chloramine"); + Materials aMaterial_Dimethylamine = MaterialUtils.getMaterial("Dimethylamine"); + Materials aMaterial_DilutedHydrochloricAcid = MaterialUtils.getMaterial("DilutedHydrochloricAcid"); + Materials aMaterial_NitrogenDioxide = MaterialUtils.getMaterial("NitrogenDioxide"); + Materials aMaterial_DinitrogenTetroxide = MaterialUtils.getMaterial("DinitrogenTetroxide"); + Materials aMaterial_Dimethylhydrazine = MaterialUtils.getMaterial("Dimethylhydrazine"); + + Materials aMaterial_Oxygen = Materials.Oxygen; + Materials aMaterial_Water = Materials.Water; + Materials aMaterial_HypochlorousAcid = MaterialUtils.getMaterial("HypochlorousAcid"); + Materials aMaterial_Ammonia = MaterialUtils.getMaterial("Ammonia"); + Materials aMaterial_Methanol = MaterialUtils.getMaterial("Methanol"); + + if (aMaterial_Chloramine == null || aMaterial_Dimethylamine == null || aMaterial_DilutedHydrochloricAcid == null + || aMaterial_Dimethylhydrazine == null || aMaterial_NitrogenDioxide == null || aMaterial_DinitrogenTetroxide == null + || aMaterial_HypochlorousAcid == null || aMaterial_Ammonia == null || aMaterial_Methanol == null) { + return false; + } + + + ItemStack aCellEmpty = CI.emptyCells(1); + ItemStack aCellWater = aMaterial_Water.getCells(1); + ItemStack aCellOxygen = aMaterial_Oxygen.getCells(1); + ItemStack aCellChloramine = aMaterial_Chloramine.getCells(1); + ItemStack aCellDimethylamine = aMaterial_Dimethylamine.getCells(1); + ItemStack aCellDilutedHydrochloricAcid = aMaterial_DilutedHydrochloricAcid.getCells(1); + ItemStack aCellNitrogenDioxide = aMaterial_NitrogenDioxide.getCells(1); + ItemStack aCellDinitrogenTetroxide = aMaterial_DinitrogenTetroxide.getCells(1); + ItemStack aCellDimethylhydrazine = aMaterial_Dimethylhydrazine.getCells(1); + + + + + + + GT_Recipe aChemReactor_1 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_2 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + + + + GT_Recipe aChemReactor_Basic_1 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_Basic_2 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_Basic_3 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_Basic_4 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + + + + + + + + + + + + + GT_Recipe aChemReactor_Adv_1 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + GT_Recipe aChemReactor_Adv_2 = new Recipe_GT( + true, //Optimise + new ItemStack[] {}, //I + new ItemStack[] {}, //O + null, //Special + new int[] {}, //Chance + new FluidStack[] {}, //I + new FluidStack[] {}, //O + 0, //Dura + 0, //Eu + 0); //Special + + + + + //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); + //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); + //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); + //RecipeUtils.removeGtRecipe(aChemReactor_Basic_1, GT_Recipe.GT_Recipe_Map.sChemicalRecipes); + + + + + + + /* GT_Values.RA.addChemicalRecipe( Materials.Chloramine.getCells(2), GT_Utility.getIntegratedCircuit(1), Materials.Dimethylamine.getGas(5000), Materials.Dimethylhydrazine.getFluid(6000), Materials.DilutedHydrochloricAcid.getCells(1), Materials.Empty.getCells(1), 960, 480); + GT_Values.RA.addChemicalRecipe( Materials.Dimethylamine.getCells(5), GT_Utility.getIntegratedCircuit(1), Materials.Chloramine.getFluid(2000), Materials.Dimethylhydrazine.getFluid(6000), Materials.DilutedHydrochloricAcid.getCells(1), Materials.Empty.getCells(4), 960, 480); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Chloramine.getCells(2), Materials.Empty.getCells(4), Materials.Dimethylamine.getGas(5000), Materials.DilutedHydrochloricAcid.getFluid(1000), Materials.Dimethylhydrazine.getCells(6), GT_Values.NI, 960, 480); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Dimethylamine.getCells(5), Materials.Empty.getCells(1), Materials.Chloramine.getFluid(2000), Materials.DilutedHydrochloricAcid.getFluid(1000), Materials.Dimethylhydrazine.getCells(6), GT_Values.NI, 960, 480); + GT_Values.RA.addChemicalRecipeForBasicMachineOnly(Materials.Dimethylamine.getCells(5), Materials.Chloramine.getCells(2), Materials.Chloramine.getFluid(2000), Materials.DilutedHydrochloricAcid.getFluid(1000), Materials.Dimethylhydrazine.getCells(6), Materials.DilutedHydrochloricAcid.getCells(1), 960, 480); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(24)}, new FluidStack[]{Materials.HypochlorousAcid.getFluid(3000), Materials.Ammonia.getGas(8000), Materials.Methanol.getFluid(12000)}, new FluidStack[]{Materials.Dimethylhydrazine.getFluid(12000), Materials.DilutedHydrochloricAcid.getFluid(2000), Materials.Water.getFluid(9000)}, null, 1040, 480); + + GT_Values.RA.addChemicalRecipe(GT_Utility.getIntegratedCircuit(2), GT_Values.NI, Materials.NitrogenDioxide.getGas(1000), Materials.DinitrogenTetroxide.getGas(1000), GT_Values.NI, 640); + GT_Values.RA.addChemicalRecipe(Materials.NitrogenDioxide.getCells(1), GT_Utility.getIntegratedCircuit(2), GT_Values.NF, Materials.DinitrogenTetroxide.getGas(1000), Materials.Empty.getCells(1), 640); + GT_Values.RA.addChemicalRecipe(Materials.NitrogenDioxide.getCells(1), GT_Utility.getIntegratedCircuit(12), GT_Values.NF, GT_Values.NF, Materials.DinitrogenTetroxide.getCells(1), 640); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(23)}, new FluidStack[]{Materials.Ammonia.getGas(8000), Materials.Oxygen.getGas(7000)}, new FluidStack[]{Materials.DinitrogenTetroxide.getGas(6000), Materials.Water.getFluid(9000)}, null, 480, 30); + GT_Values.RA.addMultiblockChemicalRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(23)}, new FluidStack[]{Materials.Nitrogen.getGas(2000), Materials.Hydrogen.getGas(6000), Materials.Oxygen.getGas(7000)}, new FluidStack[]{Materials.DinitrogenTetroxide.getGas(6000), Materials.Water.getFluid(9000)}, null, 1100, 480); + + GT_Values.RA.addMixerRecipe(Materials.Dimethylhydrazine.getCells(1), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.DinitrogenTetroxide.getGas(1000), new FluidStack(ItemList.sRocketFuel, 2000), Materials.Empty.getCells(1), 60, 16); + GT_Values.RA.addMixerRecipe(Materials.DinitrogenTetroxide.getCells(1), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.Dimethylhydrazine.getFluid(1000), new FluidStack(ItemList.sRocketFuel, 2000), Materials.Empty.getCells(1), 60, 16); + GT_Values.RA.addMixerRecipe(Materials.Dimethylhydrazine.getCells(2), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.Oxygen.getGas(1000), new FluidStack(ItemList.sRocketFuel, 3000), Materials.Empty.getCells(2), 60, 16); + GT_Values.RA.addMixerRecipe(Materials.Oxygen.getCells(1), GT_Values.NI, GT_Values.NI, GT_Values.NI, Materials.Dimethylhydrazine.getFluid(2000), new FluidStack(ItemList.sRocketFuel, 3000), Materials.Empty.getCells(1), 60, 16); + + + */ + + + + + + + + + + //Get Rocket Fuel + + //Find recipes using default values + + //Remove + + //Rebake map + + return true; + }; + + @Override + public void items() { + Formaldehyde_Catalyst = ItemUtils.generateSpecialUseDusts("FormaldehydeCatalyst", "Formaldehyde Catalyst", "Fe16V1", Utils.rgbtoHexValue(25, 5, 25))[0]; + } + + @Override + public void blocks() { + } + + @Override + public void fluids() { + + //Register default fluids + Diesel = MaterialUtils.getMaterial("Fuel", "Diesel").getFluid(1).getFluid(); + Oil_Heavy = MaterialUtils.getMaterial("OilHeavy", "Oil").getFluid(1).getFluid(); + + + //Create Kerosene + Kerosene = FluidUtils.generateFluidNonMolten("Kerosene", "Kerosene", 500, new short[]{150, 40, 150, 100}, null, null); + CoalTar.Coal_Oil = Kerosene; + + //RP! Focket Fuel + RP1 = FluidUtils.generateFluidNonMolten("RP1Fuel", "RP-1 Rocket Fuel", 500, new short[]{210, 50, 50, 100}, null, null); + + //Create Nitrogen Tetroxide + Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten("NitrogenTetroxide", "Nitrogen Tetroxide", -11, new short[]{170, 170, 0, 100}, null, null); + + //Create Hydrazine + Hydrazine = FluidUtils.generateFluidNonMolten("Hydrazine", "Hydrazine", 2, new short[]{250, 250, 250, 100}, null, null); + + //Create Monomethylhydrazine + Monomethylhydrazine = FluidUtils.generateFluidNonMolten("Monomethylhydrazine", "Monomethylhydrazine", -52, new short[]{125, 125, 125, 100}, null, null); + + //Create Anthracene + Nitrous_Oxide = FluidUtils.generateFluidNonMolten("NitrousOxide", "Nitrous Oxide", -91, new short[]{255, 255, 255, 100}, null, null); + + //Nos + if (!FluidUtils.doesFluidExist("NitrousOxide")){ + Nitrous_Oxide = FluidUtils.generateFluidNoPrefix("NitrousOxide", "Nitrous Oxide", -91, new short[]{255, 255, 255, 100}); + } + else { + Nitrous_Oxide = FluidUtils.getWildcardFluidStack("NitrousOxide", 1).getFluid(); + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellNitrousOxide", 1) == null){ + new BaseItemComponent("NitrousOxide", "Nitrous Oxide", new short[] {10, 10, 175}); + } + } + + //Unsymmetrical_Dimethylhydrazine + if (FluidUtils.getFluidStack("1,1dimethylhydrazine", 1) == null){ + Unsymmetrical_Dimethylhydrazine = FluidUtils.generateFluidNonMolten("UnsymmetricalDimethylhydrazine", "Unsymmetrical Dimethylhydrazine", -57, new short[]{70, 210, 20, 100}, null, null); + } + else { + Unsymmetrical_Dimethylhydrazine = FluidUtils.getFluidStack("1,1dimethylhydrazine", 1000).getFluid(); + } + + //Create Hydrated_Ammonium_Nitrate_Slurry + Hydrated_Ammonium_Nitrate_Slurry = FluidUtils.generateFluidNonMolten("AmmoniumNitrateSlurry", "Hydrated Ammonium Nitrate Slurry", 450, new short[]{150, 75, 150, 100}, null, null); + + //Lithium Hydroperoxide - LiOH + H2O2 → LiOOH + 2 H2O + Ammonium_Nitrate_Dust = ItemUtils.generateSpecialUseDusts("AmmoniumNitrate", "Ammonium Nitrate", "N2H4O3", Utils.rgbtoHexValue(150, 75, 150))[0]; + + //Create Liquid_Oxygen + if (FluidUtils.getFluidStack("LiquidOxygen", 1) == null && FluidUtils.getFluidStack("liquidoxygen", 1) == null){ + Liquid_Oxygen = FluidUtils.generateFluidNonMolten("LiquidOxygen", "Liquid Oxygen", -240, new short[]{75, 75, 220, 100}, null, null); + } + else { + if (FluidUtils.getFluidStack("LiquidOxygen", 1) != null ) { + Liquid_Oxygen = FluidUtils.getFluidStack("LiquidOxygen", 1).getFluid(); + } + else { + Liquid_Oxygen = FluidUtils.getFluidStack("liquidoxygen", 1).getFluid(); + } + if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cellLiquidOxygen", 1) == null){ + new BaseItemComponent("LiquidOxygen", "Liquid Oxygen", new short[] {10, 10, 175}); + } + } + + + Formaldehyde = FluidUtils.generateFluidNonMolten("Formaldehyde", "Formaldehyde", -92, new short[]{150, 75, 150, 100}, null, null); + + Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide = FluidUtils.generateFluidNonMolten("RocketFuelMixA", "H8N4C2O4 Rocket Fuel", -185, new short[]{50, 220, 50, 100}, null, null); + RP1_Plus_Liquid_Oxygen = FluidUtils.generateFluidNonMolten("RocketFuelMixB", "Rp-1 Fuel Mixture", -250, new short[]{250, 50, 50, 100}, null, null); + Monomethylhydrazine_Plus_Nitric_Acid = FluidUtils.generateFluidNonMolten("RocketFuelMixC", "CN3H7O3 Rocket Fuel", -300, new short[]{125, 75, 180, 100}, null, null); + Dense_Hydrazine_Mix = FluidUtils.generateFluidNonMolten("RocketFuelMixD", "Dense Hydrazine Fuel Mixture", -250, new short[]{175, 80, 120, 100}, null, null); + + + } + } diff --git a/src/Java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java b/src/Java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java new file mode 100644 index 0000000000..1c28f99ff8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/crafting/ItemDummyResearch.java @@ -0,0 +1,111 @@ +package gtPlusPlus.core.item.crafting; + +import java.util.LinkedHashMap; +import java.util.Map; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.general.ItemGenericToken; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +public class ItemDummyResearch extends ItemGenericToken { + + public static enum ASSEMBLY_LINE_RESEARCH { + + + RESEARCH_1_CONTAINMENT("Containment Fields", "Advanced scientific study"), + RESEARCH_2_BASIC_CHEM("Basic Chemistry", "Time to start at the beginning"), + RESEARCH_3_ADV_CHEM("Advanced Chemistry", "Best learn more than chemical equations"), + RESEARCH_4_BASIC_PHYSICS("Basic Physics", "Fundamental laws of motion"), + RESEARCH_5_ADV_PHYSICS("Advanced Physics", "Advanced knowledge!"), + RESEARCH_6_BASIC_METALLURGY("Basic Metallurgy", "Information about material smelting"), + RESEARCH_7_ADV_METALLURGY("Advanced Metallurgy", "Advanced Material Sciences!"); + + + + + + + + + + + + + + + + + + + private String mName; + private String mDesc; + + private ASSEMBLY_LINE_RESEARCH(String aName, String aDesc) { + mName = aName; + mDesc = aDesc; + ModItems.itemDummyResearch.register(mName, mDesc); + } + + } + + + + + + + + + + + private static Map<String, Integer> mInternalNameToIdMap = new LinkedHashMap<String, Integer>(); + + public static ItemStack getResearchStack(ASSEMBLY_LINE_RESEARCH aResearchName, int aStacksize) { + Integer aMeta = mInternalNameToIdMap.get(Utils.sanitizeString(aResearchName.mName)); + if (aMeta == null) { + aMeta = 0; + } + return ItemUtils.simpleMetaStack(ModItems.itemDummyResearch, aMeta, aStacksize); + } + + private int aID = 0; + public ItemDummyResearch() { + super("dummyResearch", "Research", new String[] {"This object requires some further study"}, "research"); + + + + } + + /** + * + * @param aResearchType - What is the research for? + * @param aDescriptThe - tooltip for this research + * @return - Did we register a custom research item? + */ + public boolean register(String aResearchType, String aDescript) { + int aNewID = aID++; + mInternalNameToIdMap.put(Utils.sanitizeString(aResearchType), aNewID); + return register(aNewID, "Research on "+aResearchType, 1, aDescript); + } + + @Override + public boolean register(int id, String aLocalName, int aMaxStack, String aDescript) { + return register(id, aLocalName, 1, new String[] {aDescript, EnumChatFormatting.DARK_GRAY+"Used to further your knowledge"}, EnumRarity.common, EnumChatFormatting.LIGHT_PURPLE); + } + + @Override + @SideOnly(Side.CLIENT) + public final void registerIcons(final IIconRegister aIconRegister) { + for (int i = 0, j = mLocalNames.size(); i < j; i++) { + mIcons.put(i, aIconRegister.registerIcon(CORE.MODID + ":" + "research" + "/" + "note")); + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java b/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java index eb22f8fa07..5ef72b6f17 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemControlCore.java @@ -17,7 +17,7 @@ import gtPlusPlus.core.lib.CORE; public class ItemControlCore extends Item { - public IIcon[] icons = new IIcon[10]; + public static IIcon[] icons = new IIcon[10]; public ItemControlCore() { super(); @@ -31,16 +31,16 @@ public class ItemControlCore extends Item { @Override public void registerIcons(IIconRegister reg) { - this.icons[0] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_0"); - this.icons[1] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_1"); - this.icons[2] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_2"); - this.icons[3] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_3"); - this.icons[4] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_4"); - this.icons[5] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_5"); - this.icons[6] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_6"); - this.icons[7] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_7"); - this.icons[8] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_8"); - this.icons[9] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_9"); + icons[0] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_0"); + icons[1] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_1"); + icons[2] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_2"); + icons[3] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_3"); + icons[4] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_4"); + icons[5] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_5"); + icons[6] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_6"); + icons[7] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_7"); + icons[8] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_8"); + icons[9] = reg.registerIcon(CORE.MODID + ":" + "controlcore/Core_9"); } @Override diff --git a/src/Java/gtPlusPlus/core/item/general/ItemGenericToken.java b/src/Java/gtPlusPlus/core/item/general/ItemGenericToken.java index dfd5eca203..c076bf5c95 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemGenericToken.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemGenericToken.java @@ -19,37 +19,38 @@ import net.minecraft.util.IIcon; public class ItemGenericToken extends CoreItem { - public final static HashMap<Integer, String> mLocalNames; - public final static HashMap<Integer, Integer> mMaxStackSizes; - public final static HashMap<Integer, String[]> mDescriptionArrays; - public final static HashMap<Integer, EnumRarity> mRarities; - public final static HashMap<Integer, EnumChatFormatting> mCustomNameColours; - public final static HashMap<Integer, IIcon> mIcons; - - static { + public final HashMap<Integer, String> mLocalNames; + public final HashMap<Integer, Integer> mMaxStackSizes; + public final HashMap<Integer, String[]> mDescriptionArrays; + public final HashMap<Integer, EnumRarity> mRarities; + public final HashMap<Integer, EnumChatFormatting> mCustomNameColours; + public final HashMap<Integer, IIcon> mIcons; + private final String mTextureDir; + + public ItemGenericToken() { + this("itemGenericToken", "Token", new String[] { "Can be reclaimed in some way, shape or form" }, "token"); + } + + public ItemGenericToken(String aUnlocalName, String aInternalName, String[] aBaseTooltip, String aTextureDir) { + super(aUnlocalName, aInternalName, AddToCreativeTab.tabMisc, 64, 1000, aBaseTooltip, EnumRarity.common, EnumChatFormatting.RESET, false, null); mLocalNames = new HashMap<Integer, String>(); mMaxStackSizes = new HashMap<Integer, Integer>(); mDescriptionArrays = new HashMap<Integer, String[]>(); mRarities = new HashMap<Integer, EnumRarity>(); mCustomNameColours = new HashMap<Integer, EnumChatFormatting>(); mIcons = new HashMap<Integer, IIcon>(); + mTextureDir = aTextureDir; } - public ItemGenericToken() { - super("itemGenericToken", "Token", AddToCreativeTab.tabMisc, 64, 1000, - new String[] { "Can be reclaimed in some way, shape or form" }, EnumRarity.common, - EnumChatFormatting.RESET, false, null); - } - - public static boolean register(int id, String aLocalName, int aMaxStack, String aDescript) { + public boolean register(int id, String aLocalName, int aMaxStack, String aDescript) { return register(id, aLocalName, aMaxStack, new String[] { aDescript }); } - public static boolean register(int id, String aLocalName, int aMaxStack, String[] aDescript) { + public boolean register(int id, String aLocalName, int aMaxStack, String[] aDescript) { return register(id, aLocalName, aMaxStack, aDescript, EnumRarity.common, EnumChatFormatting.RESET); } - public static boolean register(int id, String aLocalName, int aMaxStack, String[] aDescript, EnumRarity aRarity, + public boolean register(int id, String aLocalName, int aMaxStack, String[] aDescript, EnumRarity aRarity, EnumChatFormatting aCustomNameColour) { int[][] sizes = new int[2][6]; sizes[0][0] = mLocalNames.size(); @@ -153,9 +154,9 @@ public class ItemGenericToken extends CoreItem { @Override @SideOnly(Side.CLIENT) - public final void registerIcons(final IIconRegister aIconRegister) { + public void registerIcons(final IIconRegister aIconRegister) { for (int i = 0, j = mLocalNames.size(); i < j; i++) { - mIcons.put(i, aIconRegister.registerIcon(CORE.MODID + ":" + "token" + "/" + i)); + mIcons.put(i, aIconRegister.registerIcon(CORE.MODID + ":" + mTextureDir + "/" + i)); } } diff --git a/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java b/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java index 7f6a52f135..2f49ac1287 100644 --- a/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java +++ b/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java @@ -27,6 +27,7 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.handler.BookHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class ItemBaseBook extends ItemWritableBook{ @@ -113,11 +114,11 @@ public class ItemBaseBook extends ItemWritableBook{ if (player.worldObj.isRemote){ try { - Class<?> clazz = Class.forName("net.minecraft.client.gui.GuiScreenBook"); + Class<?> clazz = ReflectionUtils.getClass("net.minecraft.client.gui.GuiScreenBook"); Constructor<?> ctor = clazz.getConstructor(EntityPlayer.class, ItemStack.class, boolean.class); Object object = ctor.newInstance(new Object[] { player, bookstack, false }); Minecraft.getMinecraft().displayGuiScreen((GuiScreen) object); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java b/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java index 592b68d06a..a95fab4b6c 100644 --- a/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java +++ b/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java @@ -21,6 +21,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.NBTUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class ItemEntityCatcher extends Item implements IEntityCatcher { @@ -117,14 +118,10 @@ public class ItemEntityCatcher extends Item implements IEntityCatcher { } Class<? extends Entity> mEntityClass; String mClassName; - mClassName = NBTUtils.getString(aStack,"mClassName"); - try { - mEntityClass = (Class<? extends Entity>) Class.forName(mClassName); - if (mEntityClass != null) { - return mEntityClass; - } - } - catch (ClassNotFoundException e) { + mClassName = NBTUtils.getString(aStack, "mClassName"); + mEntityClass = (Class<? extends Entity>) ReflectionUtils.getClass(mClassName); + if (mEntityClass != null) { + return mEntityClass; } return null; } diff --git a/src/Java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java b/src/Java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java new file mode 100644 index 0000000000..9467c3a58c --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/throwables/ItemThrowableBomb.java @@ -0,0 +1,123 @@ +package gtPlusPlus.core.item.general.throwables; + +import java.util.List; + +import gregtech.api.enums.ItemList; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.entity.projectile.EntityThrowableBomb; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.NBTUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class ItemThrowableBomb extends CoreItem { + + private static AutoMap<ItemStack> mLighters = new AutoMap<ItemStack>(); + public static IIcon[] icons = new IIcon[10]; + + public ItemThrowableBomb() { + super("gtpp.throwable.bomb", "Bomb", AddToCreativeTab.tabMisc, 16, 0, new String[] {"Just like Bomberman", "Have a fire source in inventory to prime"}, EnumRarity.uncommon, EnumChatFormatting.GRAY, false, null); + this.setHasSubtypes(true); + } + + @Override + public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { + + if (mLighters.isEmpty()) { + mLighters.put(ItemUtils.getSimpleStack(Items.flint_and_steel)); + mLighters.put(ItemList.Tool_Lighter_Invar_Full.get(1)); + mLighters.put(ItemList.Tool_Lighter_Invar_Used.get(1)); + mLighters.put(ItemList.Tool_Lighter_Platinum_Full.get(1)); + mLighters.put(ItemList.Tool_Lighter_Platinum_Used.get(1)); + mLighters.put(ItemUtils.getSimpleStack(ModItems.itemBasicFireMaker)); + } + + //Unlit + if (item.getItemDamage() == 0) { + boolean hasLighter = false; + for (ItemStack aPlaySlot : player.inventory.mainInventory) { + if (aPlaySlot != null) { + for (ItemStack aLighter : mLighters) { + if (GT_Utility.areStacksEqual(aPlaySlot, aLighter)) { + hasLighter = true; + break; + } + } + } + } + if (hasLighter) { + item.setItemDamage(1); + } + } + //Lit + else if (item.getItemDamage() == 1) { + if (!player.capabilities.isCreativeMode) { + --item.stackSize; + } + world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + if (!world.isRemote) { + world.spawnEntityInWorld(new EntityThrowableBomb(world, player)); + } + /*if (item.stackSize <= 0) { + item = null; + }*/ + } + return item; + } + + + + @Override + public void registerIcons(IIconRegister reg) { + icons[0] = reg.registerIcon(CORE.MODID + ":" + "bomb"); + icons[1] = reg.registerIcon(CORE.MODID + ":" + "bomb_lit"); + } + + @Override + public IIcon getIconFromDamage(int meta) { + return this.icons[meta]; + } + + @SuppressWarnings({ "unchecked" }) + @Override + public void getSubItems(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < 2; i ++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + String aLitStatus = "unlit"; + if (stack.getItemDamage() == 0) { + aLitStatus = EnumChatFormatting.BLUE+"Unlit"; + } + else if (stack.getItemDamage() == 1) { + aLitStatus = EnumChatFormatting.RED+"Lit"; + } + list.add(EnumChatFormatting.GOLD+"Fuse Status: "+aLitStatus); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public String getItemStackDisplayName(ItemStack p_77653_1_) { + // TODO Auto-generated method stub + return super.getItemStackDisplayName(p_77653_1_); + } + + + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java b/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java index 77a06edac2..94ebb3ffcb 100644 --- a/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java +++ b/src/Java/gtPlusPlus/core/item/init/ItemsFoods.java @@ -21,24 +21,24 @@ public class ItemsFoods { //Raisin Bread ModItems.itemIngotRaisinBread = new BaseItemFood("itemIngotRaisinBread", "Raisin Bread", 3, 1.5f, false, new PotionEffect(Potion.weakness.id, 40, 1)).setAlwaysEdible(); - GT_OreDictUnificator.registerOre("foodRaisinBread", ItemUtils.getItemStack(CORE.MODID+":itemIngotRaisinBread", 1)); + GT_OreDictUnificator.registerOre("foodRaisinBread", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemIngotRaisinBread", 1)); //Hot Raisin Bread ModItems.itemHotIngotRaisinBread = new BaseItemHotFood("itemHotIngotRaisinBread", 1, 0.5f, "Raisin Bread", 120, ModItems.itemIngotRaisinBread); - GT_OreDictUnificator.registerOre("foodHotRaisinBread", ItemUtils.getItemStack(CORE.MODID+":itemHotIngotRaisinBread", 1)); + GT_OreDictUnificator.registerOre("foodHotRaisinBread", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemHotIngotRaisinBread", 1)); //Raisin Bread ModItems.itemFoodRaisinToast = new BaseItemFood("itemFoodRaisinToast", "Raisin Toast", 1, 0.5f, false).setAlwaysEdible(); - GT_OreDictUnificator.registerOre("foodRaisinToast", ItemUtils.getItemStack(CORE.MODID+":itemFoodRaisinToast", 1)); + GT_OreDictUnificator.registerOre("foodRaisinToast", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemFoodRaisinToast", 1)); //Hot Raisin Bread ModItems.itemHotFoodRaisinToast = new BaseItemHotFood("itemHotFoodRaisinToast", 1, 0.5f, "Raisin Toast", 20, ModItems.itemFoodRaisinToast); - GT_OreDictUnificator.registerOre("foodHotRaisinToast", ItemUtils.getItemStack(CORE.MODID+":itemHotFoodRaisinToast", 1)); + GT_OreDictUnificator.registerOre("foodHotRaisinToast", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemHotFoodRaisinToast", 1)); //Raisin Bread ModItems.itemFoodCurriedSausages = new BaseItemFood("itemFoodCurriedSausages", "Curried Sausages", 5, 2f, false); - GT_OreDictUnificator.registerOre("foodCurriedSausages", ItemUtils.getItemStack(CORE.MODID+":itemFoodCurriedSausages", 1)); + GT_OreDictUnificator.registerOre("foodCurriedSausages", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemFoodCurriedSausages", 1)); //Hot Raisin Bread ModItems.itemHotFoodCurriedSausages = new BaseItemHotFood("itemHotFoodCurriedSausages", 1, 0.5f, "Curried Sausages", 240, ModItems.itemFoodCurriedSausages); - GT_OreDictUnificator.registerOre("foodHotCurriedSausages", ItemUtils.getItemStack(CORE.MODID+":itemHotFoodCurriedSausages", 1)); + GT_OreDictUnificator.registerOre("foodHotCurriedSausages", ItemUtils.getItemStackFromFQRN(CORE.MODID+":itemHotFoodCurriedSausages", 1)); } diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java b/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java new file mode 100644 index 0000000000..d0f3005d00 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/misc/DebugScanner.java @@ -0,0 +1,100 @@ +package gtPlusPlus.core.item.tool.misc; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.CoreItem; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class DebugScanner extends CoreItem { + + public DebugScanner() { + super("gtpp.debug.scanner", AddToCreativeTab.tabTools, 1, 0, + new String[] { + "Used to obtain information from GT/GT++ content", + "Right Click to use", + }, + EnumRarity.epic); + setTextureName(CORE.MODID + ":itemStickyRubber"); + } + + @Override + public boolean isDamageable() { + return false; + } + + @Override + public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int p_77648_4_, + int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + // TODO Auto-generated method stub + return super.onItemUse(aStack, aPlayer, aWorld, p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_8_, + p_77648_9_, p_77648_10_); + } + + @Override + public boolean isRepairable() { + return false; + } + + @Override + public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { + // TODO Auto-generated method stub + return super.onItemRightClick(p_77659_1_, p_77659_2_, p_77659_3_); + } + + @Override + public float getDigSpeed(ItemStack itemstack, Block block, int metadata) { + return 0f; + } + + @Override + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { + if (entity != null && player != null) { + PlayerUtils.messagePlayer(player, "Entity ID: "+entity.getEntityId()); + PlayerUtils.messagePlayer(player, "UUID: "+entity.getUniqueID()); + PlayerUtils.messagePlayer(player, "Invulnerable? "+entity.isEntityInvulnerable()); + PlayerUtils.messagePlayer(player, "Invisible? "+entity.isInvisible()); + PlayerUtils.messagePlayer(player, "Age: "+entity.ticksExisted); + + if (entity instanceof EntityLiving) { + EntityLiving g = (EntityLiving) entity; + PlayerUtils.messagePlayer(player, "Health: "+g.getHealth()+"/"+g.getMaxHealth()); + PlayerUtils.messagePlayer(player, "On ground? "+g.onGround); + PlayerUtils.messagePlayer(player, "Can Loot? "+g.canPickUpLoot()); + PlayerUtils.messagePlayer(player, "Child? "+g.isChild()); + if (entity instanceof EntityPlayer) { + EntityPlayer y = (EntityPlayer) entity; + PlayerUtils.messagePlayer(player, "Experience: "+y.experience); + PlayerUtils.messagePlayer(player, "Name: "+y.getCommandSenderName()); + } + + } + + } + return true; + } + + @Override + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { + return false; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } + + @Override + public int getHarvestLevel(ItemStack stack, String toolClass) { + return 0; + } + + + +} diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java b/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java index b42ac41a37..4616ab0aa0 100644 --- a/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java +++ b/src/Java/gtPlusPlus/core/item/tool/misc/GregtechPump.java @@ -19,6 +19,7 @@ import gregtech.api.interfaces.IItemBehaviour; import gregtech.api.interfaces.IItemContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.objects.ItemData; import gregtech.api.util.GT_LanguageManager; @@ -110,8 +111,8 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri aPumpName, // Name aEuMax, // Eu Storage (short) aTier, // Tier - "Can be used to remove fluids from GT machine input slots.", // Tooltip - EnumRarity.common, // Rarity + "Can be used to remove fluids from GT machine input & output slots.", // Tooltip + aTier <= 0 ? EnumRarity.common : aTier == 1 ? EnumRarity.uncommon : aTier == 2 ? EnumRarity.rare : aTier == 3 ? EnumRarity.epic : EnumRarity.common, // Rarity EnumChatFormatting.GRAY, // Desc colour false // Effect? ); @@ -183,7 +184,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri return false; } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({ "unchecked" }) @Override public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, List aList, final boolean aF3_H) { // aList.add("Meta: "+(aStack.getItemDamage()-mOffset)); @@ -199,7 +200,9 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri if (aOffsetMeta <= 3) { FluidStack f = getFluid(aStack); - aList.add("Can also drain any other standard fluid container block."); + aList.add("Can also drain any other standard fluid container block"); + aList.add("Cannot be emptied via RMB, use inside a tank with GUI"); + aList.add(EnumChatFormatting.DARK_GRAY+"This is technically just a fancy fluid cell"); aList.add(EnumChatFormatting.BLUE + (f != null ? f.getLocalizedName() : "No Fluids Contained")); aList.add(EnumChatFormatting.BLUE + (f != null ? ""+f.amount : ""+0) + "L" + " / " + getCapacity(aStack) + "L"); } @@ -496,7 +499,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri return this; } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({ "unchecked" }) @Override @SideOnly(Side.CLIENT) public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { @@ -968,9 +971,10 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri if ((tTileEntity instanceof IGregTechTileEntity)) { return this.drainTankGT(tTileEntity, aStack, aWorld, aPlayer, aX, aY, aZ); } - /*else if ((tTileEntity instanceof IFluidTank || tTileEntity instanceof IFluidHandler)) { + //Try support Standard Fluid Tanks too (May disable if dupes appear again) + else if ((tTileEntity instanceof IFluidTank || tTileEntity instanceof IFluidHandler)) { return this.drainIFluidTank(tTileEntity, aStack, aWorld, aPlayer, aX, aY, aZ); - }*/ + } } } } @@ -1095,7 +1099,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri FluidStack f = aTileEntity.getFluid(); Logger.WARNING("Returning Fluid stack from tile. Found: " + (f != null ? f.getLocalizedName() + " - " + f.amount + "L" : "Nothing")); - return f.copy(); + return f; } public FluidStack getStoredFluidOfVanillaTank(IFluidHandler aTileEntity) { @@ -1126,7 +1130,7 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri FluidStack f = ((IFluidTank) aTileEntity).getFluid(); if (aSetFluid == null) { aSetFluid = f; - aSetFluid.amount = 0; + aSetFluid.amount = f.amount; } int toDrain = (f.amount - aSetFluid.amount); FluidStack newStack; @@ -1144,44 +1148,48 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri return false; } } - else { - Logger.WARNING("Tile Was instanceof IFluidHandler."); - FluidStack containedStack = null; - if ((IFluidHandler) aTileEntity != null) { - FluidTankInfo[] a1 = (((IFluidHandler) aTileEntity).getTankInfo(ForgeDirection.UNKNOWN)); - if (a1 != null) { - if (a1[0] != null) { - Logger.WARNING("Found Fluid in Tank."); - containedStack = a1[0].fluid; - } - } + else { + + //Rewrite Fluid handling for Vanilla type tanks + if (!IFluidHandler.class.isInstance(aTileEntity)) { + Logger.WARNING("Tile Was not an instance of IFluidHandler."); + return false; } - if (containedStack != null) { - if (aSetFluid == null) { - aSetFluid = containedStack; - aSetFluid.amount = 0; - } - int toDrain = (containedStack.amount - aSetFluid.amount); - Logger.WARNING("Found "+containedStack.amount+"L of "+containedStack.getLocalizedName()+". Trying to drain "+toDrain+"L."); - FluidStack newStack; - if (toDrain <= 0) { - Logger.WARNING("Draining Nothing"); - newStack = containedStack; - } else { - Logger.WARNING("Draining Something"); - newStack = ((IFluidTank) aTileEntity).drain(toDrain, true); + + + IFluidHandler aTank = (IFluidHandler) aTileEntity; + FluidStack aTankContents = null; + FluidTankInfo[] a1 = aTank.getTankInfo(ForgeDirection.UNKNOWN); + if (a1 != null) { + if (a1[0] != null) { + aTankContents = a1[0].fluid; + Logger.WARNING("Found Fluid in Tank. "+aTankContents.getLocalizedName()+" - "+aTankContents.amount); } - - if (newStack.isFluidEqual(aSetFluid) && newStack.amount == aSetFluid.amount) { - Logger.WARNING("Removed fluid from vanilla IFluidHandler successfully."); + } + if (aSetFluid == null) { + Logger.WARNING("Setting fluid to tank contents, as we're going to empty it totally."); + aSetFluid = aTankContents.copy(); + } + else { + Logger.WARNING("Setting fluid to tank contents, as we're going to empty it totally."); + } + Logger.WARNING("Tile Was instance of IFluidHandler. Trying to Drain "+aSetFluid.getLocalizedName()+" - "+aSetFluid.amount); + + if (a1 == null || aTankContents == null) { + Logger.WARNING("Tank is empty."); + return false; + } + //Found some Fluid in the tank + else { + FluidStack aDrainedStack = aTank.drain(ForgeDirection.UNKNOWN, aSetFluid, true); + if (aDrainedStack.isFluidStackIdentical(aSetFluid)) { + Logger.WARNING("Drained!"); return true; - } else { - Logger.WARNING("Failed trying to remove fluid from vanilla IFluidHandler."); - return false; } - } else { - Logger.WARNING("Could not drain vanilla tank, IFluidHandler claims there is no fluid."); - return false; + else { + Logger.WARNING("Partially Drained! This is probably an error."); + return true; + } } } } else { @@ -1214,9 +1222,36 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri public FluidStack getStoredFluidOfGTMachine(GT_MetaTileEntity_BasicTank aTileEntity) { FluidStack f = aTileEntity.mFluid; + + //Let's see if this machine has output fluid too + if (f == null) { + Logger.WARNING("Could not find any input fluid, checking output if possible."); + if (aTileEntity instanceof GT_MetaTileEntity_BasicMachine) { + GT_MetaTileEntity_BasicMachine g = (GT_MetaTileEntity_BasicMachine) aTileEntity; + Logger.WARNING("Tile is a Basic Machine of some sort - "+g.mNEIName); + if (g != null) { + f = g.mOutputFluid; + if (f != null) { + Logger.WARNING("Found output fluid! "+f.getLocalizedName()); + } + else { + Logger.WARNING("Did not find anything!"); + f = g.getFluid(); + if (f != null) { + Logger.WARNING("Found fluid! "+f.getLocalizedName()); + } + else { + Logger.WARNING("Did not find anything!"); + f = g.getFluid(); + } + } + } + } + } + Logger.WARNING("Returning Fluid stack from tile. Found: " + (f != null ? f.getLocalizedName() + " - " + f.amount + "L" : "Nothing")); - return f.copy(); + return f; } public boolean setStoredFluidOfGTMachine(IGregTechTileEntity aTileEntity, FluidStack aSetFluid) { @@ -1238,6 +1273,12 @@ public class GregtechPump extends Item implements ISpecialElectricItem, IElectri public boolean setStoredFluidOfGTMachine(GT_MetaTileEntity_BasicTank aTileEntity, FluidStack aSetFluid) { try { + + //Try Handle Outputs First + if (aTileEntity.setDrainableStack(aSetFluid) != null) { + return true; + } + aTileEntity.mFluid = aSetFluid; boolean b = aTileEntity.mFluid == aSetFluid; Logger.WARNING("Trying to set Tile's tank. - Behaviour Class. [3] " + b); diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index c7d09b959d..632378987a 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -9,7 +9,6 @@ import gregtech.api.GregTech_API; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.gregtech.recipehandlers.GregtechRecipe; import gtPlusPlus.core.util.sys.GeoUtils; import gtPlusPlus.core.util.sys.NetworkUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; @@ -52,7 +51,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.7.02.24"; + public static final String VERSION = "1.7.02.99-pre"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); @@ -203,7 +202,7 @@ public class CORE { public static boolean disableIC2Recipes = false; public static boolean enableAlternativeDivisionSigilRecipe = false; public static int boilerSteamPerSecond = 750; - public static boolean requireControlCores = true; + public static final boolean requireControlCores = false; //Feature Related public static boolean enableCustomCapes = false; diff --git a/src/Java/gtPlusPlus/core/lib/LoadedMods.java b/src/Java/gtPlusPlus/core/lib/LoadedMods.java index e749885dd6..5a2b75337b 100644 --- a/src/Java/gtPlusPlus/core/lib/LoadedMods.java +++ b/src/Java/gtPlusPlus/core/lib/LoadedMods.java @@ -54,6 +54,7 @@ public class LoadedMods { public static boolean StevesCarts = false; public static boolean Witchery = false; public static boolean Waila = false; + public static boolean CropsPlusPlus = false; //Barts Crop Mod @@ -96,6 +97,11 @@ public class LoadedMods { Logger.INFO("Components enabled for: PlayerAPI"); totalMods++; } + if (Loader.isModLoaded("berriespp")) { + CropsPlusPlus = true; + Logger.INFO("Components enabled for: Crops++"); + totalMods++; + } if (Loader.isModLoaded("TConstruct")){ TiCon = true; Logger.INFO("Components enabled for: Tinkers Construct"); diff --git a/src/Java/gtPlusPlus/core/material/ALLOY.java b/src/Java/gtPlusPlus/core/material/ALLOY.java index c7397962ad..4edd36c51f 100644 --- a/src/Java/gtPlusPlus/core/material/ALLOY.java +++ b/src/Java/gtPlusPlus/core/material/ALLOY.java @@ -524,11 +524,11 @@ public final class ALLOY { "Zirconium Carbide", //Material Name MaterialState.SOLID, //State new short[]{222, 202, 180, 0}, //Material Colour - 1855, //Melting Point in C + 1555, //Melting Point in C -1, -1, -1, - true, //Uses Blast furnace? + false, //Uses Blast furnace? //Material Stacks with Percentage of required elements. new MaterialStack[]{ new MaterialStack(ELEMENT.getInstance().ZIRCONIUM, 50), @@ -787,7 +787,7 @@ public final class ALLOY { new MaterialStack(ELEMENT.getInstance().CERIUM, 6), new MaterialStack(ELEMENT.getInstance().ANTIMONY, 4), new MaterialStack(ELEMENT.getInstance().PLATINUM, 4), - new MaterialStack(ELEMENT.getInstance().YTTERBIUM, 2), + new MaterialStack(ELEMENT.getInstance().YTTRIUM, 2), new MaterialStack(ALLOY.TUNGSTENSTEEL, 8) }); diff --git a/src/Java/gtPlusPlus/core/material/ELEMENT.java b/src/Java/gtPlusPlus/core/material/ELEMENT.java index 99bc37444e..62e1163a39 100644 --- a/src/Java/gtPlusPlus/core/material/ELEMENT.java +++ b/src/Java/gtPlusPlus/core/material/ELEMENT.java @@ -11,6 +11,8 @@ import gtPlusPlus.core.util.minecraft.MaterialUtils; public final class ELEMENT { + public static final String[] NAMES = new String[]{"Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminum", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; + //First 50 Elements public final Material HYDROGEN = MaterialUtils.generateMaterialFromGtENUM(Materials.Hydrogen); public final Material HELIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Helium); @@ -148,8 +150,8 @@ public final class ELEMENT { public final Material AMERICIUM241 = new Material("Americium-241", MaterialState.SOLID, TextureSets.NUCLEAR.get(), Materials.Americium.mDurability, Materials.Americium.mRGBa, Materials.Americium.mMeltingPoint, Materials.Americium.mBlastFurnaceTemp, 95, 146, false, StringUtils.superscript("241Am"), 2, false);//Not a GT Inherited Material public final Material MAGIC = MaterialUtils.generateMaterialFromGtENUM(Materials.Magic, new short[] {10, 185, 140}); - public final Material THAUMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thaumium); - + public final Material THAUMIUM = MaterialUtils.generateMaterialFromGtENUM(Materials.Thaumium); + static { Logger.MATERIALS("Initialising Base Elements."); } diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index 03e50aa7dd..58a7f68afe 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -1,6 +1,7 @@ package gtPlusPlus.core.material; import static gregtech.api.enums.GT_Values.M; +import static gtPlusPlus.core.util.math.MathUtils.safeCast_LongToInt; import java.util.ArrayList; import java.util.HashMap; @@ -14,6 +15,7 @@ import gregtech.api.enums.TextureSet; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.item.base.cell.BaseItemCell; +import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.data.StringUtils; @@ -21,7 +23,8 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; +import gtPlusPlus.xmod.tinkers.material.BaseTinkersMaterial; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -75,7 +78,9 @@ public class Material { public int vToolQuality; public int vHarvestLevel; - private GTPP_Aspects[] vAspects; + private TC_Aspect_Wrapper[] vAspects; + + public BaseTinkersMaterial vTiConHandler; public static AutoMap<Materials> invalidMaterials = new AutoMap<Materials>(); @@ -317,28 +322,13 @@ public class Material { this.vDurability = durability; } else { - if (inputs != null){ - long durabilityTemp = 0; - int counterTemp = 0; - for (final MaterialStack m : inputs){ - if (m.getStackMaterial() != null){ - if (m.getStackMaterial().vDurability != 0){ - durabilityTemp = (durabilityTemp+m.getStackMaterial().vDurability); - counterTemp++; - - } - } - } - if ((durabilityTemp != 0) && (counterTemp != 0)){ - this.vDurability = (durabilityTemp/counterTemp); - } - else { - this.vDurability = 8196; + long aTempDura = 0; + for (MaterialStack g : this.getComposites()) { + if (g != null) { + aTempDura += safeCast_LongToInt(g.getStackMaterial().getMass() * 2000); } } - else { - this.vDurability = 0; - } + this.vDurability = aTempDura > 0 ? aTempDura : (this.getComposites().isEmpty() ? 51200 : 32000 * this.getComposites().size()); } if ((this.vDurability >= 0) && (this.vDurability < 64000)){ @@ -362,8 +352,8 @@ public class Material { this.vHarvestLevel = 4; } else { - this.vToolQuality = 0; - this.vHarvestLevel = 0; + this.vToolQuality = 1; + this.vHarvestLevel = 1; } //Sets the Rad level @@ -506,6 +496,12 @@ public class Material { } this.textureSet = setTextureSet(set, vTier); + + if (LoadedMods.TiCon && this.materialState == MaterialState.SOLID) { + if (this.getProtons() >= 98 || this.getComposites().size() > 1 || this.getMeltingPointC() >= 3600) { + this.vTiConHandler = new BaseTinkersMaterial(this); + } + } Logger.MATERIALS("Creating a Material instance for "+materialName); Logger.MATERIALS("Formula: "+this.vChemicalFormula + " Smallest Stack: "+this.smallestStackSizeWhenProcessing+" Smallest Ratio:"+ratio); @@ -759,7 +755,11 @@ public class Material { } final public Block getBlock(){ - return Block.getBlockFromItem(getBlock(1).getItem()); + Block b = Block.getBlockFromItem(getBlock(1).getItem()); + if (b == null) { + Logger.INFO("[ERROR] Tried to get invalid block for "+this.getLocalizedName()+", returning debug block instead."); + } + return b != null ? b : Blocks.lit_furnace; } public final ItemStack getBlock(final int stacksize){ diff --git a/src/Java/gtPlusPlus/core/material/ORES.java b/src/Java/gtPlusPlus/core/material/ORES.java index a8b86a142c..801e4924b3 100644 --- a/src/Java/gtPlusPlus/core/material/ORES.java +++ b/src/Java/gtPlusPlus/core/material/ORES.java @@ -807,15 +807,15 @@ public final class ORES { -1, 4, //Radiation new MaterialStack[]{// Na3AlF6 - new MaterialStack(ELEMENT.getInstance().RADON, 3), - new MaterialStack(ELEMENT.getInstance().RADIUM, 2), + new MaterialStack(ELEMENT.getInstance().RADON, 2), + new MaterialStack(ELEMENT.getInstance().RADIUM, 1), new MaterialStack(ELEMENT.getInstance().URANIUM235, 1), - new MaterialStack(ELEMENT.getInstance().URANIUM238, 13), - new MaterialStack(ELEMENT.getInstance().THORIUM, 28), - new MaterialStack(ELEMENT.getInstance().THORIUM232, 5), - new MaterialStack(FLUORCAPHITE, 4), - new MaterialStack(SAMARSKITE_Y, 6), - new MaterialStack(TITANITE, 2) + new MaterialStack(ELEMENT.getInstance().URANIUM238, 10), + new MaterialStack(ELEMENT.getInstance().THORIUM, 25), + new MaterialStack(ELEMENT.getInstance().THORIUM232, 4), + new MaterialStack(FLUORCAPHITE, 6), + new MaterialStack(SAMARSKITE_Y, 8), + new MaterialStack(TITANITE, 4) }); diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 25103c0f5a..a4dc366aee 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -2,6 +2,7 @@ package gtPlusPlus.core.recipe; import static gtPlusPlus.core.lib.CORE.GTNH; +import cpw.mods.fml.common.Loader; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.GT_Values; @@ -17,11 +18,15 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.chemistry.IonParticles; +import gtPlusPlus.core.item.chemistry.RocketFuels; +import gtPlusPlus.core.item.crafting.ItemDummyResearch; +import gtPlusPlus.core.item.crafting.ItemDummyResearch.ASSEMBLY_LINE_RESEARCH; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.MaterialStack; +import gtPlusPlus.core.material.ORES; import gtPlusPlus.core.material.Particle; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.material.nuclear.NUCLIDE; @@ -81,10 +86,34 @@ public class RECIPES_GREGTECH { breweryRecipes(); laserEngraverRecipes(); assemblyLineRecipes(); + latheRecipes(); + vacuumFreezerRecipes(); addFuels(); } + private static void vacuumFreezerRecipes() { + GT_Values.RA.addVacuumFreezerRecipe(GregtechItemList.Bomb_Cast_Molten.get(1), GregtechItemList.Bomb_Cast_Set.get(1), 20 * 30); + } + + private static void latheRecipes() { + + GT_Values.RA.addLatheRecipe( + ALLOY.EGLIN_STEEL.getBlock(1), + GregtechItemList.Bomb_Cast_Mold.get(1), + null, + 20 * 60 * 15, + 120); + + GT_Values.RA.addLatheRecipe( + GregtechItemList.Bomb_Cast_Set.get(1), + GregtechItemList.Bomb_Cast_Broken.get(2), + ItemUtils.getSimpleStack(ModItems.itemBombCasing, 2), + 20 * 60 * 5, + 30); + + } + private static void fusionRecipes() { /** @@ -122,9 +151,21 @@ public class RECIPES_GREGTECH { private static void assemblyLineRecipes() { + + + ItemStack[] aCoilWire = new ItemStack[] { + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 0, GTNH ? 64 : 32), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 1, GTNH ? 48 : 16), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 2, GTNH ? 32 : 8), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 3, GTNH ? 16 : 4), + }; + + + + //Containment Casings CORE.RA.addAssemblylineRecipe( - ItemList.Field_Generator_IV.get(1), + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_1_CONTAINMENT, 1), 20 * 60 * 30, new ItemStack[] { ItemList.Field_Generator_IV.get(GTNH ? 32 : 16), @@ -139,7 +180,8 @@ public class RECIPES_GREGTECH { CI.getTieredComponent(OrePrefixes.circuit, 5, GTNH ? 64 : 32), CI.getTieredComponent(OrePrefixes.circuit, 6, GTNH ? 32 : 16), CI.getTieredComponent(OrePrefixes.circuit, 7, GTNH ? 16 : 8), - GregtechItemList.Laser_Lens_Special.get(1) + GregtechItemList.Laser_Lens_Special.get(1), + aCoilWire[3] }, new FluidStack[] { ALLOY.NITINOL_60.getFluid(144 * 9 * (GTNH ? 4 : 2)), @@ -174,10 +216,7 @@ public class RECIPES_GREGTECH { CI.getTieredFluid(6, 144 * 9 * (GTNH ? 8 : 4)), CI.getTertiaryTieredFluid(6, 144 * 9 * (GTNH ? 8 : 4)), CI.getAlternativeTieredFluid(6, 144 * 9 * (GTNH ? 8 : 4)), - CI.getTieredFluid(5, 144 * 9 * (GTNH ? 16 : 8)), - CI.getTertiaryTieredFluid(5, 144 * 9 * (GTNH ? 16 : 8)), - CI.getAlternativeTieredFluid(5, 144 * 9 * (GTNH ? 16 : 8)), - + CI.getTieredFluid(5, 144 * 9 * (GTNH ? 16 : 8)), }, GregtechItemList.Miniature_Fusion.get(1), 20 * 60 * 5 * (GTNH ? 2 : 1), @@ -194,6 +233,7 @@ public class RECIPES_GREGTECH { CI.getTieredComponent(OrePrefixes.pipeHuge, 5, GTNH ? 16 : 4), CI.getTieredComponent(OrePrefixes.cableGt08, 7, GTNH ? 32 : 16), CI.getTieredComponent(OrePrefixes.gearGt, 6, GTNH ? 8 : 4), + aCoilWire[2] }, new FluidStack[] { CI.getTieredFluid(4, 144 * 9 * (GTNH ? 16 : 8)), @@ -205,6 +245,182 @@ public class RECIPES_GREGTECH { 20 * 60 * 1 * (GTNH ? 2 : 1), (int) GT_Values.V[5]); + + /* + * Contianment casings + */ + + ItemStack[] aGemCasings = new ItemStack[] { + GregtechItemList.Battery_Casing_Gem_1.get(1), + GregtechItemList.Battery_Casing_Gem_2.get(1), + GregtechItemList.Battery_Casing_Gem_3.get(1), + GregtechItemList.Battery_Casing_Gem_4.get(1), + }; + ItemStack[] aResearch = new ItemStack[] { + Particle.getBaseParticle(Particle.UNKNOWN), + GregtechItemList.Battery_Casing_Gem_1.get(1), + GregtechItemList.Battery_Casing_Gem_2.get(1), + GregtechItemList.Battery_Casing_Gem_3.get(1), + }; + + int aCasingSlot = 0; + for (int j = 6; j < 10; j++) { + CORE.RA.addAssemblylineRecipe( + aResearch[aCasingSlot], + 20 * 60 * 60, + new ItemStack[] { + CI.getTieredComponent(OrePrefixes.plate, j-1, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, j-2, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.cableGt08, j+1, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.gearGt, j-1, GTNH ? 8 : 4), + aCoilWire[aCasingSlot] + }, + new FluidStack[] { + CI.getTieredFluid(j, 144 * 3 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(j-2, 144 * 4 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(j, 144 * 6 * (GTNH ? 16 : 8)), + + }, + aGemCasings[aCasingSlot++], + 20 * 60 * 1 * (GTNH ? 2 : 1), + (int) GT_Values.V[j]); + } + + /* + * Gem Battery Recipes + */ + + ItemStack[] aGemBatteries = new ItemStack[] { + GregtechItemList.Battery_Gem_1.get(1), + GregtechItemList.Battery_Gem_2.get(1), + GregtechItemList.Battery_Gem_3.get(1), + GregtechItemList.Battery_Gem_4.get(1), + }; + + ItemStack[] aExoticInputs = new ItemStack[] { + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.ELECTRON), + Particle.getBaseParticle(Particle.CHARM), + Particle.getBaseParticle(Particle.GRAVITON) + }; + aCasingSlot = 0; + for (int j = 6; j < 10; j++) { + CORE.RA.addAssemblylineRecipe( + aExoticInputs[aCasingSlot], + 20 * 60 * 60 * 5, + new ItemStack[] { + aGemCasings[aCasingSlot], + ItemUtils.getSimpleStack(aExoticInputs[aCasingSlot], GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.plate, j, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, j, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.wireGt16, j+1, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.bolt, j, GTNH ? 8 : 4), + CI.getTieredComponent(OrePrefixes.screw, j-1, GTNH ? 8 : 4), + }, + new FluidStack[] { + CI.getTieredFluid(j, 144 * 3 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(j-2, 144 * 4 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(j, 144 * 6 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(j-1, 144 * 5 * (GTNH ? 16 : 8)), + }, + aGemBatteries[aCasingSlot++], + 20 * 60 * 1 * (GTNH ? 2 : 1), + (int) GT_Values.V[j]); + } + + + //Nano Healer + CORE.RA.addAssemblylineRecipe( + ItemUtils.simpleMetaStack(Items.golden_apple, 1, 1), + 20 * 60 * 10, + new ItemStack[] { + ItemUtils.getSimpleStack(aGemCasings[2], GTNH ? 4 : 2), + CI.getTieredComponent(OrePrefixes.plate, 8, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, 7, GTNH ? 16 : 4), + CI.getTieredComponent(OrePrefixes.cableGt02, 7, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.gearGt, 6, GTNH ? 6 : 3), + CI.getTieredComponent(OrePrefixes.screw, 7, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.bolt, 5, GTNH ? 24 : 12), + CI.getTieredComponent(OrePrefixes.frameGt, 4, GTNH ? 12 : 6), + aCoilWire[3] + }, + new FluidStack[] { + CI.getTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(6, 144 * 18 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(7, 144 * 18 * (GTNH ? 16 : 8)), + + }, + ItemUtils.getItemStackFromFQRN("miscutils:personalHealingDevice", 1), + 20 * 60 * 30 * (GTNH ? 2 : 1), + (int) GT_Values.V[7]); + + + + //Charge Pack LuV-UV + + ItemStack[] aChargeResearch = new ItemStack[] { + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack1, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack2, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack3, 1), + }; + + ItemStack[] aChargeOutputs = new ItemStack[] { + ItemUtils.getSimpleStack(ModItems.itemChargePack1, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack2, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack3, 1), + ItemUtils.getSimpleStack(ModItems.itemChargePack4, 1), + }; + + ItemStack[] aBufferCoreInputs = new ItemStack[] { + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore8", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore9", GTNH ? 8 : 4), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore10", GTNH ? 8 : 4), + }; + + int aCurrSlot = 0; + for (int h = 6; h < 10; h++) { + CORE.RA.addAssemblylineRecipe( + aChargeResearch[aCurrSlot], + 20 * 60 * 10 * (aCurrSlot + 1), + new ItemStack[] { + ItemUtils.getSimpleStack( + aGemBatteries[aCurrSlot], GTNH ? 4 : 2), + aBufferCoreInputs[aCurrSlot], + aCoilWire[aCurrSlot], + CI.getTieredComponent(OrePrefixes.plate, h, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.plate, h-1, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, h, GTNH ? 16 : 4), + CI.getTieredComponent(OrePrefixes.circuit, h-1, GTNH ? 32 : 8), + CI.getTieredComponent(OrePrefixes.cableGt12, h-1, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.screw, h, GTNH ? 16 : 8), + CI.getTieredComponent(OrePrefixes.bolt, h-2, GTNH ? 32 : 16), + CI.getElectricMotor(h, GTNH ? 8 : 4), + CI.getFieldGenerator(h-1, 2), + CI.getRobotArm(h-2, GTNH ? 4 : 2), + }, + new FluidStack[] { + CI.getTieredFluid(h, 144 * 18 * (GTNH ? 8 : 4)), + CI.getTertiaryTieredFluid(h-1, 144 * 18 * (GTNH ? 8 : 4)), + CI.getAlternativeTieredFluid(h-1, 144 * 18 * (GTNH ? 8 : 4)), + CI.getAlternativeTieredFluid(h-2, 144 * 18 * (GTNH ? 8 : 4)), + }, + aChargeOutputs[aCurrSlot], + 20 * 60 * 30 * (GTNH ? 2 : 1) * (aCurrSlot+1), + (int) GT_Values.V[h]); + aCurrSlot++; + } + + + + + + + + + } private static void laserEngraverRecipes() { @@ -236,6 +452,15 @@ public class RECIPES_GREGTECH { ELEMENT.STANDALONE.CHRONOMATIC_GLASS.getDust(1), 20 * 60 * 5, MaterialUtils.getVoltageForTier(ELEMENT.STANDALONE.CHRONOMATIC_GLASS.vTier)); + + + GT_Values.RA.addLaserEngraverRecipe( + CI.getFieldGenerator(6, 1), + CI.getEmitter(7, 2), + ItemDummyResearch.getResearchStack(ASSEMBLY_LINE_RESEARCH.RESEARCH_1_CONTAINMENT, 1), + 20 * 60 * 5, + MaterialUtils.getVoltageForTier(5)); + } @@ -496,21 +721,29 @@ public class RECIPES_GREGTECH { GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("sulfuricacid", 250)); - // Hydrofluoric Acid - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), - ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), - FluidUtils.getFluidStack("hydrofluoricacid", 250), null); - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), - ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid", 250)); + + // Hydrofluoric Acid + boolean addedGtExtraction = false; + // Try use Internal GT Fluid first if (Utils.getGregtechVersionAsInt() >= 50929) { // Hydrofluoric Acid GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 250), null); - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + addedGtExtraction = GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid_gt5u", 250)); } + //Add a Fill recipe for GT++ Acid + GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), + ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + FluidUtils.getFluidStack("hydrofluoricacid", 125), null); + //Add an empty recipe, but only if we didn't for the standard GT HF. Prevents Fluid transformation exploits. + if (!addedGtExtraction) + GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), + ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid", 125)); + + } private static void cokeOvenRecipes() { @@ -868,6 +1101,23 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 2) }, // Output 3 * 20, // Time in ticks 30); // EU + + /* + * Try Add custom Recipe for drying leather + */ + if (LoadedMods.PamsHarvestcraft && Loader.isModLoaded("Backpack")) { + ItemStack aLeather1, aLeather2; + aLeather1 = ItemUtils.getCorrectStacktype("harvestcraft:hardenedleatherItem", 1); + aLeather2 = ItemUtils.getCorrectStacktype("Backpack:tannedLeather", 1); + CORE.RA.addDehydratorRecipe( + aLeather1, + GT_Values.NF, + new ItemStack[] { + aLeather2 + }, + 5 * 20, + 180); + } } @@ -1024,6 +1274,21 @@ public class RECIPES_GREGTECH { FluidUtils.getFluidStack("molten.krypton", 500), T6, 2000, 512000); + addAR(ItemUtils.getItemStackOfAmountFromOreDict( + "dustClay", 32), + GregtechItemList.Bomb_Cast_Mold.get(0), + FluidUtils.getWater(4000), + GregtechItemList.Bomb_Cast.get(4), + 30, 120); + addAR(ItemUtils.getSimpleStack(Items.redstone, 32), + ItemUtils.getSimpleStack(ModItems.itemRope, 16), + Materials.Glue.getFluid(500), + ItemUtils.getSimpleStack(ModItems.itemDetCable, 24), + 30, + 120); + + + /*addAR(ItemUtils.getItemStackOfAmountFromOreDict("plateIncoloy020", 16), ItemUtils.getItemStackOfAmountFromOreDict("frameGtIncoloyMA956", 4), null, GregtechItemList.Casing_Power_SubStation.get(4), 80, 120);*/ @@ -1240,6 +1505,52 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustSmallThorium", 20), ELEMENT.getInstance().URANIUM232.getDust(1), GT_Values.NI, GT_Values.NI, GT_Values.NI, new int[] { 0, 0, 10 }, 500 * 20, 2000); + + + //Process Used Fuel Rods for Krypton + + //Uranium + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(20), + ItemUtils.getItemStackFromFQRN("IC2:reactorUraniumSimpledepleted", 8), + GT_Values.NF, + ELEMENT.getInstance().KRYPTON.getFluid(60), + ItemList.IC2_Fuel_Rod_Empty.get(8), + ELEMENT.getInstance().URANIUM238.getDust(2), + ELEMENT.getInstance().URANIUM232.getSmallDust(1), + ELEMENT.getInstance().URANIUM233.getSmallDust(1), + ELEMENT.getInstance().URANIUM235.getSmallDust(1), + ELEMENT.getInstance().PLUTONIUM239.getTinyDust(1), + new int[] { 0, 0, 1000, 1000, 1000, 500 }, 500 * 20, 4000); + //Mox + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(20), + ItemUtils.getItemStackFromFQRN("IC2:reactorMOXSimpledepleted", 8), + GT_Values.NF, + ELEMENT.getInstance().KRYPTON.getFluid(90), + ItemList.IC2_Fuel_Rod_Empty.get(8), + ELEMENT.getInstance().PLUTONIUM244.getDust(2), + ELEMENT.getInstance().PLUTONIUM241.getTinyDust(1), + ELEMENT.getInstance().PLUTONIUM239.getTinyDust(1), + ELEMENT.getInstance().PLUTONIUM238.getTinyDust(1), + ELEMENT.getInstance().PLUTONIUM239.getTinyDust(1), + new int[] { 0, 0, 500, 500, 500, 500 }, 750 * 20, 4000); + + //Thorium + GT_Values.RA.addCentrifugeRecipe( + CI.getNumberedCircuit(20), + ItemList.Depleted_Thorium_1.get(8), + GT_Values.NF, + ELEMENT.getInstance().KRYPTON.getFluid(30), + ItemList.IC2_Fuel_Rod_Empty.get(8), + ELEMENT.getInstance().THORIUM.getDust(2), + ELEMENT.getInstance().THORIUM232.getDust(1), + ELEMENT.getInstance().LUTETIUM.getSmallDust(1), + ELEMENT.getInstance().POLONIUM.getSmallDust(1), + ELEMENT.getInstance().THALLIUM.getTinyDust(1), + new int[] { 0, 0, 5000, 5000, 5000, 2500 }, 250 * 20, 4000); + + } @@ -1293,6 +1604,24 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustLithium7", 16), FluidUtils.getFluidStack("water", 1000), FluidUtils.getFluidStack("lithiumhydroxide", 144 * 4), CI.emptyCells(1), 300 * 20); + + //Bombs + GT_Values.RA.addChemicalRecipe( + ItemUtils.getSimpleStack(ModItems.itemBombCasing, 4), + ItemUtils.getSimpleStack(RocketFuels.Ammonium_Nitrate_Dust, 8), + Materials.Fuel.getFluid(1000), + null, + ItemUtils.getSimpleStack(ModItems.itemBombUnf, 4), + 300 * 20); + + GT_Values.RA.addChemicalRecipe( + ItemUtils.getSimpleStack(ModItems.itemBombUnf, 4), + ItemUtils.getSimpleStack(ModItems.itemDetCable, 4), + FluidUtils.getFluidStack(RocketFuels.Kerosene, 100), + null, + ItemUtils.getSimpleStack(ModItems.itemBomb, 4), + 10 * 20); + // LFTR Fuel Related Compounds if (GTNH) { @@ -1369,11 +1698,45 @@ public class RECIPES_GREGTECH { } private static void blastFurnaceRecipes() { + + //public boolean addBlastRecipe( + //ItemStack aInput1, ItemStack aInput2, + //FluidStack aFluidInput, FluidStack aFluidOutput, + //ItemStack aOutput1, ItemStack aOutput2, + //int aDuration, int aEUt, int aLevel) + GT_Values.RA.addBlastRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustLithiumFluoride", 2), ItemUtils.getItemStackOfAmountFromOreDict("dustBerylliumFluoride", 1), GT_Values.NF, GT_Values.NF, ItemUtils.getItemStackOfAmountFromOreDict("dustLi2BeF4", 3), null, 60 * 20, 2000, 3000); GT_Values.RA.addBlastRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustZrCl4", 1), null, GT_Values.NF, GT_Values.NF, ItemUtils.getItemStackOfAmountFromOreDict("dustCookedZrCl4", 1), null, 60 * 20, 340, 300); + + + //Synthetic Graphite + GT_Values.RA.addBlastRecipe( + CI.getNumberedCircuit(22), + ALLOY.SILICON_CARBIDE.getDust(16), + ELEMENT.getInstance().NITROGEN.getFluid(4000), + GT_Values.NF, + ItemUtils.getItemStackOfAmountFromOreDict("dustGraphite", 8), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallSilicon", 8), + 60 * 20, + MaterialUtils.getVoltageForTier(GTNH ? 5 : 4), + 4500); + + //Bomb Casings + GT_Values.RA.addBlastRecipe( + GregtechItemList.Bomb_Cast.get(4), + ALLOY.STEEL.getDust(16), + ELEMENT.getInstance().OXYGEN.getFluid(2000), + GT_Values.NF, + GregtechItemList.Bomb_Cast_Molten.get(4), + null, + 4 * 60 * 20, + MaterialUtils.getVoltageForTier(GTNH ? 3 : 2), + 2800); + + } private static void autoclaveRecipes() { @@ -1397,6 +1760,8 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("plateMeatRaw", 1)); GT_ModHandler.addCompressionRecipe(ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 9), ItemUtils.getItemStackOfAmountFromOreDict("blockMeatRaw", 1)); + + CORE.RA.addCompressorRecipe(ItemList.FusionComputer_UV.get(9), GregtechItemList.Compressed_Fusion_Reactor.get(1), (int) GT_Values.V[7], (int) GT_Values.V[8]); } private static void macerationRecipes() { @@ -1405,10 +1770,9 @@ public class RECIPES_GREGTECH { GT_ModHandler.addPulverisationRecipe(ItemUtils.getItemStackOfAmountFromOreDict("blockMeatRaw", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 9)); - /* - * GT_ModHandler.addPulverisationRecipe( FLUORIDES.FLUORITE.getOre(1), - * FLUORIDES.FLUORITE.getDust(4)); - */ + + GT_ModHandler.addPulverisationRecipe(GregtechItemList.Bomb_Cast_Broken.get(1), + ItemUtils.getItemStackOfAmountFromOreDict("dustClay", 3)); if (ItemUtils.simpleMetaStack("chisel:limestone", 0, 1) != null) { GT_ModHandler.addPulverisationRecipe(ItemUtils.getItemStackOfAmountFromOreDict("limestone", 1), @@ -1482,7 +1846,7 @@ public class RECIPES_GREGTECH { // Quark Smash CORE.RA.addCyclotronRecipe( CI.getNumberedCircuit(3), - FluidUtils.getFluidStack("plasma.hydrogen", 1000), + FluidUtils.getFluidStack("plasma.hydrogen", 100), new ItemStack[] { Particle.getBaseParticle(Particle.UP), Particle.getBaseParticle(Particle.DOWN), @@ -1493,7 +1857,7 @@ public class RECIPES_GREGTECH { }, null, new int[] { 50, 50, 50, 50, 50, 50 }, - 20 * 300 * 38, + 20 * 300 * 9, (int) GT_Values.V[7], 750 * 20); @@ -1510,8 +1874,8 @@ public class RECIPES_GREGTECH { Particle.getBaseParticle(Particle.TAU_NEUTRINO), }, null, - new int[] { 60, 40, 20, 15, 10, 5 }, - 20 * 300 * 38, + new int[] { 600, 40, 20, 15, 10, 5 }, + 20 * 300 * 8, (int) GT_Values.V[7], 750 * 20); @@ -1527,8 +1891,8 @@ public class RECIPES_GREGTECH { Particle.getBaseParticle(Particle.HIGGS_BOSON), }, null, - new int[] { 60, 60, 50, 50, 1 }, - 20 * 300 * 38, + new int[] { 160, 260, 150, 150, 1 }, + 20 * 300 * 6, (int) GT_Values.V[7], 750 * 20); @@ -1549,7 +1913,7 @@ public class RECIPES_GREGTECH { }, null, new int[] { 10, 20, 20, 10, 10, 5, 5, 2 }, - 17 * 247 * 134, + 17 * 247 * 32, (int) GT_Values.V[8], 750 * 20); @@ -1732,6 +2096,30 @@ public class RECIPES_GREGTECH { 15000); + //Create Strange Dust + CORE.RA.addCyclotronRecipe( + new ItemStack[] { + ELEMENT.getInstance().PLUTONIUM238.getDust(1), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + }, + FluidUtils.getFluidStack(FluidUtils.getWildcardFluidStack("ender", 1000), 1000), + new ItemStack[] { + ORES.DEEP_EARTH_REACTOR_FUEL_DEPOSIT.getDust(1) + }, + null, + new int[] { 2500 }, + 20 * 60 * 15, + (int) GT_Values.V[7], + 15000); + + @@ -1806,7 +2194,23 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustSmallRutile", 1), ItemUtils.getItemStackOfAmountFromOreDict("nuggetZirconium", 1), new int[] { 10000, 2500, 4000 }, 20 * 20, 24); + // Zircon + GT_Values.RA.addElectromagneticSeparatorRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedMagnetite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustMagnetite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallZircon", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyZircon", 1), new int[] { 10000, 1250, 2500 }, + 20 * 20, 24); + GT_Values.RA.addElectromagneticSeparatorRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedCassiterite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustCassiterite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallZircon", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyZircon", 1), new int[] { 10000, 1250, 2500 }, + 20 * 20, 24); + + + if (!GTNH) { // Trinium GT_Values.RA.addElectromagneticSeparatorRecipe( ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedNaquadah", 1), @@ -1829,7 +2233,12 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustWulfenite", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTrinium", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSmallTrinium", 1), new int[] { 10000, 3000, 3000 }, - 20 * 20, 24); + 20 * 20, 24); + } + + + + } private static void advancedMixerRecipes() { diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 58f9d64066..6ed5c71bcc 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -16,6 +16,7 @@ import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; @@ -49,7 +50,7 @@ public class RECIPES_General { RECIPE_Obsidian = ItemUtils.getSimpleStack(Blocks.obsidian); RECIPE_CraftingTable = ItemUtils.getSimpleStack(Blocks.crafting_table); RECIPE_HydrogenDust = ItemUtils.getSimpleStack(ModItems.itemHydrogenBlob); - RECIPE_BasicCasingIC2 = ItemUtils.getItemStack("IC2:blockMachine", 1); + RECIPE_BasicCasingIC2 = ItemUtils.getItemStackFromFQRN("IC2:blockMachine", 1); OUTPUT_Workbench_Bronze = ItemUtils.getSimpleStack(ModBlocks.blockWorkbench); OUTPUT_Blueprint = ItemUtils.getSimpleStack(ModItems.itemBlueprintBase); run(); @@ -126,9 +127,9 @@ public class RECIPES_General { //Iron bars final ItemStack ironBars; if (CORE.GTNH) { - ironBars = ItemUtils.getItemStack("dreamcraft:item.SteelBars", 1); + ironBars = ItemUtils.getItemStackFromFQRN("dreamcraft:item.SteelBars", 1); } else { - ironBars = ItemUtils.getItemStack("minecraft:iron_bars", 1); + ironBars = ItemUtils.getItemStackFromFQRN("minecraft:iron_bars", 1); } //Fish Trap @@ -153,12 +154,44 @@ public class RECIPES_General { null, CI.craftingToolWrench, null, ironRecipe, ironRecipe, ironRecipe, ironRecipe, ironRecipe, ironRecipe, - ItemUtils.getItemStack("minecraft:iron_bars", 8))) { + ItemUtils.getItemStackFromFQRN("minecraft:iron_bars", 8))) { Logger.INFO("Re-added old GT recipe for Iron Bars."); } } } + + //Shaped Crafting for ULV Material Dusts + + //Potin + if (RecipeUtils.addShapelessGregtechRecipe(new Object[] {"dustLead", "dustBronze", "dustTin", + "dustLead", "dustBronze"}, ALLOY.POTIN.getDust(5))){ + Logger.INFO("Added shapeless recipe for Potin Dust."); + } + + //Tumbaga + if (RecipeUtils.addShapelessGregtechRecipe(new Object[] { + "dustGold", "dustGold", "dustCopper"}, ItemUtils.getSimpleStack(ModItems.dustTumbagaMix))){ + Logger.INFO("Added shapeless recipe for Tumbaga Mix."); + } + if (RecipeUtils.addShapelessGregtechRecipe(new Object[] { + ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), + ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), + ItemUtils.getSimpleStack(ModItems.dustTumbagaMix), + "dustGold" + }, + ALLOY.TUMBAGA.getDust(10))){ + Logger.INFO("Added shapeless recipe for Tumbaga Dust."); + } + + + + + + + + + //Mining Explosive Logger.RECIPE("[Inspection] Explosives"); if (RecipeUtils.recipeBuilder( @@ -202,14 +235,14 @@ public class RECIPES_General { Logger.INFO("Added a recipe for Wither Cages."); } - Logger.RECIPE("[Inspection] Xp Converter"); + /*Logger.RECIPE("[Inspection] Xp Converter"); if (RecipeUtils.recipeBuilder( getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 2, 1), getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1), getSimpleStack(Items.nether_star), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1), getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 2, 1), getSimpleStack(Items.experience_bottle), ItemUtils.getSimpleStack(ModBlocks.blockXpConverter, 1))){ Logger.INFO("Added a recipe for XP Converter."); - } + }*/ @@ -247,7 +280,19 @@ public class RECIPES_General { ItemUtils.getSimpleStack(ModBlocks.blockNet, 2))){ Logger.INFO("Added a recipe for Nets."); } - + + // Slow Builders Ring + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { ItemUtils.getSimpleStack(Blocks.ice, 8), + ItemUtils.getSimpleStack(ModBlocks.blockNet, 8), ItemUtils.getSimpleStack(Blocks.vine, 8), + ALLOY.TUMBAGA.getRing(1), }, + FluidUtils.getWater(1000), // Fluid + ItemUtils.getItemStackFromFQRN("miscutils:SlowBuildingRing", 1), // Output + 20 * 30, // Dur + 16); // Eu + + + } @@ -279,8 +324,8 @@ public class RECIPES_General { input, input, input, input, input, input, output)){ - Logger.INFO("Added a recipe for Compressed Obsidian ["+r+"]"); - } + Logger.INFO("Added a recipe for Compressed Obsidian ["+r+"]"); + } if (RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{output}, ItemUtils.getSimpleStack(input, 9))){ Logger.INFO("Added a shapeless recipe for Compressed Obsidian ["+r+"]"); @@ -289,52 +334,52 @@ public class RECIPES_General { } return true; } - + private static void addHandPumpRecipes() { if (RecipeUtils.recipeBuilder( CI.electricPump_LV, "circuitBasic", null, "ringBrass", CI.electricMotor_LV, "circuitBasic", "plateSteel", "plateSteel", "rodBrass", ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1))) - Logger.INFO("Added recipe for Hand Pump I - true"); + Logger.INFO("Added recipe for Hand Pump I - true"); if (RecipeUtils.recipeBuilder( CI.electricPump_MV, "circuitAdvanced", null, "ringMagnalium", CI.electricMotor_MV, "circuitAdvanced", "plateAluminium", "plateAluminium", "rodMagnalium", ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1))) - Logger.INFO("Added recipe for Hand Pump II - true"); + Logger.INFO("Added recipe for Hand Pump II - true"); if (RecipeUtils.recipeBuilder( CI.electricPump_HV, "circuitData", null, "ringChrome", CI.electricMotor_HV, "circuitData", "plateStainlessSteel", "plateStainlessSteel", "rodChrome", ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1))) - Logger.INFO("Added recipe for Hand Pump III - true"); + Logger.INFO("Added recipe for Hand Pump III - true"); if (RecipeUtils.recipeBuilder( CI.electricPump_EV, "circuitElite", null, "ringTitanium", CI.electricMotor_EV, "circuitElite", "plateTungstenSteel", "plateTungstenSteel", "rodTitanium", ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1))) - Logger.INFO("Added recipe for Hand Pump IV - true"); - - - + Logger.INFO("Added recipe for Hand Pump IV - true"); + + + GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 1, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1000, 1), 30, 30); GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 2, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1001, 1), 120, 120); GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 3, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1002, 1), 480, 480); GT_Values.RA.addAssemblerRecipe(ItemUtils.simpleMetaStack(ModItems.itemGenericToken, 4, 1), CI.getNumberedCircuit(20), ItemUtils.simpleMetaStack(ModItems.toolGregtechPump, 1003, 1), 1820, 1820); - - + + } - + private static void migratedRecipes() { - + RecipeUtils.generateMortarRecipe(ItemUtils.getSimpleStack(ModItems.itemPlateRawMeat), ItemUtils.getItemStackOfAmountFromOreDict("dustMeatRaw", 1)); - + generateWireRecipes(ELEMENT.getInstance().ZIRCONIUM); generateWireRecipes(ALLOY.HG1223); generateWireRecipes(ALLOY.LEAGRISIUM); generateWireRecipes(ALLOY.TRINIUM_TITANIUM); - + GT_Materials[] g = new GT_Materials[] { GT_Materials.Staballoy, GT_Materials.Tantalloy60, @@ -347,7 +392,7 @@ public class RECIPES_General { GT_Materials.Inconel792, GT_Materials.HastelloyX, GT_Materials.TriniumNaquadahCarbonite, - + }; for (GT_Materials e : g) { if (e == GT_Materials.Void) { @@ -358,16 +403,16 @@ public class RECIPES_General { int tVoltageMultiplier = (e.mBlastFurnaceTemp >= 2800) ? 64 : 16; generatePipeRecipes(e.mDefaultLocalName, e.getMass(), tVoltageMultiplier); } - + Materials[] h = new Materials[] { Materials.Europium, Materials.Tungsten, Materials.DarkSteel, Materials.Clay, Materials.Lead, - + }; - + for (Materials e : h) { if (e == Materials.DarkSteel) { if (!LoadedMods.EnderIO) { @@ -377,13 +422,13 @@ public class RECIPES_General { int tVoltageMultiplier = (e.mBlastFurnaceTemp >= 2800) ? 64 : 16; generatePipeRecipes(e.mDefaultLocalName, e.getMass(), tVoltageMultiplier); } - + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) - RecipeUtils.addShapedGregtechRecipe( - CI.component_Plate[4], "rotorGtStainlessSteel", CI.component_Plate[4], - CI.getTieredCircuitOreDictName(3), CI.machineHull_HV, CI.getTieredCircuitOreDictName(3), - CI.component_Plate[4], CI.electricPump_HV, CI.component_Plate[4], - GregtechItemList.Hatch_Air_Intake.get(1L, new Object[0])); + RecipeUtils.addShapedGregtechRecipe( + CI.component_Plate[4], "rotorGtStainlessSteel", CI.component_Plate[4], + CI.getTieredCircuitOreDictName(3), CI.machineHull_HV, CI.getTieredCircuitOreDictName(3), + CI.component_Plate[4], CI.electricPump_HV, CI.component_Plate[4], + GregtechItemList.Hatch_Air_Intake.get(1L, new Object[0])); RecipeUtils.addShapedGregtechRecipe(CI.component_Plate[6], ALLOY.MARAGING250.getGear(1), CI.component_Plate[6], CI.getTieredCircuitOreDictName(4), GregtechItemList.Casing_AdvancedVacuum.get(1), @@ -399,55 +444,55 @@ public class RECIPES_General { CI.getTieredCircuitOreDictName(7), GregtechItemList.Casing_Naq_Reactor_A.get(1), CI.getTieredCircuitOreDictName(7), CI.component_Plate[9], ItemList.Hatch_Input_ZPM.get(1), CI.component_Plate[8], GregtechItemList.Hatch_Input_Naquadah.get(1L, new Object[0])); - + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_LV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_LV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_LV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_MV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_MV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_MV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_HV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_HV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_HV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_EV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_EV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_EV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_IV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_IV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_IV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_LuV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_LuV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_LuV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_ZPM.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_ZPM.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_ZPM.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_UV.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_UV.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_UV.get(1) }); - GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_MAX.get(1L, new Object[0]), bitsd, - new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_MAX.get(1), Character.valueOf('P'), - GregtechItemList.Pollution_Cleaner_MAX.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_LV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_LV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_LV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_MV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_MV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_MV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_HV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_HV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_HV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_EV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_EV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_EV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_IV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_IV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_IV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_LuV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_LuV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_LuV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_ZPM.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_ZPM.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_ZPM.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_UV.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_UV.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_UV.get(1) }); + GT_ModHandler.addCraftingRecipe(GregtechItemList.Hatch_Muffler_Adv_MAX.get(1L, new Object[0]), bitsd, + new Object[] { "M", "P", Character.valueOf('M'), ItemList.Hatch_Muffler_MAX.get(1), Character.valueOf('P'), + GregtechItemList.Pollution_Cleaner_MAX.get(1) }); } - - - - - - - - - - + + + + + + + + + + } - - - - - - - + + + + + + + } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index a12e8b28fd..54d9994edc 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -97,16 +97,16 @@ public class RECIPES_Machines { //Buffer Cores - public static ItemStack RECIPE_BufferCore_ULV = ItemUtils.getItemStack("miscutils:item.itemBufferCore1", 1); - public static ItemStack RECIPE_BufferCore_LV = ItemUtils.getItemStack("miscutils:item.itemBufferCore2", 1); - public static ItemStack RECIPE_BufferCore_MV = ItemUtils.getItemStack("miscutils:item.itemBufferCore3", 1); - public static ItemStack RECIPE_BufferCore_HV = ItemUtils.getItemStack("miscutils:item.itemBufferCore4", 1); - public static ItemStack RECIPE_BufferCore_EV = ItemUtils.getItemStack("miscutils:item.itemBufferCore5", 1); - public static ItemStack RECIPE_BufferCore_IV = ItemUtils.getItemStack("miscutils:item.itemBufferCore6", 1); - public static ItemStack RECIPE_BufferCore_LuV = ItemUtils.getItemStack("miscutils:item.itemBufferCore7", 1); - public static ItemStack RECIPE_BufferCore_ZPM = ItemUtils.getItemStack("miscutils:item.itemBufferCore8", 1); - public static ItemStack RECIPE_BufferCore_UV = ItemUtils.getItemStack("miscutils:item.itemBufferCore9", 1); - public static ItemStack RECIPE_BufferCore_MAX = ItemUtils.getItemStack("miscutils:item.itemBufferCore10", 1); + public static ItemStack RECIPE_BufferCore_ULV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore1", 1); + public static ItemStack RECIPE_BufferCore_LV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore2", 1); + public static ItemStack RECIPE_BufferCore_MV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore3", 1); + public static ItemStack RECIPE_BufferCore_HV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore4", 1); + public static ItemStack RECIPE_BufferCore_EV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore5", 1); + public static ItemStack RECIPE_BufferCore_IV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore6", 1); + public static ItemStack RECIPE_BufferCore_LuV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore7", 1); + public static ItemStack RECIPE_BufferCore_ZPM = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore8", 1); + public static ItemStack RECIPE_BufferCore_UV = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore9", 1); + public static ItemStack RECIPE_BufferCore_MAX = ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore10", 1); //Wire @@ -181,7 +181,7 @@ public class RECIPES_Machines { //Lava Boiler public static ItemStack boiler_Coal; - public static ItemStack blockBricks = ItemUtils.getItemStack("minecraft:brick_block", 1); + public static ItemStack blockBricks = ItemUtils.getItemStackFromFQRN("minecraft:brick_block", 1); //Batteries public static String batteryBasic = "batteryBasic"; @@ -207,10 +207,20 @@ public class RECIPES_Machines { } private static void run(){ + + //Determines Casing Recipe Output + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !GTNH){ + Casing_Amount=2; + } + else { + Casing_Amount=1; + } + initModItems(); controlCores(); energyCores(); wirelessChargers(); + largeArcFurnace(); } private static void initModItems(){ @@ -276,85 +286,128 @@ public class RECIPES_Machines { private static void runModRecipes(){ if (LoadedMods.Gregtech){ - //Determines Casing Recipe Output - if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !GTNH){ - Casing_Amount=2; - } - else { - Casing_Amount=1; - } - - + //Computer Cube CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - ItemUtils.getSimpleStack(CI.getDataOrb(), 4 * (GTNH ? 2 : 1)), - ItemList.Cover_Screen.get(4), - CI.machineHull_IV, - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(7), 2) + ItemUtils.getSimpleStack(CI.getDataOrb(), 4 * (GTNH ? 2 : 1)), + ItemList.Cover_Screen.get(4), + CI.machineHull_IV, + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(7), 2) }, ELEMENT.getInstance().TANTALUM.getFluid(144 * 16), GregtechItemList.Gregtech_Computer_Cube.get(1), 60 * 20 * 3, 8000); - + //Circuit programmer CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - ItemUtils.getSimpleStack(CI.robotArm_LV, 4 * (GTNH ? 2 : 1)), - ItemList.Cover_Controller.get(1, CI.electricMotor_MV), - CI.machineHull_MV, - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(2), 2), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(3), 2) + ItemUtils.getSimpleStack(CI.robotArm_LV, 4 * (GTNH ? 2 : 1)), + ItemList.Cover_Controller.get(1, CI.electricMotor_MV), + CI.machineHull_MV, + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(1), 2), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(2), 2) }, ELEMENT.getInstance().IRON.getFluid(144 * 4), ItemUtils.getSimpleStack(ModBlocks.blockCircuitProgrammer), 60 * 10 * 1, 30); - + //Lead Lined Chest CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - CI.machineHull_LV, - ItemUtils.getItemStackOfAmountFromOreDict("plateRubber", 32), - ItemUtils.getItemStackOfAmountFromOreDict("plateDenseLead", 9), - ItemUtils.getSimpleStack(Blocks.chest) + CI.machineHull_LV, + ItemUtils.getItemStackOfAmountFromOreDict("plateRubber", 32), + ItemUtils.getItemStackOfAmountFromOreDict("plateDenseLead", 9), + ItemUtils.getSimpleStack(Blocks.chest) }, ELEMENT.getInstance().LEAD.getFluid(144 * 16), ItemUtils.getSimpleStack(ModBlocks.blockDecayablesChest), 60 * 10 * 3, 60); - + //RTG CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - ItemUtils.getItemStackWithMeta(true, "IC2:blockGenerator:6", "IC2-RTG", 6, 1), - ALLOY.NITINOL_60.getPlate(GTNH ? 32 : 8), - ALLOY.MARAGING350.getGear(GTNH ? 16 : 4), - ItemUtils.getSimpleStack(GTNH ? CI.fieldGenerator_IV : CI.fieldGenerator_EV, 8 ), - ItemUtils.getItemStackOfAmountFromOreDict("wireFinePlatinum", GTNH ? 64 : 32), - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(GTNH ? 7 : 6), GTNH ? 5 : 4) + ItemUtils.getItemStackWithMeta(true, "IC2:blockGenerator:6", "IC2-RTG", 6, 1), + ALLOY.NITINOL_60.getPlate(GTNH ? 32 : 8), + ALLOY.MARAGING350.getGear(GTNH ? 16 : 4), + ItemUtils.getSimpleStack(GTNH ? CI.fieldGenerator_IV : CI.fieldGenerator_EV, 8 ), + ItemUtils.getItemStackOfAmountFromOreDict("wireFinePlatinum", GTNH ? 64 : 32), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(GTNH ? 7 : 6), GTNH ? 5 : 4) }, ALLOY.NIOBIUM_CARBIDE.getFluid(144 * 16), GregtechItemList.RTG.get(1), 60 * 20 * 10, 8000); - + // Super Jukebox CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - CI.machineHull_LV, - ItemUtils.getItemStackOfAmountFromOreDict("circuitBaisc", 8), - ItemUtils.getItemStackOfAmountFromOreDict("plateTumbaga", 8), - ItemUtils.getSimpleStack(Blocks.jukebox) + CI.machineHull_LV, + ItemUtils.getItemStackOfAmountFromOreDict("circuitBasic", 4), + ItemUtils.getItemStackOfAmountFromOreDict("plateTumbaga", 8), + ItemUtils.getSimpleStack(Blocks.jukebox) }, ELEMENT.getInstance().COPPER.getFluid(144 * 2), ItemUtils.getSimpleStack(ModBlocks.blockCustomJukebox), 20 * 30, 30); + //Poo Collector + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.machineHull_MV, + CI.getTieredComponent(OrePrefixes.circuit, 2, GTNH ? 4 : 2), + CI.getTieredComponent(OrePrefixes.pipeMedium, 2, GTNH ? 4 : 2), + CI.getElectricPump(2, GTNH ? 4 : 2), + ALLOY.EGLIN_STEEL.getPlate(GTNH ? 8 : 4), + ALLOY.POTIN.getScrew(GTNH ? 12 : 6) + }, + ALLOY.TUMBAGA.getFluid(144 * 4), + ItemUtils.getSimpleStack(ModBlocks.blockPooCollector), + 20 * 60, + 30); + + //Adv. Poo Collector + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getTieredMachineHull(-1), + ItemUtils.getSimpleStack(ModBlocks.blockPooCollector), + CI.getTieredComponent(OrePrefixes.circuit, 5, GTNH ? 8 : 4), + CI.getTieredComponent(OrePrefixes.pipeHuge, 6, GTNH ? 8 : 4), + CI.getElectricPump(5, GTNH ? 12 : 6), + CI.getTieredComponent(OrePrefixes.screw, 6, GTNH ? 32 : 16) + }, + CI.getAlternativeTieredFluid(5, 144 * 9), + ItemUtils.getSimpleStack(ModBlocks.blockPooCollector, 8, 1), + 20 * 60 * 5, + 500); + + + //Basic Steam Turbine + RecipeUtils.addShapedGregtechRecipe( + CI.getTieredComponent(OrePrefixes.pipeSmall, 0, 1), "circuitPrimitive", CI.getTieredComponent(OrePrefixes.pipeSmall, 0, 1), + ALLOY.TUMBAGA.getRotor(1), CI.machineCasing_ULV, ALLOY.TUMBAGA.getRotor(1), + CI.getElectricMotor(0, 1), "cableGt01RedAlloy", CI.getElectricMotor(0, 1), + GregtechItemList.Generator_Steam_Turbine_ULV.get(1)); + + //Basic Gas Turbine + RecipeUtils.addShapedGregtechRecipe( + "circuitPrimitive", ALLOY.TUMBAGA.getRotor(1), "circuitPrimitive", + ALLOY.TUMBAGA.getRotor(1), CI.machineCasing_ULV, ALLOY.TUMBAGA.getRotor(1), + CI.getElectricMotor(0, 1), "cableGt01RedAlloy", CI.getElectricMotor(0, 1), + GregtechItemList.Generator_Gas_Turbine_ULV.get(1)); + + //Basic Combustion Turbine + RecipeUtils.addShapedGregtechRecipe( + CI.getElectricPiston(0, 1), "circuitPrimitive", CI.getElectricPiston(0, 1), + CI.getElectricMotor(0, 1), CI.machineCasing_ULV, CI.getElectricMotor(0, 1), + ALLOY.TUMBAGA.getGear(1), "cableGt01RedAlloy", ALLOY.TUMBAGA.getGear(1), + GregtechItemList.Generator_Diesel_ULV.get(1)); + - //Steam Condenser if (CORE.ConfigSwitches.enableMachine_SteamConverter ){ @@ -773,7 +826,7 @@ public class RECIPES_Machines { "plankWood", "frameGtTumbaga", "plankWood", "plankWood", "plankWood", "plankWood", RECIPE_TreeFarmFrame); - */} + */} if (CORE.ConfigSwitches.enableMachine_Tesseracts){ //Tesseracts @@ -837,7 +890,7 @@ public class RECIPES_Machines { //Air Intake Hatch - + ItemList FluidRegulator_IV = Utils.getValueOfItemList("FluidRegulator_IV", ItemList.Pump_IV); ItemStack aTieredFluidRegulator = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? FluidRegulator_IV.get(1) : ItemList.Pump_IV.get(1); @@ -967,7 +1020,7 @@ public class RECIPES_Machines { "plateDoubleZeron100", CI.craftingToolHammer_Hard, "plateDoubleZeron100", RECIPE_LFTRInnerCasing); - ItemStack IC2HeatPlate = ItemUtils.getItemStack("IC2:reactorPlatingHeat", 1); + ItemStack IC2HeatPlate = ItemUtils.getItemStackFromFQRN("IC2:reactorPlatingHeat", 1); RecipeUtils.addShapedGregtechRecipe( "plateDoubleHastelloyN", IC2HeatPlate, "plateDoubleHastelloyN", IC2HeatPlate, "frameGtHastelloyC276", IC2HeatPlate, @@ -1045,28 +1098,60 @@ public class RECIPES_Machines { RECIPE_CyclotronController = GregtechItemList.COMET_Cyclotron.get(1); RECIPE_CyclotronOuterCasing = GregtechItemList.Casing_Cyclotron_External.get(Casing_Amount); RECIPE_CyclotronInnerCoil = GregtechItemList.Casing_Cyclotron_Coil.get(1); + + //Outer Casing + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemList.Casing_FrostProof.get(1), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 0, GTNH ? 8 : 4), + ALLOY.INCOLOY_DS.getPlate(GTNH ? 16 : 8), + ALLOY.INCONEL_690.getScrew(GTNH ? 32 : 16), + ALLOY.EGLIN_STEEL.getLongRod(GTNH ? 16 : 4), + CI.getElectricPiston(3, GTNH ? 4 : 2) + }, + ALLOY.ZIRCONIUM_CARBIDE.getFluid(144 * 8), //Input Fluid + RECIPE_CyclotronOuterCasing, + 30 * 20 * 2, + MaterialUtils.getVoltageForTier(4)); + + + //Inner Coil + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemList.Casing_Coil_Nichrome.get(1), + ItemUtils.simpleMetaStack("miscutils:itemDehydratorCoilWire", 1, GTNH ? 32 : 8), + ALLOY.INCOLOY_MA956.getPlate(GTNH ? 16 : 8), + ALLOY.TANTALLOY_61.getBolt(GTNH ? 32 : 16), + ALLOY.INCOLOY_020.getScrew(GTNH ? 64 : 32), + CI.getFieldGenerator(4, GTNH ? 2 : 1) + }, + ALLOY.HG1223.getFluid(144 * 5), //Input Fluid + RECIPE_CyclotronInnerCoil, + 60 * 20 * 2, + MaterialUtils.getVoltageForTier(5)); + + + //Controller + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.machineHull_IV, + ItemUtils.getSimpleStack(RECIPE_CyclotronInnerCoil, GTNH ? 4 : 2), + ALLOY.INCOLOY_020.getPlate(GTNH ? 16 : 8), + ALLOY.TANTALLOY_61.getGear(GTNH ? 4 : 2), + ALLOY.INCOLOY_MA956.getScrew(GTNH ? 64 : 16), + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(GTNH ? 6 : 5), GTNH ? 8 : 16) + }, + ALLOY.INCOLOY_020.getFluid(144 * 9), //Input Fluid + RECIPE_CyclotronController, + 60 * 20 * 5, + MaterialUtils.getVoltageForTier(5)); + + + + + - GT_Values.RA.addAssemblerRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("plateIncoloyMA956", 8), - ItemUtils.getItemStackOfAmountFromOreDict("frameGtIncoloy020", 1), - FluidUtils.getFluidStack("molten.hg1223", 32), - RECIPE_CyclotronOuterCasing, - 30 * 20, - 500); - - GT_Values.RA.addAssemblerRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("plateIncoloyDS", 16), - ItemList.Field_Generator_HV.get(1), - FluidUtils.getFluidStack("molten.hg1223", 144), - RECIPE_CyclotronInnerCoil, - 90 * 20, - 1000); - RecipeUtils.recipeBuilder( - "plateIncoloy020", CI.getTieredCircuit(6), "plateIncoloy020", - RECIPE_CyclotronInnerCoil, CI.machineHull_IV, RECIPE_CyclotronInnerCoil, - "plateIncoloy020", "gearGtIncoloyMA956", "plateIncoloy020", - RECIPE_CyclotronController); } if (CORE.ConfigSwitches.enableMultiblock_PowerSubstation){ @@ -1118,43 +1203,43 @@ public class RECIPES_Machines { ItemStack aCoreBlock = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? ItemList.valueOf("Block_IridiumTungstensteel").get(1, ItemUtils.getItemStackOfAmountFromOreDict("blockOsmiridium", 1)) - : ItemUtils.getItemStackOfAmountFromOreDict("blockOsmiridium", 1); - - aCoreBlock.stackSize = GTNH ? 2 : 1; - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.getSimpleStack(GregtechItemList.Casing_Multi_Use.get(1), GTNH ? 2 : 1), - aCoreBlock, - CI.getTieredComponent(OrePrefixes.circuit, GTNH ? 3 : 2, 16), - CI.getTieredComponent(OrePrefixes.screw, GTNH ? 6 : 5, 32), - CI.getTieredComponent(OrePrefixes.bolt, GTNH ? 6 : 5, 12), - CI.getTieredComponent(OrePrefixes.plate, GTNH ? 7 : 6, 8), }, - CI.getTertiaryTieredFluid(6, 144 * (GTNH ? 12 : 4)), - GregtechItemList.Casing_Autocrafter.get(Casing_Amount), 20 * 60 * 2, - MaterialUtils.getVoltageForTier(GTNH ? 7 : 6)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - GregtechItemList.Casing_Refinery_Structural.get(4), - ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR, GTNH ? 2 : 1), - CI.getTieredComponent(OrePrefixes.cableGt08, GTNH ? 7 : 6, GTNH ? 32 : 16), - CI.getEmitter(GTNH ? 7 : 5, 2), - CI.getSensor(GTNH ? 7 : 5, 2), - GregtechItemList.Gregtech_Computer_Cube.get(1), + : ItemUtils.getItemStackOfAmountFromOreDict("blockOsmiridium", 1); + + aCoreBlock.stackSize = GTNH ? 2 : 1; + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(GregtechItemList.Casing_Multi_Use.get(1), GTNH ? 2 : 1), + aCoreBlock, + CI.getTieredComponent(OrePrefixes.circuit, GTNH ? 3 : 2, 16), + CI.getTieredComponent(OrePrefixes.screw, GTNH ? 6 : 5, 32), + CI.getTieredComponent(OrePrefixes.bolt, GTNH ? 6 : 5, 12), + CI.getTieredComponent(OrePrefixes.plate, GTNH ? 7 : 6, 8), }, + CI.getTertiaryTieredFluid(6, 144 * (GTNH ? 12 : 4)), + GregtechItemList.Casing_Autocrafter.get(Casing_Amount), 20 * 60 * 2, + MaterialUtils.getVoltageForTier(GTNH ? 6 : 5)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + GregtechItemList.Casing_Refinery_Structural.get(4), + ItemUtils.getSimpleStack(ModItems.itemCircuitLFTR, GTNH ? 2 : 1), + CI.getTieredComponent(OrePrefixes.cableGt08, GTNH ? 7 : 6, GTNH ? 32 : 16), + CI.getEmitter(GTNH ? 6 : 5, 2), + CI.getSensor(GTNH ? 6 : 5, 2), + GregtechItemList.Gregtech_Computer_Cube.get(1), }, - CI.getTieredFluid(7, 144 * (GTNH ? 32 : 8)), GregtechItemList.GT4_Multi_Crafter.get(1), - 20 * 60 * 5, MaterialUtils.getVoltageForTier(GTNH ? 7 : 6)); - - CORE.RA.addSixSlotAssemblingRecipe( - new ItemStack[] { - ItemUtils.getSimpleStack(GregtechItemList.Casing_Multi_Use.get(1), Casing_Amount), - CI.getEmitter(GTNH ? 5 : 4, GTNH ? 4 : 2), CI.getRobotArm(GTNH ? 5 : 4, GTNH ? 4 : 2), - CI.getTieredComponent(OrePrefixes.circuit, GTNH ? 3 : 2, 8), - CI.getTieredComponent(OrePrefixes.screw, GTNH ? 4 : 3, 8), - CI.getTieredComponent(OrePrefixes.plate, 5, GTNH ? 16 : 4), }, - CI.getAlternativeTieredFluid(5, 144 * 4), ItemUtils.getSimpleStack(ModBlocks.blockProjectTable), - 20 * 30 * 3, MaterialUtils.getVoltageForTier(GTNH ? 5 : 4)); + CI.getTieredFluid(7, 144 * (GTNH ? 32 : 8)), GregtechItemList.GT4_Multi_Crafter.get(1), + 20 * 60 * 5, MaterialUtils.getVoltageForTier(GTNH ? 6 : 5)); + + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + ItemUtils.getSimpleStack(GregtechItemList.Casing_Multi_Use.get(1), Casing_Amount), + CI.getEmitter(GTNH ? 5 : 4, GTNH ? 4 : 2), CI.getRobotArm(GTNH ? 5 : 4, GTNH ? 4 : 2), + CI.getTieredComponent(OrePrefixes.circuit, GTNH ? 3 : 2, 8), + CI.getTieredComponent(OrePrefixes.screw, GTNH ? 4 : 3, 8), + CI.getTieredComponent(OrePrefixes.plate, 5, GTNH ? 16 : 4), }, + CI.getAlternativeTieredFluid(5, 144 * 4), ItemUtils.getSimpleStack(ModBlocks.blockProjectTable), + 20 * 30 * 3, MaterialUtils.getVoltageForTier(GTNH ? 5 : 4)); } @@ -1352,7 +1437,7 @@ public class RECIPES_Machines { ItemUtils.getSimpleStack((GTNH ? CI.fieldGenerator_MAX : CI.fieldGenerator_ZPM), 5), ItemList.Energy_LapotronicOrb2.get(1 * (GTNH ? 64 : 8)), GTNH ? GregtechItemList.Compressed_Fusion_Reactor.get(1) : ItemList.FusionComputer_UV.get(1), - GregtechItemList.Casing_Fusion_Internal.get(1) + GregtechItemList.Casing_Fusion_Internal.get(1) }, new FluidStack[] { ALLOY.PIKYONIUM.getFluid(32 * 144 * (GTNH ? 2 : 1)), @@ -1408,10 +1493,10 @@ public class RECIPES_Machines { (int) GT_Values.V[7]); - - + + ItemStack aDrillController = Utils.getValueOfItemList("OreDrill4", ItemList.Hull_UV).get(1); - + //Drilling Platform CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -1425,7 +1510,7 @@ public class RECIPES_Machines { GregtechItemList.BedrockMiner_MKI.get(1), (int) GT_Values.V[5], (int) GT_Values.V[7]); - + //Drilling Platform Casings CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -1478,8 +1563,8 @@ public class RECIPES_Machines { ItemUtils.getSimpleStack(Dimension_Everglades.blockPortalFrame, 2), 45 * 20 * 1 * (6), MaterialUtils.getVoltageForTier(6)); - - + + //Player Doors ItemStack[] aDoorInputs = new ItemStack[] { ItemUtils.getSimpleStack(Blocks.log2), @@ -1495,7 +1580,7 @@ public class RECIPES_Machines { ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorCustom_Ice), ItemUtils.getSimpleStack(ModBlocks.blockPlayerDoorCustom_Cactus), }; - + for (int y = 0; y < aDoorInputs.length; y++) { CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -1511,18 +1596,18 @@ public class RECIPES_Machines { 100, MaterialUtils.getVoltageForTier(1)); } - - - + + + Logger.INFO("Done loading recipes for the Various machine blocks."); } - - + + private static void controlCores() { - + Material[] aMat_A = new Material[] { ALLOY.POTIN, ALLOY.ZIRCONIUM_CARBIDE, @@ -1547,19 +1632,19 @@ public class RECIPES_Machines { ALLOY.ZERON_100, ALLOY.CINOBITE }; - + Item aBaseCore = ModItems.itemControlCore; ItemStack[] aInputPrevTier = new ItemStack[] { - GTNH ? ItemUtils.getItemStack("miscutils:item.itemBufferCore3", 1) : ItemUtils.getItemStack("miscutils:item.itemBufferCore2", 1), - ItemUtils.simpleMetaStack(aBaseCore, 0, 1), - ItemUtils.simpleMetaStack(aBaseCore, 1, 1), - ItemUtils.simpleMetaStack(aBaseCore, 2, 1), - ItemUtils.simpleMetaStack(aBaseCore, 3, 1), - ItemUtils.simpleMetaStack(aBaseCore, 4, 1), - ItemUtils.simpleMetaStack(aBaseCore, 5, 1), - ItemUtils.simpleMetaStack(aBaseCore, 6, 1), - ItemUtils.simpleMetaStack(aBaseCore, 7, 1), - ItemUtils.simpleMetaStack(aBaseCore, 8, 1), + GTNH ? ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore3", 1) : ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore2", 1), + ItemUtils.simpleMetaStack(aBaseCore, 0, 1), + ItemUtils.simpleMetaStack(aBaseCore, 1, 1), + ItemUtils.simpleMetaStack(aBaseCore, 2, 1), + ItemUtils.simpleMetaStack(aBaseCore, 3, 1), + ItemUtils.simpleMetaStack(aBaseCore, 4, 1), + ItemUtils.simpleMetaStack(aBaseCore, 5, 1), + ItemUtils.simpleMetaStack(aBaseCore, 6, 1), + ItemUtils.simpleMetaStack(aBaseCore, 7, 1), + ItemUtils.simpleMetaStack(aBaseCore, 8, 1), }; ItemStack[] aOutput = new ItemStack[] { ItemUtils.simpleMetaStack(aBaseCore, 0, 1), @@ -1572,32 +1657,31 @@ public class RECIPES_Machines { ItemUtils.simpleMetaStack(aBaseCore, 7, 1), ItemUtils.simpleMetaStack(aBaseCore, 8, 1), ItemUtils.simpleMetaStack(aBaseCore, 9, 1), - + }; - + CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { CI.machineHull_HV, aOutput[1], aMat_A[1].getGear(GTNH ? 4 : 2), aMat_B[2].getPlateDouble(GTNH ? 16 : 8), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+(GTNH ? "2" : "1"), GTNH ? 4 : 2), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+(GTNH ? "2" : "1"), GTNH ? 4 : 2), ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName(GTNH ? 3 : 2), GTNH ? 10 : 5) }, aMat_B[3].getFluid(144 * 8), //Input Fluid GregtechItemList.Hatch_Control_Core.get(1), 60 * 20 * 5, MaterialUtils.getVoltageForTier(3)); - - - for (int i = 0; i < 10; i++) { - boolean aDub = i >= 5; + + for (int i = 0; i < 10; i++) { + boolean aDub = false; ItemStack aPlateStack = aMat_A[i].getPlateDouble((GTNH ? 16 : 8) * (aDub ? 2 : 1)); - ItemStack aGearStack = aMat_B[i].getGear(GTNH ? 8 : 4 * (aDub ? 2 : 1)); - ItemStack aRodStack = aMat_A[i].getLongRod(GTNH ? 32 : 16 * (aDub ? 2 : 1)); + ItemStack aGearStack = aMat_B[i].getGear(GTNH ? 4 : 2 * (aDub ? 2 : 1)); + ItemStack aRodStack = aMat_A[i].getLongRod(GTNH ? 16 : 8 * (aDub ? 2 : 1)); ItemStack aScrewStack = aMat_B[i].getScrew(32 * (aDub ? 2 : 1)); - + if (!ItemUtils.checkForInvalidItems(aPlateStack)) { aPlateStack = aMat_A[i].getPlate((GTNH ? 16 : 8) * (aDub ? 2 : 1) * 2); if (!ItemUtils.checkForInvalidItems(aPlateStack)) { @@ -1616,25 +1700,25 @@ public class RECIPES_Machines { if (!ItemUtils.checkForInvalidItems(aScrewStack)) { aScrewStack = aMat_A[i].getScrew(32 * (aDub ? 2 : 1)); } - + CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { - aInputPrevTier[i], + CI.getEnergyCore(i, 4), aPlateStack, aGearStack, aRodStack, aScrewStack, - ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName((int) (4+Math.ceil((double) i / (double) 2))), GTNH ? (i * 2 * 2 * 2) : (i * 2 * 2)) + ItemUtils.getItemStackOfAmountFromOreDict(CI.getTieredCircuitOreDictName((int) (4+Math.ceil((double) i / (double) 2))), GTNH ? (i * 2 * 2) : (i * 2)) }, - aMat_A[i].getFluid(144 * 4 * (i+1)), //Input Fluid + CI.getTieredFluid(i, 144 * 4 * (i+1)), //Input Fluid aOutput[i], 60 * 20 * 1 * (i+1), MaterialUtils.getVoltageForTier(i)); } } - + private static void energyCores() { - + //Simpler Recipes for normal Players, Force assembly crafting in GTNH if (!GTNH) { //Buffer Core @@ -1741,32 +1825,32 @@ public class RECIPES_Machines { CI.circuitTier9, RECIPE_BufferCore_MAX, CI.circuitTier9, RECIPE_Buffer_MAX);*/ } - + ItemStack[] aBufferOutput = new ItemStack[] { RECIPE_Buffer_ULV, RECIPE_Buffer_LV, RECIPE_Buffer_MV, RECIPE_Buffer_HV, RECIPE_Buffer_EV, RECIPE_Buffer_IV, RECIPE_Buffer_LuV, RECIPE_Buffer_ZPM, RECIPE_Buffer_UV, RECIPE_Buffer_MAX }; - - - + + + ItemStack[] aOutput = new ItemStack[] { - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"1", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"2", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"3", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"4", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"5", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"6", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"7", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"8", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"9", 1), - ItemUtils.getItemStack("miscutils:item.itemBufferCore"+"10", 1) + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"1", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"2", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"3", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"4", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"5", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"6", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"7", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"8", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"9", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"10", 1) }; - + int aCostMultiplier = GTNH ? 4 : 1; - + for (int i = 0; i < 10; i++) { - + ItemStack aPrevTier = (i == 0 ? CI.getTieredMachineHull(GTNH ? 2 : 1) : aOutput[i-1]); aPrevTier.stackSize = GTNH ? 2 : 1; int aTier = (i + 1); @@ -1783,7 +1867,7 @@ public class RECIPES_Machines { aOutput[i], 45 * 10 * 1 * (aTier), MaterialUtils.getVoltageForTier(i)); - + //Energy Buffer CORE.RA.addSixSlotAssemblingRecipe( new ItemStack[] { @@ -1798,14 +1882,14 @@ public class RECIPES_Machines { aBufferOutput[i], 45 * 20 * 1 * (aTier), MaterialUtils.getVoltageForTier(i)); - + } - - - + + + } - + private static void wirelessChargers() { ItemStack[] aChargers = new ItemStack[] { @@ -1819,10 +1903,10 @@ public class RECIPES_Machines { GregtechItemList.Charger_ZPM.get(1), GregtechItemList.Charger_UV.get(1), GregtechItemList.Charger_MAX.get(1) - }; - + }; + int aCostMultiplier = GTNH ? 2 : 1; - + for (int i = 0; i < 10; i++) { if (i == 0) { continue; @@ -1842,7 +1926,37 @@ public class RECIPES_Machines { aChargers[i], 45 * 10 * 1 * (aTier), MaterialUtils.getVoltageForTier(i)); - + } } + + private static void largeArcFurnace() { + int aCostMultiplier = GTNH ? 2 : 1; + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.getTieredMachineHull(-1, 1 * aCostMultiplier), + CI.getEmitter(2, 2 * aCostMultiplier), + CI.getElectricPiston(4, 2 * aCostMultiplier), + CI.getSensor(4, 1 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.plate, 5, 4 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.pipeSmall, 4, 1 * aCostMultiplier), + }, + CI.getAlternativeTieredFluid(5, (144 * 2 * 4)), //Input Fluid + GregtechItemList.Casing_Industrial_Arc_Furnace.get(Casing_Amount), + 20 * 10 * 1 * (6), + MaterialUtils.getVoltageForTier(5)); + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + GregtechItemList.Casing_Industrial_Arc_Furnace.get(Casing_Amount), + CI.getFieldGenerator(4, 2 * aCostMultiplier), + CI.getRobotArm(5, 4 * aCostMultiplier), + CI.getEnergyCore(4, 2 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.plate, 6, 8 * aCostMultiplier), + CI.getTieredComponent(OrePrefixes.circuit, 5, 8 * aCostMultiplier), + }, + CI.getAlternativeTieredFluid(6, (144 * 4 * 5)), //Input Fluid + GregtechItemList.Industrial_Arc_Furnace.get(1), + 60 * 20 * 8, + MaterialUtils.getVoltageForTier(6)); + } } diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index b473b30c3c..ba592bcb65 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -13,6 +13,7 @@ import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.recipe.LOADER_Machine_Components; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.eio.material.MaterialEIO; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; @@ -435,8 +436,11 @@ public class CI { else if (tier == 8){ return machineHull_UV; } + else if (tier == 9){ + return machineHull_MAX; + } else { - return machineHull_MAX; + return GregtechItemList.Casing_Multi_Use.get(1); } } @@ -468,8 +472,11 @@ public class CI { else if (tier == 8){ return machineCasing_UV; } + else if (tier == 9){ + return machineCasing_MAX; + } else { - return machineCasing_MAX; + return GregtechItemList.Casing_Multi_Use.get(1); } } @@ -628,6 +635,38 @@ public class CI { return a; } + public static ItemStack getEnergyCore(int aTier, int aAmount) { + ItemStack[] aOutput = new ItemStack[] { + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"1", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"2", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"3", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"4", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"5", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"6", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"7", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"8", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"9", 1), + ItemUtils.getItemStackFromFQRN("miscutils:item.itemBufferCore"+"10", 1) + }; + return ItemUtils.getSimpleStack(aOutput[MathUtils.balance(aTier, 0, 9)], aAmount); + } + + public static ItemStack getPlate(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.plate, aTier, aAmount); + } + + public static ItemStack getGear(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.gearGt, aTier, aAmount); + } + + public static ItemStack getIngot(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.ingot, aTier, aAmount); + } + + public static ItemStack getBolt(int aTier, int aAmount) { + return getTieredComponent(OrePrefixes.bolt, aTier, aAmount); + } + public static ItemStack getTieredComponent(OrePrefixes aPrefix, int aTier, int aAmount) { aTier = Math.max(0, aTier); @@ -685,6 +724,11 @@ public class CI { } if (aPrefix == OrePrefixes.pipeTiny || aPrefix == OrePrefixes.pipeSmall || aPrefix == OrePrefixes.pipe || aPrefix == OrePrefixes.pipeMedium || aPrefix == OrePrefixes.pipeLarge || aPrefix == OrePrefixes.pipeHuge) { + + if (aPrefix == OrePrefixes.pipe) { + aPrefix = OrePrefixes.pipeMedium; + } + if (aTier == 0) { return ItemUtils.getOrePrefixStack(aPrefix, Materials.Lead, aAmount); } @@ -1144,7 +1188,7 @@ public class CI { aType = CI.machineHull_MAX; } else { - aType = CI.machineHull_LV; + aType = GregtechItemList.Casing_Multi_Use.get(1, CI.machineHull_MV); } return ItemUtils.getSimpleStack(aType, aSize); } diff --git a/src/Java/gtPlusPlus/core/slots/SlotToolBox.java b/src/Java/gtPlusPlus/core/slots/SlotToolBox.java index c6d025fd21..87967b75b5 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotToolBox.java +++ b/src/Java/gtPlusPlus/core/slots/SlotToolBox.java @@ -18,34 +18,34 @@ public class SlotToolBox extends SlotGtTool { Class temp; //IHL Pumps - temp = ReflectionUtils.getClassByName("ihl.handpump.IHLHandPump"); + temp = ReflectionUtils.getClass("ihl.handpump.IHLHandPump"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; } //IC2 Electrics - temp = ReflectionUtils.getClassByName("ic2.api.item.IElectricItem"); + temp = ReflectionUtils.getClass("ic2.api.item.IElectricItem"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; } //IC2 Boxables - temp = ReflectionUtils.getClassByName(" ic2.api.item.IBoxable"); + temp = ReflectionUtils.getClass(" ic2.api.item.IBoxable"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; } //Tinkers Tools - temp = ReflectionUtils.getClassByName("tconstruct.library.tools.Weapon"); + temp = ReflectionUtils.getClass("tconstruct.library.tools.Weapon"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; } //BattleGear Weapons - temp = ReflectionUtils.getClassByName("mods.battlegear2.api.weapons.IBattlegearWeapon"); + temp = ReflectionUtils.getClass("mods.battlegear2.api.weapons.IBattlegearWeapon"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; @@ -55,7 +55,7 @@ public class SlotToolBox extends SlotGtTool { //OpenMods String[] OpenModsContent = new String[] {"openblocks.common.item.ItemDevNull", "openblocks.common.item.ItemHangGlider", "openblocks.common.item.ItemWrench", "openblocks.common.item.ItemSleepingBag"}; for (String t : OpenModsContent) { - temp = ReflectionUtils.getClassByName(t); + temp = ReflectionUtils.getClass(t); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; @@ -63,7 +63,7 @@ public class SlotToolBox extends SlotGtTool { } //GC Wrench - temp = ReflectionUtils.getClassByName("micdoodle8.mods.galacticraft.core.items.ItemUniversalWrench"); + temp = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.items.ItemUniversalWrench"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; @@ -72,7 +72,7 @@ public class SlotToolBox extends SlotGtTool { //EIO String[] EioContent = new String[] {"crazypants.enderio.api.tool.ITool", "crazypants.enderio.item.ItemMagnet", "crazypants.enderio.item.ItemConduitProbe"}; for (String t : EioContent) { - temp = ReflectionUtils.getClassByName(t); + temp = ReflectionUtils.getClass(t); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; @@ -80,7 +80,7 @@ public class SlotToolBox extends SlotGtTool { } //Forestry - temp = ReflectionUtils.getClassByName("forestry.core.items.ItemForestryTool"); + temp = ReflectionUtils.getClass("forestry.core.items.ItemForestryTool"); if (temp != null) { mSupportedCustomTools.put(temp); temp = null; diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java index da018675f3..bb7004350d 100644 --- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -14,7 +14,8 @@ public class ModTileEntities { public static void init() { Logger.INFO("Registering Tile Entities."); - GameRegistry.registerTileEntity(TileEntityHeliumGenerator.class, "HeliumGenerator"); + GameRegistry.registerTileEntity(TileEntityPooCollector.class, "TileEntityPooCollector"); + GameRegistry.registerTileEntity(TileEntityAdvPooCollector.class, "TileEntityAdvPooCollector"); GameRegistry.registerTileEntity(TileEntityWorkbench.class, "TileWorkbench"); GameRegistry.registerTileEntity(TileEntityWorkbenchAdvanced.class, "TileWorkbenchAdvanced"); GameRegistry.registerTileEntity(TileEntityFishTrap.class, "TileFishTrap"); diff --git a/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java b/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java index 0a1c53d79d..4f9a8d3748 100644 --- a/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java +++ b/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java @@ -28,6 +28,7 @@ import net.minecraftforge.fluids.IFluidHandler; import gtPlusPlus.api.interfaces.ILazyCoverable; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.BTF_Inventory; +import gtPlusPlus.core.util.data.ArrayUtils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import ic2.api.Direction; @@ -81,6 +82,9 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT public void updateEntity() { long aTick = System.currentTimeMillis(); this.isDead = false; + if (!firstTicked) { + onFirstTick(); + } try{ if (this.isServerSide()){ onPreTick(aTick); @@ -1297,7 +1301,22 @@ public class TileEntityBase extends TileEntity implements ILazyCoverable, IGregT public boolean energyStateReady() { return false; } - + + + private boolean firstTicked = false; + + public boolean onFirstTick() { + if (!firstTicked) { + firstTicked = true; + if (this.mInventory != null) { + this.mInventory.purgeNulls(); + return true; + } + } + return false; + } + + diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java new file mode 100644 index 0000000000..18954f12b6 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java @@ -0,0 +1,157 @@ +package gtPlusPlus.core.tileentities.machines; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.passive.EntityMooshroom; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.passive.IAnimals; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; + +public class TileEntityAdvPooCollector extends TileEntityBaseFluidCollector { + + public TileEntityAdvPooCollector() { + super(18, 128000); + } + + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return true; + } + + public void onPreLogicTick() { + + } + + public <V> boolean addDrop(V aPooMaker) { + int aChance = MathUtils.randInt(0, 50000); + if (aChance > 0) { + ItemStack aPoop; + if (aChance<= 200) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1); + } + else if (aChance <= 1000) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + } + else if (aChance <= 2000) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); + } + else { + return false; + } + + //Add to inventory if not full, else espawn in world + if (!this.mInventory.addItemStack(aPoop)) { + EntityItem entity = new EntityItem(worldObj, xCoord, yCoord+1.5, zCoord, aPoop); + worldObj.spawnEntityInWorld(entity); + } + + } + + + return false; + } + + private static AutoMap<Class> aEntityToDrain = new AutoMap<Class>(); + + @Override + public AutoMap<Class> aThingsToLookFor() { + if (aEntityToDrain.isEmpty()) { + aEntityToDrain.add(EntityAnimal.class); + aEntityToDrain.add(IAnimals.class); + aEntityToDrain.add(EntityVillager.class); + aEntityToDrain.add(EntityPlayer.class); + } + return aEntityToDrain; + } + + @Override + public <V> int onPostTick(V aPooMaker) { + if (this.tank.getFluidAmount() < this.tank.getCapacity()) { + int aPooAmount = 0; + // Vanilla Animals + if (aPooMaker instanceof EntityChicken) { + aPooAmount = MathUtils.randInt(1, 40); + } + else if (aPooMaker instanceof EntityHorse) { + aPooAmount = MathUtils.randInt(20, 40); + } + else if (aPooMaker instanceof EntityCow) { + aPooAmount = MathUtils.randInt(18, 45); + } + else if (aPooMaker instanceof EntityMooshroom) { + aPooAmount = 17; + } + else if (aPooMaker instanceof EntitySheep) { + aPooAmount = MathUtils.randInt(8, 30); + } + + else { + if (aPooMaker instanceof EntityAnimal || aPooMaker instanceof IAnimals) { + aPooAmount = MathUtils.randInt(5, 35); + } + else if (aPooMaker instanceof EntityVillager) { + aPooAmount = MathUtils.randInt(25, 30); + } + else if (aPooMaker instanceof EntityPlayer) { + aPooAmount = MathUtils.randInt(1, 3); + } + else { + aPooAmount = MathUtils.randInt(1, 10); + } + } + aPooAmount = Math.max(Math.min(this.tank.getCapacity()-this.tank.getFluidAmount(), aPooAmount), 1); + return Math.max(1, (aPooAmount * MathUtils.getRandomFromArray(new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4}) / 10)); + } + else { + return 0; + } + } + + @Override + public Fluid fluidToProvide() { + return AgriculturalChem.PoopJuice; + } + + @Override + public Item itemToSpawnInWorldIfTankIsFull() { + int a = MathUtils.randInt(0, 75); + Item aItem = null; + if (a <= 30) { + aItem = AgriculturalChem.dustDirt; + } + else if (a <= 40) { + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1).getItem(); + } + else if (a <= 55) { + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1).getItem(); + } + return aItem; + } + + public int getBaseTickRate() { + return MathUtils.randInt(50, 200); + } + + + + +} diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java new file mode 100644 index 0000000000..78b8f74799 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java @@ -0,0 +1,238 @@ +package gtPlusPlus.core.tileentities.machines; + +import java.util.List; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.BTF_FluidTank; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.tileentities.base.TileEntityBase; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidEvent; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public abstract class TileEntityBaseFluidCollector extends TileEntityBase implements IFluidHandler { + + public final FluidTank tank; + private boolean needsUpdate = false; + private int updateTimer = 0; + private long internalTickCounter = 0; + private BlockPos internalBlockLocation; + + public TileEntityBaseFluidCollector(int aInvSlotCount, int aTankCapcity) { + super(aInvSlotCount); + tank = new BTF_FluidTank(aTankCapcity); + } + + @Override + public final int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + needsUpdate = true; + return this.tank.fill(resource, doFill); + } + + @Override + public final FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + needsUpdate = true; + return this.tank.drain(resource.amount, doDrain); + } + + @Override + public final FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + needsUpdate = true; + FluidStack fluid = this.tank.getFluid(); + // return this.tank.drain(maxDrain, doDrain); + if (fluid == null) { + return null; + } + + int drained = maxDrain; + if (fluid.amount < drained) { + drained = fluid.amount; + } + + FluidStack stack = new FluidStack(fluid, drained); + if (doDrain) { + fluid.amount -= drained; + if (fluid.amount <= 0) { + fluid = null; + } + + if (this != null) { + FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, this.getWorldObj(), this.xCoord, + this.yCoord, this.zCoord, this.tank, 0)); + } + } + return stack; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return true; + } + + @Override + public final FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[] { this.tank.getInfo() }; + } + + @Override + public final void updateEntity() { + super.updateEntity(); + onPreLogicTick(); + logicTick(); + if (needsUpdate) { + if (updateTimer == 0) { + updateTimer = 10; // every 10 ticks it will send an update + } else { + --updateTimer; + if (updateTimer == 0) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + needsUpdate = false; + } + } + } + } + + @Override + public void readFromNBT(NBTTagCompound tag) { + tank.readFromNBT(tag); + super.readFromNBT(tag); + } + + @Override + public void writeToNBT(NBTTagCompound tag) { + tank.writeToNBT(tag); + super.writeToNBT(tag); + } + + @Override + public final Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); + } + + @Override + public final void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + NBTTagCompound tag = pkt.func_148857_g(); + readFromNBT(tag); + } + + public int getBaseTickRate() { + return MathUtils.randInt(200, 300); + } + + public abstract AutoMap<Class> aThingsToLookFor(); + + public abstract void onPreLogicTick(); + + public final void logicTick() { + + if (this.worldObj == null || this.worldObj.isRemote) { + return; + } + if (internalTickCounter % getBaseTickRate() == 0) { + if (internalBlockLocation == null) { + internalBlockLocation = new BlockPos(this); + } + BlockPos p = internalBlockLocation; + if (p != null) { + if (p.world != null) { + World w = this.worldObj; + if (w == null) { + return; + } + Chunk c = w.getChunkFromBlockCoords(p.xPos, p.zPos); + if (c != null) { + if (c.isChunkLoaded) { + int startX = p.xPos - 2; + int startY = p.yPos; + int startZ = p.zPos - 2; + int endX = p.xPos + 3; + int endY = p.yPos + 5; + int endZ = p.zPos + 3; + AxisAlignedBB box = AxisAlignedBB.getBoundingBox(startX, startY, startZ, endX, endY, endZ); + if (box != null) { + for (Class c2 : aThingsToLookFor()) { + tickEntityType(w, box, c2); + } + } else { + return; + } + } + } + } + } + + } + + internalTickCounter++; + } + + @SuppressWarnings("unchecked") + public final void tickEntityType(World w, AxisAlignedBB box, Class aClassToFind) { + List<?> entities = w.getEntitiesWithinAABB(aClassToFind, box); + if (entities != null && !entities.isEmpty()) { + interactWithEntities(entities); + } + } + + public final <V> void interactWithEntities(List<V> entities) { + for (V aEntity : entities) { + addDrop(aEntity); + if (this.tank.getFluidAmount() < this.tank.getCapacity()) { + int aFluidAmount = onPostTick(aEntity); + aFluidAmount = Math.max(Math.min(this.tank.getCapacity()-this.tank.getFluidAmount(), aFluidAmount), 1); + this.tank.fill(FluidUtils.getFluidStack(fluidToProvide(), aFluidAmount), true); + } + else { + ItemStack aDirtStack = ItemUtils.getSimpleStack(itemToSpawnInWorldIfTankIsFull()); + if (aDirtStack != null) + if (!this.mInventory.addItemStack(aDirtStack)) { + EntityItem entity = new EntityItem(worldObj, xCoord, yCoord+1.5, zCoord, aDirtStack); + worldObj.spawnEntityInWorld(entity); + } + } + } + } + + + /** + * Return the amount of fluid for this entity type + * @param aEntity + * @return + */ + public abstract <V> int onPostTick(V aEntity); + + public abstract <V> boolean addDrop(V aPooMaker); + + public abstract Fluid fluidToProvide(); + + public abstract Item itemToSpawnInWorldIfTankIsFull(); + + + + +} diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java new file mode 100644 index 0000000000..f6570c6cc6 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java @@ -0,0 +1,144 @@ +package gtPlusPlus.core.tileentities.machines; + +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.item.chemistry.AgriculturalChem; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.passive.EntityMooshroom; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.passive.IAnimals; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; + +public class TileEntityPooCollector extends TileEntityBaseFluidCollector { + + public TileEntityPooCollector() { + super(9, 8000); + } + + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return true; + } + + public void onPreLogicTick() { + + } + + public <V> boolean addDrop(V aPooMaker) { + int aChance = MathUtils.randInt(0, 50000); + if (aChance > 0) { + ItemStack aPoop; + if (aChance<= 100) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1); + } + else if (aChance <= 500) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); + } + else if (aChance <= 1250) { + aPoop = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); + } + else { + return false; + } + //Add poop to world + //Logger.INFO("Adding animal waste for "+aPooMaker.getCommandSenderName()); + + //Add to inventory if not full, else espawn in world + if (!this.mInventory.addItemStack(aPoop)) { + EntityItem entity = new EntityItem(worldObj, xCoord, yCoord+1.5, zCoord, aPoop); + worldObj.spawnEntityInWorld(entity); + } + + } + + + return false; + } + + private static AutoMap<Class> aEntityToDrain = new AutoMap<Class>(); + + @Override + public AutoMap<Class> aThingsToLookFor() { + if (aEntityToDrain.isEmpty()) { + aEntityToDrain.add(EntityAnimal.class); + aEntityToDrain.add(IAnimals.class); + } + return aEntityToDrain; + } + + @Override + public <V> int onPostTick(V aPooMaker) { + if (this.tank.getFluidAmount() < this.tank.getCapacity()) { + int aPooAmount = 0; + // Vanilla Animals + if (aPooMaker instanceof EntityChicken) { + aPooAmount = MathUtils.randInt(1, 40); + } + else if (aPooMaker instanceof EntityHorse) { + aPooAmount = MathUtils.randInt(20, 40); + } + else if (aPooMaker instanceof EntityCow) { + aPooAmount = MathUtils.randInt(18, 45); + } + else if (aPooMaker instanceof EntityMooshroom) { + aPooAmount = 17; + } + else if (aPooMaker instanceof EntitySheep) { + aPooAmount = MathUtils.randInt(8, 30); + } + + else { + if (aPooMaker instanceof EntityAnimal || aPooMaker instanceof IAnimals) { + aPooAmount = MathUtils.randInt(5, 35); + } + else { + aPooAmount = MathUtils.randInt(1, 10); + } + } + aPooAmount = Math.max((Math.min(this.tank.getCapacity()-this.tank.getFluidAmount(), aPooAmount)/10), 1); + return aPooAmount; + } + else { + return 0; + } + } + + @Override + public Fluid fluidToProvide() { + return AgriculturalChem.PoopJuice; + } + + @Override + public Item itemToSpawnInWorldIfTankIsFull() { + int a = MathUtils.randInt(0, 100); + Item aItem = null; + if (a <= 30) { + aItem = AgriculturalChem.dustDirt; + } + else if (a <= 40) { + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1).getItem(); + } + else if (a <= 55) { + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1).getItem(); + } + return aItem; + } + + + + +} diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index eef768e799..d032384638 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -46,6 +46,7 @@ import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; @@ -791,7 +792,13 @@ public class Utils { if (GT_Mod.VERSION == 509){ Class<GT_Mod> clazz; try { - clazz = (Class<GT_Mod>) Class.forName("gregtech.GT_Mod"); + + if (LoadedMods.BeyondRealityCore) { + //Safely assume it's Beyond Reality running .28-pre (If it's not, tough shit really?) + return new Pair<Integer, Integer>(9, 28); + } + + clazz = (Class<GT_Mod>) ReflectionUtils.getClass("gregtech.GT_Mod"); Field mSubversion = ReflectionUtils.getField(clazz, "SUBVERSION"); if (mSubversion != null){ int mSub = 0; @@ -802,7 +809,9 @@ public class Utils { } } } - catch (Throwable t){} + catch (Throwable t){ + + } } //5.08.33 else if (GT_Mod.VERSION == 508){ @@ -939,4 +948,16 @@ public class Utils { return aOther; } + public static long getMillisSince(long aStartTime, long aCurrentTime) { + return (aCurrentTime - aStartTime); + } + + public static long getSecondsFromMillis(long aMillis) { + return (aMillis/1000); + } + + public static long getTicksFromSeconds(long aSeconds) { + return (aSeconds*20); + } + } diff --git a/src/Java/gtPlusPlus/core/util/data/StringUtils.java b/src/Java/gtPlusPlus/core/util/data/StringUtils.java index e58b68665a..2372d04c15 100644 --- a/src/Java/gtPlusPlus/core/util/data/StringUtils.java +++ b/src/Java/gtPlusPlus/core/util/data/StringUtils.java @@ -1,5 +1,9 @@ package gtPlusPlus.core.util.data; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.Utils; + public class StringUtils { public static String superscript(String str) { @@ -116,4 +120,100 @@ public class StringUtils { String restLetters = data.substring(1).toLowerCase(); return firstLetter + restLetters; } + + public static <V> String getDataStringFromArray(V[] parameterTypes) { + if (parameterTypes == null || parameterTypes.length == 0) { + return "empty/null"; + } + else { + String aData = ""; + for (V y : parameterTypes) { + if (y != null) { + aData += ", "+y.toString(); + } + } + return aData; + } + } + + + + /** + * Is this a special regex character for delimination? (.$|()[]{}^?*+\\) + * @param aChar - The char to test + * @return - Is this a special character? + */ + public static boolean isSpecialCharacter(char aChar) { + if (aChar == '"' || aChar == '.' || aChar == '$' || aChar == '|' || aChar == '(' || aChar == ')' || aChar == '[' + || aChar == ']' || aChar == '{' || aChar == '}' || aChar == '^' || aChar == '?' || aChar == '*' + || aChar == '+' || aChar == '\\') { + return true; + } + return false; + } + + public static boolean isEscaped(String aString) { + return aString.substring(0, 1).equals("\\"); + } + + public static String splitAndUppercase(String aInput, String aDelim) { + + if (!isEscaped(aDelim)) { + boolean isSpecial = false; + for (int o=0;o<aInput.length();o++) { + if (isSpecialCharacter(aInput.charAt(o))) { + isSpecial = true; + } + } + if (isSpecial) { + aDelim = "\\"+aDelim; + } + } + + + Logger.INFO("Splitting "+aInput); + String[] aSplit = aInput.split(aDelim); + Logger.INFO("Split into "+aSplit == null ? ""+0 : aSplit.length+" parts."); + if (aSplit == null || aSplit.length == 0) { + return aInput; + } + else { + AutoMap<String> aTemp = new AutoMap<String>(); + for (String s : aSplit) { + Logger.INFO("Found: "+s); + s = s.replace(".", ""); + s = Utils.sanitizeString(s); + s = firstLetterCaps(s); + Logger.INFO("Formatted & Captilized: "+s); + aTemp.put(s); + } + Logger.INFO("Rebuilding"); + String aReturn = ""; + for (String s : aTemp) { + aReturn += s; + Logger.INFO("Step: "+aReturn); + } + return aReturn; + } + } + + public static int characterCount(String aString, char aChar) { + return characterCount(aString, ""+aChar); + } + + public static int characterCount(String aString, String aChar) { + int aLength = aString.length(); + int aFound = 0; + if (aLength == 0 || !aString.contains(aChar)) { + return 0; + } + else { + for (int index = 0; index < aLength; index++) { + if (aString.substring(index, index+1).equals(aChar)) { + aFound++; + } + } + return aFound; + } + } } diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index 40ac23a1b8..f9a4d8f548 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -463,14 +463,14 @@ public class MathUtils { return 0; } int divisor = aDataSet.length; - Logger.INFO("Calculating Average Short. Divisor: "+divisor); + Logger.WARNING("Calculating Average Short. Divisor: "+divisor); short total = 0; for (short i : aDataSet) { - Logger.INFO("Adding "+i); + Logger.WARNING("Adding "+i); total += i; } short result = safeShort((total/divisor)); - Logger.INFO("Average: "+result); + Logger.WARNING("Average: "+result); return result; } public static int getIntAverage(int[] aDataSet) { @@ -681,4 +681,15 @@ public class MathUtils { return i; } + /** + * Balances a number within a range. + * @param aInput - The number to balance + * @param aMin - The minimum bounds + * @param aMax - The maximum bounds + * @return - An Integer which will be between the bounds, or a boundary value. + */ + public static int balance(int aInput, int aMin, int aMax) { + return Math.max(Math.min(aInput, aMax), aMin); + } + } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java index ed1cbe0c64..0ae751a20b 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/FluidUtils.java @@ -10,9 +10,7 @@ import gregtech.api.util.GT_LanguageManager; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.FluidGT6; -import gtPlusPlus.core.fluids.GenericFluid; import gtPlusPlus.core.item.base.BaseItemComponent; -import gtPlusPlus.core.item.base.cell.BaseItemCell; import gtPlusPlus.core.item.base.cell.BaseItemPlasmaCell; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialGenerator; @@ -93,82 +91,6 @@ public class FluidUtils { } - - /** - * @param String displayName - * @param String fluidName - * @param int meltingPointC Temp - * @param short[] rgba - * @param byte state - * States: 0 (Solid), 1 (Fluid), 2(Gas), 3(Plasma) 4(Fuel I think? Don't use.) - * - * @return short[] - */ - public static Fluid generateFluid(final String displayName, final String fluidName, final int tempK, final short[] rgba ,final int aState){ - Fluid generatedFluid = null; - switch (aState) { - case 0: { - generatedFluid = new GenericFluid(displayName, fluidName, 0, 100, tempK, 10000, false, rgba); - break; - } - default: - case 1: - case 4: { - generatedFluid = new GenericFluid(displayName, fluidName, 0, 100, tempK, 1000, false, rgba); - break; - } - case 2: { - generatedFluid = new GenericFluid(displayName, fluidName, 0, -100, tempK, 200, true, rgba); - break; - } - case 3: { - generatedFluid = new GenericFluid(displayName, fluidName, 15, -10000, tempK, 10, true, rgba); - break; - } - } - return generatedFluid; - } - /** - * - * @param String fluidName - * @param int meltingPointC Temp - * @param short[] rgba - * @param byte state - * States: 0 (Solid), 1 (Fluid), 2(Gas), 3(Plasma) 4(Fuel I think? Don't use.) - * - * @return short[] - */ - public static Fluid generateFluid(final Material material ,final int aState){ - final int tempK = material.getMeltingPointC(); - Fluid generatedFluid = null; - switch (aState) { - case 0: { - generatedFluid = new GenericFluid(material, 0, 100, tempK, 10000, false); - break; - } - default: - case 1: - case 4: { - generatedFluid = new GenericFluid(material, 0, 100, tempK, 1000, false); - break; - } - case 2: { - generatedFluid = new GenericFluid(material, 0, -100, tempK, 200, true); - break; - } - case 3: { - generatedFluid = new GenericFluid(material, 15, -10000, tempK, 10, true); - break; - } - } - return generatedFluid; - } - - - - - - public static Fluid addGtFluid(final String aName, final String aLocalized, final GT_Materials aMaterial, final int aState, final long aTemperatureK, final ItemStack aFullContainer, final ItemStack aEmptyContainer, final int aFluidAmount) { return addGtFluid(aName, aLocalized, aMaterial, aState, aTemperatureK, aFullContainer, aEmptyContainer, aFluidAmount, true); } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java index a1c2bf6104..9f5d4f36ca 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/FoodUtils.java @@ -13,7 +13,7 @@ public class FoodUtils { public static final Class IEdibleClass; static { - IEdibleClass = ReflectionUtils.getClassByName("squeek.applecore.api.food.IEdible"); + IEdibleClass = ReflectionUtils.getClass("squeek.applecore.api.food.IEdible"); } public static boolean isFood(ItemStack food) { diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java index a5cf9527a9..d32ff4e160 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -35,6 +35,7 @@ import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; @@ -123,7 +124,7 @@ public class ItemUtils { final int meta) { try { Item em = null; - final Item em1 = getItem(FQRN); + final Item em1 = getItemFromFQRN(FQRN); // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); if (em1 != null) { em = em1; @@ -157,7 +158,7 @@ public class ItemUtils { if (MOD) { try { Item em = null; - final Item em1 = getItem(FQRN); + final Item em1 = getItemFromFQRN(FQRN); // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); if (em1 != null) { if (null == em) { @@ -180,7 +181,7 @@ public class ItemUtils { public static ItemStack simpleMetaStack(final String FQRN, final int meta, final int itemstackSize) { try { Item em = null; - final Item em1 = getItem(FQRN); + final Item em1 = getItemFromFQRN(FQRN); // Utils.LOG_WARNING("Found: "+em1.getUnlocalizedName()+":"+meta); if (em1 != null) { if (null == em) { @@ -232,7 +233,7 @@ public class ItemUtils { ItemStack temp; if (fqrn.toLowerCase().contains(oreDict.toLowerCase())) { final String sanitizedName = fqrn.replace(oreDict, ""); - temp = ItemUtils.getItemStack(sanitizedName, stackSize); + temp = ItemUtils.getItemStackFromFQRN(sanitizedName, stackSize); return temp; } final String[] fqrnSplit = fqrn.split(":"); @@ -257,13 +258,13 @@ public class ItemUtils { return null; } - public static Item getItem(final String fqrn) // fqrn = fully qualified resource name + public static Item getItemFromFQRN(final String fqrn) // fqrn = fully qualified resource name { final String[] fqrnSplit = fqrn.split(":"); return GameRegistry.findItem(fqrnSplit[0], fqrnSplit[1]); } - public static ItemStack getItemStack(final String fqrn, final int Size) // fqrn = fully qualified resource name + public static ItemStack getItemStackFromFQRN(final String fqrn, final int Size) // fqrn = fully qualified resource name { final String[] fqrnSplit = fqrn.split(":"); return GameRegistry.findItemStack(fqrnSplit[0], fqrnSplit[1], Size); @@ -395,6 +396,61 @@ public class ItemUtils { new BaseItemDustUnique("itemDust" + unlocalizedName, materialName, mChemForm, Colour, "Dust"), new BaseItemDustUnique("itemDustSmall" + unlocalizedName, materialName, mChemForm, Colour, "Small"), new BaseItemDustUnique("itemDustTiny" + unlocalizedName, materialName, mChemForm, Colour, "Tiny") }; + + //Generate Shaped/Shapeless Recipes + + final ItemStack normalDust = ItemUtils.getSimpleStack(output[0]); + final ItemStack smallDust = ItemUtils.getSimpleStack(output[1]); + final ItemStack tinyDust = ItemUtils.getSimpleStack(output[2]); + + + if (ItemUtils.checkForInvalidItems(tinyDust) && ItemUtils.checkForInvalidItems(normalDust)) { + if (RecipeUtils.recipeBuilder( + tinyDust, tinyDust, tinyDust, + tinyDust, tinyDust, tinyDust, + tinyDust, tinyDust, tinyDust, + normalDust)){ + Logger.WARNING("9 Tiny dust to 1 Dust Recipe: "+materialName+" - Success"); + } + else { + Logger.WARNING("9 Tiny dust to 1 Dust Recipe: "+materialName+" - Failed"); + } + + if (RecipeUtils.recipeBuilder( + normalDust, null, null, + null, null, null, + null, null, null, + ItemUtils.getSimpleStack(tinyDust, 9))){ + Logger.WARNING("9 Tiny dust from 1 Recipe: "+materialName+" - Success"); + } + else { + Logger.WARNING("9 Tiny dust from 1 Recipe: "+materialName+" - Failed"); + } + } + + if (ItemUtils.checkForInvalidItems(smallDust) && ItemUtils.checkForInvalidItems(normalDust)) { + if (RecipeUtils.recipeBuilder( + smallDust, smallDust, null, + smallDust, smallDust, null, + null, null, null, + normalDust)){ + Logger.WARNING("4 Small dust to 1 Dust Recipe: "+materialName+" - Success"); + } + else { + Logger.WARNING("4 Small dust to 1 Dust Recipe: "+materialName+" - Failed"); + } + if (RecipeUtils.recipeBuilder( + null, normalDust, null, + null, null, null, + null, null, null, + ItemUtils.getSimpleStack(smallDust, 4))){ + Logger.WARNING("4 Small dust from 1 Dust Recipe: "+materialName+" - Success"); + } + else { + Logger.WARNING("4 Small dust from 1 Dust Recipe: "+materialName+" - Failed"); + } + } + return output; } @@ -607,7 +663,7 @@ public class ItemUtils { } public static String getArrayStackNames(final ItemStack[] aStack) { - String itemNames = "Item Array: "; + String itemNames = ""; int aPos = 0; for (final ItemStack alph : aStack) { if (alph == null) { @@ -1012,4 +1068,50 @@ public class ItemUtils { } + public static String getItemName(ItemStack aStack) { + if (aStack == null) { + return "ERROR - Empty Stack"; + } + String aDisplay = null; + try { + aDisplay = ("" + StatCollector + .translateToLocal(aStack.getItem().getUnlocalizedNameInefficiently(aStack) + ".name")) + .trim(); + if (aStack.hasTagCompound()) { + if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = aStack.stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.hasKey("Name", 8)) { + aDisplay = nbttagcompound.getString("Name"); + } + } + } + } catch (Throwable t) { + + } + if (aDisplay == null || aDisplay.length() <= 0) { + aDisplay = aStack.getUnlocalizedName() + ":" + aStack.getItemDamage(); + } else { + aDisplay += " | Meta: " + aStack.getItemDamage(); + } + return aDisplay; + } + + public static String getUnlocalizedItemName(ItemStack aStack) { + if (aStack == null) { + return "ERROR.Empty.Stack"; + } + String aDisplay = null; + try { + aDisplay = (aStack.getUnlocalizedName()).trim(); + + } catch (Throwable t) { + aDisplay = aStack.getItem().getUnlocalizedName(); + } + if (aDisplay == null || aDisplay.length() <= 0) { + aDisplay = aStack.getItem().getUnlocalizedNameInefficiently(aStack); + } + return aDisplay; + } + } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java index 45d21a3016..a7fc4507e8 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/MaterialUtils.java @@ -322,7 +322,7 @@ public class MaterialUtils { mName = (String) ReflectionUtils.getField(Materials.class, "mName").get(mat); } } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + catch (IllegalArgumentException | IllegalAccessException e) { } @@ -348,12 +348,30 @@ public class MaterialUtils { TextureSet o = (r != null && r.isPresent() && r.get() != null) ? r.get() : null; return o;*/ } + + + + public static Materials getMaterial(String aMaterialName, String aFallbackMaterialName) { + Materials g = getMaterial(aMaterialName); + if (g == null) { + g = getMaterial(aFallbackMaterialName); + } + if (g == null) { + Logger.INFO("Failed finding material '"+aMaterialName+"' & fallback '"+aFallbackMaterialName+"', returning _NULL."); + g = Materials._NULL; + } + return g; + } public static Materials getMaterial(String aMaterialName) { Materials m = gtPlusPlus.xmod.gregtech.common.StaticFields59.getMaterial(aMaterialName); if (m == null) { m = getMaterialByName(aMaterialName); } + if (m == null) { + Logger.INFO("Failed finding material '"+aMaterialName+"', returning _NULL."); + m = Materials._NULL; + } return m; } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java index e7ced98f5a..080b5665a3 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/MiningUtils.java @@ -152,7 +152,7 @@ public class MiningUtils { try { aTextWorldGen = (String) ReflectionUtils.getField(GT_Worldgen_GT_Ore_Layer.class, "aTextWorldgen").get(h); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { aTextWorldGen = h.mWorldGenName; } @@ -180,27 +180,27 @@ public class MiningUtils { boolean aEndAsteroids; try { - if (Class.forName("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore") != null && mMoonID == -99) { - mMoonID = ReflectionUtils.getField(Class.forName("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore"), "idDimensionMoon").getInt(null); + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore") != null && mMoonID == -99) { + mMoonID = ReflectionUtils.getField(ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore"), "idDimensionMoon").getInt(null); } } - catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} //Gets Mars ID try { - if (Class.forName("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars") != null && mMarsID == -99) { - mMarsID = ReflectionUtils.getField(Class.forName("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars"), "dimensionIDMars").getInt(null); + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars") != null && mMarsID == -99) { + mMarsID = ReflectionUtils.getField(ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars"), "dimensionIDMars").getInt(null); } } - catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} //Get Comets ID try { - if (Class.forName("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids") != null && mCometsID == -99) { - mCometsID = ReflectionUtils.getField(Class.forName("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids"), "dimensionIDAsteroids").getInt(null); + if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids") != null && mCometsID == -99) { + mCometsID = ReflectionUtils.getField(ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids"), "dimensionIDAsteroids").getInt(null); } } - catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} //Clear Cache Ores_Overworld.clear(); @@ -215,7 +215,7 @@ public class MiningUtils { try { aEndAsteroids = ReflectionUtils.getField(GT_Worldgen_GT_Ore_Layer.class, "mEndAsteroid").getBoolean(x); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + catch (IllegalArgumentException | IllegalAccessException e) { aEndAsteroids = false; } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java index a5f5c778bf..774c8b6f13 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/RecipeUtils.java @@ -5,15 +5,10 @@ import java.util.Iterator; import java.util.List; import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; - import gregtech.api.enums.Materials; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.api.objects.Logger; @@ -22,9 +17,12 @@ import gtPlusPlus.api.objects.minecraft.ShapedRecipe; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; @@ -33,7 +31,8 @@ public class RecipeUtils { public static int mInvalidID = 1; public static boolean recipeBuilder(final Object slot_1, final Object slot_2, final Object slot_3, final Object slot_4, final Object slot_5, final Object slot_6, final Object slot_7, final Object slot_8, final Object slot_9, ItemStack resultItem){ - if (gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE != GTplusplus.INIT_PHASE.POST_INIT) { + //Old Debug Code, useful for finding recipes loading too early. + /*if (gtPlusPlus.GTplusplus.CURRENT_LOAD_PHASE != GTplusplus.INIT_PHASE.POST_INIT) { Logger.INFO(ReflectionUtils.getMethodName(1)); Logger.INFO(ReflectionUtils.getMethodName(2)); Logger.INFO(ReflectionUtils.getMethodName(3)); @@ -44,7 +43,7 @@ public static int mInvalidID = 1; Logger.INFO(ReflectionUtils.getMethodName(8)); Logger.INFO(ReflectionUtils.getMethodName(9)); System.exit(1); - } + }*/ if (resultItem == null){ Logger.RECIPE("[Fix] Found a recipe with an invalid output, yet had a valid inputs. Using Dummy output so recipe can be found.."); @@ -212,7 +211,7 @@ public static int mInvalidID = 1; public static boolean removeCraftingRecipe(Object x){ if (null == x){return false;} if (x instanceof String){ - final Item R = ItemUtils.getItem((String) x); + final Item R = ItemUtils.getItemFromFQRN((String) x); if (R != null){ x = R; } @@ -395,6 +394,7 @@ public static int mInvalidID = 1; else { Logger.RECIPE("[Fix] Output is Null for a recipe. Report to Alkalus."); output = ItemUtils.getItemStackOfAmountFromOreDict("sadibasdkjnad", 1); + RegistrationHandler.recipesFailed++; } } } @@ -574,5 +574,13 @@ public static int mInvalidID = 1; } + public static boolean removeGtRecipe(GT_Recipe aRecipeToRemove, GT_Recipe_Map aRecipeMap) { + if (aRecipeMap.mRecipeList.contains(aRecipeToRemove)) { + return aRecipeMap.mRecipeList.remove(aRecipeToRemove); + } + return false; + } + + } diff --git a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java index dde785cee6..aeeb4ae5be 100644 --- a/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java +++ b/src/Java/gtPlusPlus/core/util/minecraft/gregtech/PollutionUtils.java @@ -39,7 +39,7 @@ public class PollutionUtils { return mPollution.getBoolean(GT_Pollution); } } - } catch (SecurityException | IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) { } return false; } @@ -53,16 +53,16 @@ public class PollutionUtils { if (mAddPollution != null) { mAddPollution.invoke(null, te, pollutionValue); } - Class<?> GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); + Class<?> GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); if (GT_Pollution != null) { - Method addPollution = GT_Pollution.getMethod("addPollution", IGregTechTileEntity.class, int.class); + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "addPollution", IGregTechTileEntity.class, int.class); if (addPollution != null) { mAddPollution = addPollution; addPollution.invoke(null, te, pollutionValue); return true; } } - } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return false; @@ -92,16 +92,16 @@ public class PollutionUtils { mAddPollution2.invoke(null, aChunk, pollutionValue); return true; } - Class<?> GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); + Class<?> GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); if (GT_Pollution != null) { - Method addPollution = GT_Pollution.getMethod("addPollution", Chunk.class, int.class); + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "addPollution", Chunk.class, int.class); if (addPollution != null) { mAddPollution2 = addPollution; mAddPollution2.invoke(null, aChunk, pollutionValue); return true; } } - } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return false; @@ -128,15 +128,15 @@ public class PollutionUtils { if (mGetPollution != null) { mGetPollution.invoke(null, te); } - Class<?> GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); + Class<?> GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); if (GT_Pollution != null) { - Method addPollution = GT_Pollution.getMethod("getPollution", IGregTechTileEntity.class); + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "getPollution", IGregTechTileEntity.class); if (addPollution != null) { mGetPollution = addPollution; return (int) addPollution.invoke(null, te); } } - } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return 0; @@ -151,15 +151,15 @@ public class PollutionUtils { if (mGetPollution2 != null) { mGetPollution2.invoke(null, te); } - Class<?> GT_Pollution = Class.forName("gregtech.common.GT_Pollution"); + Class<?> GT_Pollution = ReflectionUtils.getClass("gregtech.common.GT_Pollution"); if (GT_Pollution != null) { - Method addPollution = GT_Pollution.getMethod("getPollution", Chunk.class); + Method addPollution = ReflectionUtils.getMethod(GT_Pollution, "getPollution", Chunk.class); if (addPollution != null) { mGetPollution2 = addPollution; return (int) addPollution.invoke(null, te); } } - } catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalAccessException + } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return 0; diff --git a/src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java b/src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java deleted file mode 100644 index 99a9bf2fa9..0000000000 --- a/src/Java/gtPlusPlus/core/util/reflect/ClientProxyFinder.java +++ /dev/null @@ -1,32 +0,0 @@ -package gtPlusPlus.core.util.reflect; - -import java.lang.reflect.Field; - -import cpw.mods.fml.common.SidedProxy; - -public class ClientProxyFinder { - - public static Object getInstance(final Object modInstance) throws ReflectiveOperationException { - for(final Field field : modInstance.getClass().getDeclaredFields()) { - if(field.isAnnotationPresent(SidedProxy.class)) { - final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); - final Object fieldValue = field.get(modInstance); - try { - final Class<?> clientSideClass = Class.forName(sidedProxy.clientSide()); - if(clientSideClass.isAssignableFrom(fieldValue.getClass())) { - final Object clientProxy = clientSideClass.cast(fieldValue); - //do what you want with client proxy instance - return clientProxy; - } - - } catch (final NoClassDefFoundError err) { - //its server side - return null; - } - break; - } - } - return null; - } - -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java b/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java index 85599e4695..d22fafb37b 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java @@ -12,7 +12,7 @@ public class ProxyFinder { final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); final Object fieldValue = field.get(modInstance); try { - final Class<?> serverSideClass = Class.forName(sidedProxy.serverSide()); + final Class<?> serverSideClass = ReflectionUtils.getClass(sidedProxy.serverSide()); if(serverSideClass.isAssignableFrom(fieldValue.getClass())) { final Object serverProxy = serverSideClass.cast(fieldValue); //do what you want with server proxy instance @@ -35,7 +35,7 @@ public class ProxyFinder { final SidedProxy sidedProxy = field.getAnnotation(SidedProxy.class); final Object fieldValue = field.get(modInstance); try { - final Class<?> clientSideClass = Class.forName(sidedProxy.clientSide()); + final Class<?> clientSideClass = ReflectionUtils.getClass(sidedProxy.clientSide()); if(clientSideClass.isAssignableFrom(fieldValue.getClass())) { final Object clientProxy = clientSideClass.cast(fieldValue); //do what you want with client proxy instance diff --git a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index dee9d76a4c..722a4f3ff7 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/Java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -1,110 +1,245 @@ package gtPlusPlus.core.util.reflect; import java.io.IOException; -import java.lang.reflect.*; -import java.net.URL; -import java.util.HashSet; -import java.util.Scanner; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.LinkedHashMap; +import java.util.Map; -import org.apache.commons.lang3.reflect.FieldUtils; +import org.apache.commons.lang3.ArrayUtils; import com.google.common.reflect.ClassPath; -import net.minecraft.client.Minecraft; - -import gregtech.GT_Mod; -import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.data.StringUtils; public class ReflectionUtils { - public static Field getField(final Class<?> clazz, final String fieldName) throws NoSuchFieldException { - try { - Field k = clazz.getDeclaredField(fieldName); - makeAccessible(k); - //Logger.REFLECTION("Got Field from Class. "+fieldName+" did exist within "+clazz.getCanonicalName()+"."); - return k; - } catch (final NoSuchFieldException e) { - final Class<?> superClass = clazz.getSuperclass(); - if (superClass == null) { - //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+"."); - throw e; - } - //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+". Trying super class."); - return getField(superClass, fieldName); + public static Map<String, Class> mCachedClasses = new LinkedHashMap<String, Class>(); + public static Map<String, CachedMethod> mCachedMethods = new LinkedHashMap<String, CachedMethod>(); + public static Map<String, CachedField> mCachedFields = new LinkedHashMap<String, CachedField>(); + + private static class CachedMethod { + + private final boolean STATIC; + private final Method METHOD; + + public CachedMethod(Method aMethod, boolean isStatic) { + METHOD = aMethod; + STATIC = isStatic; + } + + public Method get() { + return METHOD; } + + public boolean type() { + return STATIC; + } + } - public static void makeAccessible(final Field field) { - if (!Modifier.isPublic(field.getModifiers()) || - !Modifier.isPublic(field.getDeclaringClass().getModifiers())) - { - field.setAccessible(true); + private static class CachedField { + + private final boolean STATIC; + private final Field FIELD; + + public CachedField(Field aField, boolean isStatic) { + FIELD = aField; + STATIC = isStatic; } + + public Field get() { + return FIELD; + } + + public boolean type() { + return STATIC; + } + } - //Some Reflection utils - http://stackoverflow.com/questions/14374878/using-reflection-to-set-an-object-property - @SuppressWarnings("unchecked") - public static <V> V getField(final Object object, final String fieldName) { - Class<?> clazz = object.getClass(); - while (clazz != null) { - try { - final Field field = clazz.getDeclaredField(fieldName); - field.setAccessible(true); - return (V) field.get(object); - } catch (final NoSuchFieldException e) { - Logger.REFLECTION("getField("+object.toString()+", "+fieldName+") failed."); - clazz = clazz.getSuperclass(); - } catch (final Exception e) { - Logger.REFLECTION("getField("+object.toString()+", "+fieldName+") failed."); - throw new IllegalStateException(e); + private static boolean cacheClass(Class aClass) { + if (aClass == null) { + return false; + } + Class y = mCachedClasses.get(aClass.getCanonicalName()); + if (y == null) { + mCachedClasses.put(aClass.getCanonicalName(), aClass); + return true; + } + return false; + } + + private static boolean cacheMethod(Class aClass, Method aMethod) { + if (aMethod == null) { + return false; + } + boolean isStatic = Modifier.isStatic(aMethod.getModifiers()); + CachedMethod y = mCachedMethods.get(aClass.getName()+"."+aMethod.getName()+"."+ArrayUtils.toString(aMethod.getParameterTypes())); + if (y == null) { + mCachedMethods.put(aClass.getName()+"."+aMethod.getName()+"."+ArrayUtils.toString(aMethod.getParameterTypes()), new CachedMethod(aMethod, isStatic)); + return true; + } + return false; + } + + private static boolean cacheField(Class aClass, Field aField) { + if (aField == null) { + return false; + } + boolean isStatic = Modifier.isStatic(aField.getModifiers()); + CachedField y = mCachedFields.get(aClass.getName()+"."+aField.getName()); + if (y == null) { + mCachedFields.put(aClass.getName()+"."+aField.getName(), new CachedField(aField, isStatic)); + return true; + } + return false; + } + + + /** + * Returns a cached {@link Class} object. + * @param aClassCanonicalName - The canonical name of the underlying class. + * @return - Valid, {@link Class} object, or {@link null}. + */ + public static Class getClass(String aClassCanonicalName) { + if (aClassCanonicalName == null || aClassCanonicalName.length() <= 0) { + return null; + } + Class y = mCachedClasses.get(aClassCanonicalName); + if (y == null) { + y = getClass_Internal(aClassCanonicalName); + if (y != null) { + Logger.REFLECTION("Caching Class: "+aClassCanonicalName); + cacheClass(y); } } - return null; + return y; } - public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { - Class<?> clazz = object.getClass(); - while (clazz != null) { + + + /** + * Returns a cached {@link Method} object. Wraps {@link #getMethod(Class, String, Class...)}. + * @param aObject - Object containing the Method. + * @param aMethodName - Method's name in {@link String} form. + * @param aTypes - Class Array of Types for {@link Method}'s constructor. + * @return - Valid, non-final, {@link Method} object, or {@link null}. + */ + public static Method getMethod(Object aObject, String aMethodName, Class[] aTypes) { + return getMethod(aObject.getClass(), aMethodName, aTypes); + } + + + /** + * Returns a cached {@link Method} object. + * @param aClass - Class containing the Method. + * @param aMethodName - Method's name in {@link String} form. + * @param aTypes - Varags Class Types for {@link Method}'s constructor. + * @return - Valid, non-final, {@link Method} object, or {@link null}. + */ + public static Method getMethod(Class aClass, String aMethodName, Class... aTypes) { + if (aClass == null || aMethodName == null || aMethodName.length() <= 0) { + return null; + } + String aMethodKey = ArrayUtils.toString(aTypes); + //Logger.REFLECTION("Looking up method in cache: "+(aClass.getName()+"."+aMethodName + "." + aMethodKey)); + CachedMethod y = mCachedMethods.get(aClass.getName()+"."+aMethodName + "." + aMethodKey); + if (y == null) { + Method u = getMethod_Internal(aClass, aMethodName, aTypes); + if (u != null) { + Logger.REFLECTION("Caching Method: "+aMethodName + "." + aMethodKey); + cacheMethod(aClass, u); + return u; + } else { + return null; + } + } else { + return y.get(); + } + } + + + + /** + * Returns a cached {@link Field} object. + * @param aClass - Class containing the Method. + * @param aFieldName - Field name in {@link String} form. + * @return - Valid, non-final, {@link Field} object, or {@link null}. + */ + public static Field getField(final Class aClass, final String aFieldName) { + if (aClass == null || aFieldName == null || aFieldName.length() <= 0) { + return null; + } + CachedField y = mCachedFields.get(aClass.getName()+"."+aFieldName); + if (y == null) { + Field u; try { - final Field field = getField(clazz, fieldName); - if (field != null) { - setValue(object, field, fieldValue); - return true; + u = getField_Internal(aClass, aFieldName); + if (u != null) { + Logger.REFLECTION("Caching Field '"+aFieldName+"' from "+aClass.getName()); + cacheField(aClass, u); + return u; } - } catch (final NoSuchFieldException e) { - Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); - clazz = clazz.getSuperclass(); - } catch (final Exception e) { - Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); - throw new IllegalStateException(e); + } catch (NoSuchFieldException e) { } + return null; + + } else { + return y.get(); } - return false; } - - public static boolean becauseIWorkHard(){ - /* TODO: fix this stuff \u002a\u002f\u0066\u0069\u006e\u0061\u006c\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u003c\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u004f\u0062\u006a\u0065\u0063\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u003b\u0009\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u0020\u003d\u0020\u0043\u006c\u0069\u0065\u006e\u0074\u0050\u0072\u006f\u0078\u0079\u0046\u0069\u006e\u0064\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0047\u0054\u005f\u004d\u006f\u0064\u002e\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0029\u003b\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0052\u0065\u0066\u006c\u0065\u0063\u0074\u0069\u0076\u0065\u004f\u0070\u0065\u0072\u0061\u0074\u0069\u006f\u006e\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0031\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u0020\u003d\u0020\u006e\u0075\u006c\u006c\u003b\u000a\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u006f\u0062\u0074\u0061\u0069\u006e\u0065\u0064\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0020\u006f\u0066\u0020\u0061\u0020\u0063\u006c\u0069\u0065\u006e\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0020\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u0028\u006e\u0065\u0077\u0020\u0055\u0052\u004c\u0028\u0022\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0067\u0072\u0065\u0067\u0074\u0065\u0063\u0068\u002e\u006f\u0076\u0065\u0072\u006d\u0069\u006e\u0064\u0064\u006c\u0031\u002e\u0063\u006f\u006d\u002f\u0063\u006f\u006d\u002f\u0067\u0072\u0065\u0067\u006f\u0072\u0069\u0075\u0073\u0074\u002f\u0067\u0072\u0065\u0067\u0074\u0065\u0063\u0068\u002f\u0073\u0075\u0070\u0070\u006f\u0072\u0074\u0065\u0072\u006c\u0069\u0073\u0074\u002e\u0074\u0078\u0074\u0022\u0029\u002e\u006f\u0070\u0065\u006e\u0053\u0074\u0072\u0065\u0061\u006d\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0054\u0072\u0079\u0069\u006e\u0067\u0020\u0074\u006f\u0020\u0062\u0075\u0069\u006c\u0064\u0020\u0061\u0020\u0048\u0061\u0073\u0068\u0053\u0065\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u0068\u0061\u0073\u004e\u0065\u0078\u0074\u004c\u0069\u006e\u0065\u0028\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0074\u004e\u0061\u006d\u0065\u0020\u003d\u0020\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u006e\u0065\u0078\u0074\u004c\u0069\u006e\u0065\u0028\u0029\u003b\u000a\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0074\u004e\u0061\u006d\u0065\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0074\u004e\u0061\u006d\u0065\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0009\u002f\u002f\u0041\u0064\u0064\u0020\u004d\u0079\u0073\u0065\u006c\u0066\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0022\u0064\u0072\u0061\u006b\u006e\u0079\u0074\u0065\u0031\u0022\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0022\u0064\u0072\u0061\u006b\u006e\u0079\u0074\u0065\u0031\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0009\u002f\u002f\u0041\u0064\u0064\u0020\u0074\u0068\u0065\u0020\u0063\u0061\u0070\u0065\u0064\u0020\u0074\u0065\u0073\u0074\u0020\u0068\u0065\u0072\u006f\u000a\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0043\u004f\u0052\u0045\u002e\u0044\u0045\u0056\u0045\u004e\u0056\u0029\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0020\u003d\u0020\u004d\u0069\u006e\u0065\u0063\u0072\u0061\u0066\u0074\u002e\u0067\u0065\u0074\u004d\u0069\u006e\u0065\u0063\u0072\u0061\u0066\u0074\u0028\u0029\u002e\u0067\u0065\u0074\u0053\u0065\u0073\u0073\u0069\u006f\u006e\u0028\u0029\u002e\u0067\u0065\u0074\u0055\u0073\u0065\u0072\u006e\u0061\u006d\u0065\u0028\u0029\u002e\u0074\u006f\u004c\u006f\u0077\u0065\u0072\u0043\u0061\u0073\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0046\u006f\u0075\u006e\u0064\u0020\u0022\u002b\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0021\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0063\u006f\u006e\u0074\u0061\u0069\u006e\u0073\u0028\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u0009\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002e\u0061\u0064\u0064\u0028\u0064\u0065\u0076\u0050\u006c\u0061\u0079\u0065\u0072\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u0009\u007d\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u0009\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0074\u0029\u007b\u000a\u0009\u0009\u0009\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u0061\u0064\u0064\u0069\u006e\u0067\u0020\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u0069\u006e\u0020\u0063\u0075\u0072\u0072\u0065\u006e\u0074\u0020\u0065\u006e\u0076\u0069\u0072\u006f\u006e\u006d\u0065\u006e\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0009\u007d\u000a\u000a\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u0009\u0074\u0053\u0063\u0061\u006e\u006e\u0065\u0072\u002e\u0063\u006c\u006f\u0073\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0046\u0061\u0069\u006c\u0065\u0064\u0020\u0067\u0065\u0074\u0074\u0069\u006e\u0067\u0020\u0074\u0068\u0065\u0020\u0077\u0065\u0062\u0020\u006c\u0069\u0073\u0074\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u007d\u0009\u0009\u000a\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u007b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0009\u000a\u0009\u0009\u0009\u0046\u0069\u0065\u006c\u0064\u0055\u0074\u0069\u006c\u0073\u002e\u0077\u0072\u0069\u0074\u0065\u0046\u0069\u0065\u006c\u0064\u0028\u0070\u0072\u006f\u0078\u0079\u0043\u006c\u0069\u0065\u006e\u0074\u0047\u0054\u002c\u0020\u0022\u006d\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u0022\u002c\u0020\u0078\u0043\u0061\u0070\u0065\u004c\u0069\u0073\u0074\u002c\u0020\u0074\u0072\u0075\u0065\u0029\u003b\u000a\u0009\u0009\u0009Logger\u002eWARNING\u0028\u0022\u0041\u0064\u0064\u0065\u0064\u0020\u006d\u006f\u0064\u0069\u0066\u0069\u0065\u0064\u0020\u0068\u0061\u0073\u0068\u0073\u0065\u0074\u0020\u0062\u0061\u0063\u006b\u0020\u0069\u006e\u0074\u006f\u0020\u0074\u0068\u0065\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u002e\u0022\u0029\u003b\u0020\u0020\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0074\u0072\u0075\u0065\u003b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0054\u0068\u0072\u006f\u0077\u0061\u0062\u006c\u0065\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009Logger\u002eINFO\u0028\u0022\u0052\u0065\u0066\u006c\u0065\u0063\u0074\u0069\u006f\u006e\u0020\u0069\u006e\u0074\u006f\u0020\u0061\u0063\u0074\u0069\u0076\u0065\u0020\u0063\u006c\u0069\u0065\u006e\u0074\u0020\u0070\u0072\u006f\u0078\u0079\u0020\u0069\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0020\u0066\u0061\u0069\u006c\u0065\u0064\u002e\u0022\u0029\u003b\u000a\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u0020\u0020\u0020\u0020\u0020\u0020\u000a\u0009\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0066\u0061\u006c\u0073\u0065\u003b\u0020\u0020\u0009\u000a\u0009\u0009\u007d\u002f\u002a */ + + /** + * Returns a cached {@link Field} object. + * @param aInstance - {@link Object} to get the field instance from. + * @param aFieldName - Field name in {@link String} form. + * @return - Valid, non-final, {@link Field} object, or {@link null}. + */ + public static <T> T getField(final Object aInstance, final String aFieldName) { + try { + return (T) getField(aInstance.getClass(), aFieldName).get(aInstance); + } catch (IllegalArgumentException | IllegalAccessException e) { + return null; + } } + + + + /* + * Utility Functions + */ + public static boolean doesClassExist(final String classname) { - boolean exists = true; - try { - // Load any class that should be present if driver's available - Class.forName(classname); - } catch (final ClassNotFoundException e) { - // Driver is not available - exists = false; + return isClassPresent(classname); + } + + public static void makeFieldAccessible(final Field field) { + if (!Modifier.isPublic(field.getModifiers()) || + !Modifier.isPublic(field.getDeclaringClass().getModifiers())) + { + field.setAccessible(true); + } + } + + public static void makeMethodAccessible(final Method field) { + if (!Modifier.isPublic(field.getModifiers()) || + !Modifier.isPublic(field.getDeclaringClass().getModifiers())) + { + field.setAccessible(true); } - return exists; } /** * Get the method name for a depth in call stack. <br /> * Utility function * @param depth depth in the call stack (0 means current method, 1 means call method, ...) - * @return method name + * @return Method name */ public static String getMethodName(final int depth) { final StackTraceElement[] ste = new Throwable().getStackTrace(); @@ -114,42 +249,60 @@ public class ReflectionUtils { /** - * Allows to change the state of an immutable instance. Huh?!? + * + * @param aPackageName - The full {@link Package} name in {@link String} form. + * @return - {@link Boolean} object. True if loaded > 0 classes. */ - public static void setFieldValue(Class<?> clazz, String fieldName, Object newValue) throws Exception { - Field nameField = getField(clazz, fieldName); - setValue(clazz, nameField, newValue); - } + public static boolean dynamicallyLoadClassesInPackage(String aPackageName) { + ClassLoader classLoader = ReflectionUtils.class.getClassLoader(); + int loaded = 0; + try { + ClassPath path = ClassPath.from(classLoader); + for (ClassPath.ClassInfo info : path.getTopLevelClassesRecursive(aPackageName)) { + Class<?> clazz = Class.forName(info.getName(), true, classLoader); + if (clazz != null) { + loaded++; + Logger.INFO("Found "+clazz.getCanonicalName()+". ["+loaded+"]"); + } + } + } catch (ClassNotFoundException | IOException e) { - /** - * Allows to change the state of final statics. Huh?!? - */ - public static void setDefault(Class<?> clazz, String fieldName, Object newValue) throws Exception { - Field staticField = clazz.getDeclaredField(fieldName); - setValue(null, staticField, newValue); + } + + return loaded > 0; } + - /** - * - * Set the value of a field reflectively. - */ - protected static void setValue(Object owner, Field field, Object value) throws Exception { - makeModifiable(field); - field.set(owner, value); + public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { + Class<?> clazz = object.getClass(); + while (clazz != null) { + try { + final Field field = getField(clazz, fieldName); + if (field != null) { + setFieldValue_Internal(object, field, fieldValue); + return true; + } + } catch (final NoSuchFieldException e) { + Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); + clazz = clazz.getSuperclass(); + } catch (final Exception e) { + Logger.REFLECTION("setField("+object.toString()+", "+fieldName+") failed."); + throw new IllegalStateException(e); + } + } + return false; } + /** - * Force the field to be modifiable and accessible. + * Allows to change the state of an immutable instance. Huh?!? */ - protected static void makeModifiable(Field nameField) throws Exception { - nameField.setAccessible(true); - int modifiers = nameField.getModifiers(); - Field modifierField = nameField.getClass().getDeclaredField("modifiers"); - modifiers = modifiers & ~Modifier.FINAL; - modifierField.setAccessible(true); - modifierField.setInt(nameField, modifiers); + public static void setFinalFieldValue(Class<?> clazz, String fieldName, Object newValue) throws Exception { + Field nameField = getField(clazz, fieldName); + setFieldValue_Internal(clazz, nameField, newValue); } + @Deprecated public static void setFinalStatic(Field field, Object newValue) throws Exception { field.setAccessible(true); Field modifiersField = Field.class.getDeclaredField("modifiers"); @@ -258,13 +411,58 @@ public class ReflectionUtils { return null; } + + + + + + + + + + + + + + + + + + + + /* - * @ if (isPresent("com.optionaldependency.DependencyClass")) { // This - * block will never execute when the dependency is not present // There is + * Internal Magic that probably should not get exposed. + */ + + + private static Field getField_Internal(final Class<?> clazz, final String fieldName) throws NoSuchFieldException { + try { + Logger.REFLECTION("Field: Internal Lookup: "+fieldName); + Field k = clazz.getDeclaredField(fieldName); + makeFieldAccessible(k); + //Logger.REFLECTION("Got Field from Class. "+fieldName+" did exist within "+clazz.getCanonicalName()+"."); + return k; + } catch (final NoSuchFieldException e) { + Logger.REFLECTION("Field: Internal Lookup Failed: "+fieldName); + final Class<?> superClass = clazz.getSuperclass(); + if (superClass == null) { + Logger.REFLECTION("Unable to find field '"+fieldName+"'"); + //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+"."); + throw e; + } + Logger.REFLECTION("Method: Recursion Lookup: "+fieldName+" - Checking in "+superClass.getName()); + //Logger.REFLECTION("Failed to get Field from Class. "+fieldName+" does not existing within "+clazz.getCanonicalName()+". Trying super class."); + return getField_Internal(superClass, fieldName); + } + } + + /** + * if (isPresent("com.optionaldependency.DependencyClass")) || + * This block will never execute when the dependency is not present. There is * therefore no more risk of code throwing NoClassDefFoundException. - * executeCodeLinkingToDependency(); } */ - public static boolean isPresent(final String className) { + private static boolean isClassPresent(final String className) { try { Class.forName(className); return true; @@ -274,7 +472,6 @@ public class ReflectionUtils { } } - @SuppressWarnings("rawtypes") @Deprecated public static Method getMethodViaReflection(final Class<?> lookupClass, final String methodName, final boolean invoke) throws Exception { @@ -287,16 +484,10 @@ public class ReflectionUtils { return m; } - /** - * Removes final modifier & returns a {@link Method} object. - * @param aClass - Class containing the Method. - * @param aMethodName - Method's name in {@link String} form. - * @param aTypes - Varags Class Types for {@link Method}'s constructor. - * @return - Valid, non-final, {@link Method} object. - */ - public static Method getMethod(Class aClass, String aMethodName, Class... aTypes) { + private static Method getMethod_Internal(Class aClass, String aMethodName, Class... aTypes) { Method m = null; try { + Logger.REFLECTION("Method: Internal Lookup: "+aMethodName); m = aClass.getDeclaredMethod(aMethodName, aTypes); if (m != null) { m.setAccessible(true); @@ -308,35 +499,55 @@ public class ReflectionUtils { } } catch (Throwable t) { + Logger.REFLECTION("Method: Internal Lookup Failed: "+aMethodName); + try { + m = getMethodRecursively(aClass, aMethodName); + } catch (NoSuchMethodException e) { + Logger.REFLECTION("Unable to find method '"+aMethodName+"'"); + e.printStackTrace(); + dumpClassInfo(aClass); + } } return m; } - - public static Method getMethodRecursively(final Class<?> clazz, final String fieldName) throws NoSuchMethodException { + + private static Method getMethodRecursively(final Class<?> clazz, final String aMethodName) throws NoSuchMethodException { try { - Method k = clazz.getDeclaredMethod(fieldName); + Logger.REFLECTION("Method: Recursion Lookup: "+aMethodName); + Method k = clazz.getDeclaredMethod(aMethodName); makeMethodAccessible(k); return k; } catch (final NoSuchMethodException e) { final Class<?> superClass = clazz.getSuperclass(); - if (superClass == null) { + if (superClass == null || superClass == Object.class) { throw e; } - return getMethod(superClass, fieldName); - } - } - - public static void makeMethodAccessible(final Method field) { - if (!Modifier.isPublic(field.getModifiers()) || - !Modifier.isPublic(field.getDeclaringClass().getModifiers())) - { - field.setAccessible(true); + return getMethod_Internal(superClass, aMethodName); } - } - + } + private static void dumpClassInfo(Class aClass) { + Logger.INFO("We ran into an error processing reflection in "+aClass.getName()+", dumping all data for debugging."); + // Get the methods + Method[] methods = aClass.getDeclaredMethods(); + Field[] fields = aClass.getDeclaredFields(); + Constructor[] consts = aClass.getDeclaredConstructors(); + + Logger.INFO("Dumping all Methods."); + for (Method method : methods) { + System.out.println(method.getName()+" | "+StringUtils.getDataStringFromArray(method.getParameterTypes())); + } + Logger.INFO("Dumping all Fields."); + for (Field f : fields) { + System.out.println(f.getName()); + } + Logger.INFO("Dumping all Constructors."); + for (Constructor c : consts) { + System.out.println(c.getName()+" | "+c.getParameterCount()+" | "+StringUtils.getDataStringFromArray(c.getParameterTypes())); + } + } - public static Class<?> getNonPublicClass(final String className) { + private static Class<?> getNonPublicClass(final String className) { Class<?> c = null; try { c = Class.forName(className); @@ -377,7 +588,7 @@ public class ReflectionUtils { return null; } - public static Class<?> getClassByName(String string) { + private static Class<?> getClass_Internal(String string) { if (ReflectionUtils.doesClassExist(string)) { try { return Class.forName(string); @@ -389,23 +600,25 @@ public class ReflectionUtils { return null; } - public static boolean dynamicallyLoadClassesInPackage(String aPackageName) { - ClassLoader classLoader = GTplusplus.class.getClassLoader(); - int loaded = 0; - try { - ClassPath path = ClassPath.from(classLoader); - for (ClassPath.ClassInfo info : path.getTopLevelClassesRecursive(aPackageName)) { - Class<?> clazz = Class.forName(info.getName(), true, classLoader); - if (clazz != null) { - loaded++; - Logger.INFO("Found "+clazz.getCanonicalName()+". ["+loaded+"]"); - } - } - } catch (ClassNotFoundException | IOException e) { - - } + /** + * + * Set the value of a field reflectively. + */ + private static void setFieldValue_Internal(Object owner, Field field, Object value) throws Exception { + makeModifiable(field); + field.set(owner, value); + } - return loaded > 0; + /** + * Force the field to be modifiable and accessible. + */ + private static void makeModifiable(Field nameField) throws Exception { + nameField.setAccessible(true); + int modifiers = nameField.getModifiers(); + Field modifierField = nameField.getClass().getDeclaredField("modifiers"); + modifiers = modifiers & ~Modifier.FINAL; + modifierField.setAccessible(true); + modifierField.setInt(nameField, modifiers); } diff --git a/src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java b/src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java index fe4897fd0d..140098ee06 100644 --- a/src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java +++ b/src/Java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java @@ -72,7 +72,7 @@ extends WorldGen_GT { Field temp = ReflectionUtils.getField(GregTech_API.class, "sBlockStones"); tempBlock = temp.get(null); } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {} + catch (IllegalArgumentException | IllegalAccessException e) {} mStoneTypes = (Block) tempBlock; } else { diff --git a/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java b/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java index 88b6914ad2..6612ab703f 100644 --- a/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java +++ b/src/Java/gtPlusPlus/nei/GT_NEI_MultiBlockHandler.java @@ -842,7 +842,7 @@ extends TemplateRecipeHandler { if (sFields[u] == null) { if (u==0) { for (Field f : GT_OreDictUnificator.class.getDeclaredFields()) { - ReflectionUtils.makeAccessible(f); + ReflectionUtils.makeFieldAccessible(f); if (f.getName().equalsIgnoreCase("sUnificationTable")) { hasLooked = true; } diff --git a/src/Java/gtPlusPlus/plugin/agrichem/Core_Agrichem.java b/src/Java/gtPlusPlus/plugin/agrichem/Core_Agrichem.java new file mode 100644 index 0000000000..d515375149 --- /dev/null +++ b/src/Java/gtPlusPlus/plugin/agrichem/Core_Agrichem.java @@ -0,0 +1,43 @@ +package gtPlusPlus.plugin.agrichem; + +import gtPlusPlus.api.interfaces.IPlugin; +import gtPlusPlus.plugin.agrichem.fluids.FluidLoader; +import gtPlusPlus.plugin.manager.Core_Manager; + +public class Core_Agrichem implements IPlugin { + + final static Core_Agrichem mInstance; + + static { + mInstance = new Core_Agrichem(); + Core_Manager.registerPlugin(mInstance); + mInstance.log("Preparing "+mInstance.getPluginName()+" for use."); + } + + @Override + public boolean preInit() { + FluidLoader.generate(); + return true; + } + + @Override + public boolean init() { + return true; + } + + @Override + public boolean postInit() { + return true; + } + + @Override + public String getPluginName() { + return "GT++ Agrichemistry Module"; + } + + @Override + public String getPluginAbbreviation() { + return "FARM"; + } + +} diff --git a/src/Java/gtPlusPlus/plugin/agrichem/fluids/FluidLoader.java b/src/Java/gtPlusPlus/plugin/agrichem/fluids/FluidLoader.java new file mode 100644 index 0000000000..a60a8c09de --- /dev/null +++ b/src/Java/gtPlusPlus/plugin/agrichem/fluids/FluidLoader.java @@ -0,0 +1,21 @@ +package gtPlusPlus.plugin.agrichem.fluids; + +import gtPlusPlus.core.fluids.FluidFactory; + +public class FluidLoader { + + private static final int ID_DIRTY_WATER = 50; + private static final int ID_RAW_SEWERAGE = 51; + private static final int ID_GUANO = 52; + private static final int ID_POOPJUICE = 53; + + public static void generate() { + + FluidFactory.generate(ID_DIRTY_WATER, "dirtywater", new short[] {25, 25, 180}); + FluidFactory.generate(ID_RAW_SEWERAGE, "sewerage", new short[] {100, 45, 25}); + FluidFactory.generate(ID_GUANO, "guano", new short[] {175, 175, 180}); + FluidFactory.generate(ID_POOPJUICE, "poo", new short[] {75, 45, 10}); + + } + +} diff --git a/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java b/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java index 8e7b73ccdf..cf9676635d 100644 --- a/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java +++ b/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java @@ -1,7 +1,11 @@ package gtPlusPlus.plugin.fixes.vanilla; import gtPlusPlus.api.interfaces.IPlugin; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.plugin.manager.Core_Manager; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; public class Core_VanillaFixes implements IPlugin { @@ -10,7 +14,7 @@ public class Core_VanillaFixes implements IPlugin { static { mInstance = new Core_VanillaFixes(); - mBedFixInstance = new VanillaBedHeightFix(); + mBedFixInstance = new VanillaBedHeightFix(mInstance); mInstance.log("Preparing "+mInstance.getPluginName()+" for use."); } @@ -19,18 +23,18 @@ public class Core_VanillaFixes implements IPlugin { } @Override - public boolean preInit() { - return false; + public boolean preInit() { + return fixVanillaOD(); } @Override public boolean init() { - return false; + return true; } @Override public boolean postInit() { - return false; + return true; } @Override @@ -42,5 +46,31 @@ public class Core_VanillaFixes implements IPlugin { public String getPluginAbbreviation() { return "VFIX"; } + + private boolean fixVanillaOD() { + registerToOreDict(ItemUtils.getSimpleStack(Items.nether_wart), "cropNetherWart"); + registerToOreDict(ItemUtils.getSimpleStack(Items.reeds), "sugarcane"); + registerToOreDict(ItemUtils.getSimpleStack(Items.paper), "paper"); + registerToOreDict(ItemUtils.getSimpleStack(Items.ender_pearl), "enderpearl"); + registerToOreDict(ItemUtils.getSimpleStack(Items.bone), "bone"); + registerToOreDict(ItemUtils.getSimpleStack(Items.gunpowder), "gunpowder"); + registerToOreDict(ItemUtils.getSimpleStack(Items.string), "string"); + registerToOreDict(ItemUtils.getSimpleStack(Items.nether_star), "netherStar"); + registerToOreDict(ItemUtils.getSimpleStack(Items.leather), "leather"); + registerToOreDict(ItemUtils.getSimpleStack(Items.feather), "feather"); + registerToOreDict(ItemUtils.getSimpleStack(Items.egg), "egg"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.end_stone), "endstone"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.vine), "vine"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.cactus), "blockCactus"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.grass), "grass"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.obsidian), "obsidian"); + registerToOreDict(ItemUtils.getSimpleStack(Blocks.crafting_table), "workbench"); + return true; + } + + private void registerToOreDict(ItemStack aStack, String aString) { + mInstance.log("Registering "+aStack.getDisplayName()+" to OreDictionary under the tag '"+aString+"'. (Added to Forge in 1.8.9)"); + ItemUtils.addItemToOreDictionary(aStack, aString); + } } diff --git a/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java b/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java index e0fef80b52..5f3b1d8abd 100644 --- a/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java +++ b/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java @@ -5,8 +5,10 @@ import java.lang.reflect.Method; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gtPlusPlus.api.interfaces.IPlugin; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.plugin.fixes.interfaces.IBugFix; import gtPlusPlus.preloader.DevHelper; import net.minecraft.entity.player.EntityPlayer; @@ -15,13 +17,21 @@ import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; public class VanillaBedHeightFix implements IBugFix { private final Method mSleepInBedAt; + private final IPlugin mParent; - public VanillaBedHeightFix() { - if (DevHelper.isValidHelperObject()) { - Method m = DevHelper.getForgeMethod(EntityPlayer.class, "sleepInBedAt", int.class, int.class, - int.class); + public VanillaBedHeightFix(IPlugin minstance) { + mParent = minstance; + if (DevHelper.isValidHelperObject()) { + Method m; + if (DevHelper.IsObfuscatedEnvironment()) { + m = ReflectionUtils.getMethod(EntityPlayer.class, "func_71018_a", int.class, int.class, int.class); + } + else { + m = ReflectionUtils.getMethod(net.minecraft.entity.player.EntityPlayer.class, "sleepInBedAt", int.class, int.class, int.class); + } if (m != null) { mSleepInBedAt = m; + mParent.log("Registering Bed Height Fix."); Utils.registerEvent(this); } else { mSleepInBedAt = null; diff --git a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java index 98e6d7ae1a..4dc5a15b4b 100644 --- a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java +++ b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityBaseVillager.java @@ -169,15 +169,10 @@ public class EntityBaseVillager extends EntityVillager { */ protected float getField_82191_bN() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "field_82191_bN"); try { - v82191 = ReflectionUtils.getField(getClass(), "field_82191_bN"); - try { - return v82191 != null ? v82191.getFloat(this) : 0f; - } catch (IllegalArgumentException | IllegalAccessException e) { - return 0f; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? v82191.getFloat(this) : 0f; + } catch (IllegalArgumentException | IllegalAccessException e) { return 0f; } } @@ -190,15 +185,10 @@ public class EntityBaseVillager extends EntityVillager { } protected boolean getNeedsInitilization() { - Field v82191; + Field v82191 = ReflectionUtils.getField(EntityVillager.class, "needsInitilization"); try { - v82191 = ReflectionUtils.getField(EntityVillager.class, "needsInitilization"); - try { - return v82191 != null ? v82191.getBoolean(this) : false; - } catch (IllegalArgumentException | IllegalAccessException e) { - return false; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? v82191.getBoolean(this) : false; + } catch (IllegalArgumentException | IllegalAccessException e) { return false; } } @@ -213,20 +203,16 @@ public class EntityBaseVillager extends EntityVillager { protected MerchantRecipeList getBuyingList() { Field v82191; MerchantRecipeList o; + v82191 = ReflectionUtils.getField(getClass(), "buyingList"); try { - v82191 = ReflectionUtils.getField(getClass(), "buyingList"); - try { - o = (MerchantRecipeList) v82191.get(this); - Logger.WARNING("Is BuyingList Valid? "+(v82191 != null)); - return v82191 != null ? o : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); - return null; - } - } catch (NoSuchFieldException e1) { - e1.printStackTrace(); + o = (MerchantRecipeList) v82191.get(this); + Logger.WARNING("Is BuyingList Valid? " + (v82191 != null)); + return v82191 != null ? o : null; + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); return null; } + } protected void setBuyingList(MerchantRecipeList f) { @@ -238,29 +224,19 @@ public class EntityBaseVillager extends EntityVillager { } protected Village getVillageObject() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "villageObj"); try { - v82191 = ReflectionUtils.getField(getClass(), "villageObj"); - try { - return v82191 != null ? (Village) v82191.get(this) : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - return null; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? (Village) v82191.get(this) : null; + } catch (IllegalArgumentException | IllegalAccessException e) { return null; } } protected String getLastBuyingPlayer() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "lastBuyingPlayer"); try { - v82191 = ReflectionUtils.getField(getClass(), "lastBuyingPlayer"); - try { - return v82191 != null ? (String) v82191.get(this) : ""; - } catch (IllegalArgumentException | IllegalAccessException e) { - return ""; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? (String) v82191.get(this) : ""; + } catch (IllegalArgumentException | IllegalAccessException e) { return ""; } } diff --git a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java index 6e7234297e..967647cff6 100644 --- a/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java +++ b/src/Java/gtPlusPlus/plugin/villagers/entity/EntityNativeAustralian.java @@ -157,15 +157,10 @@ public class EntityNativeAustralian extends EntityVillager { */ protected float getField_82191_bN() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "field_82191_bN"); try { - v82191 = ReflectionUtils.getField(getClass(), "field_82191_bN"); - try { - return v82191 != null ? v82191.getFloat(this) : 0f; - } catch (IllegalArgumentException | IllegalAccessException e) { - return 0f; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? v82191.getFloat(this) : 0f; + } catch (IllegalArgumentException | IllegalAccessException e) { return 0f; } } @@ -178,15 +173,10 @@ public class EntityNativeAustralian extends EntityVillager { } protected boolean getNeedsInitilization() { - Field v82191; + Field v82191 = ReflectionUtils.getField(EntityVillager.class, "needsInitilization"); try { - v82191 = ReflectionUtils.getField(EntityVillager.class, "needsInitilization"); - try { - return v82191 != null ? v82191.getBoolean(this) : false; - } catch (IllegalArgumentException | IllegalAccessException e) { - return false; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? v82191.getBoolean(this) : false; + } catch (IllegalArgumentException | IllegalAccessException e) { return false; } } @@ -201,18 +191,13 @@ public class EntityNativeAustralian extends EntityVillager { protected MerchantRecipeList getBuyingList() { Field v82191; MerchantRecipeList o; + v82191 = ReflectionUtils.getField(getClass(), "buyingList"); try { - v82191 = ReflectionUtils.getField(getClass(), "buyingList"); - try { - o = (MerchantRecipeList) v82191.get(this); - Logger.WARNING("Is BuyingList Valid? "+(v82191 != null)); - return v82191 != null ? o : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); - return null; - } - } catch (NoSuchFieldException e1) { - e1.printStackTrace(); + o = (MerchantRecipeList) v82191.get(this); + Logger.WARNING("Is BuyingList Valid? " + (v82191 != null)); + return v82191 != null ? o : null; + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); return null; } } @@ -226,29 +211,19 @@ public class EntityNativeAustralian extends EntityVillager { } protected Village getVillageObject() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "villageObj"); try { - v82191 = ReflectionUtils.getField(getClass(), "villageObj"); - try { - return v82191 != null ? (Village) v82191.get(this) : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - return null; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? (Village) v82191.get(this) : null; + } catch (IllegalArgumentException | IllegalAccessException e) { return null; } } protected String getLastBuyingPlayer() { - Field v82191; + Field v82191 = ReflectionUtils.getField(getClass(), "lastBuyingPlayer"); try { - v82191 = ReflectionUtils.getField(getClass(), "lastBuyingPlayer"); - try { - return v82191 != null ? (String) v82191.get(this) : ""; - } catch (IllegalArgumentException | IllegalAccessException e) { - return ""; - } - } catch (NoSuchFieldException e1) { + return v82191 != null ? (String) v82191.get(this) : ""; + } catch (IllegalArgumentException | IllegalAccessException e) { return ""; } } diff --git a/src/Java/gtPlusPlus/plugin/villagers/tile/TileEntityGenericSpawner.java b/src/Java/gtPlusPlus/plugin/villagers/tile/TileEntityGenericSpawner.java index 232b6b6e87..45b8c9941b 100644 --- a/src/Java/gtPlusPlus/plugin/villagers/tile/TileEntityGenericSpawner.java +++ b/src/Java/gtPlusPlus/plugin/villagers/tile/TileEntityGenericSpawner.java @@ -221,7 +221,7 @@ public class TileEntityGenericSpawner extends TileEntityMobSpawner { } } }*/ - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } } return false; diff --git a/src/Java/gtPlusPlus/preloader/DevHelper.java b/src/Java/gtPlusPlus/preloader/DevHelper.java index 320cbe610a..d942de503a 100644 --- a/src/Java/gtPlusPlus/preloader/DevHelper.java +++ b/src/Java/gtPlusPlus/preloader/DevHelper.java @@ -32,7 +32,7 @@ public class DevHelper { - public boolean IsObfuscatedEnvironment() { + public static boolean IsObfuscatedEnvironment() { // Are we in a 'decompiled' environment? boolean deobfuscatedEnvironment = false; byte[] bs; diff --git a/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java b/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java index 2dcbe46056..8e7001903d 100644 --- a/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java +++ b/src/Java/gtPlusPlus/preloader/Preloader_GT_OreDict.java @@ -11,6 +11,7 @@ import gregtech.common.items.GT_MetaGenerated_Item_01; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class Preloader_GT_OreDict { @@ -33,9 +34,8 @@ public class Preloader_GT_OreDict { } } else { - try { - if (Class.forName("gregtech.common.items.GT_MetaGenerated_Item_03") != null) { // 6/11/12/14/16/20/30-57/69-73/79-96 - final Class<?> MetaItem03 = Class.forName("gregtech.common.items.GT_MetaGenerated_Item_03"); + if (ReflectionUtils.doesClassExist("gregtech.common.items.GT_MetaGenerated_Item_03")) { // 6/11/12/14/16/20/30-57/69-73/79-96 + final Class<?> MetaItem03 = ReflectionUtils.getClass("gregtech.common.items.GT_MetaGenerated_Item_03"); if (isInstanceOf(MetaItem03, bannedItem.getItem())) { if ((damageValue == 6) || (damageValue == 7) || (damageValue == 11) || (damageValue == 12) || (damageValue == 14) || (damageValue == 16) || (damageValue == 20) || (damageValue == 21) || (damageValue == 22)) { @@ -52,9 +52,6 @@ public class Preloader_GT_OreDict { } } } - } - catch (final ClassNotFoundException e) { - } } } } @@ -62,8 +59,8 @@ public class Preloader_GT_OreDict { //Mekanism Support - Let's not make Mek Osmium useful in GT anymore. if ((((bannedItem != null) && !LoadedMods.RedTech && (ItemUtils.getModId(bannedItem).toLowerCase().equals("mekanism"))) || (LoadedMods.Mekanism)) && !LoadedMods.RedTech){ //Circuits - if (Class.forName("mekanism.common.item.ItemControlCircuit") != null) { - final Class<?> MekCircuit = Class.forName("mekanism.common.item.ItemControlCircuit"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemControlCircuit")) { + final Class<?> MekCircuit = ReflectionUtils.getClass("mekanism.common.item.ItemControlCircuit"); if (isInstanceOf(MekCircuit, bannedItem.getItem())) { for (int r=0;r<4;r++){ if (bannedItem.getItemDamage() == r){ @@ -74,8 +71,8 @@ public class Preloader_GT_OreDict { } } //Ingots - if (Class.forName("mekanism.common.item.ItemIngot") != null) { - final Class<?> MekIngot = Class.forName("mekanism.common.item.ItemIngot"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemIngot")) { + final Class<?> MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemIngot"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 1){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -84,8 +81,8 @@ public class Preloader_GT_OreDict { } } //Dirty Dust - if (Class.forName("mekanism.common.item.ItemDirtyDust") != null) { - final Class<?> MekIngot = Class.forName("mekanism.common.item.ItemDirtyDust"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemDirtyDust")) { + final Class<?> MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemDirtyDust"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -94,8 +91,8 @@ public class Preloader_GT_OreDict { } } //Dust - if (Class.forName("mekanism.common.item.ItemDust") != null) { - final Class<?> MekIngot = Class.forName("mekanism.common.item.ItemDust"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemDust")) { + final Class<?> MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemDust"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -104,8 +101,8 @@ public class Preloader_GT_OreDict { } } //Crystal - if (Class.forName("mekanism.common.item.ItemCrystal") != null) { - final Class<?> MekIngot = Class.forName("mekanism.common.item.ItemCrystal"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemCrystal")) { + final Class<?> MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemCrystal"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -114,8 +111,8 @@ public class Preloader_GT_OreDict { } } //Shard - if (Class.forName("mekanism.common.item.ItemShard") != null) { - final Class<?> MekIngot = Class.forName("mekanism.common.item.ItemShard"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemShard")) { + final Class<?> MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemShard"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -124,8 +121,8 @@ public class Preloader_GT_OreDict { } } //Clump - if (Class.forName("mekanism.common.item.ItemClump") != null) { - final Class<?> MekIngot = Class.forName("mekanism.common.item.ItemClump"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemClump")) { + final Class<?> MekIngot = ReflectionUtils.getClass("mekanism.common.item.ItemClump"); if (isInstanceOf(MekIngot, bannedItem.getItem())) { if (bannedItem.getItemDamage() == 2){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); @@ -134,8 +131,8 @@ public class Preloader_GT_OreDict { } } //Ores - if (Class.forName("mekanism.common.item.ItemBlockOre") != null) { - final Class<?> MekOre = Class.forName("mekanism.common.item.ItemBlockOre"); + if (ReflectionUtils.doesClassExist("mekanism.common.item.ItemBlockOre")) { + final Class<?> MekOre = ReflectionUtils.getClass("mekanism.common.item.ItemBlockOre"); if (isInstanceOf(MekOre, bannedItem.getItem()) || (bannedItem == ItemUtils.simpleMetaStack("Mekanism:OreBlock", 0, 1))) { if (bannedItem.getItemDamage() == 0){ FMLRelaunchLog.log("[GT++ ASM] OreDictTransformer", Level.INFO, "Removing %s from the OreDictionary to balance Mekanism.", bannedItem.getDisplayName()); diff --git a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java index 01efcfb412..c29d8423d8 100644 --- a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java +++ b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java @@ -19,6 +19,7 @@ public class AsmConfig { public static boolean enableCofhPatch; public static boolean enableGcFuelChanges; public static boolean enableRcFlowFix; + public static boolean enableTcAspectSafety; public AsmConfig(File file) { if (!loaded) { @@ -91,6 +92,13 @@ public class AsmConfig { propOrder.add(prop.getName()); + //TC Aspect Safety + prop = config.get("general", "enableTcAspectSafety", true); + prop.comment = "Fixes small oversights in Thaumcraft 4."; + prop.setLanguageKey("gtpp.enableTcAspectSafety").setRequiresMcRestart(true); + enableTcAspectSafety = prop.getBoolean(true); + propOrder.add(prop.getName()); + config.setCategoryPropertyOrder("general", propOrder); config.setCategoryPropertyOrder("debug", propOrderDebug); @@ -104,6 +112,8 @@ public class AsmConfig { FMLLog.log(Level.INFO, "[GT++ ASM] Gt Tooltip Fix - Enabled: "+enableGtTooltipFix, new Object[0]); FMLLog.log(Level.INFO, "[GT++ ASM] COFH Patch - Enabled: "+enableCofhPatch, new Object[0]); FMLLog.log(Level.INFO, "[GT++ ASM] Gc Fuel Changes Patch - Enabled: "+enableGcFuelChanges, new Object[0]); + FMLLog.log(Level.INFO, "[GT++ ASM] Railcraft Fluid Flow Patch - Enabled: "+enableRcFlowFix, new Object[0]); + FMLLog.log(Level.INFO, "[GT++ ASM] Thaumcraft Aspect Safety Patch - Enabled: "+enableTcAspectSafety, new Object[0]); } catch (Exception var3) { FMLLog.log(Level.ERROR, var3, "GT++ ASM had a problem loading it's config", new Object[0]); diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_COFH_OreDictionaryArbiter.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_COFH_OreDictionaryArbiter.java index 50ba79bfe0..6f08dc4ff5 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_COFH_OreDictionaryArbiter.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_COFH_OreDictionaryArbiter.java @@ -1,8 +1,12 @@ package gtPlusPlus.preloader.asm.transformers; -import static org.objectweb.asm.Opcodes.*; +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; +import static org.objectweb.asm.Opcodes.ACC_STATIC; +import static org.objectweb.asm.Opcodes.ALOAD; +import static org.objectweb.asm.Opcodes.ASM5; +import static org.objectweb.asm.Opcodes.INVOKESTATIC; +import static org.objectweb.asm.Opcodes.RETURN; -import java.io.IOException; import java.util.ArrayList; import org.apache.logging.log4j.Level; @@ -34,16 +38,11 @@ public class ClassTransformer_COFH_OreDictionaryArbiter { private final boolean isValid; private final ClassReader reader; - private final ClassWriter writer; - private final boolean isObfuscated; + private final ClassWriter writer; - public ClassTransformer_COFH_OreDictionaryArbiter(byte[] basicClass, boolean obfuscated) { - + public ClassTransformer_COFH_OreDictionaryArbiter(byte[] basicClass) { ClassReader aTempReader = null; - ClassWriter aTempWriter = null; - - isObfuscated = obfuscated; - + ClassWriter aTempWriter = null; aTempReader = new ClassReader(basicClass); aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); aTempReader.accept(new localClassVisitor(aTempWriter), 0); @@ -75,7 +74,14 @@ public class ClassTransformer_COFH_OreDictionaryArbiter { return writer; } - public void injectMethod(String aMethodName) { + public void injectMethod(String aMethodName) { + + boolean isObfuscated; + try { + isObfuscated = Class.forName("net.minecraft.item.ItemStack") != null ? false : true; + } catch (ClassNotFoundException e) { + isObfuscated = true; + } String aItemStack = isObfuscated ? DevHelper.getObfuscated("net/minecraft/item/ItemStack") : "net/minecraft/item/ItemStack"; MethodVisitor mv; if (aMethodName.equals("registerOreDictionaryEntry")) { diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements.java new file mode 100644 index 0000000000..2b9729a8a3 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements.java @@ -0,0 +1,1896 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import net.minecraftforge.common.MinecraftForge; + +public class ClassTransformer_GT_Achievements { + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + private static boolean mDidRemoveAssLineRecipeAdder = false; + + public ClassTransformer_GT_Achievements(byte[] basicClass) { + + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + + aTempReader.accept(new MethodAdaptor(aTempWriter), 0); + + if (mDidRemoveAssLineRecipeAdder) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patching GT .09"); + injectMethod(aTempWriter); + patchOnItemPickup09(aTempWriter); + } + else { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patching GT .08"); + patchOnItemPickup08(aTempWriter); + } + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Valid? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean injectMethod(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "registerAssAchievement" + "."); + + /** + * Inject new, safer code + */ + + + /*mv = cw.visitMethod(ACC_PUBLIC, "registerAssAchievement", "(Lgregtech/api/util/GT_Recipe;)Lnet/minecraft/stats/Achievement;", null, null); + mv.visitCode(); + Label l0 = new Label(); + Label l1 = new Label(); + Label l2 = new Label(); + mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Throwable"); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(291, l3); + mv.visitVarInsn(ALOAD, 1); + Label l4 = new Label(); + mv.visitJumpInsn(IFNONNULL, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(292, l5); + mv.visitLdcInsn("Someone tried to register an achievement for an invalid recipe. Please report this to Alkalus."); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/api/objects/Logger", "INFO", "(Ljava/lang/String;)V", false); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(293, l6); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + mv.visitLabel(l4); + mv.visitLineNumber(295, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + Label l7 = new Label(); + mv.visitJumpInsn(IFNONNULL, l7); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLineNumber(296, l8); + mv.visitLdcInsn("Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/api/objects/Logger", "INFO", "(Ljava/lang/String;)V", false); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(297, l9); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + mv.visitLabel(l7); + mv.visitLineNumber(299, l7); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitVarInsn(ASTORE, 3); + mv.visitLabel(l0); + mv.visitLineNumber(301, l0); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitVarInsn(ASTORE, 2); + mv.visitLabel(l1); + mv.visitLineNumber(302, l1); + Label l10 = new Label(); + mv.visitJumpInsn(GOTO, l10); + mv.visitLabel(l2); + mv.visitLineNumber(303, l2); + mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/loaders/misc/GT_Achievements", "gregtech/api/util/GT_Recipe", TOP, "net/minecraft/item/ItemStack"}, 1, new Object[] {"java/lang/Throwable"}); + mv.visitVarInsn(ASTORE, 4); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(304, l11); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/ItemUtils", "getUnlocalizedItemName", "(Lnet/minecraft/item/ItemStack;)Ljava/lang/String;", false); + mv.visitVarInsn(ASTORE, 2); + mv.visitLabel(l10); + mv.visitLineNumber(306, l10); + mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/loaders/misc/GT_Achievements", "gregtech/api/util/GT_Recipe", "java/lang/String", "net/minecraft/item/ItemStack"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/loaders/misc/GT_Achievements", "achievementList", "Ljava/util/concurrent/ConcurrentHashMap;"); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/concurrent/ConcurrentHashMap", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", false); + Label l12 = new Label(); + mv.visitJumpInsn(IFNONNULL, l12); + Label l13 = new Label(); + mv.visitLabel(l13); + mv.visitLineNumber(307, l13); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitFieldInsn(PUTSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLineNumber(308, l14); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitIntInsn(BIPUSH, 11); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_5); + mv.visitInsn(IREM); + mv.visitInsn(IADD); + mv.visitInsn(INEG); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_5); + mv.visitInsn(IDIV); + mv.visitIntInsn(BIPUSH, 8); + mv.visitInsn(ISUB); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitFieldInsn(GETSTATIC, "net/minecraft/stats/AchievementList", "openInventory", "Lnet/minecraft/stats/Achievement;"); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "registerAchievement", "(Ljava/lang/String;IILnet/minecraft/item/ItemStack;Lnet/minecraft/stats/Achievement;Z)Lnet/minecraft/stats/Achievement;", false); + mv.visitInsn(ARETURN); + mv.visitLabel(l12); + mv.visitLineNumber(310, l12); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l3, l15, 0); + mv.visitLocalVariable("recipe", "Lgregtech/api/util/GT_Recipe;", null, l3, l15, 1); + mv.visitLocalVariable("aSafeUnlocalName", "Ljava/lang/String;", null, l1, l2, 2); + mv.visitLocalVariable("aSafeUnlocalName", "Ljava/lang/String;", null, l10, l15, 2); + mv.visitLocalVariable("aStack", "Lnet/minecraft/item/ItemStack;", null, l0, l15, 3); + mv.visitLocalVariable("t", "Ljava/lang/Throwable;", null, l11, l10, 4); + mv.visitMaxs(7, 5); + mv.visitEnd();*/ + + //Lets just static call my replacement function + mv = cw.visitMethod(ACC_PUBLIC, "registerAssAchievement", "(Lgregtech/api/util/GT_Recipe;)Lnet/minecraft/stats/Achievement;", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(291, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements", "registerAssAchievement", "(Lgregtech/api/util/GT_Recipe;)Lnet/minecraft/stats/Achievement;", false); + mv.visitInsn(ARETURN); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l0, l1, 0); + mv.visitLocalVariable("recipe", "Lgregtech/api/util/GT_Recipe;", null, l0, l1, 1); + mv.visitMaxs(1, 2); + mv.visitEnd(); + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + + + public boolean patchOnItemPickup08(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "onItemPickup" + "."); + + AnnotationVisitor av0; + mv = cw.visitMethod(ACC_PUBLIC, "onItemPickup", "(Lnet/minecraftforge/event/entity/player/EntityItemPickupEvent;)V", null, null); + av0 = mv.visitAnnotation("Lcpw/mods/fml/common/eventhandler/SubscribeEvent;", true); + av0.visitEnd(); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(418, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "entityPlayer", "Lnet/minecraft/entity/player/EntityPlayer;"); + mv.visitVarInsn(ASTORE, 2); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(419, l1); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "item", "Lnet/minecraft/entity/item/EntityItem;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/item/EntityItem", "getEntityItem", "()Lnet/minecraft/item/ItemStack;", false); + mv.visitVarInsn(ASTORE, 3); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(420, l2); + mv.visitVarInsn(ALOAD, 2); + Label l3 = new Label(); + mv.visitJumpInsn(IFNULL, l3); + mv.visitVarInsn(ALOAD, 3); + Label l4 = new Label(); + mv.visitJumpInsn(IFNONNULL, l4); + mv.visitLabel(l3); + mv.visitLineNumber(421, l3); + mv.visitFrame(F_APPEND,2, new Object[] {"net/minecraft/entity/player/EntityPlayer", "net/minecraft/item/ItemStack"}, 0, null); + mv.visitInsn(RETURN); + mv.visitLabel(l4); + mv.visitLineNumber(424, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKESTATIC, "gregtech/api/util/GT_OreDictUnificator", "getItemData", "(Lnet/minecraft/item/ItemStack;)Lgregtech/api/objects/ItemData;", false); + mv.visitVarInsn(ASTORE, 4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(425, l5); + mv.visitVarInsn(ALOAD, 4); + Label l6 = new Label(); + mv.visitJumpInsn(IFNULL, l6); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(426, l7); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "dust", "Lgregtech/api/enums/OrePrefixes;"); + Label l8 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l8); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(427, l9); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Lutetium", "Lgregtech/api/enums/Materials;"); + Label l10 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l10); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(428, l11); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("newmetal"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l10); + mv.visitLineNumber(430, l10); + mv.visitFrame(F_APPEND,1, new Object[] {"gregtech/api/objects/ItemData"}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("cleandust"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(431, l12); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l8); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "ore", "Lgregtech/api/enums/OrePrefixes;"); + Label l13 = new Label(); + mv.visitJumpInsn(IF_ACMPEQ, l13); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "oreBlackgranite", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPEQ, l13); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "oreEndstone", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPEQ, l13); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLineNumber(432, l14); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "oreNetherrack", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPEQ, l13); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "oreRedgranite", "Lgregtech/api/enums/OrePrefixes;"); + Label l15 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l15); + mv.visitLabel(l13); + mv.visitLineNumber(433, l13); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ISTORE, 5); + Label l16 = new Label(); + mv.visitLabel(l16); + Label l17 = new Label(); + mv.visitJumpInsn(GOTO, l17); + Label l18 = new Label(); + mv.visitLabel(l18); + mv.visitLineNumber(434, l18); + mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 5); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/enums/Materials", "name", "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l19 = new Label(); + mv.visitLabel(l19); + mv.visitLineNumber(435, l19); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 5); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "AnyIron", "Lgregtech/api/enums/Materials;"); + Label l20 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l20); + Label l21 = new Label(); + mv.visitLabel(l21); + mv.visitLineNumber(436, l21); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("iron"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l20); + mv.visitLineNumber(433, l20); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitIincInsn(5, 1); + mv.visitLabel(l17); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 5); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "size", "()I", false); + mv.visitJumpInsn(IF_ICMPLT, l18); + Label l22 = new Label(); + mv.visitLabel(l22); + mv.visitLineNumber(439, l22); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l15); + mv.visitFrame(F_CHOP,1, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushed", "Lgregtech/api/enums/OrePrefixes;"); + Label l23 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l23); + Label l24 = new Label(); + mv.visitLabel(l24); + mv.visitLineNumber(440, l24); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("crushed"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l25 = new Label(); + mv.visitLabel(l25); + mv.visitLineNumber(441, l25); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l23); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushedPurified", "Lgregtech/api/enums/OrePrefixes;"); + Label l26 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l26); + Label l27 = new Label(); + mv.visitLabel(l27); + mv.visitLineNumber(442, l27); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("washing"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l28 = new Label(); + mv.visitLabel(l28); + mv.visitLineNumber(443, l28); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l26); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushedCentrifuged", "Lgregtech/api/enums/OrePrefixes;"); + Label l29 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l29); + Label l30 = new Label(); + mv.visitLabel(l30); + mv.visitLineNumber(444, l30); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("spinit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l31 = new Label(); + mv.visitLabel(l31); + mv.visitLineNumber(445, l31); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l29); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Steel", "Lgregtech/api/enums/Materials;"); + Label l32 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l32); + Label l33 = new Label(); + mv.visitLabel(l33); + mv.visitLineNumber(446, l33); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "ingot", "Lgregtech/api/enums/OrePrefixes;"); + Label l34 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l34); + mv.visitVarInsn(ALOAD, 3); + mv.visitFieldInsn(GETFIELD, "net/minecraft/item/ItemStack", "stackSize", "I"); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getMaxStackSize", "()I", false); + mv.visitJumpInsn(IF_ICMPNE, l34); + Label l35 = new Label(); + mv.visitLabel(l35); + mv.visitLineNumber(447, l35); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("steel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l36 = new Label(); + mv.visitLabel(l36); + mv.visitLineNumber(448, l36); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l34); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "nugget", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + mv.visitLdcInsn("Thaumcraft"); + mv.visitMethodInsn(INVOKESTATIC, "cpw/mods/fml/common/Loader", "isModLoaded", "(Ljava/lang/String;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + Label l37 = new Label(); + mv.visitLabel(l37); + mv.visitLineNumber(449, l37); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/player/EntityPlayer", "getDisplayName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("GT_IRON_TO_STEEL"); + mv.visitMethodInsn(INVOKESTATIC, "thaumcraft/api/ThaumcraftApiHelper", "isResearchComplete", "(Ljava/lang/String;Ljava/lang/String;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + Label l38 = new Label(); + mv.visitLabel(l38); + mv.visitLineNumber(450, l38); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("steel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l39 = new Label(); + mv.visitLabel(l39); + mv.visitLineNumber(453, l39); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l32); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "circuit", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Advanced", "Lgregtech/api/enums/Materials;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + Label l40 = new Label(); + mv.visitLabel(l40); + mv.visitLineNumber(454, l40); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("stepforward"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l6); + mv.visitLineNumber(457, l6); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem."); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "startsWith", "(Ljava/lang/String;)Z", false); + Label l41 = new Label(); + mv.visitJumpInsn(IFEQ, l41); + Label l42 = new Label(); + mv.visitLabel(l42); + mv.visitLineNumber(458, l42); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32500"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l43 = new Label(); + mv.visitJumpInsn(IFEQ, l43); + Label l44 = new Label(); + mv.visitLabel(l44); + mv.visitLineNumber(459, l44); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestlead"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l45 = new Label(); + mv.visitLabel(l45); + mv.visitLineNumber(460, l45); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l43); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32501"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l46 = new Label(); + mv.visitJumpInsn(IFEQ, l46); + Label l47 = new Label(); + mv.visitLabel(l47); + mv.visitLineNumber(461, l47); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestsilver"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l48 = new Label(); + mv.visitLabel(l48); + mv.visitLineNumber(462, l48); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l46); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32503"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l49 = new Label(); + mv.visitJumpInsn(IFEQ, l49); + Label l50 = new Label(); + mv.visitLabel(l50); + mv.visitLineNumber(463, l50); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestiron"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l51 = new Label(); + mv.visitLabel(l51); + mv.visitLineNumber(464, l51); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l49); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32504"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l52 = new Label(); + mv.visitJumpInsn(IFEQ, l52); + Label l53 = new Label(); + mv.visitLabel(l53); + mv.visitLineNumber(465, l53); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestgold"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l54 = new Label(); + mv.visitLabel(l54); + mv.visitLineNumber(466, l54); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l52); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32530"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l55 = new Label(); + mv.visitJumpInsn(IFEQ, l55); + Label l56 = new Label(); + mv.visitLabel(l56); + mv.visitLineNumber(467, l56); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestcopper"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l57 = new Label(); + mv.visitLabel(l57); + mv.visitLineNumber(468, l57); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l55); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32540"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l58 = new Label(); + mv.visitJumpInsn(IFEQ, l58); + Label l59 = new Label(); + mv.visitLabel(l59); + mv.visitLineNumber(469, l59); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havesttin"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l60 = new Label(); + mv.visitLabel(l60); + mv.visitLineNumber(470, l60); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l58); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32510"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l61 = new Label(); + mv.visitJumpInsn(IFEQ, l61); + Label l62 = new Label(); + mv.visitLabel(l62); + mv.visitLineNumber(471, l62); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestoil"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l63 = new Label(); + mv.visitLabel(l63); + mv.visitLineNumber(472, l63); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l61); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32511"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l64 = new Label(); + mv.visitJumpInsn(IFEQ, l64); + Label l65 = new Label(); + mv.visitLabel(l65); + mv.visitLineNumber(473, l65); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestemeralds"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l66 = new Label(); + mv.visitLabel(l66); + mv.visitLineNumber(474, l66); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l64); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32706"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l67 = new Label(); + mv.visitJumpInsn(IFEQ, l67); + Label l68 = new Label(); + mv.visitLabel(l68); + mv.visitLineNumber(475, l68); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("energyflow"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l69 = new Label(); + mv.visitLabel(l69); + mv.visitLineNumber(476, l69); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l67); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32702"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l70 = new Label(); + mv.visitJumpInsn(IFEQ, l70); + Label l71 = new Label(); + mv.visitLabel(l71); + mv.visitLineNumber(477, l71); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("bettercircuits"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l72 = new Label(); + mv.visitLabel(l72); + mv.visitLineNumber(478, l72); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l70); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32707"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l73 = new Label(); + mv.visitJumpInsn(IFEQ, l73); + Label l74 = new Label(); + mv.visitLabel(l74); + mv.visitLineNumber(479, l74); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("datasaving"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l75 = new Label(); + mv.visitLabel(l75); + mv.visitLineNumber(480, l75); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l73); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32597"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l76 = new Label(); + mv.visitJumpInsn(IFEQ, l76); + Label l77 = new Label(); + mv.visitLabel(l77); + mv.visitLineNumber(481, l77); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("orbs"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l78 = new Label(); + mv.visitLabel(l78); + mv.visitLineNumber(482, l78); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l76); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32599"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l79 = new Label(); + mv.visitJumpInsn(IFEQ, l79); + Label l80 = new Label(); + mv.visitLabel(l80); + mv.visitLineNumber(483, l80); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("thatspower"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l81 = new Label(); + mv.visitLabel(l81); + mv.visitLineNumber(484, l81); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l79); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32598"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l82 = new Label(); + mv.visitJumpInsn(IFEQ, l82); + Label l83 = new Label(); + mv.visitLabel(l83); + mv.visitLineNumber(485, l83); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("luck"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l84 = new Label(); + mv.visitLabel(l84); + mv.visitLineNumber(486, l84); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l82); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32749"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l85 = new Label(); + mv.visitJumpInsn(IFEQ, l85); + Label l86 = new Label(); + mv.visitLabel(l86); + mv.visitLineNumber(487, l86); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("closeit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l87 = new Label(); + mv.visitLabel(l87); + mv.visitLineNumber(488, l87); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l85); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32730"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l88 = new Label(); + mv.visitJumpInsn(IFEQ, l88); + Label l89 = new Label(); + mv.visitLabel(l89); + mv.visitLineNumber(489, l89); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("manipulation"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l90 = new Label(); + mv.visitLabel(l90); + mv.visitLineNumber(490, l90); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l88); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32729"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l91 = new Label(); + mv.visitJumpInsn(IFEQ, l91); + Label l92 = new Label(); + mv.visitLabel(l92); + mv.visitLineNumber(491, l92); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("filterregulate"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l93 = new Label(); + mv.visitLabel(l93); + mv.visitLineNumber(492, l93); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l91); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32605"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l94 = new Label(); + mv.visitJumpInsn(IFEQ, l94); + Label l95 = new Label(); + mv.visitLabel(l95); + mv.visitLineNumber(493, l95); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("whatnow"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l96 = new Label(); + mv.visitLabel(l96); + mv.visitLineNumber(494, l96); + mv.visitJumpInsn(GOTO, l41); + mv.visitLabel(l94); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.Thoriumcell"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + mv.visitJumpInsn(IFEQ, l41); + Label l97 = new Label(); + mv.visitLabel(l97); + mv.visitLineNumber(495, l97); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("newfuel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l41); + mv.visitLineNumber(498, l41); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitInsn(RETURN); + Label l98 = new Label(); + mv.visitLabel(l98); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l0, l98, 0); + mv.visitLocalVariable("event", "Lnet/minecraftforge/event/entity/player/EntityItemPickupEvent;", null, l0, l98, 1); + mv.visitLocalVariable("player", "Lnet/minecraft/entity/player/EntityPlayer;", null, l1, l98, 2); + mv.visitLocalVariable("stack", "Lnet/minecraft/item/ItemStack;", null, l2, l98, 3); + mv.visitLocalVariable("data", "Lgregtech/api/objects/ItemData;", null, l5, l98, 4); + mv.visitLocalVariable("i", "I", null, l16, l22, 5); + mv.visitMaxs(4, 6); + mv.visitEnd(); + + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + + public boolean patchOnItemPickup09(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "onItemPickup" + "."); + + /** + * Inject new, safer code + */ + AnnotationVisitor av0; + mv = cw.visitMethod(ACC_PUBLIC, "onItemPickup", "(Lnet/minecraftforge/event/entity/player/EntityItemPickupEvent;)V", null, null); + av0 = mv.visitAnnotation("Lcpw/mods/fml/common/eventhandler/SubscribeEvent;", true); + av0.visitEnd(); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(546, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "entityPlayer", "Lnet/minecraft/entity/player/EntityPlayer;"); + mv.visitVarInsn(ASTORE, 2); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(547, l1); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "item", "Lnet/minecraft/entity/item/EntityItem;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/item/EntityItem", "getEntityItem", "()Lnet/minecraft/item/ItemStack;", false); + mv.visitVarInsn(ASTORE, 3); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(548, l2); + mv.visitVarInsn(ALOAD, 2); + Label l3 = new Label(); + mv.visitJumpInsn(IFNULL, l3); + mv.visitVarInsn(ALOAD, 3); + Label l4 = new Label(); + mv.visitJumpInsn(IFNONNULL, l4); + mv.visitLabel(l3); + mv.visitLineNumber(549, l3); + mv.visitFrame(F_APPEND,2, new Object[] {"net/minecraft/entity/player/EntityPlayer", "net/minecraft/item/ItemStack"}, 0, null); + mv.visitInsn(RETURN); + mv.visitLabel(l4); + mv.visitLineNumber(551, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKESTATIC, "gregtech/api/util/GT_OreDictUnificator", "getItemData", "(Lnet/minecraft/item/ItemStack;)Lgregtech/api/objects/ItemData;", false); + mv.visitVarInsn(ASTORE, 4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(552, l5); + mv.visitVarInsn(ALOAD, 4); + Label l6 = new Label(); + mv.visitJumpInsn(IFNULL, l6); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IFNULL, l6); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(553, l7); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "dust", "Lgregtech/api/enums/OrePrefixes;"); + Label l8 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l8); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(554, l9); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Lutetium", "Lgregtech/api/enums/Materials;"); + Label l10 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l10); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(555, l11); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("newmetal"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l10); + mv.visitLineNumber(557, l10); + mv.visitFrame(F_APPEND,1, new Object[] {"gregtech/api/objects/ItemData"}, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Gunpowder", "Lgregtech/api/enums/Materials;"); + mv.visitJumpInsn(IF_ACMPEQ, l6); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(558, l12); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("cleandust"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l13 = new Label(); + mv.visitLabel(l13); + mv.visitLineNumber(560, l13); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l8); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/enums/OrePrefixes", "name", "()Ljava/lang/String;", false); + mv.visitLdcInsn("ore"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "startsWith", "(Ljava/lang/String;)Z", false); + Label l14 = new Label(); + mv.visitJumpInsn(IFEQ, l14); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLineNumber(561, l15); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "size", "()I", false); + mv.visitVarInsn(ISTORE, 5); + Label l16 = new Label(); + mv.visitLabel(l16); + mv.visitLineNumber(562, l16); + mv.visitInsn(ICONST_0); + mv.visitVarInsn(ISTORE, 6); + Label l17 = new Label(); + mv.visitLabel(l17); + Label l18 = new Label(); + mv.visitJumpInsn(GOTO, l18); + Label l19 = new Label(); + mv.visitLabel(l19); + mv.visitLineNumber(563, l19); + mv.visitFrame(F_APPEND,2, new Object[] {INTEGER, INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 6); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/enums/Materials", "mName", "Ljava/lang/String;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l20 = new Label(); + mv.visitLabel(l20); + mv.visitLineNumber(564, l20); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 6); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Iron", "Lgregtech/api/enums/Materials;"); + Label l21 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l21); + Label l22 = new Label(); + mv.visitLabel(l22); + mv.visitLineNumber(565, l22); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("iron"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l21); + mv.visitLineNumber(567, l21); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 6); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Copper", "Lgregtech/api/enums/Materials;"); + Label l23 = new Label(); + mv.visitJumpInsn(IF_ACMPEQ, l23); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/objects/ItemData", "getAllMaterialStacks", "()Ljava/util/ArrayList;", false); + mv.visitVarInsn(ILOAD, 6); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "get", "(I)Ljava/lang/Object;", false); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/objects/MaterialStack"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Tin", "Lgregtech/api/enums/Materials;"); + Label l24 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l24); + mv.visitLabel(l23); + mv.visitLineNumber(568, l23); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/event/entity/player/EntityItemPickupEvent", "entityPlayer", "Lnet/minecraft/entity/player/EntityPlayer;"); + mv.visitLdcInsn("mineOre"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l24); + mv.visitLineNumber(562, l24); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitIincInsn(6, 1); + mv.visitLabel(l18); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ILOAD, 6); + mv.visitVarInsn(ILOAD, 5); + mv.visitJumpInsn(IF_ICMPLT, l19); + Label l25 = new Label(); + mv.visitLabel(l25); + mv.visitLineNumber(572, l25); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l14); + mv.visitFrame(F_CHOP,2, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushed", "Lgregtech/api/enums/OrePrefixes;"); + Label l26 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l26); + Label l27 = new Label(); + mv.visitLabel(l27); + mv.visitLineNumber(573, l27); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("crushed"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l28 = new Label(); + mv.visitLabel(l28); + mv.visitLineNumber(574, l28); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l26); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushedPurified", "Lgregtech/api/enums/OrePrefixes;"); + Label l29 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l29); + Label l30 = new Label(); + mv.visitLabel(l30); + mv.visitLineNumber(575, l30); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("washing"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l31 = new Label(); + mv.visitLabel(l31); + mv.visitLineNumber(576, l31); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l29); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "crushedCentrifuged", "Lgregtech/api/enums/OrePrefixes;"); + Label l32 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l32); + Label l33 = new Label(); + mv.visitLabel(l33); + mv.visitLineNumber(577, l33); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("spinit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l34 = new Label(); + mv.visitLabel(l34); + mv.visitLineNumber(578, l34); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l32); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mMaterial", "Lgregtech/api/objects/MaterialStack;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/MaterialStack", "mMaterial", "Lgregtech/api/enums/Materials;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/Materials", "Steel", "Lgregtech/api/enums/Materials;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + Label l35 = new Label(); + mv.visitLabel(l35); + mv.visitLineNumber(579, l35); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "ingot", "Lgregtech/api/enums/OrePrefixes;"); + Label l36 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l36); + mv.visitVarInsn(ALOAD, 3); + mv.visitFieldInsn(GETFIELD, "net/minecraft/item/ItemStack", "stackSize", "I"); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getMaxStackSize", "()I", false); + mv.visitJumpInsn(IF_ICMPNE, l36); + Label l37 = new Label(); + mv.visitLabel(l37); + mv.visitLineNumber(580, l37); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("steel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l38 = new Label(); + mv.visitLabel(l38); + mv.visitLineNumber(581, l38); + mv.visitJumpInsn(GOTO, l6); + mv.visitLabel(l36); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitFieldInsn(GETFIELD, "gregtech/api/objects/ItemData", "mPrefix", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/enums/OrePrefixes", "nugget", "Lgregtech/api/enums/OrePrefixes;"); + mv.visitJumpInsn(IF_ACMPNE, l6); + mv.visitLdcInsn("Thaumcraft"); + mv.visitMethodInsn(INVOKESTATIC, "cpw/mods/fml/common/Loader", "isModLoaded", "(Ljava/lang/String;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/entity/player/EntityPlayer", "getDisplayName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("GT_IRON_TO_STEEL"); + mv.visitMethodInsn(INVOKESTATIC, "thaumcraft/api/ThaumcraftApiHelper", "isResearchComplete", "(Ljava/lang/String;Ljava/lang/String;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + Label l39 = new Label(); + mv.visitLabel(l39); + mv.visitLineNumber(582, l39); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("steel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l6); + mv.visitLineNumber(589, l6); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem."); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "startsWith", "(Ljava/lang/String;)Z", false); + Label l40 = new Label(); + mv.visitJumpInsn(IFEQ, l40); + Label l41 = new Label(); + mv.visitLabel(l41); + mv.visitLineNumber(590, l41); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32500"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l42 = new Label(); + mv.visitJumpInsn(IFEQ, l42); + Label l43 = new Label(); + mv.visitLabel(l43); + mv.visitLineNumber(591, l43); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestlead"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l44 = new Label(); + mv.visitLabel(l44); + mv.visitLineNumber(592, l44); + Label l45 = new Label(); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l42); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32501"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l46 = new Label(); + mv.visitJumpInsn(IFEQ, l46); + Label l47 = new Label(); + mv.visitLabel(l47); + mv.visitLineNumber(593, l47); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestsilver"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l48 = new Label(); + mv.visitLabel(l48); + mv.visitLineNumber(594, l48); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l46); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32503"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l49 = new Label(); + mv.visitJumpInsn(IFEQ, l49); + Label l50 = new Label(); + mv.visitLabel(l50); + mv.visitLineNumber(595, l50); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestiron"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l51 = new Label(); + mv.visitLabel(l51); + mv.visitLineNumber(596, l51); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l49); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32504"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l52 = new Label(); + mv.visitJumpInsn(IFEQ, l52); + Label l53 = new Label(); + mv.visitLabel(l53); + mv.visitLineNumber(597, l53); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestgold"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l54 = new Label(); + mv.visitLabel(l54); + mv.visitLineNumber(598, l54); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l52); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32530"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l55 = new Label(); + mv.visitJumpInsn(IFEQ, l55); + Label l56 = new Label(); + mv.visitLabel(l56); + mv.visitLineNumber(599, l56); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestcopper"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l57 = new Label(); + mv.visitLabel(l57); + mv.visitLineNumber(600, l57); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l55); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32540"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l58 = new Label(); + mv.visitJumpInsn(IFEQ, l58); + Label l59 = new Label(); + mv.visitLabel(l59); + mv.visitLineNumber(601, l59); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havesttin"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l60 = new Label(); + mv.visitLabel(l60); + mv.visitLineNumber(602, l60); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l58); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32510"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l61 = new Label(); + mv.visitJumpInsn(IFEQ, l61); + Label l62 = new Label(); + mv.visitLabel(l62); + mv.visitLineNumber(603, l62); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestoil"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l63 = new Label(); + mv.visitLabel(l63); + mv.visitLineNumber(604, l63); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l61); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.02.32511"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l64 = new Label(); + mv.visitJumpInsn(IFEQ, l64); + Label l65 = new Label(); + mv.visitLabel(l65); + mv.visitLineNumber(605, l65); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("havestemeralds"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l66 = new Label(); + mv.visitLabel(l66); + mv.visitLineNumber(606, l66); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l64); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32082"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l67 = new Label(); + mv.visitJumpInsn(IFEQ, l67); + Label l68 = new Label(); + mv.visitLabel(l68); + mv.visitLineNumber(607, l68); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("energyflow"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l69 = new Label(); + mv.visitLabel(l69); + mv.visitLineNumber(608, l69); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l67); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32702"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l70 = new Label(); + mv.visitJumpInsn(IFEQ, l70); + Label l71 = new Label(); + mv.visitLabel(l71); + mv.visitLineNumber(609, l71); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("bettercircuits"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l72 = new Label(); + mv.visitLabel(l72); + mv.visitLineNumber(610, l72); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l70); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32707"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l73 = new Label(); + mv.visitJumpInsn(IFEQ, l73); + Label l74 = new Label(); + mv.visitLabel(l74); + mv.visitLineNumber(611, l74); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("datasaving"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l75 = new Label(); + mv.visitLabel(l75); + mv.visitLineNumber(612, l75); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l73); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32597"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l76 = new Label(); + mv.visitJumpInsn(IFEQ, l76); + Label l77 = new Label(); + mv.visitLabel(l77); + mv.visitLineNumber(613, l77); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("orbs"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l78 = new Label(); + mv.visitLabel(l78); + mv.visitLineNumber(614, l78); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l76); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32599"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l79 = new Label(); + mv.visitJumpInsn(IFEQ, l79); + Label l80 = new Label(); + mv.visitLabel(l80); + mv.visitLineNumber(615, l80); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("thatspower"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l81 = new Label(); + mv.visitLabel(l81); + mv.visitLineNumber(616, l81); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l79); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32598"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l82 = new Label(); + mv.visitJumpInsn(IFEQ, l82); + Label l83 = new Label(); + mv.visitLabel(l83); + mv.visitLineNumber(617, l83); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("luck"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l84 = new Label(); + mv.visitLabel(l84); + mv.visitLineNumber(618, l84); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l82); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32749"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l85 = new Label(); + mv.visitJumpInsn(IFEQ, l85); + Label l86 = new Label(); + mv.visitLabel(l86); + mv.visitLineNumber(619, l86); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("closeit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l87 = new Label(); + mv.visitLabel(l87); + mv.visitLineNumber(620, l87); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l85); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32730"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l88 = new Label(); + mv.visitJumpInsn(IFEQ, l88); + Label l89 = new Label(); + mv.visitLabel(l89); + mv.visitLineNumber(621, l89); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("manipulation"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l90 = new Label(); + mv.visitLabel(l90); + mv.visitLineNumber(622, l90); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l88); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32729"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l91 = new Label(); + mv.visitJumpInsn(IFEQ, l91); + Label l92 = new Label(); + mv.visitLabel(l92); + mv.visitLineNumber(623, l92); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("filterregulate"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l93 = new Label(); + mv.visitLabel(l93); + mv.visitLineNumber(624, l93); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l91); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32605"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l94 = new Label(); + mv.visitJumpInsn(IFEQ, l94); + Label l95 = new Label(); + mv.visitLabel(l95); + mv.visitLineNumber(625, l95); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("whatnow"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l96 = new Label(); + mv.visitLabel(l96); + mv.visitLineNumber(626, l96); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l94); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32736"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l97 = new Label(); + mv.visitJumpInsn(IFEQ, l97); + Label l98 = new Label(); + mv.visitLabel(l98); + mv.visitLineNumber(627, l98); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("zpmage"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l99 = new Label(); + mv.visitLabel(l99); + mv.visitLineNumber(628, l99); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l97); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32737"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l100 = new Label(); + mv.visitJumpInsn(IFEQ, l100); + Label l101 = new Label(); + mv.visitLabel(l101); + mv.visitLineNumber(629, l101); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("uvage"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l102 = new Label(); + mv.visitLabel(l102); + mv.visitLineNumber(630, l102); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l100); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32030"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l103 = new Label(); + mv.visitJumpInsn(IFEQ, l103); + Label l104 = new Label(); + mv.visitLabel(l104); + mv.visitLineNumber(631, l104); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtmonosilicon"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l105 = new Label(); + mv.visitLabel(l105); + mv.visitLineNumber(632, l105); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l103); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32036"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l106 = new Label(); + mv.visitJumpInsn(IFEQ, l106); + Label l107 = new Label(); + mv.visitLabel(l107); + mv.visitLineNumber(633, l107); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtlogicwafer"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l108 = new Label(); + mv.visitLabel(l108); + mv.visitLineNumber(634, l108); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l106); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32701"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l109 = new Label(); + mv.visitJumpInsn(IFEQ, l109); + Label l110 = new Label(); + mv.visitLabel(l110); + mv.visitLineNumber(635, l110); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtlogiccircuit"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l111 = new Label(); + mv.visitLabel(l111); + mv.visitLineNumber(636, l111); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l109); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32085"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l112 = new Label(); + mv.visitJumpInsn(IFEQ, l112); + Label l113 = new Label(); + mv.visitLabel(l113); + mv.visitLineNumber(637, l113); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtquantumprocessor"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l114 = new Label(); + mv.visitLabel(l114); + mv.visitLineNumber(638, l114); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l112); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32089"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l115 = new Label(); + mv.visitJumpInsn(IFEQ, l115); + Label l116 = new Label(); + mv.visitLabel(l116); + mv.visitLineNumber(639, l116); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtcrystalprocessor"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l117 = new Label(); + mv.visitLabel(l117); + mv.visitLineNumber(640, l117); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l115); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32092"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l118 = new Label(); + mv.visitJumpInsn(IFEQ, l118); + Label l119 = new Label(); + mv.visitLabel(l119); + mv.visitLineNumber(641, l119); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtwetware"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l120 = new Label(); + mv.visitLabel(l120); + mv.visitLineNumber(642, l120); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l118); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.03.32095"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l121 = new Label(); + mv.visitJumpInsn(IFEQ, l121); + Label l122 = new Label(); + mv.visitLabel(l122); + mv.visitLineNumber(643, l122); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("gtwetmain"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l123 = new Label(); + mv.visitLabel(l123); + mv.visitLineNumber(644, l123); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l121); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32736"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l124 = new Label(); + mv.visitJumpInsn(IFEQ, l124); + Label l125 = new Label(); + mv.visitLabel(l125); + mv.visitLineNumber(645, l125); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("zpmage"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l126 = new Label(); + mv.visitLabel(l126); + mv.visitLineNumber(646, l126); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l124); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.metaitem.01.32737"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + mv.visitJumpInsn(IFEQ, l45); + Label l127 = new Label(); + mv.visitLabel(l127); + mv.visitLineNumber(647, l127); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("uvage"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l128 = new Label(); + mv.visitLabel(l128); + mv.visitLineNumber(649, l128); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l40); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("gt.Thoriumcell"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + Label l129 = new Label(); + mv.visitJumpInsn(IFEQ, l129); + Label l130 = new Label(); + mv.visitLabel(l130); + mv.visitLineNumber(650, l130); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("newfuel"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l131 = new Label(); + mv.visitLabel(l131); + mv.visitLineNumber(651, l131); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l129); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitFieldInsn(GETSTATIC, "ic2/core/Ic2Items", "quantumBodyarmor", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + Label l132 = new Label(); + mv.visitJumpInsn(IF_ACMPEQ, l132); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitFieldInsn(GETSTATIC, "ic2/core/Ic2Items", "quantumBoots", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitJumpInsn(IF_ACMPEQ, l132); + Label l133 = new Label(); + mv.visitLabel(l133); + mv.visitLineNumber(652, l133); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitFieldInsn(GETSTATIC, "ic2/core/Ic2Items", "quantumHelmet", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitJumpInsn(IF_ACMPEQ, l132); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + mv.visitFieldInsn(GETSTATIC, "ic2/core/Ic2Items", "quantumLeggings", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getItem", "()Lnet/minecraft/item/Item;", false); + Label l134 = new Label(); + mv.visitJumpInsn(IF_ACMPNE, l134); + mv.visitLabel(l132); + mv.visitLineNumber(653, l132); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("buildQArmor"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + Label l135 = new Label(); + mv.visitLabel(l135); + mv.visitLineNumber(654, l135); + mv.visitJumpInsn(GOTO, l45); + mv.visitLabel(l134); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitLdcInsn("ic2.itemPartCircuitAdv"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false); + mv.visitJumpInsn(IFEQ, l45); + Label l136 = new Label(); + mv.visitLabel(l136); + mv.visitLineNumber(655, l136); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitLdcInsn("stepforward"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "issueAchievement", "(Lnet/minecraft/entity/player/EntityPlayer;Ljava/lang/String;)V", false); + mv.visitLabel(l45); + mv.visitLineNumber(657, l45); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitInsn(RETURN); + Label l137 = new Label(); + mv.visitLabel(l137); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l0, l137, 0); + mv.visitLocalVariable("event", "Lnet/minecraftforge/event/entity/player/EntityItemPickupEvent;", null, l0, l137, 1); + mv.visitLocalVariable("player", "Lnet/minecraft/entity/player/EntityPlayer;", null, l1, l137, 2); + mv.visitLocalVariable("stack", "Lnet/minecraft/item/ItemStack;", null, l2, l137, 3); + mv.visitLocalVariable("data", "Lgregtech/api/objects/ItemData;", null, l5, l137, 4); + mv.visitLocalVariable("data_getAllMaterialStacks_sS", "I", null, l16, l25, 5); + mv.visitLocalVariable("i", "I", null, l17, l25, 6); + mv.visitMaxs(4, 7); + mv.visitEnd(); + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + + + + + + + + public class MethodAdaptor extends ClassVisitor { + + public MethodAdaptor(ClassVisitor cv) { + super(ASM5, cv); + this.cv = cv; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + if (name.equals("registerAssAchievement") || name.equals("onItemPickup")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, + "Found method " + name + ", removing."); + methodVisitor = null; + if (name.equals("registerAssAchievement")) { + mDidRemoveAssLineRecipeAdder = true; + } + } else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + return methodVisitor; + } + } + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements_CrashFix.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements_CrashFix.java new file mode 100644 index 0000000000..fb297ed76e --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Achievements_CrashFix.java @@ -0,0 +1,218 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; +import org.apache.logging.log4j.Level; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import gtPlusPlus.preloader.DevHelper; + +public class ClassTransformer_GT_Achievements_CrashFix { + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + private final boolean mObfuscated; + private static boolean mDidRemoveAssLineRecipeAdder = false; + + public ClassTransformer_GT_Achievements_CrashFix(byte[] basicClass, boolean obfuscated) { + + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + mObfuscated = obfuscated; + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + + aTempReader.accept(new MethodAdaptor(aTempWriter), 0); + + if (mDidRemoveAssLineRecipeAdder) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patching GT .09"); + injectMethod(aTempWriter); + } + else { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patch not required, skipping."); + } + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Valid? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean injectMethod(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "registerAssAchievement" + ". Obfuscated? "+mObfuscated); + + /** + * Inject new, safer code + */ + + mv = cw.visitMethod(ACC_PUBLIC, "registerAssAchievement", "(Lgregtech/api/util/GT_Recipe;)Lnet/minecraft/stats/Achievement;", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(293, l0); + mv.visitVarInsn(ALOAD, 1); + Label l1 = new Label(); + mv.visitJumpInsn(IFNONNULL, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(294, l2); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitLdcInsn("GTPP_MOD: Someone tried to register an achievement for an invalid recipe. Please report this to Alkalus."); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(295, l3); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + mv.visitLabel(l1); + mv.visitLineNumber(297, l1); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + Label l4 = new Label(); + mv.visitJumpInsn(IFNONNULL, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(298, l5); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitLdcInsn("GTPP_MOD: Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(299, l6); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + mv.visitLabel(l4); + mv.visitLineNumber(301, l4); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitVarInsn(ASTORE, 3); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(302, l7); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/core/util/minecraft/ItemUtils", "getUnlocalizedItemName", "(Lnet/minecraft/item/ItemStack;)Ljava/lang/String;", false); + mv.visitVarInsn(ASTORE, 2); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLineNumber(304, l8); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/loaders/misc/GT_Achievements", "achievementList", "Ljava/util/concurrent/ConcurrentHashMap;"); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/concurrent/ConcurrentHashMap", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", false); + Label l9 = new Label(); + mv.visitJumpInsn(IFNONNULL, l9); + Label l10 = new Label(); + mv.visitLabel(l10); + mv.visitLineNumber(305, l10); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_1); + mv.visitInsn(IADD); + mv.visitFieldInsn(PUTSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(306, l11); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 2); + mv.visitIntInsn(BIPUSH, 11); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_5); + mv.visitInsn(IREM); + mv.visitInsn(IADD); + mv.visitInsn(INEG); + mv.visitFieldInsn(GETSTATIC, "gregtech/loaders/misc/GT_Achievements", "assReg", "I"); + mv.visitInsn(ICONST_5); + mv.visitInsn(IDIV); + mv.visitIntInsn(BIPUSH, 8); + mv.visitInsn(ISUB); + mv.visitVarInsn(ALOAD, 1); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitLdcInsn("NO_REQUIREMENT"); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/loaders/misc/GT_Achievements", "registerAchievement", "(Ljava/lang/String;IILnet/minecraft/item/ItemStack;Ljava/lang/String;Z)Lnet/minecraft/stats/Achievement;", false); + mv.visitVarInsn(ASTORE, 4); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(307, l12); + Label l13 = new Label(); + mv.visitJumpInsn(GOTO, l13); + mv.visitLabel(l9); + mv.visitLineNumber(309, l9); + mv.visitFrame(F_APPEND,2, new Object[] {"java/lang/String", "net/minecraft/item/ItemStack"}, 0, null); + mv.visitInsn(ACONST_NULL); + mv.visitVarInsn(ASTORE, 4); + mv.visitLabel(l13); + mv.visitLineNumber(311, l13); + mv.visitFrame(F_APPEND,1, new Object[] {"net/minecraft/stats/Achievement"}, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitInsn(ARETURN); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLocalVariable("this", "Lgregtech/loaders/misc/GT_Achievements;", null, l0, l14, 0); + mv.visitLocalVariable("recipe", "Lgregtech/api/util/GT_Recipe;", null, l0, l14, 1); + mv.visitLocalVariable("aSafeUnlocalName", "Ljava/lang/String;", null, l8, l14, 2); + mv.visitLocalVariable("aStack", "Lnet/minecraft/item/ItemStack;", null, l7, l14, 3); + mv.visitLocalVariable("aYouDidSomethingInGT", "Lnet/minecraft/stats/Achievement;", null, l12, l9, 4); + mv.visitLocalVariable("aYouDidSomethingInGT", "Lnet/minecraft/stats/Achievement;", null, l13, l14, 4); + mv.visitMaxs(7, 5); + mv.visitEnd(); + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + + + public class MethodAdaptor extends ClassVisitor { + + public MethodAdaptor(ClassVisitor cv) { + super(ASM5, cv); + this.cv = cv; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + if (name.equals("registerAssAchievement")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Found method " + name + ", removing."); + methodVisitor = null; + mDidRemoveAssLineRecipeAdder = true; + } else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + return methodVisitor; + } + } + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BaseMetaTileEntity.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BaseMetaTileEntity.java new file mode 100644 index 0000000000..da5859eb55 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BaseMetaTileEntity.java @@ -0,0 +1,158 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; + +public class ClassTransformer_GT_BaseMetaTileEntity { + + //The qualified name of the class we plan to transform. + //gregtech/common/blocks/GT_Block_Machines + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + + public ClassTransformer_GT_BaseMetaTileEntity(byte[] basicClass) { + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Attempting to make setMetaTileEntity(IMetaTileEntity) safer."); + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + aTempReader.accept(new localClassVisitor(aTempWriter), 0); + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Valid patch? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + + + if (reader != null && writer != null) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Attempting Method Injection."); + injectMethod("setMetaTileEntity"); + } + + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean injectMethod(String aMethodName) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Injecting "+aMethodName+"."); + if (aMethodName.equals("setMetaTileEntity")) { + + mv = getWriter().visitMethod(ACC_PUBLIC, "setMetaTileEntity", "(Lgregtech/api/interfaces/metatileentity/IMetaTileEntity;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + Label l1 = new Label(); + Label l2 = new Label(); + mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Throwable"); + mv.visitLabel(l0); + mv.visitLineNumber(1568, l0); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/metatileentity/MetaTileEntity"); + mv.visitFieldInsn(PUTFIELD, "gregtech/api/metatileentity/BaseMetaTileEntity", "mMetaTileEntity", "Lgregtech/api/metatileentity/MetaTileEntity;"); + mv.visitLabel(l1); + mv.visitLineNumber(1569, l1); + Label l3 = new Label(); + mv.visitJumpInsn(GOTO, l3); + mv.visitLabel(l2); + mv.visitLineNumber(1570, l2); + mv.visitFrame(F_SAME1, 0, null, 1, new Object[] {"java/lang/Throwable"}); + mv.visitVarInsn(ASTORE, 2); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(1571, l4); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitLdcInsn("[BMTE] Bad Tile Entity set in world, your game would have crashed if not for me!"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(1572, l5); + mv.visitVarInsn(ALOAD, 1); + Label l6 = new Label(); + mv.visitJumpInsn(IFNULL, l6); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(1573, l7); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); + mv.visitInsn(DUP); + mv.visitLdcInsn("Tile was of type: "); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "(Ljava/lang/String;)V", false); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEINTERFACE, "gregtech/api/interfaces/metatileentity/IMetaTileEntity", "getInventoryName", "()Ljava/lang/String;", true); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + mv.visitLabel(l6); + mv.visitLineNumber(1574, l6); + mv.visitFrame(F_APPEND,1, new Object[] {"java/lang/Throwable"}, 0, null); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Throwable", "printStackTrace", "()V", false); + mv.visitLabel(l3); + mv.visitLineNumber(1576, l3); + mv.visitFrame(F_CHOP,1, null, 0, null); + mv.visitInsn(RETURN); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLocalVariable("this", "Lgregtech/api/metatileentity/BaseMetaTileEntity;", null, l0, l8, 0); + mv.visitLocalVariable("aMetaTileEntity", "Lgregtech/api/interfaces/metatileentity/IMetaTileEntity;", null, l0, l8, 1); + mv.visitLocalVariable("t", "Ljava/lang/Throwable;", null, l4, l3, 2); + mv.visitMaxs(4, 3); + mv.visitEnd(); + + didInject = true; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + public final class localClassVisitor extends ClassVisitor { + + public localClassVisitor(ClassVisitor cv) { + super(ASM5, cv); + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + if (name.equals("setMetaTileEntity")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Found method "+name+", removing."); + methodVisitor = null; + } + else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + return methodVisitor; + } + } + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java index 85300c043c..f71615b7c1 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_BlockMachines_MetaPipeEntity.java @@ -19,7 +19,9 @@ import org.objectweb.asm.MethodVisitor; import cpw.mods.fml.relauncher.FMLRelaunchLog; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; +import gregtech.api.enums.SubTag; import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -45,6 +47,9 @@ public class ClassTransformer_GT_BlockMachines_MetaPipeEntity { return "wrench"; } + /* + * Used to patch the method in Fluid pipes, Frame Boxes and Item Pipes + */ /** * This determines the BaseMetaTileEntity belonging to this MetaTileEntity by using the Meta ID of the Block itself. * <p/> @@ -68,15 +73,20 @@ public class ClassTransformer_GT_BlockMachines_MetaPipeEntity { * <p/> * == Reserved For Alkalus (Was previously used to allow axes on wooden blocks, but that's fucking stupid.) * <p/> - * 12 = BaseMetaTileEntity, Wrench lvl 0 to dismantle - * 13 = BaseMetaTileEntity, Wrench lvl 1 to dismantle + * 12 = BaseCustomPower_MTE, Wrench lvl 0 to dismantle + * 13 = BaseCustomTileEntity, Wrench lvl 1 to dismantle * <p/> - * 14 = BaseMetaTileEntity, Wrench lvl 2 to dismantle - * 15 = BaseMetaTileEntity, Wrench lvl 3 to dismantle + * 14 = BaseCustomTileEntity, Wrench lvl 2 to dismantle + * 15 = BaseCustomTileEntity, Wrench lvl 3 to dismantle */ public static byte getTileEntityBaseType(Materials mMaterial) { - //FMLRelaunchLog.log("[GT++ ASM] Gregtech getTileEntityBaseType Patch", Level.INFO, "Attempting to call getTileEntityBaseType."); - return (byte) (mMaterial == null ? 4 : (byte) (4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); + byte mMetaID; + //Modified code that should never return 12-15 for Wooden items. + //mMetaID = (byte) (mMaterial == null ? 4 : (byte) (4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); + //Original Code for debug purposes + mMetaID = mMaterial == null ? 4 : (byte) ((mMaterial.contains(SubTag.WOOD) ? 4 : 4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); + //FMLRelaunchLog.log("[GT++ ASM] Gregtech getTileEntityBaseType Patch", Level.INFO, "Attempting to call getTileEntityBaseType. Using Meta: "+mMetaID); + return mMetaID; } @@ -104,11 +114,11 @@ public class ClassTransformer_GT_BlockMachines_MetaPipeEntity { * <p/> * == Reserved For Alkalus (Was previously used to allow axes on wooden blocks, but that's fucking stupid.) * <p/> - * 12 = BaseMetaTileEntity, Wrench lvl 2 to dismantle - * 13 = BaseMetaTileEntity, Wrench lvl 2 to dismantle + * 12 = BaseCustomPower_MTE, Wrench lvl 2 to dismantle + * 13 = BaseCustomTileEntity, Wrench lvl 2 to dismantle * <p/> - * 14 = BaseMetaTileEntity, Wrench lvl 3 to dismantle - * 15 = BaseMetaTileEntity, Wrench lvl 3 to dismantle + * 14 = BaseCustomTileEntity, Wrench lvl 3 to dismantle + * 15 = BaseCustomTileEntity, Wrench lvl 3 to dismantle */ public static TileEntity createTileEntity(World aWorld, int aMeta) { //Logger.INFO("Creating Tile Entity with Meta of "+aMeta); @@ -121,12 +131,21 @@ public class ClassTransformer_GT_BlockMachines_MetaPipeEntity { try { return Meta_GT_Proxy.constructCustomGregtechMetaTileEntityByMeta(aMeta); } - catch (ClassCastException c) { + catch (Throwable c) { //Returns a pipe entity, once this returns, it should correct itself and no longer error in future. return new BaseMetaPipeEntity(); } } } + + public static TileEntity createTileEntity_Original(World aWorld, int aMeta) { + // Logger.INFO("Creating Tile Entity with Meta of "+aMeta); + if (aMeta < 4) { + return GregTech_API.constructBaseMetaTileEntity(); + } else { + return new BaseMetaPipeEntity(); + } + } int mMode; diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java new file mode 100644 index 0000000000..eb33366401 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java @@ -0,0 +1,581 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; +import static org.objectweb.asm.Opcodes.ALOAD; +import static org.objectweb.asm.Opcodes.ASM5; +import static org.objectweb.asm.Opcodes.INVOKESTATIC; +import static org.objectweb.asm.Opcodes.RETURN; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.lang.reflect.Field; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.UUID; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.google.common.reflect.ClassPath; +import com.google.common.reflect.ClassPath.ClassInfo; + +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_PlayedSound; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import gtPlusPlus.xmod.gregtech.loaders.misc.AssLineAchievements; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatFileWriter; + +public class ClassTransformer_GT_Client { + + private final boolean valid; + private final ClassReader read; + private final ClassWriter write; + private boolean mModern; + private byte[] mTooledClass; + + public ClassTransformer_GT_Client(byte[] basicClass) { + + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + + /** + * Let's just read the GT archive for some info + */ + mModern = findAssemblyLineClass(); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Found Assembly Line? "+mModern+"."); + if (mModern) { + aTempReader.accept(new MethodAdaptor2(aTempWriter), 0); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patching Client handling of Assembly Line recipe visibility for GT 5.09"); + injectMethod(aTempWriter); + if (aTempReader != null && aTempWriter != null) { + valid = true; + mTooledClass = aTempWriter.toByteArray(); + } + else { + valid = false; + } + } + else { + mTooledClass = basicClass; + valid = true; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Valid? "+valid+"."); + read = aTempReader; + write = aTempWriter; + } + + public boolean isValidTransformer() { + return valid; + } + + public ClassReader getReader() { + return read; + } + + public ClassWriter getWriter() { + return write; + } + + public boolean findAssemblyLineClass() { + ClassLoader cl = getClass().getClassLoader(); + try { + Set<ClassPath.ClassInfo> classesInPackage = ClassPath.from(cl).getTopLevelClassesRecursive("gregtech"); + if (classesInPackage != null && classesInPackage.size() > 0) { + for (ClassInfo x : classesInPackage) { + if (x.getResourceName().contains("GT_MetaTileEntity_AssemblyLine")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, + "Patchable class | " + x.getResourceName()); + return true; + } + } + } + } catch (IOException e) { + } + + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Failed to find Gregtech classes using prefered method, using backup."); + + cl = ClassLoader.getSystemClassLoader(); + ImmutableMap<File, ClassLoader> g = getClassPathEntries(cl); + File aGregtech = null; + if (g.size() > 0) { + for (int i = 0; i < g.size(); i++) { + String aName; + try { + File aF = g.keySet().asList().get(i); + aName = aF.getName(); + if (aName != null && aName.length() > 0) { + if (aName.toLowerCase().contains("gregtech")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patchable class | "+aName); + aGregtech = aF; + } + } + } + catch (Throwable t) {} + } + } + + if (aGregtech != null) { + try { + File file = aGregtech; + FileInputStream fis = new FileInputStream(file); + JarInputStream jis = new JarInputStream(fis); + System.out.println(jis.markSupported()); + JarEntry je; + while((je=jis.getNextJarEntry())!=null){ + if (je.getName().contains("GT_MetaTileEntity_AssemblyLine")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Patchable class | "+je.getName()); + return true; + } + } + jis.close(); + return true; + } catch (IOException e1) { + } + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Failed to find Gregtech classes using backup method, probably using GT 5.08"); + + return false; + } + + static ImmutableMap<File, ClassLoader> getClassPathEntries(ClassLoader classloader) { + LinkedHashMap<File, ClassLoader> entries = Maps.newLinkedHashMap(); + // Search parent first, since it's the order ClassLoader#loadClass() uses. + ClassLoader parent = classloader.getParent(); + if (parent != null) { + entries.putAll(getClassPathEntries(parent)); + } + if (classloader instanceof URLClassLoader) { + URLClassLoader urlClassLoader = (URLClassLoader) classloader; + for (URL entry : urlClassLoader.getURLs()) { + if (entry.getProtocol().equals("file")) { + File file = new File(entry.getFile()); + if (!entries.containsKey(file)) { + entries.put(file, classloader); + } + } + } + } + return ImmutableMap.copyOf(entries); + } + + public boolean injectMethod(ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Injecting " + "onPlayerTickEventClient" + "."); + + /** + * Inject new, safer code + */ + + AnnotationVisitor av0; + + + /** + * Full Patch ASM - Original Idea, now second to static injection of a custom handler. + */ + + /*mv = cw.visitMethod(ACC_PUBLIC, "onPlayerTickEventClient", "(Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;)V", null, null); + { + av0 = mv.visitAnnotation("Lcpw/mods/fml/common/eventhandler/SubscribeEvent;", true); + av0.visitEnd(); + } + mv.visitCode(); + Label l0 = new Label(); + Label l1 = new Label(); + Label l2 = new Label(); + mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Exception"); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(370, l3); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "side", "Lcpw/mods/fml/relauncher/Side;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "cpw/mods/fml/relauncher/Side", "isClient", "()Z", false); + Label l4 = new Label(); + mv.visitJumpInsn(IFEQ, l4); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "phase", "Lcpw/mods/fml/common/gameevent/TickEvent$Phase;"); + mv.visitFieldInsn(GETSTATIC, "cpw/mods/fml/common/gameevent/TickEvent$Phase", "END", "Lcpw/mods/fml/common/gameevent/TickEvent$Phase;"); + mv.visitJumpInsn(IF_ACMPNE, l4); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(GETFIELD, "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "player", "Lnet/minecraft/entity/player/EntityPlayer;"); + mv.visitFieldInsn(GETFIELD, "net/minecraft/entity/player/EntityPlayer", "isDead", "Z"); + mv.visitJumpInsn(IFNE, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(371, l5); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(DUP); + mv.visitFieldInsn(GETFIELD, "gregtech/common/GT_Client", "afterSomeTime", "J"); + mv.visitInsn(LCONST_1); + mv.visitInsn(LADD); + mv.visitFieldInsn(PUTFIELD, "gregtech/common/GT_Client", "afterSomeTime", "J"); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(372, l6); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/common/GT_Client", "afterSomeTime", "J"); + mv.visitLdcInsn(new Long(100L)); + mv.visitInsn(LCMP); + Label l7 = new Label(); + mv.visitJumpInsn(IFLT, l7); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLineNumber(373, l8); + mv.visitVarInsn(ALOAD, 0); + mv.visitInsn(LCONST_0); + mv.visitFieldInsn(PUTFIELD, "gregtech/common/GT_Client", "afterSomeTime", "J"); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(374, l9); + mv.visitMethodInsn(INVOKESTATIC, "net/minecraft/client/Minecraft", "getMinecraft", "()Lnet/minecraft/client/Minecraft;", false); + mv.visitFieldInsn(GETFIELD, "net/minecraft/client/Minecraft", "thePlayer", "Lnet/minecraft/client/entity/EntityClientPlayerMP;"); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/client/entity/EntityClientPlayerMP", "getStatFileWriter", "()Lnet/minecraft/stats/StatFileWriter;", false); + mv.visitVarInsn(ASTORE, 2); + mv.visitLabel(l0); + mv.visitLineNumber(376, l0); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Recipe$GT_Recipe_Map", "sAssemblylineVisualRecipes", "Lgregtech/api/util/GT_Recipe$GT_Recipe_Map;"); + mv.visitFieldInsn(GETFIELD, "gregtech/api/util/GT_Recipe$GT_Recipe_Map", "mRecipeList", "Ljava/util/Collection;"); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Collection", "iterator", "()Ljava/util/Iterator;", true); + mv.visitVarInsn(ASTORE, 4); + Label l10 = new Label(); + mv.visitJumpInsn(GOTO, l10); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter", TOP, "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/util/GT_Recipe"); + mv.visitVarInsn(ASTORE, 3); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(377, l12); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 3); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/util/GT_Recipe", "getOutput", "(I)Lnet/minecraft/item/ItemStack;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", "getUnlocalizedName", "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements", "getAchievement", "(Ljava/lang/String;)Lnet/minecraft/stats/Achievement;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/stats/StatFileWriter", "hasAchievementUnlocked", "(Lnet/minecraft/stats/Achievement;)Z", false); + Label l13 = new Label(); + mv.visitJumpInsn(IFEQ, l13); + mv.visitInsn(ICONST_0); + Label l14 = new Label(); + mv.visitJumpInsn(GOTO, l14); + mv.visitLabel(l13); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter", "gregtech/api/util/GT_Recipe", "java/util/Iterator"}, 1, new Object[] {"gregtech/api/util/GT_Recipe"}); + mv.visitInsn(ICONST_1); + mv.visitLabel(l14); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter", "gregtech/api/util/GT_Recipe", "java/util/Iterator"}, 2, new Object[] {"gregtech/api/util/GT_Recipe", INTEGER}); + mv.visitFieldInsn(PUTFIELD, "gregtech/api/util/GT_Recipe", "mHidden", "Z"); + mv.visitLabel(l10); + mv.visitLineNumber(376, l10); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter", TOP, "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true); + mv.visitJumpInsn(IFNE, l11); + mv.visitLabel(l1); + mv.visitLineNumber(379, l1); + mv.visitJumpInsn(GOTO, l7); + mv.visitLabel(l2); + mv.visitFrame(F_FULL, 3, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "net/minecraft/stats/StatFileWriter"}, 1, new Object[] {"java/lang/Exception"}); + mv.visitVarInsn(ASTORE, 3); + mv.visitLabel(l7); + mv.visitLineNumber(381, l7); + mv.visitFrame(F_CHOP,1, null, 0, null); + mv.visitTypeInsn(NEW, "java/util/ArrayList"); + mv.visitInsn(DUP); + mv.visitMethodInsn(INVOKESPECIAL, "java/util/ArrayList", "<init>", "()V", false); + mv.visitVarInsn(ASTORE, 2); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLineNumber(382, l15); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Utility", "sPlayedSoundMap", "Ljava/util/Map;"); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map", "entrySet", "()Ljava/util/Set;", true); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Set", "iterator", "()Ljava/util/Iterator;", true); + mv.visitVarInsn(ASTORE, 4); + Label l16 = new Label(); + mv.visitJumpInsn(GOTO, l16); + Label l17 = new Label(); + mv.visitLabel(l17); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "java/util/ArrayList", TOP, "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "java/util/Map$Entry"); + mv.visitVarInsn(ASTORE, 3); + Label l18 = new Label(); + mv.visitLabel(l18); + mv.visitLineNumber(383, l18); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "getValue", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "java/lang/Integer"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false); + Label l19 = new Label(); + mv.visitJumpInsn(IFGE, l19); + Label l20 = new Label(); + mv.visitLabel(l20); + mv.visitLineNumber(384, l20); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "getKey", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/util/GT_PlayedSound"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "add", "(Ljava/lang/Object;)Z", false); + mv.visitInsn(POP); + Label l21 = new Label(); + mv.visitLabel(l21); + mv.visitLineNumber(385, l21); + mv.visitJumpInsn(GOTO, l16); + mv.visitLabel(l19); + mv.visitLineNumber(386, l19); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "java/util/ArrayList", "java/util/Map$Entry", "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 3); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "getValue", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "java/lang/Integer"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I", false); + mv.visitInsn(ICONST_1); + mv.visitInsn(ISUB); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;", false); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map$Entry", "setValue", "(Ljava/lang/Object;)Ljava/lang/Object;", true); + mv.visitInsn(POP); + mv.visitLabel(l16); + mv.visitLineNumber(382, l16); + mv.visitFrame(F_FULL, 5, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent", "java/util/ArrayList", TOP, "java/util/Iterator"}, 0, new Object[] {}); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true); + mv.visitJumpInsn(IFNE, l17); + Label l22 = new Label(); + mv.visitLabel(l22); + mv.visitLineNumber(390, l22); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/util/ArrayList", "iterator", "()Ljava/util/Iterator;", false); + mv.visitVarInsn(ASTORE, 4); + Label l23 = new Label(); + mv.visitLabel(l23); + Label l24 = new Label(); + mv.visitJumpInsn(GOTO, l24); + Label l25 = new Label(); + mv.visitLabel(l25); + mv.visitLineNumber(391, l25); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/util/GT_PlayedSound"); + mv.visitVarInsn(ASTORE, 3); + Label l26 = new Label(); + mv.visitLabel(l26); + mv.visitLineNumber(390, l26); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Utility", "sPlayedSoundMap", "Ljava/util/Map;"); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map", "remove", "(Ljava/lang/Object;)Ljava/lang/Object;", true); + mv.visitInsn(POP); + mv.visitLabel(l24); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 4); + mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true); + mv.visitJumpInsn(IFNE, l25); + Label l27 = new Label(); + mv.visitLabel(l27); + mv.visitLineNumber(393, l27); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/GregTech_API", "mServerStarted", "Z"); + mv.visitJumpInsn(IFNE, l4); + Label l28 = new Label(); + mv.visitLabel(l28); + mv.visitLineNumber(394, l28); + mv.visitInsn(ICONST_1); + mv.visitFieldInsn(PUTSTATIC, "gregtech/api/GregTech_API", "mServerStarted", "Z"); + mv.visitLabel(l4); + mv.visitLineNumber(397, l4); + mv.visitFrame(F_FULL, 2, new Object[] {"gregtech/common/GT_Client", "cpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent"}, 0, new Object[] {}); + mv.visitInsn(RETURN); + Label l29 = new Label(); + mv.visitLabel(l29); + mv.visitLocalVariable("this", "Lgregtech/common/GT_Client;", null, l3, l29, 0); + mv.visitLocalVariable("aEvent", "Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;", null, l3, l29, 1); + mv.visitLocalVariable("sfw", "Lnet/minecraft/stats/StatFileWriter;", null, l0, l7, 2); + mv.visitLocalVariable("recipe", "Lgregtech/api/util/GT_Recipe;", null, l12, l10, 3); + mv.visitLocalVariable("tList", "Ljava/util/ArrayList;", "Ljava/util/ArrayList<Lgregtech/api/util/GT_PlayedSound;>;", l15, l4, 2); + mv.visitLocalVariable("tEntry", "Ljava/util/Map$Entry;", "Ljava/util/Map$Entry<Lgregtech/api/util/GT_PlayedSound;Ljava/lang/Integer;>;", l18, l16, 3); + mv.visitLocalVariable("tKey", "Lgregtech/api/util/GT_PlayedSound;", null, l26, l24, 3); + mv.visitLocalVariable("i", "Ljava/util/Iterator;", "Ljava/util/Iterator<Lgregtech/api/util/GT_PlayedSound;>;", l23, l27, 4); + mv.visitMaxs(5, 5); + mv.visitEnd();*/ + + /** + * Static invocation of custom handler instead + */ + + + mv = cw.visitMethod(ACC_PUBLIC, "onPlayerTickEventClient", "(Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;)V", null, null); + av0 = mv.visitAnnotation("Lcpw/mods/fml/common/eventhandler/SubscribeEvent;", true); + av0.visitEnd(); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(371, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKESTATIC, "gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client", "onPlayerTickEventClient", "(Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;)V", false); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(372, l1); + mv.visitInsn(RETURN); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLocalVariable("this", "Lgregtech/common/GT_Client;", null, l0, l2, 0); + mv.visitLocalVariable("aEvent", "Lcpw/mods/fml/common/gameevent/TickEvent$PlayerTickEvent;", null, l0, l2, 1); + mv.visitMaxs(1, 2); + mv.visitEnd(); + + + didInject = true; + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Method injection complete."); + return didInject; + + } + + public class MethodAdaptor2 extends ClassVisitor { + + public MethodAdaptor2(ClassVisitor cv) { + super(ASM5, cv); + this.cv = cv; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + if (name.equals("onPlayerTickEventClient")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, + "Found method " + name + ", removing."); + methodVisitor = null; + } else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + return methodVisitor; + } + } + + public byte[] getByteArray() { + if (mTooledClass != null) { + return mTooledClass; + } + return getWriter().toByteArray(); + } + + + private static final Map<UUID, Long> aTimeMap = new HashMap<UUID, Long>(); + + + public static void onPlayerTickEventClient(PlayerTickEvent aEvent) { + if (aEvent.side.isClient() && aEvent.phase == Phase.END && !aEvent.player.isDead) { + long aTime = 0; + if (aTimeMap.get(aEvent.player.getUniqueID()) == null) { + aTimeMap.put(aEvent.player.getUniqueID(), 0l); + } + else { + aTime = aTimeMap.get(aEvent.player.getUniqueID()) + 1; + aTimeMap.put(aEvent.player.getUniqueID(), aTime); + } + if (aTime >= 100L) { + aTimeMap.put(aEvent.player.getUniqueID(), 0l); + /** + * Remove original handling + */ + if (StaticFields59.mAssLineVisualMapNEI != null) { + StatFileWriter tList = Minecraft.getMinecraft().thePlayer.getStatFileWriter(); + GT_Recipe_Map aAssLineNei; + try { + aAssLineNei = (GT_Recipe_Map) StaticFields59.mAssLineVisualMapNEI.get(null); + for (GT_Recipe aFakeAssLineRecipe : aAssLineNei.mRecipeList) { + String aSafeUnlocalName; + if (aFakeAssLineRecipe.getOutput(0) == null) { + Logger.INFO( + "Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + continue; + } + ItemStack aStack = aFakeAssLineRecipe.getOutput(0); + try { + aSafeUnlocalName = aStack.getUnlocalizedName(); + } catch (Throwable t) { + aSafeUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + } + boolean aHidden = true; + try { + aHidden = tList.hasAchievementUnlocked(AssLineAchievements.getAchievement(aSafeUnlocalName)); + Logger.INFO("Found achievement for "+aSafeUnlocalName); + } + catch (NullPointerException rrr) { + aHidden = true; + //Logger.INFO("Exception handling achievement for "+aSafeUnlocalName); + //rrr.printStackTrace(); + } + aFakeAssLineRecipe.mHidden = !aHidden; + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } + } + + Iterator tKey; + ArrayList arg5 = new ArrayList(); + tKey = GT_Utility.sPlayedSoundMap.entrySet().iterator(); + + while (tKey.hasNext()) { + Entry arg7 = (Entry) tKey.next(); + if (((Integer) arg7.getValue()).intValue() < 0) { + arg5.add(arg7.getKey()); + } else { + arg7.setValue(Integer.valueOf(((Integer) arg7.getValue()).intValue() - 1)); + } + } + + Iterator arg8 = arg5.iterator(); + + while (arg8.hasNext()) { + GT_PlayedSound arg6 = (GT_PlayedSound) arg8.next(); + GT_Utility.sPlayedSoundMap.remove(arg6); + } + + if (!GregTech_API.mServerStarted) { + GregTech_API.mServerStarted = true; + } + } + } + + + + + + + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Packet_TileEntity.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Packet_TileEntity.java new file mode 100644 index 0000000000..1f281ce492 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Packet_TileEntity.java @@ -0,0 +1,319 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; + +public class ClassTransformer_GT_Packet_TileEntity { + + //The qualified name of the class we plan to transform. + //gregtech/common/blocks/GT_Block_Machines + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + + public ClassTransformer_GT_Packet_TileEntity(byte[] basicClass, boolean obfuscated) { + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Attempting to make GT Packets safer."); + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + aTempReader.accept(new localClassVisitor(aTempWriter), 0); + + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Valid patch? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + + + if (reader != null && writer != null) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Attempting Method Injection."); + injectMethod("process", obfuscated); + } + + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean injectMethod(String aMethodName, boolean obfuscated) { + MethodVisitor mv; + boolean didInject = false; + String aGetTile = obfuscated ? "func_147438_o" : "getTileEntity"; + + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Injecting "+aMethodName+"."); + if (aMethodName.equals("process")) { + mv = getWriter().visitMethod(ACC_PUBLIC, "process", "(Lnet/minecraft/world/IBlockAccess;)V", null, null); + mv.visitCode(); + Label l0 = new Label(); + Label l1 = new Label(); + Label l2 = new Label(); + mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Throwable"); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(93, l3); + mv.visitVarInsn(ALOAD, 1); + Label l4 = new Label(); + mv.visitJumpInsn(IFNULL, l4); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(94, l5); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mX", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mY", "S"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mZ", "I"); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraft/world/IBlockAccess", ""+aGetTile+"", "(III)Lnet/minecraft/tileentity/TileEntity;", true); + mv.visitVarInsn(ASTORE, 2); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(95, l6); + mv.visitVarInsn(ALOAD, 2); + mv.visitJumpInsn(IFNULL, l4); + mv.visitLabel(l0); + mv.visitLineNumber(97, l0); + mv.visitVarInsn(ALOAD, 2); + mv.visitTypeInsn(INSTANCEOF, "gregtech/api/metatileentity/BaseMetaTileEntity"); + Label l7 = new Label(); + mv.visitJumpInsn(IFEQ, l7); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLineNumber(98, l8); + mv.visitVarInsn(ALOAD, 2); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/metatileentity/BaseMetaTileEntity"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mID", "S"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC0", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC1", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC2", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC3", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC4", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC5", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mTexture", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mTexturePage", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mUpdate", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mRedstone", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mColor", "B"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/metatileentity/BaseMetaTileEntity", "receiveMetaTileEntityData", "(SIIIIIIBBBBB)V", false); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(99, l9); + mv.visitJumpInsn(GOTO, l4); + mv.visitLabel(l7); + mv.visitLineNumber(101, l7); + mv.visitFrame(F_APPEND,1, new Object[] {"net/minecraft/tileentity/TileEntity"}, 0, null); + mv.visitVarInsn(ALOAD, 2); + mv.visitTypeInsn(INSTANCEOF, "gregtech/api/metatileentity/BaseMetaPipeEntity"); + mv.visitJumpInsn(IFEQ, l4); + Label l10 = new Label(); + mv.visitLabel(l10); + mv.visitLineNumber(102, l10); + mv.visitVarInsn(ALOAD, 2); + mv.visitTypeInsn(CHECKCAST, "gregtech/api/metatileentity/BaseMetaPipeEntity"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mID", "S"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC0", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC1", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC2", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC3", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC4", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mC5", "I"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mTexture", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mUpdate", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mRedstone", "B"); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mColor", "B"); + mv.visitMethodInsn(INVOKEVIRTUAL, "gregtech/api/metatileentity/BaseMetaPipeEntity", "receiveMetaTileEntityData", "(SIIIIIIBBBB)V", false); + mv.visitLabel(l1); + mv.visitLineNumber(104, l1); + mv.visitJumpInsn(GOTO, l4); + mv.visitLabel(l2); + mv.visitLineNumber(105, l2); + mv.visitFrame(F_SAME1, 0, null, 1, new Object[] {"java/lang/Throwable"}); + mv.visitVarInsn(ASTORE, 3); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(106, l11); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); + mv.visitInsn(DUP); + mv.visitLdcInsn("[GTPTE] Bad Tile Entity set in world, your game would have crashed if not for me! Was Null? "); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "(Ljava/lang/String;)V", false); + mv.visitVarInsn(ALOAD, 2); + Label l12 = new Label(); + mv.visitJumpInsn(IFNONNULL, l12); + mv.visitInsn(ICONST_1); + Label l13 = new Label(); + mv.visitJumpInsn(GOTO, l13); + mv.visitLabel(l12); + mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/api/net/GT_Packet_TileEntity", "net/minecraft/world/IBlockAccess", "net/minecraft/tileentity/TileEntity", "java/lang/Throwable"}, 2, new Object[] {"java/io/PrintStream", "java/lang/StringBuilder"}); + mv.visitInsn(ICONST_0); + mv.visitLabel(l13); + mv.visitFrame(F_FULL, 4, new Object[] {"gregtech/api/net/GT_Packet_TileEntity", "net/minecraft/world/IBlockAccess", "net/minecraft/tileentity/TileEntity", "java/lang/Throwable"}, 3, new Object[] {"java/io/PrintStream", "java/lang/StringBuilder", INTEGER}); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Z)Ljava/lang/StringBuilder;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLineNumber(107, l14); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); + mv.visitInsn(DUP); + mv.visitLdcInsn("Tile location ["); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "<init>", "(Ljava/lang/String;)V", false); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mX", "I"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(I)Ljava/lang/StringBuilder;", false); + mv.visitLdcInsn("]["); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mY", "S"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(I)Ljava/lang/StringBuilder;", false); + mv.visitLdcInsn("]["); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, "gregtech/api/net/GT_Packet_TileEntity", "mZ", "I"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(I)Ljava/lang/StringBuilder;", false); + mv.visitLdcInsn("]"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + Label l15 = new Label(); + mv.visitLabel(l15); + mv.visitLineNumber(108, l15); + mv.visitVarInsn(ALOAD, 2); + Label l16 = new Label(); + mv.visitJumpInsn(IFNULL, l16); + Label l17 = new Label(); + mv.visitLabel(l17); + mv.visitLineNumber(109, l17); + mv.visitVarInsn(ALOAD, 2); + mv.visitTypeInsn(INSTANCEOF, "gregtech/api/metatileentity/BaseMetaPipeEntity"); + Label l18 = new Label(); + mv.visitJumpInsn(IFEQ, l18); + Label l19 = new Label(); + mv.visitLabel(l19); + mv.visitLineNumber(110, l19); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitLdcInsn("Type: Pipe"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + Label l20 = new Label(); + mv.visitLabel(l20); + mv.visitLineNumber(111, l20); + mv.visitJumpInsn(GOTO, l16); + mv.visitLabel(l18); + mv.visitLineNumber(112, l18); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 2); + mv.visitTypeInsn(INSTANCEOF, "gregtech/api/metatileentity/BaseMetaTileEntity"); + Label l21 = new Label(); + mv.visitJumpInsn(IFEQ, l21); + Label l22 = new Label(); + mv.visitLabel(l22); + mv.visitLineNumber(113, l22); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitLdcInsn("Type: Machine"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + Label l23 = new Label(); + mv.visitLabel(l23); + mv.visitLineNumber(114, l23); + mv.visitJumpInsn(GOTO, l16); + mv.visitLabel(l21); + mv.visitLineNumber(116, l21); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitFieldInsn(GETSTATIC, "gregtech/api/util/GT_Log", "err", "Ljava/io/PrintStream;"); + mv.visitLdcInsn("Type: Non-GT (Could be GT++/TT/BW)"); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false); + mv.visitLabel(l16); + mv.visitLineNumber(119, l16); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 3); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Throwable", "printStackTrace", "()V", false); + mv.visitLabel(l4); + mv.visitLineNumber(123, l4); + mv.visitFrame(F_CHOP,2, null, 0, null); + mv.visitInsn(RETURN); + Label l24 = new Label(); + mv.visitLabel(l24); + mv.visitLocalVariable("this", "Lgregtech/api/net/GT_Packet_TileEntity;", null, l3, l24, 0); + mv.visitLocalVariable("aWorld", "Lnet/minecraft/world/IBlockAccess;", null, l3, l24, 1); + mv.visitLocalVariable("tTileEntity", "Lnet/minecraft/tileentity/TileEntity;", null, l6, l4, 2); + mv.visitLocalVariable("t", "Ljava/lang/Throwable;", null, l11, l4, 3); + mv.visitMaxs(13, 4); + mv.visitEnd(); + + + didInject = true; + } + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + public final class localClassVisitor extends ClassVisitor { + + public localClassVisitor(ClassVisitor cv) { + super(ASM5, cv); + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor methodVisitor; + if (name.equals("process")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Found method "+name+", removing."); + methodVisitor = null; + } + else { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + return methodVisitor; + } + } + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_IC2_GetHarvestTool.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_IC2_GetHarvestTool.java index 1e67619337..6aad6831cb 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_IC2_GetHarvestTool.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_IC2_GetHarvestTool.java @@ -22,6 +22,9 @@ public class ClassTransformer_IC2_GetHarvestTool { private final ClassWriter writer; private final String className; + private final String aName_getItemDropped; + private final String aName_damageDropped; + public static String getHarvestTool(int aMeta) { return "wrench"; } @@ -37,10 +40,13 @@ public class ClassTransformer_IC2_GetHarvestTool { public ClassTransformer_IC2_GetHarvestTool(byte[] basicClass, boolean obfuscated, String aClassName) { className = aClassName; ClassReader aTempReader = null; - ClassWriter aTempWriter = null; + ClassWriter aTempWriter = null; + + aName_getItemDropped = obfuscated ? "func_149650_a" : "getItemDropped"; + aName_damageDropped = obfuscated ? "func_149692_a" : "damageDropped"; FMLRelaunchLog.log("[GT++ ASM] IC2 getHarvestTool Patch", Level.INFO, - "Attempting to patch in mode " + className + "."); + "Attempting to patch in mode " + className + ". Obfuscated? "+obfuscated); aTempReader = new ClassReader(basicClass); aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); @@ -51,6 +57,7 @@ public class ClassTransformer_IC2_GetHarvestTool { } else { isValid = false; } + FMLRelaunchLog.log("[GT++ ASM] IC2 getHarvestTool Patch", Level.INFO, "Valid patch? " + isValid + "."); reader = aTempReader; writer = aTempWriter; @@ -58,15 +65,15 @@ public class ClassTransformer_IC2_GetHarvestTool { if (reader != null && writer != null) { FMLRelaunchLog.log("[GT++ ASM] IC2 getHarvestTool Patch", Level.INFO, "Attempting Method Injection."); injectMethod("getHarvestTool"); - if (aClassName.equals("ic2.core.block.machine.BlockMachine2") - || aClassName.equals("ic2.core.block.machine.BlockMachine3")) { - injectMethod("getItemDropped"); - injectMethod("damageDropped"); + || aClassName.equals("ic2.core.block.machine.BlockMachine3") + || aClassName.equals("ic2.core.block.wiring.BlockElectric")) { + injectMethod(aName_getItemDropped); + injectMethod(aName_damageDropped); } else if (aClassName.equals("ic2.core.block.generator.block.BlockGenerator") || aClassName.equals("ic2.core.block.machine.BlockMachine")) { - injectMethod("damageDropped"); + injectMethod(aName_damageDropped); } } @@ -111,8 +118,8 @@ public class ClassTransformer_IC2_GetHarvestTool { mv.visitEnd(); didInject = true; } - else if (aMethodName.equals("getItemDropped")) { - mv = cw.visitMethod(ACC_PUBLIC, "getItemDropped", "(ILjava/util/Random;I)Lnet/minecraft/item/Item;", null, null); + else if (aMethodName.equals(aName_getItemDropped)) { + mv = cw.visitMethod(ACC_PUBLIC, aName_getItemDropped, "(ILjava/util/Random;I)Lnet/minecraft/item/Item;", null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); @@ -133,8 +140,8 @@ public class ClassTransformer_IC2_GetHarvestTool { mv.visitEnd(); didInject = true; } - else if (aMethodName.equals("damageDropped")) { - mv = cw.visitMethod(ACC_PUBLIC, "damageDropped", "(I)I", null, null); + else if (aMethodName.equals(aName_damageDropped)) { + mv = cw.visitMethod(ACC_PUBLIC, aName_damageDropped, "(I)I", null, null); mv.visitCode(); Label l0 = new Label(); mv.visitLabel(l0); @@ -167,10 +174,11 @@ public class ClassTransformer_IC2_GetHarvestTool { public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { MethodVisitor methodVisitor; if (aClassName.equals("ic2.core.block.machine.BlockMachine2") - || aClassName.equals("ic2.core.block.machine.BlockMachine3")) { - if (name.equals("getItemDropped")) { + || aClassName.equals("ic2.core.block.machine.BlockMachine3") + || aClassName.equals("ic2.core.block.wiring.BlockElectric")) { + if (name.equals(aName_getItemDropped)) { methodVisitor = null; - } else if (name.equals("damageDropped")) { + } else if (name.equals(aName_damageDropped)) { methodVisitor = null; } else if (name.equals("getHarvestTool")) { methodVisitor = null; @@ -180,7 +188,7 @@ public class ClassTransformer_IC2_GetHarvestTool { } else if (aClassName.equals("ic2.core.block.generator.block.BlockGenerator") || aClassName.equals("ic2.core.block.machine.BlockMachine")) { - if (name.equals("damageDropped")) { + if (name.equals(aName_damageDropped)) { methodVisitor = null; } else if (name.equals("getHarvestTool")) { methodVisitor = null; diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidHelper.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidHelper.java index 7359bbeb53..d1e2f1acb3 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidHelper.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidHelper.java @@ -2,6 +2,8 @@ package gtPlusPlus.preloader.asm.transformers; import static org.objectweb.asm.Opcodes.*; +import java.lang.reflect.Method; + import org.apache.logging.log4j.Level; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; @@ -11,6 +13,7 @@ import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import cpw.mods.fml.relauncher.FMLRelaunchLog; +import net.minecraft.inventory.IInventory; public class ClassTransformer_Railcraft_FluidHelper { @@ -20,19 +23,54 @@ public class ClassTransformer_Railcraft_FluidHelper { public static final int PROCESS_VOLUME = 16000; - public ClassTransformer_Railcraft_FluidHelper(byte[] basicClass) { + public ClassTransformer_Railcraft_FluidHelper(byte[] basicClass, boolean obfuscated2) { ClassReader aTempReader = null; ClassWriter aTempWriter = null; FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Attempting to patch field PROCESS_VOLUME in mods.railcraft.common.fluids.FluidHelper"); + boolean obfuscated = false; + boolean a1 = false; + boolean a2 = false; + + //Find Non-Obf method + try { + Method aGetStackInSlot = IInventory.class.getDeclaredMethod("getStackInSlot", int.class); + if (aGetStackInSlot != null) { + a1 = true; + } + } catch (NoSuchMethodException | SecurityException e) {} + + //Find Obf method + try { + Method aGetStackInSlotObf = IInventory.class.getDeclaredMethod("func_70301_a", int.class); + if (aGetStackInSlotObf != null) { + a2 = true; + } + } catch (NoSuchMethodException | SecurityException e) {} + + + if (a1) { + obfuscated = false; + } + else if (a2) { + obfuscated = true; + } + else { + //Fallback + obfuscated = false; + } + FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Are we patching obfuscated methods? "+obfuscated); + aTempReader = new ClassReader(basicClass); aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); aTempReader.accept(new AddFieldAdapter(aTempWriter), 0); - injectMethod("fillContainers", aTempWriter); - injectMethod("drainContainers", aTempWriter); + + addField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, "PROCESS_VOLUME", aTempWriter); + injectMethod("fillContainers", aTempWriter, obfuscated); + injectMethod("drainContainers", aTempWriter, obfuscated); - if (aTempReader != null && aTempWriter != null && addField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, "PROCESS_VOLUME", aTempWriter)) { + if (aTempReader != null && aTempWriter != null) { isValid = true; } else { @@ -69,12 +107,12 @@ public class ClassTransformer_Railcraft_FluidHelper { return false; } - public boolean injectMethod(String aMethodName, ClassWriter cw) { + public boolean injectMethod(String aMethodName, ClassWriter cw, boolean obfuscated) { MethodVisitor mv; boolean didInject = false; FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Injecting " + aMethodName + "."); - - if (aMethodName.equals("fillContainers")) { + + if (aMethodName.equals("fillContainers") && !obfuscated) { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "fillContainers", "(Lnet/minecraftforge/fluids/IFluidHandler;Lnet/minecraft/inventory/IInventory;IILnet/minecraftforge/fluids/Fluid;)Z", null, null); mv.visitCode(); Label l0 = new Label(); @@ -208,7 +246,141 @@ public class ClassTransformer_Railcraft_FluidHelper { mv.visitEnd(); didInject = true; } - else if (aMethodName.equals("drainContainers")) { + else if (aMethodName.equals("fillContainers") && obfuscated) { + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "fillContainers", "(Lnet/minecraftforge/fluids/IFluidHandler;Lnet/minecraft/inventory/IInventory;IILnet/minecraftforge/fluids/Fluid;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(126, l0); + mv.visitVarInsn(ALOAD, 4); + Label l1 = new Label(); + mv.visitJumpInsn(IFNONNULL, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(127, l2); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + mv.visitLabel(l1); + mv.visitLineNumber(128, l1); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraft/inventory/IInventory", "func_70301_a", "(I)Lnet/minecraft/item/ItemStack;", true); + mv.visitVarInsn(ASTORE, 5); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(129, l3); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraft/inventory/IInventory", "func_70301_a", "(I)Lnet/minecraft/item/ItemStack;", true); + mv.visitVarInsn(ASTORE, 6); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(130, l4); + mv.visitVarInsn(ALOAD, 5); + mv.visitTypeInsn(NEW, "net/minecraftforge/fluids/FluidStack"); + mv.visitInsn(DUP); + mv.visitVarInsn(ALOAD, 4); + mv.visitIntInsn(SIPUSH, PROCESS_VOLUME); + mv.visitMethodInsn(INVOKESPECIAL, "net/minecraftforge/fluids/FluidStack", "<init>", "(Lnet/minecraftforge/fluids/Fluid;I)V", false); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidItemHelper", "fillContainer", "(Lnet/minecraft/item/ItemStack;Lnet/minecraftforge/fluids/FluidStack;)Lmods/railcraft/common/fluids/FluidItemHelper$FillReturn;", false); + mv.visitVarInsn(ASTORE, 7); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(131, l5); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "container", "Lnet/minecraft/item/ItemStack;"); + Label l6 = new Label(); + mv.visitJumpInsn(IFNULL, l6); + mv.visitVarInsn(ALOAD, 6); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "container", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidHelper", "hasPlaceToPutContainer", "(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(132, l7); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraftforge/common/util/ForgeDirection", "UNKNOWN", "Lnet/minecraftforge/common/util/ForgeDirection;"); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "amount", "I"); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraftforge/fluids/IFluidHandler", "drain", "(Lnet/minecraftforge/common/util/ForgeDirection;IZ)Lnet/minecraftforge/fluids/FluidStack;", true); + mv.visitVarInsn(ASTORE, 8); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLineNumber(133, l8); + mv.visitVarInsn(ALOAD, 8); + mv.visitJumpInsn(IFNULL, l6); + mv.visitVarInsn(ALOAD, 8); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/fluids/FluidStack", "amount", "I"); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "amount", "I"); + mv.visitJumpInsn(IF_ICMPNE, l6); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(134, l9); + mv.visitVarInsn(ALOAD, 5); + mv.visitVarInsn(ALOAD, 8); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidItemHelper", "fillContainer", "(Lnet/minecraft/item/ItemStack;Lnet/minecraftforge/fluids/FluidStack;)Lmods/railcraft/common/fluids/FluidItemHelper$FillReturn;", false); + mv.visitVarInsn(ASTORE, 7); + Label l10 = new Label(); + mv.visitLabel(l10); + mv.visitLineNumber(135, l10); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "container", "Lnet/minecraft/item/ItemStack;"); + Label l11 = new Label(); + mv.visitJumpInsn(IFNULL, l11); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "amount", "I"); + mv.visitVarInsn(ALOAD, 8); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/fluids/FluidStack", "amount", "I"); + mv.visitJumpInsn(IF_ICMPNE, l11); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(136, l12); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraftforge/common/util/ForgeDirection", "UNKNOWN", "Lnet/minecraftforge/common/util/ForgeDirection;"); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "amount", "I"); + mv.visitInsn(ICONST_1); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraftforge/fluids/IFluidHandler", "drain", "(Lnet/minecraftforge/common/util/ForgeDirection;IZ)Lnet/minecraftforge/fluids/FluidStack;", true); + mv.visitInsn(POP); + Label l13 = new Label(); + mv.visitLabel(l13); + mv.visitLineNumber(137, l13); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 3); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "container", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidHelper", "storeContainer", "(Lnet/minecraft/inventory/IInventory;IILnet/minecraft/item/ItemStack;)V", false); + mv.visitLabel(l11); + mv.visitLineNumber(139, l11); + mv.visitFrame(F_FULL, 9, new Object[] {"net/minecraftforge/fluids/IFluidHandler", "net/minecraft/inventory/IInventory", INTEGER, INTEGER, "net/minecraftforge/fluids/Fluid", "net/minecraft/item/ItemStack", "net/minecraft/item/ItemStack", "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "net/minecraftforge/fluids/FluidStack"}, 0, new Object[] {}); + mv.visitInsn(ICONST_1); + mv.visitInsn(IRETURN); + mv.visitLabel(l6); + mv.visitLineNumber(142, l6); + mv.visitFrame(F_CHOP,1, null, 0, null); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLocalVariable("drain", "Lnet/minecraftforge/fluids/FluidStack;", null, l8, l6, 8); + mv.visitLocalVariable("fluidHandler", "Lnet/minecraftforge/fluids/IFluidHandler;", null, l0, l14, 0); + mv.visitLocalVariable("inv", "Lnet/minecraft/inventory/IInventory;", null, l0, l14, 1); + mv.visitLocalVariable("inputSlot", "I", null, l0, l14, 2); + mv.visitLocalVariable("outputSlot", "I", null, l0, l14, 3); + mv.visitLocalVariable("fluidToFill", "Lnet/minecraftforge/fluids/Fluid;", null, l0, l14, 4); + mv.visitLocalVariable("input", "Lnet/minecraft/item/ItemStack;", null, l3, l14, 5); + mv.visitLocalVariable("output", "Lnet/minecraft/item/ItemStack;", null, l4, l14, 6); + mv.visitLocalVariable("fill", "Lmods/railcraft/common/fluids/FluidItemHelper$FillReturn;", null, l5, l14, 7); + mv.visitMaxs(5, 9); + mv.visitEnd(); + didInject = true; + } + else if (aMethodName.equals("drainContainers") && !obfuscated) { mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "drainContainers", "(Lnet/minecraftforge/fluids/IFluidHandler;Lnet/minecraft/inventory/IInventory;II)Z", null, null); mv.visitCode(); Label l0 = new Label(); @@ -327,9 +499,129 @@ public class ClassTransformer_Railcraft_FluidHelper { mv.visitMaxs(4, 8); mv.visitEnd(); didInject = true; - } - FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Method injection complete."); + else if (aMethodName.equals("drainContainers") && obfuscated) { + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "drainContainers", "(Lnet/minecraftforge/fluids/IFluidHandler;Lnet/minecraft/inventory/IInventory;II)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(146, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraft/inventory/IInventory", "func_70301_a", "(I)Lnet/minecraft/item/ItemStack;", true); + mv.visitVarInsn(ASTORE, 4); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(147, l1); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraft/inventory/IInventory", "func_70301_a", "(I)Lnet/minecraft/item/ItemStack;", true); + mv.visitVarInsn(ASTORE, 5); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(148, l2); + mv.visitVarInsn(ALOAD, 4); + Label l3 = new Label(); + mv.visitJumpInsn(IFNULL, l3); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(149, l4); + mv.visitVarInsn(ALOAD, 4); + mv.visitIntInsn(SIPUSH, PROCESS_VOLUME); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidItemHelper", "drainContainer", "(Lnet/minecraft/item/ItemStack;I)Lmods/railcraft/common/fluids/FluidItemHelper$DrainReturn;", false); + mv.visitVarInsn(ASTORE, 6); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(150, l5); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "fluidDrained", "Lnet/minecraftforge/fluids/FluidStack;"); + mv.visitJumpInsn(IFNULL, l3); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "container", "Lnet/minecraft/item/ItemStack;"); + Label l6 = new Label(); + mv.visitJumpInsn(IFNULL, l6); + mv.visitVarInsn(ALOAD, 5); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "container", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidHelper", "hasPlaceToPutContainer", "(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z", false); + mv.visitJumpInsn(IFEQ, l3); + mv.visitLabel(l6); + mv.visitLineNumber(151, l6); + mv.visitFrame(F_APPEND,3, new Object[] {"net/minecraft/item/ItemStack", "net/minecraft/item/ItemStack", "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn"}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraftforge/common/util/ForgeDirection", "UNKNOWN", "Lnet/minecraftforge/common/util/ForgeDirection;"); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "fluidDrained", "Lnet/minecraftforge/fluids/FluidStack;"); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraftforge/fluids/IFluidHandler", "fill", "(Lnet/minecraftforge/common/util/ForgeDirection;Lnet/minecraftforge/fluids/FluidStack;Z)I", true); + mv.visitVarInsn(ISTORE, 7); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(152, l7); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "isAtomic", "Z"); + Label l8 = new Label(); + mv.visitJumpInsn(IFEQ, l8); + mv.visitVarInsn(ILOAD, 7); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "fluidDrained", "Lnet/minecraftforge/fluids/FluidStack;"); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/fluids/FluidStack", "amount", "I"); + Label l9 = new Label(); + mv.visitJumpInsn(IF_ICMPEQ, l9); + mv.visitLabel(l8); + mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "isAtomic", "Z"); + mv.visitJumpInsn(IFNE, l3); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "fluidDrained", "Lnet/minecraftforge/fluids/FluidStack;"); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/fluids/FluidStack", "amount", "I"); + mv.visitJumpInsn(IFLE, l3); + mv.visitLabel(l9); + mv.visitLineNumber(153, l9); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraftforge/common/util/ForgeDirection", "UNKNOWN", "Lnet/minecraftforge/common/util/ForgeDirection;"); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "fluidDrained", "Lnet/minecraftforge/fluids/FluidStack;"); + mv.visitInsn(ICONST_1); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraftforge/fluids/IFluidHandler", "fill", "(Lnet/minecraftforge/common/util/ForgeDirection;Lnet/minecraftforge/fluids/FluidStack;Z)I", true); + mv.visitInsn(POP); + Label l10 = new Label(); + mv.visitLabel(l10); + mv.visitLineNumber(154, l10); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 3); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "container", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidHelper", "storeContainer", "(Lnet/minecraft/inventory/IInventory;IILnet/minecraft/item/ItemStack;)V", false); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(155, l11); + mv.visitInsn(ICONST_1); + mv.visitInsn(IRETURN); + mv.visitLabel(l3); + mv.visitLineNumber(159, l3); + mv.visitFrame(F_CHOP,2, null, 0, null); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLocalVariable("used", "I", null, l7, l3, 7); + mv.visitLocalVariable("drain", "Lmods/railcraft/common/fluids/FluidItemHelper$DrainReturn;", null, l5, l3, 6); + mv.visitLocalVariable("fluidHandler", "Lnet/minecraftforge/fluids/IFluidHandler;", null, l0, l12, 0); + mv.visitLocalVariable("inv", "Lnet/minecraft/inventory/IInventory;", null, l0, l12, 1); + mv.visitLocalVariable("inputSlot", "I", null, l0, l12, 2); + mv.visitLocalVariable("outputSlot", "I", null, l0, l12, 3); + mv.visitLocalVariable("input", "Lnet/minecraft/item/ItemStack;", null, l1, l12, 4); + mv.visitLocalVariable("output", "Lnet/minecraft/item/ItemStack;", null, l2, l12, 5); + mv.visitMaxs(4, 8); + mv.visitEnd(); + didInject = true; + } + + FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Method injection complete. "+(obfuscated ? "Obfuscated" : "Non-Obfuscated")); return didInject; } @@ -367,7 +659,7 @@ public class ClassTransformer_Railcraft_FluidHelper { MethodVisitor methodVisitor; boolean found = false; - + for (String s : aMethodsToStrip) { if (name.equals(s)) { found = true; diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java new file mode 100644 index 0000000000..06759429b9 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence.java @@ -0,0 +1,277 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.preloader.DevHelper; +import net.minecraft.item.ItemStack; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; + +public class ClassTransformer_TC_ItemWispEssence { + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + public ClassTransformer_TC_ItemWispEssence(byte[] basicClass, boolean obfuscated2) { + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + boolean obfuscated = obfuscated2; + FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Are we patching obfuscated methods? "+obfuscated); + String aGetColour = obfuscated ? DevHelper.getSRG("getColorFromItemStack") : "getColorFromItemStack"; + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + aTempReader.accept(new AddAdapter(aTempWriter, new String[] {"getAspects", aGetColour}), 0); + injectMethod("getAspects", aTempWriter, obfuscated); + injectMethod(aGetColour, aTempWriter, obfuscated); + if (aTempReader != null && aTempWriter != null) { + isValid = true; + } + else { + isValid = false; + } + FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Valid? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean injectMethod(String aMethodName, ClassWriter cw, boolean obfuscated) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Injecting " + aMethodName + "."); + + String aGetColour = obfuscated ? "func_82790_a" : "getColorFromItemStack"; + String aHasTagCompound = obfuscated ? "func_77942_o" : "hasTagCompound"; + String aGetTagCompound = obfuscated ? "func_77978_p" : "getTagCompound"; + + if (aMethodName.equals("getAspects")) { + mv = cw.visitMethod(ACC_PUBLIC, "getAspects", "(Lnet/minecraft/item/ItemStack;)Lthaumcraft/api/aspects/AspectList;", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(141, l0); + mv.visitVarInsn(ALOAD, 1); + Label l1 = new Label(); + mv.visitJumpInsn(IFNONNULL, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(142, l2); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + mv.visitLabel(l1); + mv.visitLineNumber(144, l1); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", aHasTagCompound, "()Z", false); + Label l3 = new Label(); + mv.visitJumpInsn(IFEQ, l3); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(145, l4); + mv.visitTypeInsn(NEW, "thaumcraft/api/aspects/AspectList"); + mv.visitInsn(DUP); + mv.visitMethodInsn(INVOKESPECIAL, "thaumcraft/api/aspects/AspectList", "<init>", "()V", false); + mv.visitVarInsn(ASTORE, 2); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(146, l5); + mv.visitVarInsn(ALOAD, 2); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "net/minecraft/item/ItemStack", aGetTagCompound, "()Lnet/minecraft/nbt/NBTTagCompound;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/AspectList", "readFromNBT", "(Lnet/minecraft/nbt/NBTTagCompound;)V", false); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLineNumber(147, l6); + mv.visitVarInsn(ALOAD, 2); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/AspectList", "size", "()I", false); + Label l7 = new Label(); + mv.visitJumpInsn(IFLE, l7); + mv.visitVarInsn(ALOAD, 2); + Label l8 = new Label(); + mv.visitJumpInsn(GOTO, l8); + mv.visitLabel(l7); + mv.visitFrame(F_APPEND,1, new Object[] {"thaumcraft/api/aspects/AspectList"}, 0, null); + mv.visitInsn(ACONST_NULL); + mv.visitLabel(l8); + mv.visitFrame(F_SAME1, 0, null, 1, new Object[] {"thaumcraft/api/aspects/AspectList"}); + mv.visitInsn(ARETURN); + mv.visitLabel(l3); + mv.visitLineNumber(149, l3); + mv.visitFrame(F_CHOP,1, null, 0, null); + mv.visitInsn(ACONST_NULL); + mv.visitInsn(ARETURN); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLocalVariable("this", "LgtPlusPlus/preloader/asm/transformers/ClassTransformer_TC_ItemWispEssence;", null, l0, l9, 0); + mv.visitLocalVariable("itemstack", "Lnet/minecraft/item/ItemStack;", null, l0, l9, 1); + mv.visitLocalVariable("aspects", "Lthaumcraft/api/aspects/AspectList;", null, l5, l3, 2); + mv.visitMaxs(2, 3); + mv.visitEnd(); + didInject = true; + } + else if (aMethodName.equals(aGetColour)) { + + //thaumcraft/common/items/ItemWispEssence + mv = cw.visitMethod(ACC_PUBLIC, aGetColour, "(Lnet/minecraft/item/ItemStack;I)I", null, null); + AnnotationVisitor av0; + { + av0 = mv.visitAnnotation("Lcpw/mods/fml/relauncher/SideOnly;", true); + av0.visitEnum("value", "Lcpw/mods/fml/relauncher/Side;", "CLIENT"); + av0.visitEnd(); + } + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(197, l0); + mv.visitVarInsn(ALOAD, 1); + Label l1 = new Label(); + mv.visitJumpInsn(IFNONNULL, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(198, l2); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + mv.visitLabel(l1); + mv.visitLineNumber(200, l1); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/common/items/ItemWispEssence", "getAspects", "(Lnet/minecraft/item/ItemStack;)Lthaumcraft/api/aspects/AspectList;", false); + Label l3 = new Label(); + mv.visitJumpInsn(IFNULL, l3); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(201, l4); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/common/items/ItemWispEssence", "getAspects", "(Lnet/minecraft/item/ItemStack;)Lthaumcraft/api/aspects/AspectList;", false); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/AspectList", "getAspects", "()[Lthaumcraft/api/aspects/Aspect;", false); + mv.visitInsn(ICONST_0); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/Aspect", "getColor", "()I", false); + mv.visitInsn(IRETURN); + mv.visitLabel(l3); + mv.visitLineNumber(203, l3); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitMethodInsn(INVOKESTATIC, "java/lang/System", "currentTimeMillis", "()J", false); + mv.visitLdcInsn(new Long(500L)); + mv.visitInsn(LDIV); + mv.visitFieldInsn(GETSTATIC, "thaumcraft/common/items/ItemWispEssence", "displayAspects", "[Lthaumcraft/api/aspects/Aspect;"); + mv.visitInsn(ARRAYLENGTH); + mv.visitInsn(I2L); + mv.visitInsn(LREM); + mv.visitInsn(L2I); + mv.visitVarInsn(ISTORE, 3); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(204, l5); + mv.visitFieldInsn(GETSTATIC, "thaumcraft/common/items/ItemWispEssence", "displayAspects", "[Lthaumcraft/api/aspects/Aspect;"); + mv.visitVarInsn(ILOAD, 3); + mv.visitInsn(AALOAD); + mv.visitMethodInsn(INVOKEVIRTUAL, "thaumcraft/api/aspects/Aspect", "getColor", "()I", false); + mv.visitInsn(IRETURN); + Label l6 = new Label(); + mv.visitLabel(l6); + mv.visitLocalVariable("this", "Lthaumcraft/common/items/ItemWispEssence;", null, l0, l6, 0); + mv.visitLocalVariable("stack", "Lnet/minecraft/item/ItemStack;", null, l0, l6, 1); + mv.visitLocalVariable("par2", "I", null, l0, l6, 2); + mv.visitLocalVariable("idx", "I", null, l5, l6, 3); + mv.visitMaxs(4, 4); + mv.visitEnd(); + didInject = true; + } + + FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Method injection complete. "+(obfuscated ? "Obfuscated" : "Non-Obfuscated")); + return didInject; + } + + public class AddAdapter extends ClassVisitor { + + public AddAdapter(ClassVisitor cv, String[] aMethods) { + super(ASM5, cv); + this.cv = cv; + this.aMethodsToStrip = aMethods; + } + + private final String[] aMethodsToStrip; + + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + + MethodVisitor methodVisitor; + boolean found = false; + + for (String s : aMethodsToStrip) { + if (name.equals(s)) { + found = true; + break; + } + } + if (!found) { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + else { + methodVisitor = null; + } + + if (found) { + FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, + "Found method " + name + ", removing."); + } + return methodVisitor; + } + + } + static Aspect[] displayAspects; + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int par2) { + if (stack == null) { + return 0; + } + if (this.getAspects(stack) != null) { + return this.getAspects(stack).getAspects()[0].getColor(); + } else { + int idx = (int) (System.currentTimeMillis() / 500L % (long) displayAspects.length); + return displayAspects[idx].getColor(); + } + } + + public AspectList getAspects(ItemStack itemstack) { + if (itemstack.hasTagCompound()) { + AspectList aspects = new AspectList(); + aspects.readFromNBT(itemstack.getTagCompound()); + return aspects.size() > 0 ? aspects : null; + } else { + return null; + } + } + + + + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java index 402a510a79..390289d162 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java @@ -204,7 +204,7 @@ public class Preloader_ClassTransformer2 { } return new ArrayList<ItemStack>(Arrays.asList(rStack)); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException a){ + catch (IllegalArgumentException | IllegalAccessException a){ Logger.REFLECTION("getDropsHack2"); a.printStackTrace(); } @@ -242,7 +242,7 @@ public class Preloader_ClassTransformer2 { Logger.INFO("Set NBT Tag Value to map."); } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + catch (IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } @@ -360,7 +360,7 @@ public class Preloader_ClassTransformer2 { Logger.INFO("Returning Invalid NBT data"); } } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException a){ + catch (IllegalArgumentException | IllegalAccessException a){ Logger.REFLECTION("getDropsHack2"); a.printStackTrace(); } diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java index 3886145330..81302a59d4 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -2,7 +2,6 @@ package gtPlusPlus.preloader.asm.transformers; import java.io.File; import java.io.IOException; -import java.util.Random; import org.apache.logging.log4j.Level; import org.objectweb.asm.ClassReader; @@ -11,14 +10,10 @@ import org.objectweb.asm.ClassWriter; import cpw.mods.fml.relauncher.CoreModManager; import cpw.mods.fml.relauncher.FMLRelaunchLog; import cpw.mods.fml.relauncher.ReflectionHelper; -import galaxyspace.SolarSystem.core.configs.GSConfigDimensions; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.launchwrapper.IClassTransformer; -import net.minecraft.launchwrapper.Launch; -import gtPlusPlus.core.util.Utils; import gtPlusPlus.preloader.asm.AsmConfig; import gtPlusPlus.preloader.asm.transformers.Preloader_ClassTransformer.OreDictionaryVisitor; +import net.minecraft.launchwrapper.IClassTransformer; +import net.minecraft.launchwrapper.Launch; @SuppressWarnings("static-access") public class Preloader_Transformer_Handler implements IClassTransformer { @@ -86,20 +81,20 @@ public class Preloader_Transformer_Handler implements IClassTransformer { // Fix the OreDictionary COFH if (transformedName.equals("cofh.core.util.oredict.OreDictionaryArbiter") && (mConfig.enableCofhPatch || !obfuscated)) { FMLRelaunchLog.log("[GT++ ASM] COFH", Level.INFO, "Transforming %s", transformedName); - return new ClassTransformer_COFH_OreDictionaryArbiter(basicClass, probablyShouldBeFalse).getWriter().toByteArray(); + return new ClassTransformer_COFH_OreDictionaryArbiter(basicClass).getWriter().toByteArray(); } // Fix Tinkers Fluids if (transformedName.equals("tconstruct.smeltery.blocks.TConstructFluid") && mConfig.enableTiConFluidLighting) { FMLRelaunchLog.log("[GT++ ASM] Bright Fluids", Level.INFO, "Transforming %s", transformedName); - return new ClassTransformer_TiConFluids("getLightValue", probablyShouldBeFalse, basicClass).getWriter().toByteArray(); + return new ClassTransformer_TiConFluids("getLightValue", obfuscated, basicClass).getWriter().toByteArray(); } //Fix RC stuff //Patching PROCESS_VOLUME to allow 4x more transfer limits if (transformedName.equals("mods.railcraft.common.fluids.FluidHelper") && mConfig.enableRcFlowFix) { FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Transforming %s", transformedName); - return new ClassTransformer_Railcraft_FluidHelper(basicClass).getWriter().toByteArray(); + return new ClassTransformer_Railcraft_FluidHelper(basicClass, obfuscated).getWriter().toByteArray(); } //Fix GC stuff @@ -118,6 +113,39 @@ public class Preloader_Transformer_Handler implements IClassTransformer { } } + + + + + + /** + * Gregtech ASM Patches + */ + + //Try patch achievements + if (transformedName.equals("gregtech.loaders.misc.GT_Achievements")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_GT_Achievements_CrashFix(basicClass, obfuscated).getWriter().toByteArray(); + } + /*if (transformedName.equals("gregtech.common.GT_Client")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_GT_Client(basicClass).getByteArray(); + }*/ + + //Make GT packets safer, fill them with debug info. + if (transformedName.equals("gregtech.api.net.GT_Packet_TileEntity")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech GT_Packet_TileEntity Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_GT_Packet_TileEntity(basicClass, obfuscated).getWriter().toByteArray(); + } + //Make the setting of GT Tiles safer, so as not to crash the client. + if (transformedName.equals("gregtech.api.metatileentity.BaseMetaTileEntity")) { + FMLRelaunchLog.log("[GT++ ASM] Gregtech setMetaTileEntity Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_GT_BaseMetaTileEntity(basicClass).getWriter().toByteArray(); + } + + + + //Patching Meta Tile Tooltips if (transformedName.equals("gregtech.common.blocks.GT_Item_Machines") && mConfig.enableGtTooltipFix) { FMLRelaunchLog.log("[GT++ ASM] Gregtech Tooltip Patch", Level.INFO, "Transforming %s", transformedName); @@ -160,17 +188,28 @@ public class Preloader_Transformer_Handler implements IClassTransformer { "ic2.core.block.reactor.block.BlockReactorFluidPort", "ic2.core.block.reactor.block.BlockReactorRedstonePort", "ic2.core.block.reactor.block.BlockReactorVessel", + "ic2.core.block.personal.BlockPersonal.class", + "ic2.core.block.wiring.BlockChargepad.class", + "ic2.core.block.wiring.BlockElectric.class", + "ic2.core.block.wiring.BlockLuminator.class", }; //Fix IC2 Shit for (String y : aIC2ClassNames) { if (transformedName.equals(y)) { - //Fix GT NBT Persistency issue FMLRelaunchLog.log("[GT++ ASM] IC2 getHarvestTool Patch", Level.INFO, "Transforming %s", transformedName); - return new ClassTransformer_IC2_GetHarvestTool(basicClass, probablyShouldBeFalse, transformedName).getWriter().toByteArray(); + return new ClassTransformer_IC2_GetHarvestTool(basicClass, obfuscated, transformedName).getWriter().toByteArray(); } - } - + } + + //Fix Thaumcraft Shit + //Patching ItemWispEssence to allow invalid item handling + if (transformedName.equals("thaumcraft.common.items.ItemWispEssence") && mConfig.enableTcAspectSafety) { + FMLRelaunchLog.log("[GT++ ASM] Thaumcraft WispEssence_Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_TC_ItemWispEssence(basicClass, obfuscated).getWriter().toByteArray(); + } + + return basicClass; } diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java b/src/Java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java new file mode 100644 index 0000000000..ce7d919431 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/HANDLER_CropsPlusPlus.java @@ -0,0 +1,21 @@ +package gtPlusPlus.xmod.bartcrops; + +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class HANDLER_CropsPlusPlus { + + public static void preInit(FMLPreInitializationEvent preinit) { + LoaderOfTheCrops.load(preinit); + } + + public static void init(FMLInitializationEvent init) { + //registerItems(); + } + + public static void postInit(FMLPostInitializationEvent postinit) { + LoaderOfTheCrops.register(); + LoaderOfTheCrops.registerBaseSeed(); + } +} diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java b/src/Java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java new file mode 100644 index 0000000000..48813310d2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/LoaderOfTheCrops.java @@ -0,0 +1,109 @@ +package gtPlusPlus.xmod.bartcrops; + +import java.util.ArrayList; +import java.util.List; + +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.bartcrops.crops.Crop_Hemp; +import ic2.api.crops.CropCard; +import ic2.api.crops.Crops; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +/** + * Mostly borrowed from the Crops++ Crop Loader. + * @author Alkalus + */ + +public class LoaderOfTheCrops { + + private static List<Boolean> mHasCropObj = new ArrayList<Boolean>(); + private CropCard mCropObj; + private ItemStack mBaseSeed; + private static List<LoaderOfTheCrops> mCropList = cropLoader(); + + public LoaderOfTheCrops(CropCard cropObj) { + this.mCropObj = cropObj; + } + + public LoaderOfTheCrops(CropCard cropObj, ItemStack baseseed) { + this.mCropObj = cropObj; + this.mBaseSeed = baseseed; + } + + public static CropCard cropUnpackerCC(LoaderOfTheCrops inp) { + return inp.mCropObj; + } + + private static ItemStack cropUnpackerCG(LoaderOfTheCrops inp) { + return inp.mBaseSeed; + } + + private static LoaderOfTheCrops cropHelper(CropCard cropObj) { + return new LoaderOfTheCrops(cropObj, ItemUtils.getItemStackOfAmountFromOreDict("crop" + cropObj.name(), 0)); + } + + public static final List<LoaderOfTheCrops> cropLoader() { + List<LoaderOfTheCrops> p = new ArrayList<LoaderOfTheCrops>(); + + p.add(new LoaderOfTheCrops(new Crop_Hemp(), new ItemStack(Item.getItemById(111), 3))); + + return p; + } + + private static final List<CropCard> cropObjs() { + List<CropCard> p = new ArrayList<CropCard>(); + + for (int i = 0; i < mCropList.size(); ++i) { + p.add(cropUnpackerCC((LoaderOfTheCrops) mCropList.get(i))); + } + + return p; + } + + private static final List<ItemStack> setBaseSeed() { + List<ItemStack> p = new ArrayList<ItemStack>(); + + for (int i = 0; i < mCropList.size(); ++i) { + p.add(cropUnpackerCG((LoaderOfTheCrops) mCropList.get(i))); + } + + return p; + } + + private static final List<String> setnames() { + List<String> s = new ArrayList<String>(); + + for (int i = 0; i < mCropList.size(); ++i) { + s.add(((CropCard) cropObjs().get(i)).name()); + } + + return s; + } + + public static void load(FMLPreInitializationEvent preinit) { + for (int i = 0; i < mCropList.size(); ++i) { + mHasCropObj.add(true); + } + } + + public static void register() { + for (int i = 0; i < mCropList.size(); ++i) { + if ((Boolean) mHasCropObj.get(i) && cropObjs().get(i) != null) { + Crops.instance.registerCrop((CropCard) cropObjs().get(i)); + } + } + } + + public static void registerBaseSeed() { + List<ItemStack> baseseed = new ArrayList<ItemStack>(setBaseSeed()); + + for (int i = 0; i < mCropList.size(); ++i) { + if (baseseed.get(i) != null && cropObjs().get(i) != null) { + Crops.instance.registerBaseSeed((ItemStack) baseseed.get(i), (CropCard) cropObjs().get(i), 1, 1, 1, 1); + } + } + + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java new file mode 100644 index 0000000000..cddce7beb4 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseAestheticCrop.java @@ -0,0 +1,37 @@ +package gtPlusPlus.xmod.bartcrops.abstracts; + +import gtPlusPlus.core.lib.CORE; +import ic2.api.crops.ICropTile; + +public abstract class BaseAestheticCrop extends BaseHarvestableCrop { + + public int tier() { + return 1; + } + + public int stat(int n) { + switch (n) { + case 0 : + return 0; + case 1 : + return 0; + case 2 : + return 0; + case 3 : + return 4; + case 4 : + return 0; + default : + return 0; + } + } + + public int growthDuration(ICropTile crop) { + return CORE.DEBUG ? 1 : 225; + } + + public byte getSizeAfterHarvest(ICropTile crop) { + return 1; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java new file mode 100644 index 0000000000..ca2a044564 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseCrop.java @@ -0,0 +1,56 @@ +package gtPlusPlus.xmod.bartcrops.abstracts; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import ic2.api.crops.CropCard; +import ic2.api.crops.ICropTile; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import speiger.src.crops.api.ICropCardInfo; + +public abstract class BaseCrop extends CropCard implements ICropCardInfo { + @SideOnly(Side.CLIENT) + public void registerSprites(IIconRegister iconRegister) { + this.textures = new IIcon[this.maxSize()]; + + for (int i = 1; i <= this.textures.length; ++i) { + this.textures[i - 1] = iconRegister.registerIcon(CORE.MODID+":crop/blockCrop." + this.name() + "." + i); + } + + } + + public float dropGainChance() { + return (float) (Math.pow(0.95D, (double) ((float) this.tier())) * (double) 1f); + } + + public boolean canCross(ICropTile crop) { + return crop.getSize() == this.maxSize(); + } + + public int getrootslength(ICropTile crop) { + return 3; + } + + public String discoveredBy() { + return "Alkalus"; + } + + public String owner() { + return "Gtplusplus"; + } + + public List<String> getCropInformation() { + List<String> ret = new ArrayList<String>(); + ret.add(this.attributes().toString()); + return ret; + } + + public ItemStack getDisplayItem(CropCard card) { + return ItemUtils.getItemStackOfAmountFromOreDict("crop" + this.name(), 0); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java new file mode 100644 index 0000000000..fee6cf654c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/abstracts/BaseHarvestableCrop.java @@ -0,0 +1,69 @@ +package gtPlusPlus.xmod.bartcrops.abstracts; + +import gtPlusPlus.core.lib.CORE; +import ic2.api.crops.ICropTile; + +public abstract class BaseHarvestableCrop extends BaseCrop { + + public int tier() { + return 2; + } + + public int stat(int n) { + switch (n) { + case 0 : + return 0; + case 1 : + return 4; + case 2 : + return 0; + case 3 : + return 4; + case 4 : + return 0; + default : + return 0; + } + } + + public boolean canGrow(ICropTile crop) { + return crop.getSize() < 3; + } + + public int getOptimalHavestSize(ICropTile crop) { + return 3; + } + + public boolean canBeHarvested(ICropTile crop) { + return crop.getSize() == 3; + } + + public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) { + return (int) ((double) humidity * 1.2D + (double) nutrients * 0.9D + (double) air * 0.9D); + } + + public int growthDuration(ICropTile crop) { + short r; + if (CORE.DEBUG) { + r = 1; + } else if (crop.getSize() == 2) { + r = 200; + } else { + r = 700; + } + + return r; + } + + public byte getSizeAfterHarvest(ICropTile crop) { + return 2; + } + + public int maxSize() { + return 3; + } + + public String discoveredBy() { + return "Alkalus"; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java b/src/Java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java new file mode 100644 index 0000000000..a921182d66 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/bartcrops/crops/Crop_Hemp.java @@ -0,0 +1,56 @@ +package gtPlusPlus.xmod.bartcrops.crops; + +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.bartcrops.abstracts.BaseAestheticCrop; +import ic2.api.crops.ICropTile; +import net.minecraft.item.ItemStack; + +public class Crop_Hemp extends BaseAestheticCrop { + + public int tier() { + return 2; + } + + public String name() { + return "Hemp"; + } + + public String discoveredBy() { + return "Alkalus"; + } + + public int growthDuration(ICropTile crop) { + int ret = 550; + + /*if (crop.isBlockBelow(Blocks.dirt) || crop.isBlockBelow(Blocks.flowing_water)) { + ret = 225; + }*/ + + if (CORE.DEBUG) { + ret = 1; + } + + return ret; + } + + public String[] attributes() { + return new String[]{"Green", "Soil", "Orange"}; + } + + public ItemStack getGain(ICropTile crop) { + + ItemStack ret = this.getDisplayItem(); + if (MathUtils.randInt(0, 10) > 8) { + ret = ItemUtils.getSimpleStack(ModItems.itemRope, MathUtils.randInt(1, 3)); + } + + return ret; + } + + public ItemStack getDisplayItem() { + return ItemUtils.getSimpleStack(ModItems.itemRope, 0); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java index 6d50f64e6d..5b3210d58a 100644 --- a/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java +++ b/src/Java/gtPlusPlus/xmod/eio/handler/HandlerTooltip_EIO.java @@ -12,6 +12,7 @@ import gregtech.api.enums.Materials; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.eio.material.MaterialEIO; import net.minecraftforge.event.entity.player.ItemTooltipEvent; @@ -30,11 +31,10 @@ public class HandlerTooltip_EIO { //If it is, reflect in. if (mIngot == null){ try { - oMainClass = Class.forName("crazypants.enderio.EnderIO"); - oIngotClass = Class.forName("crazypants.enderio.material.ItemAlloy"); + oMainClass = ReflectionUtils.getClass("crazypants.enderio.EnderIO"); + oIngotClass = ReflectionUtils.getClass("crazypants.enderio.material.ItemAlloy"); if (oMainClass != null && oIngotClass != null){ - Field oAlloyField = oMainClass.getDeclaredField("itemAlloy"); - oAlloyField.setAccessible(true); + Field oAlloyField = ReflectionUtils.getField(oMainClass, "itemAlloy"); Object oAlloy = oAlloyField.get(oMainClass); if (oAlloy != null){ if (oIngotClass.isInstance(oAlloy) || Item.class.isInstance(oAlloy)){ diff --git a/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java index 1343bdc8af..05d00b06d9 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java +++ b/src/Java/gtPlusPlus/xmod/forestry/HANDLER_FR.java @@ -45,14 +45,14 @@ public class HANDLER_FR { if (LoadedMods.Forestry){ Class oClass; try { - oClass = Class.forName("forestry.core.proxy.ProxyCommon"); + oClass = ReflectionUtils.getClass("forestry.core.proxy.ProxyCommon"); Object oProxy = ReflectionUtils.getField(oClass, "common"); - if (oProxy != null && oClass.isInstance(oProxy)){ - Method mParticles = oClass.getDeclaredMethod("addBlockDestroyEffects", World.class, int.class, int.class, int.class, Block.class, int.class); + if (oProxy != null && oClass.isInstance(oProxy)){ + Method mParticles = ReflectionUtils.getMethod(oClass, "addBlockDestroyEffects", World.class, int.class, int.class, int.class, Block.class, int.class); mParticles.invoke(oProxy, world, x, y, z, block, 0); } } - catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } } } diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java index d842c37fcd..b36508f6aa 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java @@ -864,7 +864,7 @@ public enum GTPP_Bee_Definition implements IBeeDefinition { Enum gtBeeEnumObject = Enum.valueOf(gtBeeTypes, name); Field gtBeesField = FieldUtils.getDeclaredField(gtBeeTypes, "species", true); gtBeesField.setAccessible(true); - ReflectionUtils.makeAccessible(gtBeesField); + ReflectionUtils.makeFieldAccessible(gtBeesField); Object beeType = gtBeesField.get(gtBeeEnumObject); return (IAlleleBeeSpecies) beeType; } diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java index 29ece40c3d..bb360d5a87 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java @@ -141,7 +141,7 @@ public class GTPP_Bees { Class gtCombEnumClass = Class.forName("gregtech.common.items.CombType"); Field gtCombs = FieldUtils.getDeclaredField(gtBees, "combs", true); gtCombs.setAccessible(true); - ReflectionUtils.makeAccessible(gtCombs); + ReflectionUtils.makeFieldAccessible(gtCombs); Enum gtCombTypeSlag = Enum.valueOf(gtCombEnumClass, "SLAG"); Enum gtCombTypeStone = Enum.valueOf(gtCombEnumClass, "STONE"); Object oCombObject = gtCombs.get(null); diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java b/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java index 0bba3d1f84..7e011a808e 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/recipe/FR_Gregtech_Recipes.java @@ -31,7 +31,7 @@ public class FR_Gregtech_Recipes { private static ItemStack hiveFrameClay = ItemUtils.getSimpleStack(FR_ItemRegistry.hiveFrameClay); private static ItemStack hiveFrameNova = ItemUtils.getSimpleStack(FR_ItemRegistry.hiveFrameNova); - private static ItemStack hiveFrameImpregnated = ItemUtils.getItemStack("Forestry:frameImpregnated", 1); + private static ItemStack hiveFrameImpregnated = ItemUtils.getItemStackFromFQRN("Forestry:frameImpregnated", 1); private static ItemStack blockSoulSand = new ItemStack(Blocks.soul_sand, 1); private static ItemStack blockIronBars = new ItemStack (Blocks.iron_bars, 1); private static ItemStack itemClayDust = new ItemStack(Items.clay_ball, 1); diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java index 9075666b8b..64f1cfbe23 100644 --- a/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java +++ b/src/Java/gtPlusPlus/xmod/galacticraft/handler/HandlerTooltip_GC.java @@ -1,6 +1,8 @@ package gtPlusPlus.xmod.galacticraft.handler; import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.LinkedHashMap; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; @@ -8,6 +10,7 @@ import net.minecraft.item.Item; import gtPlusPlus.core.item.chemistry.RocketFuels; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.preloader.asm.AsmConfig; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fluids.Fluid; @@ -17,20 +20,19 @@ public class HandlerTooltip_GC { private static Block mBlock; private static Class<?> oMainClass; private static Class<?> oFuelLoaderClass; - private static String[] mFuelNames; + private static HashMap <Integer, String> mFuelNames; @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event) { - if (LoadedMods.GalacticraftCore) { + if (LoadedMods.GalacticraftCore && AsmConfig.enableGcFuelChanges) { if (mBlock == null) { try { - Class<?> GCBlocks = Class.forName("micdoodle8.mods.galacticraft.core.blocks.GCBlocks"); + Class<?> GCBlocks = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.blocks.GCBlocks"); if (GCBlocks != null) { oMainClass = GCBlocks; - Class<?> GCFuelLoader = Class - .forName("micdoodle8.mods.galacticraft.core.blocks.BlockFuelLoader"); + Class<?> GCFuelLoader = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.blocks.BlockFuelLoader"); if (GCFuelLoader != null) { oFuelLoaderClass = GCFuelLoader; @@ -48,24 +50,26 @@ public class HandlerTooltip_GC { } catch (Throwable t) { } } - if (mFuelNames == null || mFuelNames.length == 0) { - mFuelNames = new String[RocketFuels.mValidRocketFuels.size()]; - int slot = 0; - for (Fluid f : RocketFuels.mValidRocketFuels.values()) { - mFuelNames[slot++] = f.getLocalizedName(); + + if (mFuelNames == null || mFuelNames.isEmpty()) { + mFuelNames = new LinkedHashMap<Integer, String>(); + for (int aMapKey : RocketFuels.mValidRocketFuels.keySet()) { + Fluid aFuel = RocketFuels.mValidRocketFuels.get(aMapKey); + if (aFuel != null) { + mFuelNames.put(aMapKey, aFuel.getLocalizedName()); + } } - } - if (mItemBlock != null) { + } + if (mItemBlock != null && !mFuelNames.isEmpty()) { Item aTempItem = event.itemStack.getItem(); Block aTempBlock = Block.getBlockFromItem(aTempItem); - if (aTempItem == mItemBlock || oFuelLoaderClass.isInstance(aTempBlock) - || event.itemStack.getUnlocalizedName().toLowerCase().contains("fuelloader")) { - int aTier = 0; - for (String s : mFuelNames) { - if (s != null) { - event.toolTip.add("Tier "+aTier+": "+s); + if (aTempItem == mItemBlock || oFuelLoaderClass.isInstance(aTempBlock) || event.itemStack.getUnlocalizedName().toLowerCase().contains("fuelloader")) { + for (int aMapKey : mFuelNames.keySet()) { + String aFuel = mFuelNames.get(aMapKey); + if (aFuel != null) { + event.toolTip.add("Tier "+(aMapKey+1)+": "+aFuel); } - } + } } } } diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/system/core/world/gen/ChunkProviderGalactic.java b/src/Java/gtPlusPlus/xmod/galacticraft/system/core/world/gen/ChunkProviderGalactic.java index 3b9633b21d..aafa9ef9a1 100644 --- a/src/Java/gtPlusPlus/xmod/galacticraft/system/core/world/gen/ChunkProviderGalactic.java +++ b/src/Java/gtPlusPlus/xmod/galacticraft/system/core/world/gen/ChunkProviderGalactic.java @@ -4,12 +4,11 @@ import java.util.List; import com.google.common.collect.Lists; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import micdoodle8.mods.galacticraft.api.prefab.core.BlockMetaPair; import micdoodle8.mods.galacticraft.api.prefab.world.gen.BiomeDecoratorSpace; import micdoodle8.mods.galacticraft.api.prefab.world.gen.MapGenBaseMeta; -import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedCreeper; -import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSkeleton; -import micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSpider; import net.minecraft.block.Block; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -46,20 +45,37 @@ public abstract class ChunkProviderGalactic extends ChunkProviderGalaxyLakes { } protected SpawnListEntry[] getMonsters() { - SpawnListEntry skele = new SpawnListEntry(EntityEvolvedSkeleton.class, 100, 4, 4); - SpawnListEntry creeper = new SpawnListEntry(EntityEvolvedCreeper.class, 100, 4, 4); - SpawnListEntry spider = new SpawnListEntry(EntityEvolvedSpider.class, 100, 4, 4); + + Class aSkele = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSkeleton"); + Class aCreeper = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.entities.EntityEvolvedCreeper"); + Class aSpider = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.entities.EntityEvolvedSpider"); + Class aEnderman = ReflectionUtils.getClass("galaxyspace.SolarSystem.planets.pluto.entities.EntityEvolvedEnderman"); + + SpawnListEntry skele; + SpawnListEntry creeper; + SpawnListEntry spider; + SpawnListEntry enderman; - Class<?> aEnderman; - try { - aEnderman = Class.forName("galaxyspace.SolarSystem.planets.pluto.entities.EntityEvolvedEnderman"); - if (aEnderman != null) { - SpawnListEntry enderman = new SpawnListEntry(aEnderman, 100, 4, 4); - return new SpawnListEntry[] { skele, creeper, spider, enderman }; - } - } catch (ClassNotFoundException e) {} + AutoMap<SpawnListEntry> aMobs = new AutoMap<SpawnListEntry>(); - return new SpawnListEntry[] { skele, creeper, spider }; + if (aSkele != null) { + skele = new SpawnListEntry(aSkele, 100, 4, 4); + aMobs.put(skele); + } + if (aCreeper != null) { + creeper = new SpawnListEntry(aCreeper, 100, 4, 4); + aMobs.put(creeper); + } + if (aSpider != null) { + spider = new SpawnListEntry(aSpider, 100, 4, 4); + aMobs.put(spider); + } + if (aEnderman != null) { + enderman = new SpawnListEntry(aEnderman, 100, 4, 4); + aMobs.put(enderman); + } + + return aMobs.toArray(); } public void onPopulate(IChunkProvider arg0, int arg1, int arg2) { diff --git a/src/Java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java b/src/Java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java index 94dc2d0cc0..f237aed335 100644 --- a/src/Java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java +++ b/src/Java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java @@ -26,11 +26,11 @@ public class GalacticUtils { Class<?> a1, a2, a3, a4, a5; Method m1, m2, m3; try { - a1 = Class.forName("micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket"); - a2 = Class.forName("micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad"); - a3 = Class.forName("micdoodle8.mods.galacticraft.core.tile.TileEntityBuggyFueler"); - a4 = Class.forName("micdoodle8.mods.galacticraft.api.entity.IDockable"); - a5 = Class.forName("micdoodle8.mods.galacticraft.api.entity.IFuelable"); + a1 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket"); + a2 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad"); + a3 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.tile.TileEntityBuggyFueler"); + a4 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.entity.IDockable"); + a5 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.entity.IFuelable"); m1 = ReflectionUtils.getMethod(a1, "getRocketTier"); m2 = ReflectionUtils.getMethod(a2, "getDockedEntity"); m3 = ReflectionUtils.getMethod(a3, "getDockedEntity"); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 6903305f9d..6edc47badf 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -12,18 +12,23 @@ import gregtech.api.interfaces.IToolStats; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gregtech.api.util.Recipe_GT; import gregtech.common.items.GT_MetaGenerated_Tool_01; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.australia.gen.gt.WorldGen_GT_Australia; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.handler.OldCircuitHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.CORE.ConfigSwitches; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.everglades.gen.gt.WorldGen_GT; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; import gtPlusPlus.xmod.gregtech.api.world.GTPP_Worldgen; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.fluid.GregtechFluidHandler; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import gtPlusPlus.xmod.gregtech.loaders.*; @@ -104,6 +109,7 @@ public class HANDLER_GT { public static void onLoadComplete(FMLLoadCompleteEvent event) { removeCrudeTurbineRotors(); + cleanAssemblyLineRecipeMap(); } private static int removeCrudeTurbineRotors() { @@ -165,5 +171,83 @@ public class HANDLER_GT { return aRemoved; } + + /** + * Should clean out any invalid Assembly Line recipes, if the map actually exists. + * Prevents NPE's being thrown by GT's AL handler. (Fucking Annoying) + * @return - Amount of Recipes removed, which were invalid in some way. + */ + private static int cleanAssemblyLineRecipeMap() { + GT_Recipe_Map g = StaticFields59.sAssemblylineVisualRecipes; + if (g == null) { + return 0; + } + else { + AutoMap<GT_Recipe> aNewMap = new AutoMap<GT_Recipe>(); + AutoMap<GT_Recipe> aBadRecipeTempMap = new AutoMap<GT_Recipe>(); + for (GT_Recipe r : g.mRecipeList) { + if (r != null) { + if (r.mOutputs == null || r.mOutputs.length == 0 || r.mOutputs[0] == null) { + aBadRecipeTempMap.put(r.copy()); + continue; + } + else { + aNewMap.put(r.copy()); + } + } + } + if (aNewMap.size() > 0) { + g.mRecipeList.clear(); + for (GT_Recipe i : aNewMap) { + g.add(i); + } + } + if (aBadRecipeTempMap.size() > 0) { + Logger.INFO("Found "+aBadRecipeTempMap.size()+" bad Assembly Line Recipes, attempting to dump all data about them."); + Logger.INFO("This data should be given to the mod author for the recipe in question."); + for (GT_Recipe i : aBadRecipeTempMap) { + if (i == null) { + Logger.INFO("Found NULL recipe. Impossible to determine who added this one. Please Report to Alkalus on Github."); + } + else { + if (i.mOutputs == null || i.mOutputs.length == 0 || i.mOutputs[0] == null) { + Logger.INFO("Found recipe with NULL output array, this will cause some issues. Attempting to determine other info about recipe."); + if (i.mInputs != null && i.mInputs.length > 0) { + Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(i.mInputs)); + } + else { + Logger.INFO("Recipe had no valid inputs."); + } + Logger.INFO("Time: "+i.mDuration); + Logger.INFO("EU/T: "+i.mEUt); + Logger.INFO("Special: "+i.mSpecialValue); + } + else { + Logger.INFO("Found bad recipe, Attempting to determine other info."); + if (i.mInputs != null && i.mInputs.length > 0) { + Logger.INFO("Inputs: "+ItemUtils.getArrayStackNames(i.mInputs)); + } + else { + Logger.INFO("Recipe had no valid inputs."); + } + if (i.mOutputs != null && i.mOutputs.length > 0) { + Logger.INFO("Outputs: "+ItemUtils.getArrayStackNames(i.mOutputs)); + } + else { + Logger.INFO("Recipe had no valid outputs."); + } + Logger.INFO("Time: "+i.mDuration); + Logger.INFO("EU/T: "+i.mEUt); + Logger.INFO("Special: "+i.mSpecialValue); + } + } + } + } + else { + Logger.INFO("No bad Assembly Line recipes found, this is great news!"); + } + return aBadRecipeTempMap.size(); + } + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index c228364149..83abe22568 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -84,8 +84,13 @@ public enum GregtechItemList implements GregtechItemContainer { //Computer Cube Gregtech_Computer_Cube, - //Custom Batteries (Unused) - Battery_Gem_1, Battery_Gem_2, Battery_Gem_3, + //Casings for batteries + Battery_Casing_Gem_1, Battery_Casing_Gem_2, + Battery_Casing_Gem_3, Battery_Casing_Gem_4, + + //Custom Batteries + Battery_Gem_1, Battery_Gem_2, + Battery_Gem_3, Battery_Gem_4, //Compressed Fusion MK3 Compressed_Fusion_Reactor, @@ -99,6 +104,11 @@ public enum GregtechItemList implements GregtechItemContainer { //End Game Laser Engraver Lens Laser_Lens_Special, + //Bombs + Bomb_Cast, Bomb_Cast_Molten, + Bomb_Cast_Set, Bomb_Cast_Broken, + Bomb_Cast_Mold, + //---------------------------------------------------------------------------- @@ -556,7 +566,7 @@ public enum GregtechItemList implements GregtechItemContainer { */ //Fluid Void Covers - Cover_Overflow_ULV, Cover_Overflow_LV, Cover_Overflow_MV, Cover_Overflow_HV, Cover_Overflow_EV, Cover_Overflow_IV, + Cover_Overflow_ULV, Cover_Overflow_LV, Cover_Overflow_MV, Cover_Overflow_HV, Cover_Overflow_EV, Cover_Overflow_IV, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index d5b484e314..721facd8d0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -141,7 +141,23 @@ public interface IGregtech_RecipeAdder { public boolean addLFTRRecipe(ItemStack aInput1, FluidStack aInput2, ItemStack aOutput1, FluidStack aOutput2, int aDuration, int aEUt); public boolean addLFTRRecipe(FluidStack aInput1, FluidStack aInput2, FluidStack aOutput1, int aDuration, int aEUt); - + + /** + * Adds a custom Semifluid fuel for the GT++ SemiFluid Generators. + * @param aFuelItem - A Fluidstack to be consumed. + * @param aFuelValue - Fuel value in thousands (1 = 1000) + * @return - Was the Fuel added? + */ + public boolean addSemifluidFuel(FluidStack aFuelItem, int aFuelValue); + + /** + * Adds a custom Semifluid fuel for the GT++ SemiFluid Generators. + * @param aFuelItem - A Fluidstack to be consumed. + * @param aFuelValue - Fuel value in thousands (1 = 1000) + * @return - Was the Fuel added? + */ + public boolean addSemifluidFuel(ItemStack aFuelItem, int aFuelValue); + public boolean addFissionFuel( FluidStack aInput1, FluidStack aInput2, FluidStack aInput3, FluidStack aInput4, FluidStack aInput5, FluidStack aInput6, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java index 47e4a7ae53..e637365c1e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java @@ -12,6 +12,7 @@ import gregtech.api.util.GT_Utility; import gregtech.common.GT_Pollution; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import ic2.api.Direction; import net.minecraft.item.ItemStack; @@ -88,7 +89,7 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity { } } - GT_Pollution.addPollution(this, 100000); + PollutionUtils.addPollution(this, 100000); this.mMetaTileEntity.doExplosion(aAmount); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java index b0dc635aee..19ba932a02 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java @@ -361,17 +361,7 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; - if(!GT_Mod.gregtechproxy.mForceFreeFace) { - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - for(byte i=0;i < 6; i++){ - if(aBaseMetaTileEntity.getAirAtSide(i)){ - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - } - GT_Utility.sendChatToPlayer(aPlayer,"No free Side!"); + aBaseMetaTileEntity.openGUI(aPlayer); return true; } @@ -461,7 +451,8 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { } if (mProgresstime > 5) mStuttering = false; XSTR aXSTR = new XSTR(); - if(GT_Mod.gregtechproxy.mAprilFool && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); + //Dumb April Fools Shit + // if(GT_Mod.gregtechproxy.mAprilFool && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); } else { if (!mStuttering) { stutterProcess(); @@ -726,7 +717,7 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { mAllowInputFromOutputSide = !mAllowInputFromOutputSide; - GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? trans("095","Input from Output Side allowed") : trans("096","Input from Output Side forbidden")); + GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? "Input from Output Side allowed" : "Input from Output Side forbidden"); } } @@ -790,9 +781,6 @@ public abstract class GTPP_MTE_BasicMachine extends GTPP_MTE_BasicTank { GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); if (tRecipe == null) return DID_NOT_FIND_RECIPE; - if (GT_Mod.gregtechproxy.mLowGravProcessing && tRecipe.mSpecialValue == -100 && - !isValidForLowGravity(tRecipe,getBaseMetaTileEntity().getWorld().provider.dimensionId)) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; if (!canOutput(tRecipe)) { mOutputBlocked++; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java index d5180ef4e1..18665538d0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java @@ -27,7 +27,7 @@ public class GT_MetaTileEntity_BasicMachine_GTPP_Recipe extends GT_MetaTileEntit GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) { - super(aName, aTier, aDescription, aRecipes, aInputSlots, aOutputSlots, aTankCapacity, aAmperage, aGUIParameterA, + super(aName, aTier, aDescription[0], aRecipes, aInputSlots, aOutputSlots, aTankCapacity, aAmperage, aGUIParameterA, aGUIParameterB, aTextures, aGUIName, aNEIName, aSound, aSharedTank, aRequiresFluidForFiltering, aSpecialEffect); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java index fe0ffd5dc8..7a532807c8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java @@ -8,16 +8,20 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.item.general.ItemControlCore; import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch { public GT_Recipe_Map mRecipeMap = null; + + public BlockPos mControllerLocation; public GT_MetaTileEntity_Hatch_ControlCore(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, getSlots(aTier), "Core determines maximum tier machine will operate at"); @@ -113,4 +117,24 @@ public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return aSide == getBaseMetaTileEntity().getFrontFacing() && (aStack != null && aStack.getItem() instanceof ItemControlCore); } + + public boolean setOwner(TileEntity aTileEntity) { + if (mControllerLocation != null) { + return false; + } + else { + mControllerLocation = new BlockPos(aTileEntity); + return true; + } + } + + public boolean setOwner(IGregTechTileEntity aTileEntity) { + if (mControllerLocation != null) { + return false; + } + else { + mControllerLocation = new BlockPos(aTileEntity); + return true; + } + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java index e427587be0..9b730c84a3 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java @@ -2,7 +2,8 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; - +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -47,7 +48,14 @@ public class GT_MetaTileEntity_Hatch_DynamoBuffer extends GT_MetaTileEntity_Hatc @Override public String[] getDescription() { - String[] g = new String[]{"Generating electric Energy from Multiblocks", "Stores "+maxEUStore()+"EU", "Puts out up to 4 Amps", "Does not accept more than "+this.maxEUOutput()+"EU/t as input", "Large Turbines only supply 1A to this, other Multiblocks can inject more amps"}; + String[] g; + if (CORE.GTNH || (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechVersionAsInt() >= 50932)) { + g = new String[]{"Dynamo with internal storage and additional Amp capacity", "Capacity: "+maxEUStore()+"EU", "Voltage: "+this.maxEUOutput(), "Amperage In: 4", "Amperage Out: 4"}; + + } + else { + g = new String[]{"Dynamo with internal storage and additional Amp capacity", "Stores "+maxEUStore()+"EU", "Amperage In: 4", "Amperage Out: 4", "Does not accept more than "+this.maxEUOutput()+"EU/t as input", "Large Turbines only supply 1A to this, other Multiblocks can inject more amps"}; + } return g; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java index 2b7f44be59..0d4d8b6cdd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java @@ -184,7 +184,7 @@ public class GT_MetaTileEntity_Hatch_Naquadah extends GT_MetaTileEntity_Hatch_In a2 = F2.getByte(this); } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException n) {} + catch (IllegalArgumentException | IllegalAccessException n) {} int textureIndex = a1 | a2 << 7; byte texturePointer = (byte) (a1 & 127); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java index aeae474fb7..bed80d8d13 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java @@ -9,6 +9,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -19,7 +20,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Input { +public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Output { public final AutoMap<Fluid> mFluidsToUse = new AutoMap<Fluid>(); public final int mFluidCapacity; @@ -49,11 +50,9 @@ public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Inpu //Get all Plasmas, but the easiest way to do this is to just ask the Fluid Registry what exists and filter through them lazily. Field fluidNameCache; - try { - fluidNameCache = ReflectionUtils.getField(FluidRegistry.class, "fluidNames"); - } catch (NoSuchFieldException e) { - fluidNameCache = null; - } + + fluidNameCache = ReflectionUtils.getField(FluidRegistry.class, "fluidNames"); + AutoMap<String> mValidPlasmaNameCache = new AutoMap<String>(); if (fluidNameCache != null) { try { @@ -198,7 +197,7 @@ public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Inpu a2 = F2.getByte(this); } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException n) {} + catch (IllegalArgumentException | IllegalAccessException n) {} int textureIndex = a1 | a2 << 7; byte texturePointer = (byte) (a1 & 127); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java index 96df4dbfd0..5e41af86af 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Input.java @@ -28,7 +28,7 @@ public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_In } public GT_MetaTileEntity_SuperBus_Input(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); + super(aName, aTier, aDescription[0], aTextures); } /** @@ -65,7 +65,7 @@ public class GT_MetaTileEntity_SuperBus_Input extends GT_MetaTileEntity_Hatch_In } public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_SuperBus_Input(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + return new GT_MetaTileEntity_SuperBus_Input(this.mName, this.mTier, this.mDescription, this.mTextures); } public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java index d09b71ee35..4fac3d36d8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SuperBus_Output.java @@ -26,7 +26,7 @@ public class GT_MetaTileEntity_SuperBus_Output extends GT_MetaTileEntity_Hatch_O } public GT_MetaTileEntity_SuperBus_Output(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); + super(aName, aTier, aDescription[0], aTextures); } /** @@ -43,7 +43,7 @@ public class GT_MetaTileEntity_SuperBus_Output extends GT_MetaTileEntity_Hatch_O } public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_SuperBus_Output(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + return new GT_MetaTileEntity_SuperBus_Output(this.mName, this.mTier, this.mDescription, this.mTextures); } public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 04c1cf34cc..9393ca08be 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -16,6 +16,7 @@ import org.apache.commons.lang3.ArrayUtils; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; +import gregtech.api.enums.TAE; import gregtech.api.gui.GT_Container_MultiMachine; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -38,7 +39,10 @@ import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.GTplusplus.INIT_PHASE; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; @@ -68,6 +72,7 @@ extends GT_MetaTileEntity_MultiBlockBase { + public static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true; static { @@ -199,7 +204,7 @@ GT_MetaTileEntity_MultiBlockBase { } } - int tTier = requireControlCores ? this.getControlCoreTier() : -1; + int tTier = this.getControlCoreTier(); mInfo.add(getMachineTooltip()); @@ -265,6 +270,10 @@ GT_MetaTileEntity_MultiBlockBase { private final String aRequiresCoreModule = "1x Core Module"; private final String aRequiresMaint = "1x Maintanence Hatch";*/ + public final static String TAG_HIDE_HATCHES = "TAG_HIDE_HATCHES"; + public final static String TAG_HIDE_POLLUTION = "TAG_HIDE_POLLUTION"; + public final static String TAG_HIDE_MACHINE_TYPE = "TAG_HIDE_MACHINE_TYPE"; + @Override public final String[] getDescription() { /*if (aCachedToolTip != null) { @@ -287,22 +296,62 @@ GT_MetaTileEntity_MultiBlockBase { String aRequiresCoreModule = "1x Core Module"; String aRequiresMaint = "1x Maintanence Hatch"; - String[] x = getTooltip(); - //Add Stock Tooltip to bottom of list - String[] z; - if (getPollutionPerTick(null) > 0) { - z = new String[] { - aRequiresMaint, - aRequiresCoreModule, - aRequiresMuffler, - getPollutionTooltip(), - getMachineTooltip()}; + String[] x = getTooltip(); + + //Filter List, toggle switches, rebuild map without flags + boolean showHatches = true; + boolean showMachineType = true; + boolean showPollution = getPollutionPerTick(null) > 0; + AutoMap<String> aTempMap = new AutoMap<String>(); + for (int ee = 0; ee < x.length; ee++) { + String hh = x[ee]; + if (hh.equals(TAG_HIDE_HATCHES)) { + showHatches = false; + } + else if (hh.equals(TAG_HIDE_POLLUTION)) { + showPollution = false; + } + else if (hh.equals(TAG_HIDE_MACHINE_TYPE)) { + showMachineType = false; + } + else { + aTempMap.put(x[ee]); + } } - else { - z = new String[] { - aRequiresMaint, - aRequiresCoreModule, - getMachineTooltip(),}; + //Rebuild + x = new String[aTempMap.size()]; + for (int ee = 0; ee < x.length; ee++) { + x[ee] = aTempMap.get(ee); + } + + + //Assemble ordered map for misc tooltips + AutoMap<String> aOrderedMap = new AutoMap<String>(); + if (showHatches) { + aOrderedMap.put(aRequiresMaint); + aOrderedMap.put(aRequiresCoreModule); + if (showPollution) { + aOrderedMap.put(aRequiresMuffler); + } + } + + if (showMachineType) { + aOrderedMap.put(getMachineTooltip()); + } + + if (showPollution) { + aOrderedMap.put(getPollutionTooltip()); + } + + + + + + //Add Stock Tooltip to bottom of list + String[] z; + z = new String[aOrderedMap.size()]; + for (int ee = 0; ee < z.length; ee++) { + z[ee] = aOrderedMap.get(ee); } int a2, a3; @@ -435,7 +484,12 @@ GT_MetaTileEntity_MultiBlockBase { public void log(String s) { boolean isDebugLogging = CORE.DEBUG; - boolean reset = false; + boolean reset = true; + + if (!isDebugLogging) { + return; + } + if (aLogger == null || reset) { if (isDebugLogging) { try { @@ -501,8 +555,8 @@ GT_MetaTileEntity_MultiBlockBase { //Control Core to control the Multiblocks behaviour. int aControlCoreTier = getControlCoreTier(); - - //If no core, return false; + + //If no core, return false; if (aControlCoreTier == 0 && requireControlCores) { log("No control core found."); return false; @@ -587,7 +641,7 @@ GT_MetaTileEntity_MultiBlockBase { //Only Overclock as high as the control circuit. byte tTierOld = tTier; - tTier = requireControlCores ? (byte) aControlCoreTier : tTierOld; + tTier = getControlCoreTier() > 0 ? (byte) aControlCoreTier : tTierOld; // Overclock if (this.mEUt <= 16) { @@ -859,10 +913,15 @@ GT_MetaTileEntity_MultiBlockBase { public <E> boolean addToMachineListInternal(ArrayList<E> aList, final IMetaTileEntity aTileEntity, - final int aBaseCasingIndex) { + final int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } if (aList.isEmpty()) { if (aTileEntity instanceof GT_MetaTileEntity_Hatch) { - log("Adding " + aTileEntity.getInventoryName() + " at " + new BlockPos(aTileEntity.getBaseMetaTileEntity()).getLocationString()); + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Adding " + aTileEntity.getInventoryName() + " at " + new BlockPos(aTileEntity.getBaseMetaTileEntity()).getLocationString()); + } updateTexture(aTileEntity, aBaseCasingIndex); return aList.add((E) aTileEntity); } @@ -875,13 +934,17 @@ GT_MetaTileEntity_MultiBlockBase { BlockPos aPos = new BlockPos(b); if (b != null && aPos != null) { if (aCurPos.equals(aPos)) { - log("Found Duplicate "+b.getInventoryName()+" at " + aPos.getLocationString()); + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Found Duplicate "+b.getInventoryName()+" at " + aPos.getLocationString()); + } return false; } } } if (aTileEntity instanceof GT_MetaTileEntity_Hatch) { - log("Adding " + aCur.getInventoryName() + " at " + aCurPos.getLocationString()); + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Adding " + aCur.getInventoryName() + " at " + aCurPos.getLocationString()); + } updateTexture(aTileEntity, aBaseCasingIndex); return aList.add((E) aTileEntity); } @@ -892,10 +955,10 @@ GT_MetaTileEntity_MultiBlockBase { public int getControlCoreTier() { //Always return best tier if config is off. - boolean aCoresConfig = gtPlusPlus.core.lib.CORE.ConfigSwitches.requireControlCores; + /*boolean aCoresConfig = gtPlusPlus.core.lib.CORE.ConfigSwitches.requireControlCores; if (!aCoresConfig) { return 10; - } + }*/ if (mControlCoreBus.isEmpty()) { log("No Control Core Modules Found."); @@ -936,9 +999,16 @@ GT_MetaTileEntity_MultiBlockBase { log("Tried to add a secondary control core module."); return false; } - - log("Adding control core module."); - return addToMachineListInternal(mControlCoreBus, aMetaTileEntity, aBaseCasingIndex); + + GT_MetaTileEntity_Hatch_ControlCore Module = (GT_MetaTileEntity_Hatch_ControlCore) aMetaTileEntity; + + if (Module != null) { + if (Module.setOwner(aTileEntity)) { + log("Adding control core module."); + return addToMachineListInternal(mControlCoreBus, aMetaTileEntity, aBaseCasingIndex); + } + } + return false; } @Override @@ -1085,7 +1155,8 @@ GT_MetaTileEntity_MultiBlockBase { if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input || aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input){ ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = null; - ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = aMap; + ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = aMap; + log("Remapped Input Hatch to "+aMap.mNEIName); } else { ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = null; @@ -1117,7 +1188,6 @@ GT_MetaTileEntity_MultiBlockBase { * Enable Texture Casing Support if found in GT 5.09 */ - @SuppressWarnings("deprecation") public boolean updateTexture(final IGregTechTileEntity aTileEntity, int aCasingID){ final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) { @@ -1138,7 +1208,7 @@ GT_MetaTileEntity_MultiBlockBase { if (aMetaTileEntity == null) { return false; } - Method mProper = Class.forName("gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch").getDeclaredMethod("updateTexture", int.class); + Method mProper = ReflectionUtils.getMethod(GT_MetaTileEntity_Hatch.class, "updateTexture", int.class); if (mProper != null){ if (GT_MetaTileEntity_Hatch.class.isInstance(aMetaTileEntity)){ mProper.setAccessible(true); @@ -1146,7 +1216,6 @@ GT_MetaTileEntity_MultiBlockBase { log("Good Method Call for updateTexture."); return true; } - } else { log("Bad Method Call for updateTexture."); @@ -1167,7 +1236,7 @@ GT_MetaTileEntity_MultiBlockBase { log("updateTexture returning false. 1"); return false; } - catch (NoSuchMethodException | SecurityException | ClassNotFoundException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { log("updateTexture returning false."); log("updateTexture returning false. 2"); e.printStackTrace(); @@ -1221,15 +1290,12 @@ GT_MetaTileEntity_MultiBlockBase { @SuppressWarnings("rawtypes") public boolean isThisHatchMultiDynamo(Object aMetaTileEntity){ Class mDynamoClass; - try { - mDynamoClass = Class.forName("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti"); + mDynamoClass = ReflectionUtils.getClass("com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti"); if (mDynamoClass != null){ if (mDynamoClass.isInstance(aMetaTileEntity)){ return true; } } - } - catch (ClassNotFoundException e) {} return false; } @@ -1510,7 +1576,7 @@ GT_MetaTileEntity_MultiBlockBase { public final boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { boolean aStructureCheck = checkMultiblock(aBaseMetaTileEntity, aStack); - boolean aHasCore = (requireControlCores ? (this.getControlCoreBus() != null) : true); + boolean aHasCore = DEBUG_DISABLE_CORES_TEMPORARILY; //(requireControlCores ? (this.getControlCoreBus() != null) : true); return aStructureCheck && aHasCore; } @@ -1521,6 +1587,11 @@ GT_MetaTileEntity_MultiBlockBase { Block aFoundBlock, int aFoundMeta, Block aExpectedBlock, int aExpectedMeta) { boolean isHatch = false; if (aBaseMetaTileEntity != null) { + + if (aCasingID < 64) { + aCasingID = TAE.GTPP_INDEX(aCasingID); + } + isHatch = this.addToMachineList(aBaseMetaTileEntity, aCasingID); if (isHatch) { return true; @@ -1562,7 +1633,9 @@ GT_MetaTileEntity_MultiBlockBase { } else if (aFoundBlock != aExpectedBlock) { log("A1 - Found: "+aFoundBlock.getLocalizedName()+":"+aFoundMeta+", Expected: "+aExpectedBlock.getLocalizedName()+":"+aExpectedMeta); - log("Loc: "+(new BlockPos(aBaseMetaTileEntity).getLocationString())); + if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("Loc: "+(new BlockPos(aBaseMetaTileEntity).getLocationString())); + } return false; } else if (aFoundMeta != aExpectedMeta) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java index a88d6a4832..b6e7b35d68 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/generators/GregtechRocketFuelGeneratorBase.java @@ -4,10 +4,6 @@ import static gregtech.api.enums.GT_Values.V; import java.util.Collection; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -15,9 +11,12 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; - import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_BasicTank { @@ -144,7 +143,7 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ @Override public boolean isOutputFacing(final byte aSide) { - return true; + return this.getBaseMetaTileEntity().getFrontFacing() == aSide; } @Override @@ -154,7 +153,7 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ @Override public long maxEUOutput() { - return this.getBaseMetaTileEntity().isAllowedToWork() ? V[this.mTier] : 0; + return V[this.mTier]; } @Override @@ -164,22 +163,22 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ @Override public boolean doesFillContainers() { - return this.getBaseMetaTileEntity().isAllowedToWork(); + return false; } @Override public boolean doesEmptyContainers() { - return this.getBaseMetaTileEntity().isAllowedToWork(); + return true; } @Override public boolean canTankBeFilled() { - return this.getBaseMetaTileEntity().isAllowedToWork(); + return true; } @Override public boolean canTankBeEmptied() { - return this.getBaseMetaTileEntity().isAllowedToWork(); + return false; } @Override @@ -199,6 +198,61 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ @Override public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + + + //super.onPostTick(aBaseMetaTileEntity, aTick); + + /*if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { + int tFuelValue; + if (this.mFluid == null) { + if (aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() + this.getMinimumStoredEU()) { + this.mInventory[this.getStackDisplaySlot()] = null; + } else { + if (this.mInventory[this.getStackDisplaySlot()] == null) { + this.mInventory[this.getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + } + + this.mInventory[this.getStackDisplaySlot()].setStackDisplayName("Generating: " + + (aBaseMetaTileEntity.getUniversalEnergyStored() - this.getMinimumStoredEU()) + " EU"); + } + } else { + tFuelValue = this.getFuelValue(this.mFluid); + int tConsumed = this.consumedFluidPerOperation(this.mFluid); + if (tFuelValue > 0 && tConsumed > 0 && this.mFluid.amount > tConsumed) { + long tFluidAmountToUse = Math.min((long) (this.mFluid.amount / tConsumed), + (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); + if (tFluidAmountToUse > 0L && aBaseMetaTileEntity + .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) { + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + this.mFluid.amount = (int) ((long) this.mFluid.amount - tFluidAmountToUse * (long) tConsumed); + } + } + } + + if (this.mInventory[this.getInputSlot()] != null + && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20L + + this.getMinimumStoredEU() + && GT_Utility.getFluidForFilledItem(this.mInventory[this.getInputSlot()], true) == null) { + tFuelValue = this.getFuelValue(this.mInventory[this.getInputSlot()]); + if (tFuelValue > 0) { + ItemStack tEmptyContainer = this.getEmptyContainer(this.mInventory[this.getInputSlot()]); + if (aBaseMetaTileEntity.addStackToSlot(this.getOutputSlot(), tEmptyContainer)) { + aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); + aBaseMetaTileEntity.decrStackSize(this.getInputSlot(), 1); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollution()); + } + } + } + } + + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity + .getUniversalEnergyStored() >= this.maxEUOutput() + this.getMinimumStoredEU()); + }*/ + + + + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && ((aTick % 10) == 0)) { if (this.mFluid == null) { if (aBaseMetaTileEntity.getUniversalEnergyStored() < (this.maxEUOutput() + this.getMinimumStoredEU())) { @@ -211,16 +265,14 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ } } else { final int tFuelValue = this.getFuelValue(this.mFluid), tConsumed = this.consumedFluidPerOperation(this.mFluid); - if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount > tConsumed)) { + if ((tFuelValue > 0) && (tConsumed > 0) && (this.mFluid.amount >= tConsumed)) { final long tFluidAmountToUse = Math.min(this.mFluid.amount / tConsumed, (((this.maxEUOutput() * 20) + this.getMinimumStoredEU()) - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); - if ((tFluidAmountToUse > 0) && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)){ - if (this.useFuel){ - this.mFluid.amount -= tFluidAmountToUse * tConsumed; - this.useFuel = false; - } - else { - this.useFuel = true; - } + if ((tFluidAmountToUse > 0) && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)){ + useFuel = Utils.invertBoolean(useFuel); + int aSafeFloor= (int) Math.max(((tFluidAmountToUse * tConsumed)/3), 1); + int toConsumeTrue = (int) (useFuel ? aSafeFloor : 0); + //Logger.INFO("True consumption: "+toConsumeTrue+" | Consuming this tick? "+useFuel); + this.mFluid.amount -= toConsumeTrue; PollutionUtils.addPollution(getBaseMetaTileEntity(), 10 * getPollution()); } } @@ -260,14 +312,25 @@ public abstract class GregtechRocketFuelGeneratorBase extends GT_MetaTileEntity_ FluidStack tLiquid; final Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList; if (tRecipeList != null) { + //Logger.INFO("Step A"); for (final GT_Recipe tFuel : tRecipeList) { - if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) { + //Logger.INFO("Step B"); + if ((tLiquid = tFuel.mFluidInputs[0]) != null) { + //Logger.INFO("Step C"); if (aLiquid.isFluidEqual(tLiquid)) { - return (int) (((long) tFuel.mSpecialValue * this.getEfficiency() * this.consumedFluidPerOperation(tLiquid)) / 100); + //Logger.INFO("Found some fuel?"); + int aperOp = this.consumedFluidPerOperation(tLiquid); + int aConsume = (int) (((long) tFuel.mSpecialValue * this.getEfficiency() * aperOp) / 100); + //Logger.INFO("Fuel Value: "+tFuel.mSpecialValue); + //Logger.INFO("Efficiency: "+getEfficiency()); + //Logger.INFO("Consumed per op: "+aperOp); + //Logger.INFO("Consuming "+aConsume); + return aConsume; } } } } + //Logger.INFO("No Fuel Value | Valid? "+(aLiquid != null)); return 0; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java index 88b4c7bc99..c5554a6679 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/objects/MultiblockLayer.java @@ -17,6 +17,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockAir; import net.minecraft.init.Blocks; @@ -124,10 +125,11 @@ public class MultiblockLayer { GT_MetaTileEntity_Hatch.class }; } - else { - try { + else { + Class aDataHatch = ReflectionUtils.getClass("gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess"); + if (aDataHatch != null) { aHatchTypeClass = new Class[] { - Class.forName("gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess"), + aDataHatch, GT_MetaTileEntity_Hatch_Dynamo.class, GT_MetaTileEntity_Hatch_Energy.class, GT_MetaTileEntity_Hatch_Input.class, @@ -138,7 +140,7 @@ public class MultiblockLayer { GT_MetaTileEntity_Hatch_OutputBus.class, GT_MetaTileEntity_Hatch.class }; - } catch (ClassNotFoundException e) { + } else { aHatchTypeClass = new Class[] { GT_MetaTileEntity_Hatch_Dynamo.class, GT_MetaTileEntity_Hatch_Energy.class, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java b/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java index d5327a6a99..3e0084139e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java @@ -38,12 +38,9 @@ public class GregtechOreDictUnificator { private static boolean mRunThroughTheList = true; static { - try { if (ReflectionUtils.getField(GT_OreDictUnificator.class, "sUnificationTable") == null) { GregTech_API.sItemStackMappings.add(sUnificationTable); } - } - catch (NoSuchFieldException e) {} } /** diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 0556a7f4fe..6b4bab9e26 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -5,6 +5,7 @@ import static gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_Overflow.mOverfl import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -15,37 +16,42 @@ import java.util.TimerTask; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.fluids.FluidStack; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.enums.Materials; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; +import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; import gregtech.common.GT_Proxy; -import gregtech.common.blocks.GT_Block_Machines; -import gregtech.common.render.GT_Renderer_Block; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.ObjMap; import gtPlusPlus.api.objects.minecraft.FormattedTooltipString; +import gtPlusPlus.core.handler.AchievementHandler; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.reflect.ProxyFinder; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.BaseCustomTileEntity; import gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power.BaseCustomPower_MTE; -import gtPlusPlus.xmod.gregtech.common.blocks.GTPP_Block_Machines; -import gtPlusPlus.xmod.gregtech.common.render.GTPP_Render_MachineBlock; +import gtPlusPlus.xmod.gregtech.loaders.misc.AssLineAchievements; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.FluidStack; public class Meta_GT_Proxy { @@ -64,6 +70,8 @@ public class Meta_GT_Proxy { private static Class sBaseMetaTileEntityClass; private static Class sBaseMetaTileEntityClass2; + public static AchievementHandler mAssemblyAchievements; + public static final Map<String, FormattedTooltipString> mCustomGregtechMetaTooltips = new LinkedHashMap<String, FormattedTooltipString>(); @@ -102,7 +110,121 @@ public class Meta_GT_Proxy { } public void postInit() { + mAssemblyAchievements = new AchievementHandler(); + } + + public static boolean generatePlasmaRecipesForAdvVacFreezer() { + + AutoMap<Recipe_GT> aFreezerMapRebaked = new AutoMap<Recipe_GT>(); + AutoMap<Recipe_GT> aRemovedRecipes = new AutoMap<Recipe_GT>(); + + //Find recipes containing Plasma and map them + for (Recipe_GT y : Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList) { + if (y.mFluidInputs.length > 0) { + for (FluidStack r : y.mFluidInputs) { + if (r.getUnlocalizedName().toLowerCase().contains("plasma")) { + aRemovedRecipes.put(y); + continue; + } + } + aFreezerMapRebaked.put(y); + } + } + + AutoMap<Recipe_GT> aNewRecipes = new AutoMap<Recipe_GT>(); + int aAtomicMass = 0; + int aAtomicTier = 0; + + final FluidStack NULL_PLASMA = Materials._NULL.getPlasma(1); + + for (String s : ELEMENT.NAMES) { + + aAtomicMass++; + aAtomicTier = (aAtomicMass/30)+1; + FluidStack aMoltenFluid = null; + FluidStack aPlasma = null; + + //Try Get Material via Gregtech + Materials aGregMaterial = MaterialUtils.getMaterial(s); + if (aGregMaterial != null) { + aMoltenFluid = aGregMaterial.getMolten(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getFluid(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getGas(1); + if (aMoltenFluid == null) { + aMoltenFluid = aGregMaterial.getSolid(1); + } + } + } + aPlasma = aGregMaterial.getPlasma(100); + } + + //Just wildcard values + if (aMoltenFluid == null || aPlasma == null) { + if (aMoltenFluid == null) { + aMoltenFluid = FluidUtils.getWildcardFluidStack(s, 1); + } + if (aPlasma == null) { + aPlasma = FluidUtils.getFluidStack("plasma."+s.toLowerCase(), 1); + } + } + + //Skip this material + if (aMoltenFluid == null || aPlasma == null || aPlasma.isFluidEqual(NULL_PLASMA)) { + Logger.INFO("Could not generate Advanced Vacuum Freezer recipe. Cooling "+s+" plasma. Molten Form Exists? "+(aMoltenFluid != null)+" | Plasma Exists? "+(aPlasma != null)); + continue; + } + else { + //Build a new plasma recipe + int aTotalTickTime = (20 * 1 + (aAtomicMass)); + Recipe_GT aTempRecipe = new Recipe_GT(true, + new ItemStack[] {}, + new ItemStack[] {}, + null, + new int[] {10000}, + new FluidStack[] { + aPlasma, + FluidUtils.getFluidStack("cryotheum", aTotalTickTime) + }, + new FluidStack[] { + aMoltenFluid + }, + aTotalTickTime, + (int) GT_Values.V[4+aAtomicTier], + aAtomicMass); + + //Add it to the map if it's valid + if (aTempRecipe != null) { + aNewRecipes.put(aTempRecipe); + } + } + + } + + + //Add the new recipes to the map we will rebake over the original + for (Recipe_GT w : aNewRecipes) { + aFreezerMapRebaked.put(w); + } + + //Best not touch the original map if we don't have a valid map to override it with. + if (aFreezerMapRebaked.size() > 0) { + + int aOriginalCount = Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.size(); + + //Empty the original map + Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.clear(); + + //Rebake the real map + for (Recipe_GT w : aFreezerMapRebaked) { + Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.add(w); + } + + return Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes.mRecipeList.size() >= aOriginalCount; + } + return false; } public static TileEntity constructCustomGregtechMetaTileEntityByMeta(int aMeta) { @@ -280,7 +402,7 @@ public class Meta_GT_Proxy { if (proxyGT != null && proxyGT instanceof GT_Proxy) { try { return ReflectionUtils.getField(proxyGT.getClass(), fieldName).get(proxyGT); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } } return null; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java index c1db39b132..1604cc5acd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java @@ -5,7 +5,6 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -33,6 +32,8 @@ public class StaticFields59 { public static final Field mMultiblockChemicalRecipes; public static final Field mDescriptionArray; public static final Field mCasingTexturePages; + public static final Field mAssLineVisualMapNEI; + public static final GT_Recipe_Map sAssemblylineVisualRecipes; public static final Method mCalculatePollutionReduction; public static final Method mAddFurnaceRecipe; @@ -43,28 +44,51 @@ public class StaticFields59 { //OrePrefixes static { + Logger.INFO("[SH] Creating Static Helper for various fields which require reflective access."); mGtBlockCasings5 = getField(GregTech_API.class, "sBlockCasings5"); + Logger.INFO("[SH] Got Field: sBlockCasings5"); mPreventableComponents = getField(OrePrefixes.class, "mPreventableComponents"); + Logger.INFO("[SH] Got Field: mPreventableComponents"); mDisabledItems = getField(OrePrefixes.class, "mDisabledItems"); - mMultiblockChemicalRecipes = getField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes"); + Logger.INFO("[SH] Got Field: mDisabledItems"); mDescriptionArray = getField(GT_MetaTileEntity_TieredMachineBlock.class, "mDescriptionArray"); + Logger.INFO("[SH] Got Field: mDescriptionArray"); mCasingTexturePages = getField(BlockIcons.class, "casingTexturePages"); - - mCalculatePollutionReduction = getMethod(GT_MetaTileEntity_Hatch_Muffler.class, "calculatePollutionReduction", int.class); - - Logger.INFO("Initializing a recipe handler for different versions of Gregtech 5."); - //Yep... - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { - Logger.INFO("Selecting GT 5.7/5.8 Recipe Set"); - mAddFurnaceRecipe = getMethod(GT_ModHandler.class, "addSmeltingAndAlloySmeltingRecipe", ItemStack.class, ItemStack.class); + Logger.INFO("[SH] Got Field: casingTexturePages"); + + mAssLineVisualMapNEI = getField(GT_Recipe_Map.class, "sAssemblylineVisualRecipes"); + Logger.INFO("[SH] Got Field: mAssLineVisualMapNEI"); + GT_Recipe_Map aTemp; + if (mAssLineVisualMapNEI != null) { + try { + aTemp = (GT_Recipe_Map) mAssLineVisualMapNEI.get(null); + Logger.INFO("[SH] Got Field: sAssemblylineVisualRecipes"); + } catch (IllegalArgumentException | IllegalAccessException e) { + aTemp = null; + } + } else { + aTemp = null; } - else { - Logger.INFO("Selecting GT 5.9 Recipe Set"); - mAddFurnaceRecipe = getMethod(GT_ModHandler.class, "addSmeltingAndAlloySmeltingRecipe", ItemStack.class, ItemStack.class, boolean.class); + + sAssemblylineVisualRecipes = aTemp; + mMultiblockChemicalRecipes = getField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes"); + Logger.INFO("[SH] Got Field: sMultiblockChemicalRecipes"); + + mCalculatePollutionReduction = getMethod(GT_MetaTileEntity_Hatch_Muffler.class, "calculatePollutionReduction", + int.class); + Logger.INFO("[SH] Got Method: calculatePollutionReduction"); + + // Yep... + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + mAddFurnaceRecipe = getMethod(GT_ModHandler.class, "addSmeltingAndAlloySmeltingRecipe", ItemStack.class, + ItemStack.class); + Logger.INFO("[SH] Got Method: addSmeltingAndAlloySmeltingRecipe"); + } else { + mAddFurnaceRecipe = getMethod(GT_ModHandler.class, "addSmeltingAndAlloySmeltingRecipe", ItemStack.class, + ItemStack.class, boolean.class); + Logger.INFO("[SH] Got Method: addSmeltingAndAlloySmeltingRecipe"); } - - - + } public static synchronized final Block getBlockCasings5() { @@ -84,11 +108,7 @@ public class StaticFields59 { } public static Field getField(Class a, String b) { - try { - return ReflectionUtils.getField(a, b); - } catch (NoSuchFieldException e) { - return null; - } + return ReflectionUtils.getField(a, b); } public static Method getMethod(Class a, String b, Class... params) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java index b3366df96b..54323d8c2e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks4.java @@ -86,8 +86,8 @@ extends GregtechMetaCasingBlocksAbstract { case 2: return TexturesGtBlock.TEXTURE_ORGANIC_PANEL_A_GLOWING.getIcon(); //Coke Oven Casing Tier 2 - case 3: - return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); + case 3: + return TexturesGtBlock.TEXTURE_METAL_PANEL_A.getIcon(); //Material Press Casings case 4: return TexturesGtBlock.Casing_Material_MaragingSteel.getIcon(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index 0178bac4da..bda75be793 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -23,6 +23,7 @@ import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; import ic2.api.info.Info; import ic2.api.item.ElectricItem; @@ -291,12 +292,11 @@ public class ChargingHelper { } //Try get charge direct from NBT for GT and IC2 stacks - try { Logger.WARNING("3"); if (mTemp.getItem() instanceof GT_MetaGenerated_Tool_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_02 - || Class.forName("gregtech.common.items.GT_MetaGenerated_Item_03").isInstance(mTemp.getItem()) + || ReflectionUtils.getClass("gregtech.common.items.GT_MetaGenerated_Item_03").isInstance(mTemp.getItem()) || mTemp.getItem().getClass().getName().toLowerCase().equals(("gregtech.common.items.GT_MetaGenerated_Tool_01").toLowerCase())){ if (!NBTUtils.hasKey(mTemp, "GT.ItemCharge")){ if (!mTemp.getDisplayName().toLowerCase().contains("battery")){ @@ -314,10 +314,7 @@ public class ChargingHelper { } else if (mTemp.getItem() instanceof IElectricItem){ mitemCurrentCharge = NBTUtils.getLong(mTemp, "charge"); - } - } catch (ClassNotFoundException e) { - - } + } double mVoltageIncrease; if (mItemEuTLimit >= mVoltage){ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java index 2bfb07ff4a..3c60ae664e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java @@ -321,14 +321,12 @@ public class TreeFarmHelper { return blockHumus; } else if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){ - try { - final Class<?> humusClass = Class.forName("forestry.core.blocks.BlockSoil"); + final Class<?> humusClass = ReflectionUtils.getClass("forestry.core.blocks.BlockSoil"); final ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1); if (humusClass != null){ blockHumus = Block.getBlockFromItem(humusStack.getItem()); return Block.getBlockFromItem(humusStack.getItem()); } - } catch (final ClassNotFoundException e) {} } return null; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java index 7f426f8abb..f42fc49e53 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -169,12 +169,12 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { * Power Gems */ - GregtechItemList.Battery_Gem_1.set(this.addItem(tLastID = 66, "Fission Power Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 24L), getTcAspectStack(TC_Aspects.POTENTIA, 16L)})); - this.setElectricStats(32000 + tLastID, 32000000L, GT_Values.V[5], 5L, -3L, false); - GregtechItemList.Battery_Gem_2.set(this.addItem(tLastID = 68, "Fusion Power Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 16L), getTcAspectStack(TC_Aspects.METALLUM, 32L), getTcAspectStack(TC_Aspects.POTENTIA, 32L)})); - this.setElectricStats(32000 + tLastID, 750000000L, GT_Values.V[6], 6L, -3L, false); - GregtechItemList.Battery_Gem_3.set(this.addItem(tLastID = 70, "Portable Neutron Star", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 32L), getTcAspectStack(TC_Aspects.METALLUM, 48L), getTcAspectStack(TC_Aspects.POTENTIA, 64L)})); - this.setElectricStats(32000 + tLastID, 64000000000L, GT_Values.V[7], 7L, -3L, false); + GregtechItemList.Battery_Gem_1.set(this.addItem(tLastID = 66, "Proton Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 8L), getTcAspectStack(TC_Aspects.METALLUM, 24L), getTcAspectStack(TC_Aspects.POTENTIA, 16L)})); + this.setElectricStats(32000 + tLastID, GT_Values.V[6] * 20 * 300 / 4, GT_Values.V[6], 6L, -3L, false); + GregtechItemList.Battery_Gem_2.set(this.addItem(tLastID = 68, "Electron Cell", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 16L), getTcAspectStack(TC_Aspects.METALLUM, 32L), getTcAspectStack(TC_Aspects.POTENTIA, 32L)})); + this.setElectricStats(32000 + tLastID, GT_Values.V[7] * 20 * 300 / 4, GT_Values.V[7], 7L, -3L, false); + GregtechItemList.Battery_Gem_3.set(this.addItem(tLastID = 70, "Quark Entanglement", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 32L), getTcAspectStack(TC_Aspects.METALLUM, 48L), getTcAspectStack(TC_Aspects.POTENTIA, 64L)})); + this.setElectricStats(32000 + tLastID, GT_Values.V[8] * 20 * 300 / 4, GT_Values.V[8], 8L, -3L, false); //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_1.get(1), "batteryFutureBasic"); //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_2.get(1), "batteryFutureGood"); //ItemUtils.addItemToOreDictionary(GregtechItemList.Battery_Gem_3.get(1), "batteryFutureAdvanced"); @@ -285,7 +285,7 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { //Fusion Reactor MK4 Singularity GregtechItemList.Compressed_Fusion_Reactor.set(this.addItem(100, "Hypervisor Matrix (Fusion)", "A memory unit containing an RI (Restricted Intelligence)", new Object[0])); - CORE.RA.addCompressorRecipe(ItemList.FusionComputer_UV.get(9), GregtechItemList.Compressed_Fusion_Reactor.get(1), (int) GT_Values.V[7], (int) GT_Values.V[8]); + //NanoTubes GregtechItemList.NanoTube_Base_Substrate.set(this.addItem(101, "Silicon Base Substrate", "Used in the production of Carbon Nanotubes", new Object[0])); @@ -294,6 +294,30 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { GregtechItemList.Carbyne_Sheet_Finished.set(this.addItem(104, "Carbyne Composite Panel", "Nanotubes which contain LAC, arranged side by side and compressed further", new Object[0])); GregtechItemList.Laser_Lens_Special.set(this.addItem(105, "Quantum Anomaly", "Probably should shoot it with lasers", new Object[0])); + GregtechItemList.Battery_Casing_Gem_1.set(this.addItem(106, "Containment Unit I", "Used in crafting", new Object[0])); + GregtechItemList.Battery_Casing_Gem_2.set(this.addItem(107, "Containment Unit II", "Used in crafting", new Object[0])); + GregtechItemList.Battery_Casing_Gem_3.set(this.addItem(108, "Advanced Containment Unit", "Used in crafting", new Object[0])); + GregtechItemList.Battery_Casing_Gem_4.set(this.addItem(109, "Exotic Containment Unit", "Used in crafting", new Object[0])); + + GregtechItemList.Battery_Gem_4.set(this.addItem(tLastID = 110, "Graviton Anomaly", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 64L), getTcAspectStack(TC_Aspects.METALLUM, 64L), getTcAspectStack(TC_Aspects.POTENTIA, 64L)})); + this.setElectricStats(32000 + tLastID, (64000000000L*16), GT_Values.V[9], 9L, -3L, false); + + + + /* + * Bombs + */ + GregtechItemList.Bomb_Cast.set(this.addItem(111, "Bomb Cast", "Used in the production of Bombs", new Object[0])); + GregtechItemList.Bomb_Cast_Molten.set(this.addItem(112, "Bomb Cast (Hot)", "Consider cooling this off", new Object[0])); + GregtechItemList.Bomb_Cast_Set.set(this.addItem(113, "Bomb Cast (Set)", "Break it open for the goodies inside!", new Object[0])); + GregtechItemList.Bomb_Cast_Broken.set(this.addItem(114, "Bomb Cast (Broken)", "This is probably just junk", new Object[0])); + GregtechItemList.Bomb_Cast_Mold.set(this.addItem(115, "Mold (Bomb Cast)", "Used in the production of Bombs", new Object[0])); + + + + + + } private boolean registerComponents_ULV(){ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java index 22ce41282f..7dd376759a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java @@ -82,14 +82,14 @@ public class GTPP_CapeRenderer extends RenderPlayer { AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; if (!ConfigSwitches.enableCustomCapes) { aEvent.setCanceled(true); - Logger.INFO("A1"); + Logger.WARNING("A1"); return; } if (hasResourceChecked) { if (!hasCape && !CORE.DEVENV) { aEvent.setCanceled(true); - Logger.INFO("A2"); + Logger.WARNING("A2"); return; } } @@ -141,7 +141,7 @@ public class GTPP_CapeRenderer extends RenderPlayer { if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible() || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) { aEvent.setCanceled(true); - Logger.INFO("A3"); + Logger.WARNING("A3"); return; } @@ -209,7 +209,7 @@ public class GTPP_CapeRenderer extends RenderPlayer { Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152652_a(g); if (profile != null) { - Logger.INFO("[Capes++] Found for UUID check: " + profile.getName() + "."); + Logger.WARNING("[Capes++] Found for UUID check: " + profile.getName() + "."); return profile.getName(); } } else { @@ -218,7 +218,7 @@ public class GTPP_CapeRenderer extends RenderPlayer { Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152652_a(g); if (profile != null) { - Logger.INFO("[Capes++] Found for UUID check 2: " + profile.getName() + "."); + Logger.WARNING("[Capes++] Found for UUID check 2: " + profile.getName() + "."); return profile.getName(); } } @@ -230,7 +230,7 @@ public class GTPP_CapeRenderer extends RenderPlayer { Logger.WORLD("[Capes++] Mojang/Cache checking for " + name + "."); GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(name); if (profile != null) { - Logger.INFO("[Capes++] Found for name check: " + profile.getName() + "."); + Logger.WARNING("[Capes++] Found for name check: " + profile.getName() + "."); return profile.getName(); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java index 288501086b..6a42232e40 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntityRocketFuelGenerator.java @@ -1,9 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.generators; import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.item.ItemStack; - import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.ItemList; @@ -18,6 +15,7 @@ import gregtech.api.util.Recipe_GT; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.generators.GregtechRocketFuelGeneratorBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.item.ItemStack; public class GregtechMetaTileEntityRocketFuelGenerator extends GregtechRocketFuelGeneratorBase { @@ -25,7 +23,7 @@ extends GregtechRocketFuelGeneratorBase { public int mEfficiency; public GregtechMetaTileEntityRocketFuelGenerator(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier, "Requires Rocket Fuels.", new ITexture[0]); + super(aID, aName, aNameRegional, aTier, "Requires GT++ Rocket Fuels", new ITexture[0]); this.onConfigLoad(); } @@ -41,6 +39,7 @@ extends GregtechRocketFuelGeneratorBase { @Override public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + //Logger.INFO("Valid Fuels: "+Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.mRecipeList.size()); return new GregtechMetaTileEntityRocketFuelGenerator(this.mName, this.mTier, this.mDescription, this.mTextures); } @@ -60,7 +59,9 @@ extends GregtechRocketFuelGeneratorBase { @Override public int getEfficiency() { - return ((40+((this.mTier) * 16))/4)+(this.mTier); + int eff = ((40+((this.mTier) * 16))/4)+(this.mTier); + return eff; + } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java index eb6a9bfcd3..c364fe5e9e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java @@ -229,7 +229,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi //I stole this code reduction = (MathUtils.safeInt((long)reduction*this.mBaseEff)/100000)*mAirSides*Math.max((tTier-2), 1); Logger.WARNING("reduction[2]:"+reduction); - reduction = GT_Utility.safeInt(((long)reduction/100)*this.mOptimalAirFlow); + reduction = MathUtils.safeInt(((long)reduction/100)*this.mOptimalAirFlow); Logger.WARNING("reduction[3]:"+reduction); mPollutionReduction = reduction; @@ -683,7 +683,7 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); reduction += (((Math.max((tTier-2), 1)*2)*50)*mAirSides); reduction = (MathUtils.safeInt((long)reduction*this.mBaseEff)/100000)*mAirSides*Math.max((tTier-2), 1); - reduction = GT_Utility.safeInt(((long)reduction/100)*this.mOptimalAirFlow); + reduction = MathUtils.safeInt(((long)reduction/100)*this.mOptimalAirFlow); aTooltipSuper.put("Maximum pollution removed per second: "+reduction); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index 25c14a68e7..f2e3b3c3c0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -17,7 +17,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.EntityUtils; @@ -457,7 +456,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { } } - public BlockPos getTileEntityPosition(){ + public BlockPos getTileEntityPosition(){ return new BlockPos(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld()); } @@ -533,10 +532,7 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { @Override public void onServerStart() { mWirelessChargingMap.clear(); - mLocalChargingMap.clear(); - if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)){ - mHasBeenMapped = true; - } + mLocalChargingMap.clear(); super.onServerStart(); } @@ -552,4 +548,12 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity { super.doExplosion(aExplosionPower); } + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (!mHasBeenMapped && ChargingHelper.addEntry(getTileEntityPosition(), this)){ + mHasBeenMapped = true; + } + super.onPreTick(aBaseMetaTileEntity, aTick); + } + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java index 6515589905..eca02d290e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java @@ -70,13 +70,11 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase { "Only uses 75% of the eu/t normally required", "Processes five items per voltage tier", "Size: 3x3x3 (Hollow)", + "Supply Depot. Casings (10 at least!)", "Controller (front centered)", - "1x Input Bus (anywhere)", - "1x Output Bus (anywhere)", - "1x Energy Hatch (anywhere)", - "1x Maintenance Hatch (anywhere)", - "1x Muffler (anywhere)", - "Supply Depot. Casings for the rest (10 at least!)" + "1x Input Bus", + "1x Output Bus", + "1x Energy Hatch", }; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java index d90b88e4d8..c549cf9216 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java @@ -65,15 +65,13 @@ extends GregtechMeta_MultiBlockBase { "Size: nx3xn [WxHxL] (Hollow)", "n can be 3, 5 or 7", "Max Size required to process Plasma recipes", + mCasingName+"s (10 at least!)", "Controller (top centered)", - "1x Input Bus (anywhere)", - "1x Output Bus (anywhere)", - "1x Input Hatch (anywhere)", - "1x Output Hatch (anywhere)", - "1x Energy Hatch (anywhere)", - "1x Muffler Hatch (anywhere)", - "1x Maintenance Hatch (Back Center)", - mCasingName+"s for the rest", + "1x Input Bus", + "1x Output Bus", + "1x Input Hatch", + "1x Output Hatch", + "1x Energy Hatch", }; } @@ -85,10 +83,10 @@ extends GregtechMeta_MultiBlockBase { @Override public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { if (aSide == 0 || aSide == 1) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.getIndexFromPage(2, 1)], + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[mCasingTextureID], new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Default_Active : TexturesGtBlock.Overlay_Machine_Controller_Default)}; } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.getIndexFromPage(2, 1)]}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[mCasingTextureID]}; } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java index e627e99aa7..5e852b5f76 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java @@ -51,7 +51,6 @@ extends GregtechMeta_MultiBlockBase { "1x Output Bus", "1x Input Hatch", "1x Energy Hatch", - "Maintenance Hatch must be at the back, centered", }; } @@ -114,6 +113,24 @@ extends GregtechMeta_MultiBlockBase { final int tX = this.getBaseMetaTileEntity().getXCoord(); final int tY = this.getBaseMetaTileEntity().getYCoord(); final int tZ = this.getBaseMetaTileEntity().getZCoord(); + + + //Check Rear Middle + { + Block aBlock = this.getBaseMetaTileEntity() + .getBlockAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + int aMeta = this.getBaseMetaTileEntity() + .getMetaIDAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + IGregTechTileEntity aTile = this.getBaseMetaTileEntity() + .getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + if (!isValidBlockForStructure(aTile, getCasingTextureIndex(), true, aBlock, aMeta, getCasingBlock(), + getCasingMeta())) { + log("Bad Casing on Cutting Machine."); + return false; + } + } + + for (byte i = -1; i < 2; i = (byte) (i + 1)) { for (byte j = -1; j < 2; j = (byte) (j + 1)) { if ((i != 0) || (j != 0)) { @@ -122,41 +139,26 @@ extends GregtechMeta_MultiBlockBase { int aMeta = this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)); IGregTechTileEntity aTile = this.getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)); if (!isValidBlockForStructure(aTile, getCasingTextureIndex(), true, aBlock, aMeta, getCasingBlock(), getCasingMeta())) { - Logger.INFO("Bad Casing on Cutting Machine."); + log("Bad Casing on Cutting Machine."); return false; } } } } } - if ((this.mOutputHatches.size() != 0) || (this.mInputHatches.size() != 0)) { - Logger.INFO("Use Busses, Not Hatches for Input/Output."); - return false; - } if ((this.mInputBusses.size() == 0) || (this.mOutputBusses.size() == 0)) { - Logger.INFO("Incorrect amount of Input & Output busses."); + log("Incorrect amount of Input & Output busses."); return false; } - this.mMaintenanceHatches.clear(); - final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { - this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this.getCasingTextureIndex(); - } else { - Logger.INFO("Maintenance hatch must be in the middle block on the back."); - return false; - } - } if ((this.mMaintenanceHatches.size() != 1)) { - Logger.INFO("Incorrect amount of Maintenance or Energy hatches."); + log("Incorrect amount of Maintenance or Energy hatches."); return false; } } else { - Logger.INFO("False 5"); + log("False 5"); return false; } - Logger.INFO("True"); + log("True"); return true; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java index 0b1691358c..f4f8a5fe78 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java @@ -113,9 +113,9 @@ extends GregtechMeta_MultiBlockBase { } if (inputs.length > 0) { int para = (4* GT_Utility.getTier(this.getMaxInputVoltage())); - Logger.WARNING("Recipe. ["+inputs.length+"]["+para+"]"); + log("Recipe. ["+inputs.length+"]["+para+"]"); if (checkRecipeGeneric(inputs, new FluidStack[]{}, para, 100, 250, 10000)) { - Logger.WARNING("Recipe 2."); + log("Recipe 2."); return true; } } @@ -152,6 +152,22 @@ extends GregtechMeta_MultiBlockBase { return false; } } + + //Check Rear Middle + { + Block aBlock = this.getBaseMetaTileEntity() + .getBlockAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + int aMeta = this.getBaseMetaTileEntity() + .getMetaIDAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + IGregTechTileEntity aTile = this.getBaseMetaTileEntity() + .getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + if (!isValidBlockForStructure(aTile, getCasingTextureIndex(), true, aBlock, aMeta, getCasingBlock(), + getCasingMeta())) { + log("Bad Casing on Extruder."); + return false; + } + } + final int tX = this.getBaseMetaTileEntity().getXCoord(); final int tY = this.getBaseMetaTileEntity().getYCoord(); final int tZ = this.getBaseMetaTileEntity().getZCoord(); @@ -164,7 +180,7 @@ extends GregtechMeta_MultiBlockBase { int aMeta = this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)); IGregTechTileEntity aTile = this.getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)); if (!isValidBlockForStructure(aTile, getCasingTextureIndex(), true, aBlock, aMeta, getCasingBlock(), getCasingMeta())) { - Logger.INFO("Bad Casing on Extruder."); + log("Bad Casing on Extruder."); return false; } @@ -173,29 +189,18 @@ extends GregtechMeta_MultiBlockBase { } } if ((this.mInputBusses.size() == 0) || (this.mOutputBusses.size() == 0)) { - Logger.WARNING("Incorrect amount of Input || Output busses."); + log("Incorrect amount of Input || Output busses."); return false; } - this.mMaintenanceHatches.clear(); - final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { - this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this.getCasingTextureIndex(); - } else { - Logger.WARNING("Maintenance hatch must be in the middle block on the back."); - return false; - } - } if ((this.mMaintenanceHatches.size() != 1)) { - Logger.WARNING("Incorrect amount of Maintenance hatches."); + log("Incorrect amount of Maintenance hatches."); return false; } } else { - Logger.WARNING("False 5"); + log("False 5"); return false; } - Logger.WARNING("True"); + log("True"); return true; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java index 7472b71a95..064dc8372b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java @@ -3,6 +3,7 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; import static gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes; import static gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map.sAdvFreezerRecipes_GT; +import gregtech.api.GregTech_API; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; @@ -28,6 +29,7 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta public static int CASING_TEXTURE_ID; public static String mCryoFuelName = "Gelid Cryotheum"; public static String mCasingName = "Advanced Cryogenic Casing"; + public static String mHatchName = "Cryotheum Hatch"; public static FluidStack mFuelStack; public GregtechMetaTileEntity_IndustrialVacuumFreezer(final int aID, final String aName, final String aNameRegional) { @@ -36,6 +38,7 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); mCryoFuelName = mFuelStack.getLocalizedName(); mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 10); + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 967); } public GregtechMetaTileEntity_IndustrialVacuumFreezer(final String aName) { @@ -44,6 +47,7 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta CASING_TEXTURE_ID = TAE.getIndexFromPage(2, 10); mCryoFuelName = mFuelStack.getLocalizedName(); mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings3Misc, 10); + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 967); } public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { @@ -63,21 +67,19 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends GregtechMeta if (mCryoFuelName.toLowerCase().contains(".")) { mCryoFuelName = FluidUtils.getFluidStack("cryotheum", 1).getLocalizedName(); } + if (mHatchName.toLowerCase().contains(".name")) { + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 967); + } return new String[]{ - "Controller Block for the Advanced Cryogenic Freezer", - "Super cools hot ingots and cells", - "Processes four Vacuum Freezer Recipes at 200% speed", + "Factory Grade Advanced Vacuum Freezer", + "Speed: 200% | Eu Usage: 100% | Parallel: 4", "Consumes 1L of "+mCryoFuelName+"/t during operation", - "Size(WxHxD): 3x3x3 (Hollow)", - mCasingName+"s for the rest (10 at least!)", - "Controller (Front centered)", - "1x Input Bus", - "1x Output Bus", - "1x Input Hatch", - "1x Output Hatch (optional)", - "1x Energy Hatch", - }; + "Constructed exactly the same as a normal Vacuum Freezer", + "Use "+mCasingName+"s (10 at least!)", + "1x " + mHatchName + " (Required)", + "TAG_HIDE_HATCHES" + }; } public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java index bf33892420..d798691d04 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java @@ -118,6 +118,21 @@ extends GregtechMeta_MultiBlockBase { return false; } } + + //Check Rear Middle + { + Block aBlock = this.getBaseMetaTileEntity() + .getBlockAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + int aMeta = this.getBaseMetaTileEntity() + .getMetaIDAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + IGregTechTileEntity aTile = this.getBaseMetaTileEntity() + .getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); + if (!isValidBlockForStructure(aTile, getCasingTextureIndex(), true, aBlock, aMeta, getCasingBlock(), + getCasingMeta())) { + log("Bad Casing on Wiremill."); + return false; + } + } final int tX = this.getBaseMetaTileEntity().getXCoord(); final int tY = this.getBaseMetaTileEntity().getYCoord(); final int tZ = this.getBaseMetaTileEntity().getZCoord(); @@ -129,7 +144,7 @@ extends GregtechMeta_MultiBlockBase { int aMeta = this.getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)); IGregTechTileEntity aTile = this.getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)); if (!isValidBlockForStructure(aTile, getCasingTextureIndex(), true, aBlock, aMeta, getCasingBlock(), getCasingMeta())) { - Logger.INFO("Bad Casing on Wiremill."); + log("Bad Casing on Wiremill."); return false; } } @@ -137,33 +152,22 @@ extends GregtechMeta_MultiBlockBase { } } if ((this.mOutputHatches.size() != 0) || (this.mInputHatches.size() != 0)) { - Logger.INFO("Use Busses, Not Hatches for Input/Output."); + log("Use Busses, Not Hatches for Input/Output."); return false; } if ((this.mInputBusses.size() == 0) || (this.mOutputBusses.size() == 0)) { - Logger.INFO("Incorrect amount of Input & Output busses."); + log("Incorrect amount of Input & Output busses."); return false; } - this.mMaintenanceHatches.clear(); - final IGregTechTileEntity tTileEntity = this.getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(this.getBaseMetaTileEntity().getBackFacing(), 4); - if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) { - if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) { - this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity()); - ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock = this.getCasingTextureIndex(); - } else { - Logger.INFO("Maintenance hatch must be in the middle block on the back."); - return false; - } - } if ((this.mMaintenanceHatches.size() != 1)) { - Logger.INFO("Incorrect amount of Maintenance or Energy hatches."); + log("Incorrect amount of Maintenance or Energy hatches."); return false; } } else { - Logger.INFO("False 5"); + log("False 5"); return false; } - Logger.INFO("True"); + log("True"); return true; } @@ -200,12 +204,4 @@ extends GregtechMeta_MultiBlockBase { public byte getCasingTextureIndex() { return (byte) TAE.GTPP_INDEX(6); } - - private boolean addToMachineList(final IGregTechTileEntity tTileEntity) { - return ((this.addMaintenanceToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addInputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addOutputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addMufflerToMachineList(tTileEntity, this.getCasingTextureIndex()))); - } - - private boolean addEnergyInputToMachineList(final IGregTechTileEntity tTileEntity) { - return ((this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex()))); - } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java index e4f984ee18..ac362e2c40 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java @@ -103,21 +103,14 @@ public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 968); } - return new String[] { "Controller Block for the Advanced Electric Blast Furnace", - "120% faster than using an equal tier EBF", "Only uses 90% of the eu/t normally required", - "Processes upto 8 recipes at once", - "Consumes 10L of " + mHotFuelName + "/s during operation", - "Each 900K over the min. Heat Capacity grants 5% speedup (multiplicatively)", - "Each 1800K over the min. Heat Capacity allows for one upgraded overclock", - "Upgraded overclocks reduce recipe time to 25% and increase EU/t to 400%", - "Size(WxHxD): 3x4x3 (Hollow), Controller (Front middle bottom)", - "16x Heating Coils (Two middle Layers, hollow)", - "1x " + mHatchName, - "1x Input Hatch/Bus", - "1x Output Hatch/Bus (Bottom Layer)", - "1x Output Hatch to recover CO2/CO/SO2 (optional, any top layer casing),", - " Recovery scales with Muffler Hatch tier", mCasingName + "s for the rest", - "1x Energy Hatch", + return new String[] { + "Factory Grade Advanced Blast Furnace", + "Speed: 120% | Eu Usage: 90% | Parallel: 8", + "Consumes 10L of " + mHotFuelName + " per second during operation", + "Constructed exactly the same as a normal EBF", + "Use "+mCasingName+"s (10 at least!)", + "1x " + mHatchName + " (Required)", + "TAG_HIDE_HATCHES" }; } @@ -230,10 +223,10 @@ public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase this.mHeatingCapacity = 9001; break; case 7: - this.mHeatingCapacity = 12001; + this.mHeatingCapacity = 9901; break; case 8: - this.mHeatingCapacity = 15001; + this.mHeatingCapacity = 10801; break; default: Logger.INFO("Heating Coils are bad."); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java index 8abf506e55..7dfdbf75d6 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java @@ -47,15 +47,12 @@ extends GregtechMeta_MultiBlockBase { if (mCasingName.contains("gt.blockcasings")) { mCasingName = ItemList.Casing_RobustTungstenSteel.get(1).getDisplayName(); } - return new String[]{ - "Controller Block for the Advanced Implosion Compressor", - "Processes upto ((Tier/2)+1) recipes at once", - "Size(WxHxD): 3x3x3 (Hollow)", - mCasingName+"s (10 at least!)", - "Controller (Front centered)", - "1x Input Bus", - "1x Output Bus", - "1x Energy Hatch", + return new String[]{ + "Factory Grade Advanced Implosion Compressor", + "Speed: 100% | Eu Usage: 100% | Parallel: ((Tier/2)+1)", + "Constructed exactly the same as a normal Implosion Compressor", + "Use "+mCasingName+"s (10 at least!)", + "TAG_HIDE_HATCHES" }; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java index 759378013c..c31a7c0758 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java @@ -221,7 +221,7 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase { return r; } } - } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } } return GT_Recipe.GT_Recipe_Map.sAssemblerRecipes; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java index 6ec95ff16b..8925caf480 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java @@ -130,19 +130,18 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { //"Input voltage can be changed within the GUI", "Place Input/Output Hatches on sides and bottom", "Power can only be inserted into the back", - "Power can only be extracted from the top", + //e"Power can only be extracted from the top", + TAG_HIDE_HATCHES }; } @Override public int getMaxParallelRecipes() { - // TODO Auto-generated method stub return 1; } @Override public int getEuDiscountForParallelism() { - // TODO Auto-generated method stub return 0; } @@ -317,7 +316,7 @@ public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { @Override public boolean isEnetOutput() { - return true; + return false; } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java index 8446737017..23ca94e54d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java @@ -22,6 +22,7 @@ import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; import gregtech.common.GT_Pollution; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.FluidUtils; +import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import net.minecraft.block.Block; @@ -401,7 +402,7 @@ public class GregtechMetaTileEntityGeneratorArray extends GregtechMeta_MultiBloc if (this.addOutput(tEmptyContainer1)) { aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); this.depleteInput(a); - GT_Pollution.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); } } } @@ -418,7 +419,7 @@ public class GregtechMetaTileEntityGeneratorArray extends GregtechMeta_MultiBloc (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); if (tFluidAmountToUse > 0L && aBaseMetaTileEntity .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) { - GT_Pollution.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); + PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); mFluid.amount = (int) ((long) mFluid.amount - tFluidAmountToUse * (long) tEmptyContainer); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java index 1623e7cb54..de5d731dd5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java @@ -410,9 +410,13 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas //Time Counter this.mTotalRunTime++; - onRunningTick(null); + onRunningTick(null); - if (mRunningOnLoad && checkMultiblock(aBaseMetaTileEntity, mInventory[1])) { + boolean aFormCheck = (aTick % 100 == 0 ? checkMultiblock(aBaseMetaTileEntity, mInventory[1]) : true); + + + + if (mRunningOnLoad && aFormCheck) { this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); checkRecipe(mInventory[1]); } @@ -429,7 +433,7 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas mDischargeHatches.clear(); mControlCoreBus.clear(); mMultiDynamoHatches.clear(); - mMachine = checkMultiblock(aBaseMetaTileEntity, mInventory[1]); + mMachine = aFormCheck; } if (mStartUpCheck < 0) { if (mMachine) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java index b1e433e276..fc0cb85bac 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java @@ -459,7 +459,7 @@ public class GregtechMetaTileEntity_IndustrialFishingPond extends GregtechMeta_M ItemStack k = ItemUtils.getSimpleStack(t, 1); reflectiveFishMap.put(y, k); return t; - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } return null; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java index f052d64a34..e531103a37 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java @@ -134,13 +134,13 @@ public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlo public static ItemStack getScrapPile() { if (mScrap[0] == null) { - mScrap[0] = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrap")); + mScrap[0] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrap")); } return mScrap[0]; } public static ItemStack getScrapBox() { if (mScrap[1] == null) { - mScrap[1] = ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrapbox")); + mScrap[1] = ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrapbox")); } return mScrap[1]; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java index 1a19bc7b96..07c8a4a7ac 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java @@ -1,23 +1,25 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; -import java.util.ArrayList; +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.RES_PATH_GUI; + +import java.util.HashSet; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.CustomRecipeMap; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase { @@ -69,42 +71,30 @@ public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase @Override public String getCustomGUIResourceName() { - return "LFTR"; + return "MatterFabricator"; } + private static final GT_Recipe_Map mGregTypeRecipeMap = new GT_Recipe_Map(new HashSet<GT_Recipe>(), "internal.recipe.fissionfuel", "Fission Fuel Processing", null, RES_PATH_GUI + "basicmachines/FissionFuel", 0, 0, 0, 4, 1, E, 1, E, true, true); + @Override - public boolean checkRecipe(ItemStack aStack) { - ArrayList<FluidStack> tFluidList = getStoredFluids(); - int tFluidList_sS=tFluidList.size(); - for (int i = 0; i < tFluidList_sS - 1; i++) { - for (int j = i + 1; j < tFluidList_sS; j++) { - if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { - if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { - tFluidList.remove(j--); tFluidList_sS=tFluidList.size(); - } else { - tFluidList.remove(i--); tFluidList_sS=tFluidList.size(); - break; - } - } - } - } - if (tFluidList.size() > 1) { - FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); - GT_Recipe tRecipe = CustomRecipeMap.sFissionFuelProcessing.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, GT_Values.V[4], tFluids, new ItemStack[]{}); - if (tRecipe == null) { - this.mLastRecipe = null; - return false; - } - if (tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[]{})) { - this.mLastRecipe = tRecipe; - this.mEUt = this.mLastRecipe.mEUt; - this.mMaxProgresstime = this.mLastRecipe.mDuration; - this.mEfficiencyIncrease = 10000; - this.mOutputFluids = this.mLastRecipe.mFluidOutputs; - return true; - } - } - return false; + public GT_Recipe_Map getRecipeMap() { + if (mGregTypeRecipeMap.mRecipeList.size() <= 0) { + for (GT_Recipe g : CustomRecipeMap.sFissionFuelProcessing.mRecipeList) { + mGregTypeRecipeMap.mRecipeList.add(g); + } + } + return mGregTypeRecipeMap; + } + + @Override + public boolean checkRecipe(ItemStack aStack) { + //this.resetRecipeMapForAllInputHatches(); + for (GT_MetaTileEntity_Hatch_Input g : this.mInputHatches) { + g.mRecipeMap = null; + } + boolean ab = super.checkRecipeGeneric(); + //Logger.INFO("Did Recipe? "+ab); + return ab; } @Override @@ -261,7 +251,8 @@ public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase Logger.INFO("Your Muffler must be AT LEAST ZPM tier or higher."); } } - Logger.INFO("Fission Fuel Production Plant Formed."); + Logger.INFO("Fission Fuel Production Plant Formed. "+mGregTypeRecipeMap.mRecipeList.size()); + this.resetRecipeMapForAllInputHatches(this.getRecipeMap()); return true; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java index 1d2fad941b..b77529220f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaEnergyBuffer.java @@ -294,7 +294,6 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { cur = String.format(fmt, cur); return new String[] { - this.getLocalName(), cur+" EU stored", max+" EU capacity"}; } @@ -345,7 +344,7 @@ public class GregtechMetaEnergyBuffer extends GregtechMetaTileEntity { @Override public String getInventoryName() { - return null; + return super.getInventoryName(); } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java index 68f78503e8..4c8707e5e8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java @@ -38,8 +38,7 @@ public class GT_Material_Loader { instance = this; //Try Reflectively add ourselves to the GT loader. - try { - Class mInterface = Class.forName("gregtech.api.interfaces.IMaterialHandler"); + Class mInterface = ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && mInterface != null){ //Make this class Dynamically implement IMaterialHandler @@ -49,7 +48,7 @@ public class GT_Material_Loader { new MaterialHandler(getInstance())); } - if (ReflectionUtils.invoke(Materials.class, "add", new Class[]{Class.forName("gregtech.api.interfaces.IMaterialHandler")}, new Object[]{mProxyObject})){ + if (ReflectionUtils.invoke(Materials.class, "add", new Class[]{ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler")}, new Object[]{mProxyObject})){ Logger.REFLECTION("Successfully invoked add, on the proxied object implementing IMaterialHandler."); @@ -65,9 +64,7 @@ public class GT_Material_Loader { else { Logger.REFLECTION("Failed to invoke add, on the proxied object implementing IMaterialHandler."); } - } - } - catch (ClassNotFoundException e) {} + } //Materials.add(this); //Stupid shit running twice, I don't think so. @@ -139,12 +136,12 @@ public class GT_Material_Loader { return false; } try { - Method enableComponent = Class.forName("gregtech.api.enums.OrePrefixes").getDeclaredMethod("enableComponent", Materials.class); + Method enableComponent = ReflectionUtils.getClass("gregtech.api.enums.OrePrefixes").getDeclaredMethod("enableComponent", Materials.class); enableComponent.invoke(prefix, mMaterial); Logger.DEBUG_MATERIALS("Enabled "+prefix.name()+" for "+mMaterial.mDefaultLocalName+"."); return true; } - catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | ClassNotFoundException error) { + catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException error) { Logger.DEBUG_MATERIALS("Failed to enabled "+prefix.name()+" for "+mMaterial.mDefaultLocalName+". Caught "+error.getCause().toString()+"."); error.printStackTrace(); } @@ -228,7 +225,7 @@ public class GT_Material_Loader { //Loading the class at runtime public static void main(String[] args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException { - Class<?> someInterface = Class.forName("gregtech.api.interfaces.IMaterialHandler"); + Class<?> someInterface = ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); Object instance = Proxy.newProxyInstance(someInterface.getClassLoader(), new Class<?>[]{someInterface}, new InvocationHandler() { @Override @@ -274,7 +271,7 @@ public class GT_Material_Loader { public static void init(){ - Class<?> someInterface = Class.forName("gregtech.api.interfaces.IMaterialHandler"); + Class<?> someInterface = ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); GT_Material_Loader original = GT_Material_Loader.instance; MaterialHandler handler = new MaterialHandler(original); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java index 1932f30969..ecdc3af1db 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_DustGeneration.java @@ -221,14 +221,14 @@ public class RecipeGen_DustGeneration extends RecipeGen_Base { } //Add Shapeless recipe for low tier alloys. - if (tVoltageMultiplier <= 30){ + /*if (tVoltageMultiplier <= 30){ if (RecipeUtils.addShapedGregtechRecipe(inputStacks, outputStacks)){ Logger.WARNING("Dust Shapeless Recipe: "+material.getLocalizedName()+" - Success"); } else { Logger.WARNING("Dust Shapeless Recipe: "+material.getLocalizedName()+" - Failed"); } - } + }*/ } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java index ddba6b5bf0..15627a827f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java @@ -164,6 +164,15 @@ public class RecipeGen_Ore extends RecipeGen_Base { ItemStack matDustB = getDust(bonusB); /** + * Package + */ + //Allow ore dusts to be packaged + if (ItemUtils.checkForInvalidItems(material.getSmallDust(1)) && ItemUtils.checkForInvalidItems(material.getTinyDust(1))) { + RecipeGen_DustGeneration.generatePackagerRecipes(material); + } + + + /** * Macerate */ //Macerate ore to Crushed @@ -255,8 +264,8 @@ public class RecipeGen_Ore extends RecipeGen_Base { matDust, tinyDustA,null, null, null,null, new int[]{10000, 10000}, //Chances - 5*20, //Eu - tVoltageMultiplier/2)){ //Time + 5*20, //Time + tVoltageMultiplier/2)){ //Eu Logger.MATERIALS("[Centrifuge] Added Recipe: Purified Dust to Clean Dust"); } @@ -268,8 +277,8 @@ public class RecipeGen_Ore extends RecipeGen_Base { matDust, tinyDustB,null, null, null,null, new int[]{10000, 10000}, //Chances - 5*20, //Eu - tVoltageMultiplier/2)){ //Time + 5*20, //Time + tVoltageMultiplier/2)){ //Eu Logger.MATERIALS("[Centrifuge] Added Recipe: Inpure Dust to Clean Dust"); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java index 79615d8457..3249e0101d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_ShapedCrafting.java @@ -3,18 +3,15 @@ package gtPlusPlus.xmod.gregtech.loaders; import java.util.HashSet; import java.util.Set; -import net.minecraft.item.ItemStack; - import gregtech.api.util.GT_ModHandler; - import gtPlusPlus.api.interfaces.RunnableWithInfo; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; +import net.minecraft.item.ItemStack; public class RecipeGen_ShapedCrafting extends RecipeGen_Base { @@ -35,7 +32,7 @@ public class RecipeGen_ShapedCrafting extends RecipeGen_Base { private void generateRecipes(final Material material){ Logger.WARNING("Generating Shaped Crafting recipes for "+material.getLocalizedName()); //TODO - + if (!CORE.GTNH) { //Nuggets if (ItemUtils.checkForInvalidItems(material.getNugget(1)) && ItemUtils.checkForInvalidItems(material.getIngot(1))) diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java new file mode 100644 index 0000000000..351a4cc546 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java @@ -0,0 +1,180 @@ +package gtPlusPlus.xmod.gregtech.loaders.misc; + +import java.util.concurrent.ConcurrentHashMap; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.GT_Mod; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Recipe; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.Achievement; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatBase; +import net.minecraftforge.common.AchievementPage; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; + +public class AssLineAchievements { + + public static int assReg = -1; + public static ConcurrentHashMap<String, Achievement> mAchievementMap; + public static ConcurrentHashMap<String, Boolean> mIssuedAchievementMap; + public static int adjX = 5; + public static int adjY = 9; + private static boolean active = true; + + public AssLineAchievements() { + Logger.INFO(active ? "Loading custom achievement page for Assembly Line recipes." + : "Achievements are disabled."); + Utils.registerEvent(this); + } + + private static boolean ready = false; + private static int recipeTotal = 0; + private static int recipeCount = 0; + private static void init() { + if (!ready) { + active = GT_Mod.gregtechproxy.mAchievements; + try { + recipeTotal = ((GT_Recipe.GT_Recipe_Map) StaticFields59.mAssLineVisualMapNEI.get(null)).mRecipeList.size(); + } catch (IllegalArgumentException | IllegalAccessException e) { + recipeTotal = 0; + } + mAchievementMap = new ConcurrentHashMap<String, Achievement>(); + mIssuedAchievementMap = new ConcurrentHashMap<String, Boolean>(); + ready = true; + } + + } + + public static void registerAchievements() { + if (active && mAchievementMap.size() > 0) { + AchievementPage.registerAchievementPage(new AchievementPage("GT Assembly Line", + (Achievement[]) mAchievementMap.values().toArray(new Achievement[mAchievementMap.size()]))); + } + else if (active) { + Logger.INFO("Unable to register custom achievement page for Assembly Line recipes."); + } + } + + public static Achievement registerAssAchievement(GT_Recipe recipe) { + init(); + String aSafeUnlocalName; + // Debugging + if (recipe == null) { + Logger.INFO( + "Someone tried to register an achievement for an invalid recipe. Please report this to Alkalus."); + return null; + } + if (recipe.getOutput(0) == null) { + Logger.INFO( + "Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + return null; + } + ItemStack aStack = recipe.getOutput(0); + try { + aSafeUnlocalName = aStack.getUnlocalizedName(); + } catch (Throwable t) { + aSafeUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + } + + Achievement aYouDidSomethingInGT; + if (mAchievementMap.get(aSafeUnlocalName) == null) { + assReg++; + recipeCount++; + aYouDidSomethingInGT = registerAchievement(aSafeUnlocalName, -(11 + assReg % 5), ((assReg) / 5) - 8, + recipe.getOutput(0), AchievementList.openInventory, false); + } + else { + aYouDidSomethingInGT = null; + } + if (recipeCount >= recipeTotal) { + Logger.INFO("Critical mass achieved. ["+recipeCount+"]"); + registerAchievements(); + } + + return aYouDidSomethingInGT; + } + + public static Achievement registerAchievement(String textId, int x, int y, ItemStack icon, + Achievement requirement, boolean special) { + if (!GT_Mod.gregtechproxy.mAchievements) { + return null; + } + Achievement achievement = new Achievement(textId, textId, adjX + x, adjY + y, icon, requirement); + if (special) { + achievement.setSpecial(); + } + achievement.registerStat(); + if (CORE.DEVENV) { + GT_Log.out.println("achievement." + textId + "="); + GT_Log.out.println("achievement." + textId + ".desc="); + } + mAchievementMap.put(textId, achievement); + return achievement; + } + + public static void issueAchievement(EntityPlayer entityplayer, String textId) { + if (entityplayer == null || !GT_Mod.gregtechproxy.mAchievements) { + return; + } + + entityplayer.triggerAchievement((StatBase) getAchievement(textId)); + } + + public static Achievement getAchievement(String textId) { + if (mAchievementMap.containsKey(textId)) { + Logger.INFO("Found Achivement: "+textId); + return (Achievement) mAchievementMap.get(textId); + } + return null; + } + + @SubscribeEvent + public void onItemPickup(EntityItemPickupEvent event) { + EntityPlayer player = event.entityPlayer; + ItemStack stack = event.item.getEntityItem(); + String aPickupUnlocalSafe = ItemUtils.getUnlocalizedItemName(stack); + if (player == null || stack == null) { + return; + } + + if (StaticFields59.sAssemblylineVisualRecipes == null) { + return; + } + + Logger.INFO("Trying to check for achievements"); + // Debug scanner unlocks all AL recipes in creative + if (player.capabilities.isCreativeMode && aPickupUnlocalSafe.equals("gt.metaitem.01.32761")) { + for (GT_Recipe recipe : StaticFields59.sAssemblylineVisualRecipes.mRecipeList) { + issueAchievement(player, recipe.getOutput(0).getUnlocalizedName()); + recipe.mHidden = false; + } + } + for (GT_Recipe recipe : StaticFields59.sAssemblylineVisualRecipes.mRecipeList) { + + String aSafeUnlocalName; + if (recipe.getOutput(0) == null) { + Logger.INFO( + "Someone tried to register an achievement for a recipe with null output. Please report this to Alkalus."); + continue; + } + ItemStack aStack = recipe.getOutput(0); + aSafeUnlocalName = ItemUtils.getUnlocalizedItemName(aStack); + if (aSafeUnlocalName.equals(aPickupUnlocalSafe)) { + issueAchievement(player, aSafeUnlocalName); + recipe.mHidden = false; + Logger.INFO("FOUND: " + aSafeUnlocalName + " | " + aPickupUnlocalSafe); + } + else { + //Logger.INFO(aSafeUnlocalName + " | " + aPickupUnlocalSafe); + } + } + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index ace4876639..d16bffef86 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -12,9 +12,12 @@ import gregtech.api.enums.Materials; import gregtech.api.interfaces.internal.IGT_RecipeAdder; import gregtech.api.util.CustomRecipeMap; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_AssemblyLine; import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; +import gregtech.api.util.SemiFluidFuelHandler; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.MaterialGenerator; @@ -694,8 +697,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { Method T = null; if (LoadedMods.TecTech) { - try { - Class TTRecipeAdder = Class.forName("com.github.technus.tectech.recipe.TT_recipeAdder"); + Class TTRecipeAdder = ReflectionUtils.getClass("com.github.technus.tectech.recipe.TT_recipeAdder"); if (TTRecipeAdder != null) { Method ttTest = ReflectionUtils.getMethod(TTRecipeAdder, "addResearchableAssemblylineRecipe", ItemStack.class, int.class, int.class, int.class, int.class, Object[].class, @@ -704,8 +706,6 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { T = ttTest; } } - } catch (ClassNotFoundException e) { - } } else { T = null; @@ -750,11 +750,27 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { return CORE.RA.addComponentMakerRecipe(aInputs, aInputFluid, aOutput1, aDuration, aEUt); } - public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt) { + public boolean addAssemblylineRecipe(ItemStack aResearchItem, int aResearchTime, ItemStack[] aInputs, FluidStack[] aFluidInputs_OLD, ItemStack aOutput, int aDuration, int aEUt) { + + FluidStack[] aFluidInputs = new FluidStack[4]; + AutoMap<FluidStack> aNewFluidMap = new AutoMap<FluidStack>(); + if (aFluidInputs_OLD.length > 4) { + for (FluidStack s : aFluidInputs_OLD) { + aNewFluidMap.put(s); + } + for (int i = 0; i < 4; i++) { + aFluidInputs[i] = aNewFluidMap.get(i); + } + } + else { + aFluidInputs = aFluidInputs_OLD; + } + + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { if (aInputs.length < 6 && aFluidInputs.length < 2) { ItemStack[] aInputStack = new ItemStack[] {aResearchItem, aInputs[0], aInputs[1], aInputs[2], aInputs[3], aInputs[4]}; - return CORE.RA.addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, aEUt); + return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, aEUt); } return false; } @@ -766,7 +782,12 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { if (mAssemblyLine != null) { try { if (!tryAddTecTechScannerRecipe(aResearchItem, aInputs, aFluidInputs, aOutput, aDuration, aEUt)) { - Logger.INFO("Failed to generate TecTech recipe for "+aResearchItem.getDisplayName()+", please report this to Alkalus."); + try { + Logger.INFO("Failed to generate TecTech recipe for "+ItemUtils.getItemName(aResearchItem)+", please report this to Alkalus."); + } + catch (Throwable t) { + + } } return (boolean) mAssemblyLine.invoke(GT_Values.RA, aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt); @@ -774,7 +795,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { if (aInputs.length < 6 && aFluidInputs.length < 2) { ItemStack[] aInputStack = new ItemStack[] { aResearchItem, aInputs[0], aInputs[1], aInputs[2], aInputs[3], aInputs[4] }; - return CORE.RA.addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, + return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, aEUt); } return false; @@ -783,7 +804,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { if (aInputs.length < 6 && aFluidInputs.length < 2) { ItemStack[] aInputStack = new ItemStack[] { aResearchItem, aInputs[0], aInputs[1], aInputs[2], aInputs[3], aInputs[4] }; - return CORE.RA.addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, + return addSixSlotAssemblingRecipe(aInputStack, aFluidInputs[0], aOutput, aDuration, aEUt); } return false; @@ -803,10 +824,13 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { if (mScannerTT != null) { try { - return (boolean) mScannerTT.invoke(null, aResearchItem, compMax, compSec, - (assEUt/2), 16, aInputs, aFluidInputs, aOutput, assDuration, assEUt); + boolean aResult = (boolean) mScannerTT.invoke(null, aResearchItem, compMax, compSec, + (assEUt/2), 16, aInputs, aFluidInputs, aOutput, assDuration, assEUt); + Logger.INFO("Added TecTech Scanner Recipe for "+ItemUtils.getItemName(aResearchItem)+"? "+aResult); + return aResult; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - Logger.INFO("Failed to generate TecTech recipe for "+aResearchItem.getDisplayName()+", please report this to Alkalus. [Severe]"); + Logger.INFO("Failed to generate TecTech recipe for "+ItemUtils.getItemName(aResearchItem)+", please report this to Alkalus. [Severe]"); e.printStackTrace(); } } @@ -851,7 +875,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { @Override public boolean addMultiblockChemicalRecipe(ItemStack[] itemStacks, FluidStack[] fluidStacks, FluidStack[] fluidStacks2, ItemStack[] outputs, int time, int eu) { - if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK || mLargeChemReactor == null) { return false; } try { @@ -1042,10 +1066,29 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { } + @Override + public boolean addSemifluidFuel(ItemStack aFuelItem, int aFuelValue) { + return SemiFluidFuelHandler.addSemiFluidFuel(aFuelItem, aFuelValue); + } - - - + @Override + public boolean addSemifluidFuel(FluidStack aFuelItem, int aFuelValue) { + return SemiFluidFuelHandler.addSemiFluidFuel(aFuelItem, aFuelValue); + } + + + + + + + + + + + + + + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java index a3a04a44da..54ab6d45bb 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechDehydrator.java @@ -105,7 +105,7 @@ public class GregtechDehydrator { | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "ECE", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_MV, Character.valueOf('P'), ItemList.Robot_Arm_MV, Character.valueOf('E'), OrePrefixes.wireFine.get(Materials.RedAlloy), Character.valueOf('C'), - OrePrefixes.circuit.get(Materials.Basic), Character.valueOf('W'), + OrePrefixes.circuit.get(Materials.Good), Character.valueOf('W'), OrePrefixes.cableGt04.get(Materials.Copper), Character.valueOf('G'), OrePrefixes.gearGt.get(Materials.Steel) }); GT_ModHandler.addCraftingRecipe(GregtechItemList.GT_Dehydrator_HV.get(1L, new Object[0]), @@ -113,7 +113,7 @@ public class GregtechDehydrator { | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "ECE", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_HV, Character.valueOf('P'), ItemList.Robot_Arm_HV, Character.valueOf('E'), OrePrefixes.wireFine.get(Materials.Electrum), Character.valueOf('C'), - OrePrefixes.circuit.get(Materials.Good), Character.valueOf('W'), + OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('W'), OrePrefixes.cableGt04.get(Materials.Silver), Character.valueOf('G'), ALLOY.POTIN.getGear(1) }); @@ -123,7 +123,7 @@ public class GregtechDehydrator { | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] { "ECE", "WMW", "GPG", Character.valueOf('M'), ItemList.Hull_EV, Character.valueOf('P'), ItemList.Robot_Arm_EV, Character.valueOf('E'), coilT1, Character.valueOf('C'), - OrePrefixes.circuit.get(Materials.Advanced), Character.valueOf('W'), + OrePrefixes.circuit.get(Materials.Data), Character.valueOf('W'), OrePrefixes.cableGt04.get(Materials.Aluminium), Character.valueOf('G'), ALLOY.TUMBAGA.getGear(1) }); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechEnergyBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechEnergyBuffer.java index 7b87cd0f24..e07837c2ba 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechEnergyBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechEnergyBuffer.java @@ -41,20 +41,20 @@ public class GregtechEnergyBuffer //Energy Buffers - GregtechItemList.Energy_Buffer_1by1_ULV.set(new GregtechMetaEnergyBuffer(770, "energybuffer.01.tier.00", "Ultra Low Voltage Energy Buffer", 0, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_LV.set(new GregtechMetaEnergyBuffer(771, "energybuffer.01.tier.01", "Low Voltage Energy Buffer", 1, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_MV.set(new GregtechMetaEnergyBuffer(772, "energybuffer.01.tier.02", "Medium Voltage Energy Buffer", 2, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_HV.set(new GregtechMetaEnergyBuffer(773, "energybuffer.01.tier.03", "High Voltage Energy Buffer", 3, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_EV.set(new GregtechMetaEnergyBuffer(774, "energybuffer.01.tier.04", "Extreme Voltage Energy Buffer", 4, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_IV.set(new GregtechMetaEnergyBuffer(775, "energybuffer.01.tier.05", "Insane Voltage Energy Buffer", 5, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_LuV.set(new GregtechMetaEnergyBuffer(776, "energybuffer.01.tier.06", "Ludicrous Voltage Energy Buffer", 6, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_ZPM.set(new GregtechMetaEnergyBuffer(777, "energybuffer.01.tier.07", "ZPM Voltage Energy Buffer", 7, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_UV.set(new GregtechMetaEnergyBuffer(778, "energybuffer.01.tier.08", "Ultimate Voltage Energy Buffer", 8, "", 1).getStackForm(1L)); - GregtechItemList.Energy_Buffer_1by1_MAX.set(new GregtechMetaEnergyBuffer(779, "energybuffer.01.tier.09", "MAX Voltage Energy Buffer", 9, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_ULV.set(new GregtechMetaEnergyBuffer(770, "energybuffer.tier.00", "Ultra Low Voltage Energy Buffer", 0, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_LV.set(new GregtechMetaEnergyBuffer(771, "energybuffer.tier.01", "Low Voltage Energy Buffer", 1, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_MV.set(new GregtechMetaEnergyBuffer(772, "energybuffer.tier.02", "Medium Voltage Energy Buffer", 2, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_HV.set(new GregtechMetaEnergyBuffer(773, "energybuffer.tier.03", "High Voltage Energy Buffer", 3, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_EV.set(new GregtechMetaEnergyBuffer(774, "energybuffer.tier.04", "Extreme Voltage Energy Buffer", 4, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_IV.set(new GregtechMetaEnergyBuffer(775, "energybuffer.tier.05", "Insane Voltage Energy Buffer", 5, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_LuV.set(new GregtechMetaEnergyBuffer(776, "energybuffer.tier.06", "Ludicrous Voltage Energy Buffer", 6, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_ZPM.set(new GregtechMetaEnergyBuffer(777, "energybuffer.tier.07", "ZPM Voltage Energy Buffer", 7, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_UV.set(new GregtechMetaEnergyBuffer(778, "energybuffer.tier.08", "Ultimate Voltage Energy Buffer", 8, "", 1).getStackForm(1L)); + GregtechItemList.Energy_Buffer_1by1_MAX.set(new GregtechMetaEnergyBuffer(779, "energybuffer.tier.09", "MAX Voltage Energy Buffer", 9, "", 1).getStackForm(1L)); // Creative Buffer Has Special ID GregtechItemList.Energy_Buffer_CREATIVE .set(new GregtechMetaCreativeEnergyBuffer(750, - "energybuffer.01.tier.xx", + "energybuffer.tier.xx", "512V Creative Energy Buffer", 3, "", 0) .getStackForm(1L)); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCryogenicFreezer.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCryogenicFreezer.java index 213b6f0ccb..65f3e41911 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCryogenicFreezer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialCryogenicFreezer.java @@ -17,10 +17,10 @@ public class GregtechIndustrialCryogenicFreezer { private static void run1() { Logger.INFO("Gregtech 5 Content | Registering Advanced GT Multiblock replacements."); - GregtechItemList.Machine_Adv_BlastFurnace.set(new GregtechMetaTileEntity_Adv_EBF(963, "multimachine.adv.blastfurnace", "[Factory Grade] Adv. EBF").getStackForm(1L)); - GregtechItemList.Machine_Adv_ImplosionCompressor.set(new GregtechMetaTileEntity_Adv_Implosion(964, "multimachine.adv.implosioncompressor", "[Factory Grade] Adv. Implosion Compressor").getStackForm(1L)); - GregtechItemList.Industrial_Cryogenic_Freezer.set(new GregtechMetaTileEntity_IndustrialVacuumFreezer(910, "multimachine.adv.industrialfreezer", "[Factory Grade] Cryogenic Freezer").getStackForm(1L)); - GregtechItemList.FusionComputer_UV2.set(new GregtechMetaTileEntity_Adv_Fusion_MK4(965, "fusioncomputer.tier.09", "FusionTek MK IV").getStackForm(1L)); + GregtechItemList.Machine_Adv_BlastFurnace.set(new GregtechMetaTileEntity_Adv_EBF(963, "multimachine.adv.blastfurnace", "Volcanus").getStackForm(1L)); + GregtechItemList.Machine_Adv_ImplosionCompressor.set(new GregtechMetaTileEntity_Adv_Implosion(964, "multimachine.adv.implosioncompressor", "Density^2").getStackForm(1L)); + GregtechItemList.Industrial_Cryogenic_Freezer.set(new GregtechMetaTileEntity_IndustrialVacuumFreezer(910, "multimachine.adv.industrialfreezer", "Cryogenic Freezer").getStackForm(1L)); + GregtechItemList.FusionComputer_UV2.set(new GregtechMetaTileEntity_Adv_Fusion_MK4(965, "fusioncomputer.tier.09", "FusionTech MK IV").getStackForm(1L)); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java index 8064c68559..6362b07b93 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialMassFabricator.java @@ -221,10 +221,10 @@ public class GregtechIndustrialMassFabricator { public static ItemStack getScrapPile() { - return ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrap")); + return ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrap")); } public static ItemStack getScrapBox() { - return ItemUtils.getSimpleStack(ItemUtils.getItem("IC2:itemScrapbox")); + return ItemUtils.getSimpleStack(ItemUtils.getItemFromFQRN("IC2:itemScrapbox")); } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java index f924e5233d..6095413150 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java @@ -22,6 +22,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraftforge.fluids.FluidStack; public class GregtechNitroDieselFix { @@ -34,7 +35,7 @@ public class GregtechNitroDieselFix { int mSub = Utils.getGregtechSubVersion(); if (mSub != 0){ if (mSub >= 30){ - Class mb = Class.forName("gregtech.api.enums.MaterialBuilder"); + Class mb = ReflectionUtils.getClass("gregtech.api.enums.MaterialBuilder"); Object df = mb.getConstructor(int.class, TextureSet.class, String.class).newInstance(975, TextureSet.SET_FLUID, "Nitro-Diesel [Old]"); if (mb.isInstance(df)){ @@ -158,7 +159,7 @@ public class GregtechNitroDieselFix { } } } - catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) { Logger.INFO("[Nitro] ================ Error ================"); e.printStackTrace(); Logger.INFO("[Nitro] ================ Error ================"); diff --git a/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java b/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java index 5410b0f619..5a9dc748ca 100644 --- a/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java +++ b/src/Java/gtPlusPlus/xmod/growthcraft/fishtrap/FishTrapHandler.java @@ -11,6 +11,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.item.ItemStack; public class FishTrapHandler { @@ -31,14 +32,14 @@ public class FishTrapHandler { private final static Object setFishTrapRegistry(){ Class mFishingRegistryClass; try { - mFishingRegistryClass = Class.forName("growthcraft.api.fishtrap.FishTrapRegistry"); + mFishingRegistryClass = ReflectionUtils.getClass("growthcraft.api.fishtrap.FishTrapRegistry"); final Method mFishingRegistryMethod = mFishingRegistryClass.getDeclaredMethod("getInstance"); mFishingRegistry = mFishingRegistryMethod.invoke(null); if (mFishingRegistry != null){ return mFishingRegistry; } } - catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { } return null; } diff --git a/src/Java/gtPlusPlus/xmod/ob/CallbackObject.java b/src/Java/gtPlusPlus/xmod/ob/CallbackObject.java deleted file mode 100644 index 89c2952a54..0000000000 --- a/src/Java/gtPlusPlus/xmod/ob/CallbackObject.java +++ /dev/null @@ -1,20 +0,0 @@ -package gtPlusPlus.xmod.ob; - -import net.minecraft.inventory.IInventory; -import openblocks.common.tileentity.TileEntitySprinkler; -import openmods.api.IInventoryCallback; - -public class CallbackObject implements IInventoryCallback { - - private TileEntitySprinkler mTile; - - CallbackObject(TileEntitySprinkler aTile){ - mTile = aTile; - } - - @Override - public void onInventoryChanged(IInventory inventory, int slotNumber) { - mTile.updateEntity(); - } - -} diff --git a/src/Java/gtPlusPlus/xmod/ob/CustomSprinklerInventory.java b/src/Java/gtPlusPlus/xmod/ob/CustomSprinklerInventory.java deleted file mode 100644 index 60c340592b..0000000000 --- a/src/Java/gtPlusPlus/xmod/ob/CustomSprinklerInventory.java +++ /dev/null @@ -1,35 +0,0 @@ -package gtPlusPlus.xmod.ob; - -import java.util.HashMap; - -import gtPlusPlus.api.objects.Logger; -import net.minecraft.item.ItemStack; -import openblocks.common.tileentity.TileEntitySprinkler; -import openmods.inventory.TileEntityInventory; - -public class CustomSprinklerInventory extends TileEntityInventory { - private final TileEntitySprinkler owner; - - public CustomSprinklerInventory(TileEntitySprinkler owner, String name, boolean isInvNameLocalized, int size) { - super(owner, name, isInvNameLocalized, size); - this.owner = owner; - this.addCallback(new CallbackObject(this.owner)); - } - - ItemStack[] mFerts; - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - Logger.INFO("Inserting: "+itemstack != null ? itemstack.getDisplayName() : "Nothing"); - HashMap<Integer, ItemStack> mFerts = SprinklerHandler.getValidFerts(); - if (itemstack != null && mFerts != null && mFerts.size() > 0) { - for (ItemStack u : mFerts.values()) { - if (itemstack.isItemEqual(u)) { - return true; - } - } - } - return false; - } - -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java b/src/Java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java index 617c4ddd8a..dfaec8b703 100644 --- a/src/Java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java +++ b/src/Java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java @@ -87,11 +87,11 @@ public class ModuleExoticSeeds extends ModuleAddon implements ICropModule { else { if (mForestryHumusBlockClass == null || mForestryHumusBlock == null) { try { - mForestryHumusBlockClass = Class.forName("forestry.plugins.PluginCore"); + mForestryHumusBlockClass = ReflectionUtils.getClass("forestry.plugins.PluginCore"); Field blocks = ReflectionUtils.getField(mForestryHumusBlockClass, "blocks"); if (blocks != null) { Object blockRegistryCoreObject = blocks.get(null); - mForestryBlockRegistryCoreClass = Class.forName("forestry.core.blocks.BlockRegistryCore"); + mForestryBlockRegistryCoreClass = ReflectionUtils.getClass("forestry.core.blocks.BlockRegistryCore"); if (mForestryBlockRegistryCoreClass != null && blockRegistryCoreObject != null) { Field soil = ReflectionUtils.getField(mForestryBlockRegistryCoreClass, "soil"); if (soil != null) { diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java b/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java index 558b134ea9..35e608b0ca 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/HANDLER_Thaumcraft.java @@ -3,31 +3,23 @@ package gtPlusPlus.xmod.thaumcraft; import java.util.Arrays; import java.util.List; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import gregtech.api.enums.GT_Values; -import gregtech.api.interfaces.internal.IThaumcraftCompat; -import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects.TC_AspectStack_Ex; +import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectCompat; +import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectStack; import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; public class HANDLER_Thaumcraft { - public static IThaumcraftCompat sThaumcraftCompat; + public static GTPP_AspectCompat sThaumcraftCompat; public static Item mResearchNotes; - public static final AutoMap<Pair<ItemStack, TC_AspectStack_Ex[]>> sItemsToGetAspects = new AutoMap<Pair<ItemStack, TC_AspectStack_Ex[]>>(); - - static { - sThaumcraftCompat = (IThaumcraftCompat) GT_Utility.callConstructor("gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectCompat", 0, null, GT_Values.D1, new Object[0]); - } + public static final AutoMap<Pair<ItemStack, GTPP_AspectStack[]>> sItemsToGetAspects = new AutoMap<Pair<ItemStack, GTPP_AspectStack[]>>(); public static void preInit(){ if (LoadedMods.Thaumcraft){ @@ -37,10 +29,9 @@ public class HANDLER_Thaumcraft { public static void init(){ if (LoadedMods.Thaumcraft){ try { - mResearchNotes = (Item) ReflectionUtils.getField(Class.forName("thaumcraft.common.config.ConfigItems"), "itemResearchNotes").get(null); + mResearchNotes = (Item) ReflectionUtils.getField(ReflectionUtils.getClass("thaumcraft.common.config.ConfigItems"), "itemResearchNotes").get(null); } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException - | ClassNotFoundException e) { + catch (IllegalArgumentException | IllegalAccessException e) { mResearchNotes = Items.paper; } } @@ -48,10 +39,16 @@ public class HANDLER_Thaumcraft { public static void postInit(){ if (LoadedMods.Thaumcraft){ - if (!sItemsToGetAspects.isEmpty()) { - for (Pair<ItemStack, TC_AspectStack_Ex[]> j : sItemsToGetAspects) { + //Add Custom Aspects + + + //sThaumcraftCompat = (IThaumcraftCompat) GT_Utility.callConstructor("gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectCompat", 0, null, GT_Values.D1, new Object[0]); + sThaumcraftCompat = new GTPP_AspectCompat(); + + if (!sItemsToGetAspects.isEmpty() && false) { + for (Pair<ItemStack, GTPP_AspectStack[]> j : sItemsToGetAspects) { if (j .getKey() != null && (j.getValue() != null && j.getValue().length > 0)) { - List<TC_AspectStack_Ex> list = Arrays.asList(j.getValue()); + List<GTPP_AspectStack> list = Arrays.asList(j.getValue()); if (ThaumcraftUtils.registerThaumcraftAspectsToItem(j.getKey(), list, true)) { Logger.WARNING("[Aspect] Successfully added Aspects to "+j.getKey().getDisplayName()+"."); } diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java index e3aeed75bd..6cd5af02b6 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java @@ -1,114 +1,191 @@ package gtPlusPlus.xmod.thaumcraft.aspect; -import gregtech.common.GT_ThaumcraftCompat; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects.TC_AspectStack_Ex; -import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; - -import gregtech.api.enums.TC_Aspects; -import gregtech.api.enums.TC_Aspects.TC_AspectStack; -import gregtech.api.interfaces.internal.IThaumcraftCompat; -import gregtech.api.util.GT_LanguageManager; - import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; +import gregtech.api.enums.TC_Aspects; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.GT_ThaumcraftCompat; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_AspectList_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; import net.minecraft.util.ResourceLocation; -import thaumcraft.api.aspects.Aspect; -import thaumcraft.api.aspects.AspectList; -public class GTPP_AspectCompat implements IThaumcraftCompat { +public class GTPP_AspectCompat { public static volatile Method m = null; + private static HashMap<String, TC_Aspect_Wrapper> mAspectCache = new LinkedHashMap<String, TC_Aspect_Wrapper>(); + + + public static TC_Aspect_Wrapper ASPECT_BALANCE; + public static TC_Aspect_Wrapper ASPECT_LUST; + public static TC_Aspect_Wrapper ASPECT_STARBOUND; + public static TC_Aspect_Wrapper ASPECT_TOXIC; + public static TC_Aspect_Wrapper ASPECT_HEAVEN; + + +/* TC_Aspects.AER.mAspect = Aspect.AIR; + TC_Aspects.ALIENIS.mAspect = Aspect.ELDRITCH; + TC_Aspects.AQUA.mAspect = Aspect.WATER; + TC_Aspects.ARBOR.mAspect = Aspect.TREE; + TC_Aspects.AURAM.mAspect = Aspect.AURA; + TC_Aspects.BESTIA.mAspect = Aspect.BEAST; + TC_Aspects.COGNITIO.mAspect = Aspect.MIND; + TC_Aspects.CORPUS.mAspect = Aspect.FLESH; + TC_Aspects.EXANIMIS.mAspect = Aspect.UNDEAD; + TC_Aspects.FABRICO.mAspect = Aspect.CRAFT; + TC_Aspects.FAMES.mAspect = Aspect.HUNGER; + TC_Aspects.GELUM.mAspect = Aspect.COLD; + TC_Aspects.GRANUM.mAspect = Aspect.PLANT; + TC_Aspects.HERBA.mAspect = Aspect.PLANT; + TC_Aspects.HUMANUS.mAspect = Aspect.MAN; + TC_Aspects.IGNIS.mAspect = Aspect.FIRE; + TC_Aspects.INSTRUMENTUM.mAspect = Aspect.TOOL; + TC_Aspects.ITER.mAspect = Aspect.TRAVEL; + TC_Aspects.LIMUS.mAspect = Aspect.SLIME; + TC_Aspects.LUCRUM.mAspect = Aspect.GREED; + TC_Aspects.LUX.mAspect = Aspect.LIGHT; + TC_Aspects.MACHINA.mAspect = Aspect.MECHANISM; + TC_Aspects.MESSIS.mAspect = Aspect.CROP; + TC_Aspects.METALLUM.mAspect = Aspect.METAL; + TC_Aspects.METO.mAspect = Aspect.HARVEST; + TC_Aspects.MORTUUS.mAspect = Aspect.DEATH; + TC_Aspects.MOTUS.mAspect = Aspect.MOTION; + TC_Aspects.ORDO.mAspect = Aspect.ORDER; + TC_Aspects.PANNUS.mAspect = Aspect.CLOTH; + TC_Aspects.PERDITIO.mAspect = Aspect.ENTROPY; + TC_Aspects.PERFODIO.mAspect = Aspect.MINE; + TC_Aspects.PERMUTATIO.mAspect = Aspect.EXCHANGE; + TC_Aspects.POTENTIA.mAspect = Aspect.ENERGY; + TC_Aspects.PRAECANTATIO.mAspect = Aspect.MAGIC; + TC_Aspects.SANO.mAspect = Aspect.HEAL; + TC_Aspects.SENSUS.mAspect = Aspect.SENSES; + TC_Aspects.SPIRITUS.mAspect = Aspect.SOUL; + TC_Aspects.TELUM.mAspect = Aspect.WEAPON; + TC_Aspects.TERRA.mAspect = Aspect.EARTH; + TC_Aspects.TEMPESTAS.mAspect = Aspect.WEATHER; + TC_Aspects.TENEBRAE.mAspect = Aspect.DARKNESS; + TC_Aspects.TUTAMEN.mAspect = Aspect.ARMOR; + TC_Aspects.VACUOS.mAspect = Aspect.VOID; + TC_Aspects.VENENUM.mAspect = Aspect.POISON; + TC_Aspects.VICTUS.mAspect = Aspect.LIFE; + TC_Aspects.VINCULUM.mAspect = Aspect.TRAP; + TC_Aspects.VITIUM.mAspect = Aspect.TAINT; + TC_Aspects.VITREUS.mAspect = Aspect.CRYSTAL; + TC_Aspects.VOLATUS.mAspect = Aspect.FLIGHT;*/ + + public GTPP_AspectCompat() { - // Standard Aspects - GTPP_Aspects.AER.mAspect = Aspect.AIR; - GTPP_Aspects.ALIENIS.mAspect = Aspect.ELDRITCH; - GTPP_Aspects.AQUA.mAspect = Aspect.WATER; - GTPP_Aspects.ARBOR.mAspect = Aspect.TREE; - GTPP_Aspects.AURAM.mAspect = Aspect.AURA; - GTPP_Aspects.BESTIA.mAspect = Aspect.BEAST; - GTPP_Aspects.COGNITIO.mAspect = Aspect.MIND; - GTPP_Aspects.CORPUS.mAspect = Aspect.FLESH; - GTPP_Aspects.EXANIMIS.mAspect = Aspect.UNDEAD; - GTPP_Aspects.FABRICO.mAspect = Aspect.CRAFT; - GTPP_Aspects.FAMES.mAspect = Aspect.HUNGER; - GTPP_Aspects.GELUM.mAspect = Aspect.COLD; - GTPP_Aspects.GRANUM.mAspect = Aspect.PLANT; - GTPP_Aspects.HERBA.mAspect = Aspect.PLANT; - GTPP_Aspects.HUMANUS.mAspect = Aspect.MAN; - GTPP_Aspects.IGNIS.mAspect = Aspect.FIRE; - GTPP_Aspects.INSTRUMENTUM.mAspect = Aspect.TOOL; - GTPP_Aspects.ITER.mAspect = Aspect.TRAVEL; - GTPP_Aspects.LIMUS.mAspect = Aspect.SLIME; - GTPP_Aspects.LUCRUM.mAspect = Aspect.GREED; - GTPP_Aspects.LUX.mAspect = Aspect.LIGHT; - GTPP_Aspects.MACHINA.mAspect = Aspect.MECHANISM; - GTPP_Aspects.MESSIS.mAspect = Aspect.CROP; - GTPP_Aspects.METALLUM.mAspect = Aspect.METAL; - GTPP_Aspects.METO.mAspect = Aspect.HARVEST; - GTPP_Aspects.MORTUUS.mAspect = Aspect.DEATH; - GTPP_Aspects.MOTUS.mAspect = Aspect.MOTION; - GTPP_Aspects.ORDO.mAspect = Aspect.ORDER; - GTPP_Aspects.PANNUS.mAspect = Aspect.CLOTH; - GTPP_Aspects.PERDITIO.mAspect = Aspect.ENTROPY; - GTPP_Aspects.PERFODIO.mAspect = Aspect.MINE; - GTPP_Aspects.PERMUTATIO.mAspect = Aspect.EXCHANGE; - GTPP_Aspects.POTENTIA.mAspect = Aspect.ENERGY; - GTPP_Aspects.PRAECANTATIO.mAspect = Aspect.MAGIC; - GTPP_Aspects.SANO.mAspect = Aspect.HEAL; - GTPP_Aspects.SENSUS.mAspect = Aspect.SENSES; - GTPP_Aspects.SPIRITUS.mAspect = Aspect.SOUL; - GTPP_Aspects.TELUM.mAspect = Aspect.WEAPON; - GTPP_Aspects.TERRA.mAspect = Aspect.EARTH; - GTPP_Aspects.TEMPESTAS.mAspect = Aspect.WEATHER; - GTPP_Aspects.TENEBRAE.mAspect = Aspect.DARKNESS; - GTPP_Aspects.TUTAMEN.mAspect = Aspect.ARMOR; - GTPP_Aspects.VACUOS.mAspect = Aspect.VOID; - GTPP_Aspects.VENENUM.mAspect = Aspect.POISON; - GTPP_Aspects.VICTUS.mAspect = Aspect.LIFE; - GTPP_Aspects.VINCULUM.mAspect = Aspect.TRAP; - GTPP_Aspects.VITIUM.mAspect = Aspect.TAINT; - GTPP_Aspects.VITREUS.mAspect = Aspect.CRYSTAL; - GTPP_Aspects.VOLATUS.mAspect = Aspect.FLIGHT; - GTPP_Aspects.STRONTIO.mAspect = (Aspect) TC_Aspects.STRONTIO.mAspect; - GTPP_Aspects.NEBRISUM.mAspect = (Aspect) TC_Aspects.NEBRISUM.mAspect; - GTPP_Aspects.ELECTRUM.mAspect = (Aspect) TC_Aspects.ELECTRUM.mAspect; - GTPP_Aspects.MAGNETO.mAspect = (Aspect) TC_Aspects.MAGNETO.mAspect; - GTPP_Aspects.RADIO.mAspect = (Aspect) TC_Aspects.RADIO.mAspect; + + + // Generate all existing Aspects as TC_Aspects + LinkedHashMap<String, Object> h = TC_Aspect_Wrapper.getVanillaAspectList(); + for (String g : h.keySet()) { + Object aBaseAspect = h.get(g); + if (aBaseAspect != null && TC_Aspect_Wrapper.isObjectAnAspect(aBaseAspect)) { + TC_Aspect_Wrapper aS = TC_Aspect_Wrapper.getAspect(g); + if (aS != null) { + mAspectCache.put(g, aS); + continue; + } + } + } + + + // Custom Aspects - GTPP_Aspects.CUSTOM_1.mAspect = new Aspect("custom1", 15647411, new Aspect[]{Aspect.COLD, Aspect.FIRE}, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); - GTPP_Aspects.CUSTOM_2.mAspect = new Aspect("custom2", 15658622, new Aspect[]{Aspect.MAGIC, Aspect.SLIME}, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); - GTPP_Aspects.CUSTOM_3.mAspect = new Aspect("custom3", 12644078, new Aspect[]{Aspect.ENERGY, Aspect.ARMOR}, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); - GTPP_Aspects.CUSTOM_4.mAspect = new Aspect("custom4", 12632256, new Aspect[]{Aspect.METAL, Aspect.POISON}, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); - GTPP_Aspects.CUSTOM_5.mAspect = new Aspect("custom4", 12648384, new Aspect[]{Aspect.LIGHT, Aspect.SOUL}, - new ResourceLocation("gregtech:textures/aspects/" + TC_Aspects.RADIO.name() + ".png"), 1); - GT_LanguageManager.addStringLocalization("tc.aspect.custom1", "Balance"); - GT_LanguageManager.addStringLocalization("tc.aspect.custom2", "Lust"); - GT_LanguageManager.addStringLocalization("tc.aspect.custom3", "Starbound"); - GT_LanguageManager.addStringLocalization("tc.aspect.custom4", "Toxic"); - GT_LanguageManager.addStringLocalization("tc.aspect.custom5", "Heaven"); + ASPECT_BALANCE = + new TC_Aspect_Wrapper( + "Sagrausten", + Utils.rgbtoHexValue(125, 125, 125), + new TC_Aspect_Wrapper[]{ + ASPECT_STARBOUND, + get(TC_Aspects.RADIO) + }, + new ResourceLocation(CORE.MODID+":textures/aspects/" + "Sagrausten.png"), + false, + 1, + "Ancient Knowledge"); + + ASPECT_LUST = + new TC_Aspect_Wrapper( + "Slusium", + Utils.rgbtoHexValue(175, 125, 25), + new TC_Aspect_Wrapper[]{ + ASPECT_BALANCE, + get(TC_Aspects.NEBRISUM) + }, + new ResourceLocation(CORE.MODID+":textures/aspects/" + "Slusium.png"), + false, + 1, + "Warped Thoughts"); + + ASPECT_STARBOUND = + new TC_Aspect_Wrapper( + "Xenil", + Utils.rgbtoHexValue(25, 25, 25), + new TC_Aspect_Wrapper[]{ + get(TC_Aspects.MAGNETO), + get(TC_Aspects.RADIO)}, + new ResourceLocation(CORE.MODID+":textures/aspects/" + "Xenil.png"), + false, + 1, + "A beginning to something new"); + + ASPECT_TOXIC = + new TC_Aspect_Wrapper( + "Xablum", + Utils.rgbtoHexValue(25, 185, 25), + new TC_Aspect_Wrapper[]{ + ASPECT_STARBOUND, + ASPECT_LUST + }, + new ResourceLocation(CORE.MODID+":textures/aspects/" + "Xablum.png"), + false, + 1, + "Insanity"); + + ASPECT_HEAVEN = + new TC_Aspect_Wrapper( + "Zetralt", + Utils.rgbtoHexValue(225, 225, 225), + new TC_Aspect_Wrapper[]{ + get(TC_Aspects.AURAM), + ASPECT_TOXIC + }, + new ResourceLocation(CORE.MODID+":textures/aspects/" + "Zetralt.png"), + false, + 1, + "Control, Respect, Glory"); + + + } + + private TC_Aspect_Wrapper get(TC_Aspects aGtObjects) { + try { + return TC_Aspect_Wrapper.generate(aGtObjects.mAspect); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + return null; + } } - public static synchronized final AspectList getAspectList(final List<TC_AspectStack_Ex> aAspects) { - AspectList o = null; + public static synchronized final TC_AspectList_Wrapper getTC_AspectList_Wrapper(final List<GTPP_AspectStack> aAspects) { + TC_AspectList_Wrapper o = null; try { if (m == null || (m != null && !m.isAccessible())) { - m = GT_ThaumcraftCompat.class.getDeclaredMethod("getAspectList", List.class); + m = GT_ThaumcraftCompat.class.getDeclaredMethod("getTC_AspectList_Wrapper", List.class); m.setAccessible(true); } if (m != null) { - o = (AspectList) m.invoke(null, aAspects); + o = (TC_AspectList_Wrapper) m.invoke(null, aAspects); } } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { @@ -119,44 +196,6 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { } return o; } - - public static synchronized final AspectList getAspectList_Ex(final List<TC_AspectStack_Ex> aAspects) { - final AspectList rAspects = new AspectList(); - for (final TC_AspectStack_Ex tAspect : aAspects) { - rAspects.add((Aspect) tAspect.mAspect.mAspect, (int) tAspect.mAmount); - } - return rAspects; - } - - @Override - public boolean registerPortholeBlacklistedBlock(Block p0) { - return ThaumcraftUtils.registerPortholeBlacklistedBlock(p0); - } - - @Override - public boolean registerThaumcraftAspectsToItem(ItemStack p0, List<TC_AspectStack> p1, boolean p2) { - return ThaumcraftUtils.registerThaumcraftAspectsToItem(p0, ThaumcraftUtils.convertAspectStack(p1), p2); - } - - @Override - public boolean registerThaumcraftAspectsToItem(ItemStack p0, List<TC_AspectStack> p1, String p2) { - return ThaumcraftUtils.registerThaumcraftAspectsToItem(p0, ThaumcraftUtils.convertAspectStack(p1), p2); - } - - @Override - public Object addCrucibleRecipe(String p0, Object p1, ItemStack p2, List<TC_AspectStack> p3) { - return ThaumcraftUtils.addCrucibleRecipe(p0, p1, p2, ThaumcraftUtils.convertAspectStack(p3)); - } - @Override - public Object addInfusionRecipe(String p0, ItemStack p1, ItemStack[] p2, ItemStack p3, int p4, List<TC_AspectStack> p5) { - return ThaumcraftUtils.addInfusionRecipe(p0, p1, p2, p3, p4, ThaumcraftUtils.convertAspectStack(p5)); - } - - @Override - public Object addResearch(String p0, String p1, String p2, String[] p3, String p4, ItemStack p5, int p6, int p7, - int p8, int p9, List<TC_AspectStack> p10, ItemStack[] p11, Object[] p12) { - return ThaumcraftUtils.addResearch(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, ThaumcraftUtils.convertAspectStack(p10), p11, p12); - } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java new file mode 100644 index 0000000000..23e9035f40 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java @@ -0,0 +1,15 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; + +public class GTPP_AspectStack { + + public final TC_Aspect_Wrapper mAspect; + public final int mAmount; + + public GTPP_AspectStack(TC_Aspect_Wrapper aAspect, int aAmount) { + mAspect = aAspect; + mAmount= aAmount; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_Aspects.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_Aspects.java deleted file mode 100644 index e1df0dabf5..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_Aspects.java +++ /dev/null @@ -1,77 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.aspect; - -import java.util.List; - -import thaumcraft.api.aspects.Aspect; - -public enum GTPP_Aspects { - - //Standard TC and GT Aspects - AER(1), ALIENIS(20), AQUA(3), ARBOR(1), AURAM(16), BESTIA(6), - COGNITIO(2), CORPUS(2), ELECTRUM(24), EXANIMIS(32), FABRICO(2), - FAMES(2), GELUM(1), GRANUM(4), HERBA(2), HUMANUS(8), IGNIS(4), - INSTRUMENTUM(4), ITER(6), LIMUS(3), LUCRUM(32), LUX(4), MACHINA(16), - MAGNETO(24), MESSIS(3), METALLUM(8), METO(2), MORTUUS(16), MOTUS(4), - NEBRISUM(48), ORDO(8), PANNUS(6), PERDITIO(2), PERFODIO(4), - PERMUTATIO(12), POTENTIA(16), PRAECANTATIO(16), RADIO(48), - SANO(24), SENSUS(4), SPIRITUS(24), STRONTIO(64), TELUM(6), - TERRA(1), TEMPESTAS(64), TENEBRAE(24), TUTAMEN(12), VACUOS(6), - VENENUM(16), VICTUS(4), VINCULUM(16), VITIUM(48), VITREUS(3), VOLATUS(12), - - //Custom Aspects - CUSTOM_3(24), CUSTOM_4(24), CUSTOM_2(48), CUSTOM_5(48), CUSTOM_1(64); - - public Aspect mAspect; - public int mValue; - - private GTPP_Aspects(final int aValue) { - this.mValue = aValue; - } - - public static class TC_AspectStack_Ex { - public GTPP_Aspects mAspect; - public long mAmount; - - public TC_AspectStack_Ex(final GTPP_Aspects aAspect, final long aAmount) { - this.mAspect = aAspect; - this.mAmount = aAmount; - } - - public TC_AspectStack_Ex copy() { - return new TC_AspectStack_Ex(this.mAspect, this.mAmount); - } - - public TC_AspectStack_Ex copy(final long aAmount) { - return new TC_AspectStack_Ex(this.mAspect, aAmount); - } - - public List<TC_AspectStack_Ex> addToAspectList(final List<TC_AspectStack_Ex> aList) { - if (this.mAmount == 0L) { - return aList; - } - for (final TC_AspectStack_Ex tAspect : aList) { - if (tAspect.mAspect == this.mAspect) { - final TC_AspectStack_Ex tc_AspectStack = tAspect; - tc_AspectStack.mAmount += this.mAmount; - return aList; - } - } - aList.add(this.copy()); - return aList; - } - - public boolean removeFromAspectList(final List<TC_AspectStack_Ex> aList) { - for (final TC_AspectStack_Ex tAspect : aList) { - if (tAspect.mAspect == this.mAspect && tAspect.mAmount >= this.mAmount) { - final TC_AspectStack_Ex tc_AspectStack = tAspect; - tc_AspectStack.mAmount -= this.mAmount; - if (tAspect.mAmount == 0L) { - aList.remove(tAspect); - } - return true; - } - } - return false; - } - } -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/ResearchNoteDataWrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/ResearchNoteDataWrapper.java deleted file mode 100644 index 7ca5c117f0..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/ResearchNoteDataWrapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.objects; - -import thaumcraft.common.lib.research.ResearchNoteData; - -public class ResearchNoteDataWrapper extends ResearchNoteData { - - public ResearchNoteDataWrapper() { - super(); - } - - public ResearchNoteDataWrapper(ResearchNoteData data) { - key = data.key; - color = data.color; - hexEntries = data.hexEntries; - hexes = data.hexes; - complete = data.complete; - copies = data.copies; - } - - public void completeResearch() { - this.complete = true; - } - - -} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_AspectList_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_AspectList_Wrapper.java new file mode 100644 index 0000000000..9df38ca384 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_AspectList_Wrapper.java @@ -0,0 +1,40 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect; + +import net.minecraft.item.ItemStack; + +public class TC_AspectList_Wrapper { + + + //thaumcraft.api.aspects.Aspect; + //thaumcraft.api.aspects.AspectList; + + public TC_AspectList_Wrapper() { + + } + + public TC_AspectList_Wrapper(ItemStack stack) { + + } + + public TC_AspectList_Wrapper(Object invoke) { + // TODO Auto-generated constructor stub + } + + public int size() { + // TODO Auto-generated method stub + return 0; + } + + public Object getVanillaAspectList() { + // TODO Auto-generated method stub + return null; + } + + public void add(TC_Aspect_Wrapper mAspect, int mAmount) { + // TODO Auto-generated method stub + + } + + + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java new file mode 100644 index 0000000000..fda0fd27c5 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/aspect/TC_Aspect_Wrapper.java @@ -0,0 +1,327 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect; + +import java.lang.reflect.Array; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.LinkedHashMap; +import java.util.Map; + +import gregtech.api.enums.TC_Aspects; +import gregtech.api.util.GT_LanguageManager; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; +import net.minecraft.util.ResourceLocation; + +/** + * Wrapper class for Thaumcraft Aspects. + * Used to avoid compile time dependencies. + * @author Alkalus + * + */ +public class TC_Aspect_Wrapper { + + private static Class mClass_Aspect; + private static Field mField_Aspects; + + private final String tag; + private final TC_Aspect_Wrapper[] components; + private final int color; + private String chatcolor; + private final ResourceLocation image; + private final int blend; + + public final Object mAspect; + + /** + * May be null, but links back to the TC_Aspects class from GT for convinience. + */ + public final TC_Aspects mGtEnumField; + + + + + /** + * Statically set the Class objects + */ + static { + mClass_Aspect = ReflectionUtils.getClass("thaumcraft.api.aspects.Aspect"); + } + + /** + * Gets the total aspect list from Thaumcraft, which should contain all other registered aspects. + * @return - A LinkedHashMap(String, Aspect); + */ + public static LinkedHashMap<String, Object> getVanillaAspectList() { + try { + if (mField_Aspects == null) { + mField_Aspects = ReflectionUtils.getField(mClass_Aspect, "aspects"); + } + return (LinkedHashMap<String, Object>) mField_Aspects.get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { + Logger.REFLECTION("Failed configuring TC Aspect compatibility."); + return new LinkedHashMap<String, Object>(); + } + } + + public static Object getVanillaAspectObject(String aAspectName) { + return getVanillaAspectList().get(aAspectName); + } + + + + + + + + + + + + + + + /** + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param chatcolor + * @param blend + */ + public TC_Aspect_Wrapper(String tag, int color, String chatcolor, int blend, String aTooltip) { + this(tag, color, (TC_Aspect_Wrapper[]) null, blend, aTooltip); + this.chatcolor = chatcolor; + } + + /** + * + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param components + */ + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, String aTooltip) { + this(tag, color, components, false, 1, aTooltip); + } + + /** + * + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param components + * @param blend + */ + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, int blend, String aTooltip) { + this(tag, color, components, false, blend, aTooltip); + } + + + /** + * + * Vanilla Aspect Constructor + * @param tag - Aspect Name + * @param color + * @param components + * @param image + * @param blend + */ + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, boolean vanilla, int blend, String aTooltip) { + this(tag, color, components, vanilla ? new ResourceLocation("thaumcraft", "textures/aspects/" + tag.toLowerCase() + ".png") : new ResourceLocation(CORE.MODID, "textures/aspects/" + tag.toLowerCase() + ".png"), vanilla, blend, aTooltip); + } + + private static int aInternalAspectIDAllocation = 1; + + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, ResourceLocation image, boolean vanilla, int blend, String aTooltip) { + if (components == null) { + components = new TC_Aspect_Wrapper[] {}; + } + //String aTag = vanilla ? tag.toLowerCase() : "custom"+(aInternalAspectIDAllocation++); + String aTag = tag.toLowerCase(); + if (getAspectList().containsKey(tag.toLowerCase())) { + this.tag = aTag; + this.components = components; + this.color = color; + this.image = image; + this.blend = blend; + this.mAspect = null; + this.mGtEnumField = null; + } else { + this.tag = aTag; + this.components = components; + this.color = color; + this.image = image; + this.blend = blend; + this.mAspect = vanilla ? getVanillaAspectObject(this.tag) : this.generateTcAspect(); + + // Set GT Type if exists + TC_Aspects y = null; + for (TC_Aspects e : TC_Aspects.values()) { + try { + String gtTag = ThaumcraftUtils.getTagFromAspectObject(e.mAspect); + if (gtTag != null) { + if (gtTag.equals(this.tag)) { + y = e; + break; + } + } + } catch (IllegalArgumentException e1) { + e1.printStackTrace(); + } + } + this.mGtEnumField = y; + mInternalAspectCache.put(this.tag, this); + // Double link custom Aspects, but internalise names using custom# instead + if (!vanilla) { + mInternalAspectCache.put("custom"+(aInternalAspectIDAllocation++), this); + GT_LanguageManager.addStringLocalization("tc.aspect."+aTag, aTooltip); + } + Logger.INFO("[Thaumcraft++] Adding support for Aspect: "+tag); + } + } + + + + /** + * Generates a TC_Aspect from an object, presummed to be a TC Aspect. + * @param aBaseAspect - The TC Aspect to generate from. + * @return + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + @SuppressWarnings("unused") + public static TC_Aspect_Wrapper generate(Object aBaseAspect) { + try { + Field aTagF = ReflectionUtils.getField(mClass_Aspect, "tag"); + if (aTagF == null) { + return null; + } + String aTafB = (String) aTagF.get(aBaseAspect); + if (aTafB == null) { + return null; + } + String aTag = aTafB.toLowerCase(); + if (aTag != null && getAspectList().containsKey(aTag.toLowerCase())) { + return getAspect(aTag); + } else { + TC_Aspect_Wrapper aTemp = new TC_Aspect_Wrapper( + aTag, + (int) ReflectionUtils.getField(mClass_Aspect, "color").get(aBaseAspect), + generateAspectArrayInternal(ReflectionUtils.getField(mClass_Aspect, "components"), (aBaseAspect)), + (ResourceLocation) ReflectionUtils.getField(mClass_Aspect, "image").get(aBaseAspect), + true, + (int) ReflectionUtils.getField(mClass_Aspect, "blend").get(aBaseAspect), + "" + ); + if (aTemp != null) { + aTemp.chatcolor = (String) ReflectionUtils.getField(mClass_Aspect, "chatcolor").get(aBaseAspect); + return aTemp; + } + else { + return null; + } + } + } + catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + + /** + * Internal Map containing all the TC_Aspects. + */ + private static Map<String, TC_Aspect_Wrapper> mInternalAspectCache = new LinkedHashMap<String, TC_Aspect_Wrapper>(); + + /** + * Public getter for all TC_Aspects + * @param aAspectName - Aspect Name + * @return - A GT++ Aspect wrapper or null. (TC_Aspect) + */ + public static TC_Aspect_Wrapper getAspect(String aAspectName) { + String aName = aAspectName.toLowerCase(); + TC_Aspect_Wrapper g = mInternalAspectCache.get(aName); + if (g != null) { + return g; + } + else { + try { + TC_Aspect_Wrapper aTemp = generate(getVanillaAspectList().get(aName)); + if (aTemp != null) { + mInternalAspectCache.put(aName, aTemp); + return aTemp; + } + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + } + return null; + } + + public static Map<String, TC_Aspect_Wrapper> getAspectList(){ + return mInternalAspectCache; + } + + + private static TC_Aspect_Wrapper[] generateAspectArrayInternal(Field aField, Object aInstance) { + //thaumcraft.api.aspects.Aspect.Aspect() + Object[] components; + TC_Aspect_Wrapper[] aAspectArray; + try { + components = (Object[]) aField.get(aInstance); + aAspectArray = new TC_Aspect_Wrapper[components == null ? 0 : components.length]; + if (aAspectArray.length > 0) { + int i = 0; + for (Object g : components) { + aAspectArray[i] = getAspect((String) ReflectionUtils.getField(mClass_Aspect, "tag").get(g)); + i++; + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + aAspectArray = new TC_Aspect_Wrapper[0]; + } + return aAspectArray; + } + + /** + * Tasty code to generate TC Aspects reflectively. + * @return + */ + public Object generateTcAspect() { + try { + //thaumcraft.api.aspects.Aspect.Aspect() + Object aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, 0); + if (components.length > 0) { + aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, components.length); + int i = 0; + for (TC_Aspect_Wrapper g : components) { + if (g != null && g.mAspect != null) + ((Object[]) aAspectArray)[i++] = g.mAspect; + } + } + Constructor constructor = mClass_Aspect.getConstructor(String.class, int.class, aAspectArray.getClass(), ResourceLocation.class, int.class); + Object myObject = constructor.newInstance(tag, color, aAspectArray, image, blend); + + //Set chat colour + if (chatcolor != null && chatcolor.length() > 0) { + Method setChatColour = ReflectionUtils.getMethod(mClass_Aspect, "setChatcolor", String.class); + if (setChatColour != null) { + setChatColour.invoke(myObject, chatcolor); + } + } + return myObject; + } catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + public static boolean isObjectAnAspect(Object aAspect) { + return mClass_Aspect.isInstance(aAspect); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/Base_Recipe_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/Base_Recipe_Wrapper.java new file mode 100644 index 0000000000..914144445c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/Base_Recipe_Wrapper.java @@ -0,0 +1,10 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe; + +import net.minecraft.item.ItemStack; + +public interface Base_Recipe_Wrapper { + + public abstract ItemStack getRecipeOutput(); + + public abstract ItemStack getRecipeInput(); +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_CrucibleRecipe_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_CrucibleRecipe_Wrapper.java new file mode 100644 index 0000000000..8ee4e7011d --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_CrucibleRecipe_Wrapper.java @@ -0,0 +1,19 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe; + +import net.minecraft.item.ItemStack; + +public class TC_CrucibleRecipe_Wrapper implements Base_Recipe_Wrapper { + + @Override + public ItemStack getRecipeInput() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ItemStack getRecipeOutput() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_IArcaneRecipe_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_IArcaneRecipe_Wrapper.java new file mode 100644 index 0000000000..fede079f7b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_IArcaneRecipe_Wrapper.java @@ -0,0 +1,19 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe; + +import net.minecraft.item.ItemStack; + +public class TC_IArcaneRecipe_Wrapper implements Base_Recipe_Wrapper { + + @Override + public ItemStack getRecipeInput() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ItemStack getRecipeOutput() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionEnchantmentRecipe_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionEnchantmentRecipe_Wrapper.java new file mode 100644 index 0000000000..b52fa0e6a7 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionEnchantmentRecipe_Wrapper.java @@ -0,0 +1,19 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe; + +import net.minecraft.item.ItemStack; + +public class TC_InfusionEnchantmentRecipe_Wrapper implements Base_Recipe_Wrapper { + + @Override + public ItemStack getRecipeInput() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ItemStack getRecipeOutput() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionRecipe_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionRecipe_Wrapper.java new file mode 100644 index 0000000000..a0c539f937 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/recipe/TC_InfusionRecipe_Wrapper.java @@ -0,0 +1,19 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe; + +import net.minecraft.item.ItemStack; + +public class TC_InfusionRecipe_Wrapper implements Base_Recipe_Wrapper { + + @Override + public ItemStack getRecipeInput() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ItemStack getRecipeOutput() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_PageType_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_PageType_Wrapper.java new file mode 100644 index 0000000000..d6c7f66988 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_PageType_Wrapper.java @@ -0,0 +1,17 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.research; + +public class TC_PageType_Wrapper { + + public static final TC_PageType_Wrapper TEXT = null; + public static final TC_PageType_Wrapper TEXT_CONCEALED = null; + public static final TC_PageType_Wrapper NORMAL_CRAFTING = null; + public static final TC_PageType_Wrapper ARCANE_CRAFTING = null; + public static final TC_PageType_Wrapper CRUCIBLE_CRAFTING = null; + public static final TC_PageType_Wrapper INFUSION_CRAFTING = null; + public static final TC_PageType_Wrapper COMPOUND_CRAFTING = null; + public static final TC_PageType_Wrapper SMELTING = null; + public static final TC_PageType_Wrapper INFUSION_ENCHANTMENT = null; + public static final TC_PageType_Wrapper IMAGE = null; + public static final TC_PageType_Wrapper ASPECTS = null; + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategories_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategories_Wrapper.java new file mode 100644 index 0000000000..93869cb8d8 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategories_Wrapper.java @@ -0,0 +1,89 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.research; + +import cpw.mods.fml.common.FMLLog; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedHashMap; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import org.apache.logging.log4j.Level; + +public class TC_ResearchCategories_Wrapper { + + public static LinkedHashMap<String, TC_ResearchCategoryList_Wrapper> researchCategories = new LinkedHashMap<String, TC_ResearchCategoryList_Wrapper>(); + + public static TC_ResearchCategoryList_Wrapper getResearchList(String key) { + return (TC_ResearchCategoryList_Wrapper) researchCategories.get(key); + } + + public static String getCategoryName(String key) { + return StatCollector.translateToLocal("tc.research_category." + key); + } + + public static TC_ResearchItem_Wrapper getResearch(String key) { + Collection rc = researchCategories.values(); + Iterator i$ = rc.iterator(); + + while (i$.hasNext()) { + Object cat = i$.next(); + Collection rl = ((TC_ResearchCategoryList_Wrapper) cat).research.values(); + Iterator i$1 = rl.iterator(); + + while (i$1.hasNext()) { + Object ri = i$1.next(); + if (((TC_ResearchItem_Wrapper) ri).key.equals(key)) { + return (TC_ResearchItem_Wrapper) ri; + } + } + } + + return null; + } + + public static void registerCategory(String key, ResourceLocation icon, ResourceLocation background) { + if (getResearchList(key) == null) { + TC_ResearchCategoryList_Wrapper rl = new TC_ResearchCategoryList_Wrapper(icon, background); + researchCategories.put(key, rl); + } + + } + + public static void addResearch(TC_ResearchItem_Wrapper ri) { + TC_ResearchCategoryList_Wrapper rl = getResearchList(ri.category); + if (rl != null && !rl.research.containsKey(ri.key)) { + if (!ri.isVirtual()) { + Iterator i$ = rl.research.values().iterator(); + + while (i$.hasNext()) { + TC_ResearchItem_Wrapper rr = (TC_ResearchItem_Wrapper) i$.next(); + if (rr.displayColumn == ri.displayColumn && rr.displayRow == ri.displayRow) { + FMLLog.log(Level.FATAL, + "[Thaumcraft] Research [" + ri.getName() + + "] not added as it overlaps with existing research [" + rr.getName() + "]", + new Object[0]); + return; + } + } + } + + rl.research.put(ri.key, ri); + if (ri.displayColumn < rl.minDisplayColumn) { + rl.minDisplayColumn = ri.displayColumn; + } + + if (ri.displayRow < rl.minDisplayRow) { + rl.minDisplayRow = ri.displayRow; + } + + if (ri.displayColumn > rl.maxDisplayColumn) { + rl.maxDisplayColumn = ri.displayColumn; + } + + if (ri.displayRow > rl.maxDisplayRow) { + rl.maxDisplayRow = ri.displayRow; + } + } + + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategoryList_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategoryList_Wrapper.java new file mode 100644 index 0000000000..3e6f5b78f2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchCategoryList_Wrapper.java @@ -0,0 +1,21 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.research; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.util.ResourceLocation; + +public class TC_ResearchCategoryList_Wrapper { + public int minDisplayColumn; + public int minDisplayRow; + public int maxDisplayColumn; + public int maxDisplayRow; + public ResourceLocation icon; + public ResourceLocation background; + public Map<String, TC_ResearchItem_Wrapper> research = new HashMap<String, TC_ResearchItem_Wrapper>(); + + public TC_ResearchCategoryList_Wrapper(ResourceLocation icon, ResourceLocation background) { + this.icon = icon; + this.background = background; + } +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchItem_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchItem_Wrapper.java new file mode 100644 index 0000000000..6372cc0371 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchItem_Wrapper.java @@ -0,0 +1,246 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.research; + +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_AspectList_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; +import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class TC_ResearchItem_Wrapper { + + public final String key; + public final String category; + public final TC_AspectList_Wrapper tags; + public String[] parents = null; + public String[] parentsHidden = null; + public String[] siblings = null; + public final int displayColumn; + public final int displayRow; + public final ItemStack icon_item; + public final ResourceLocation icon_resource; + private int complexity; + private boolean isSpecial; + private boolean isSecondary; + private boolean isRound; + private boolean isStub; + private boolean isVirtual; + private boolean isConcealed; + private boolean isHidden; + private boolean isLost; + private boolean isAutoUnlock; + private ItemStack[] itemTriggers; + private String[] entityTriggers; + private TC_Aspect_Wrapper[] aspectTriggers; + private Object[] pages = null; + + public TC_ResearchItem_Wrapper(String key, String category) { + this.key = key; + this.category = category; + this.tags = new TC_AspectList_Wrapper(); + this.icon_resource = null; + this.icon_item = null; + this.displayColumn = 0; + this.displayRow = 0; + this.setVirtual(); + } + + public TC_ResearchItem_Wrapper(String key, String category, TC_AspectList_Wrapper tags, int col, int row, int complex, + ResourceLocation icon) { + this.key = key; + this.category = category; + this.tags = tags; + this.icon_resource = icon; + this.icon_item = null; + this.displayColumn = col; + this.displayRow = row; + this.complexity = complex; + if (this.complexity < 1) { + this.complexity = 1; + } + + if (this.complexity > 3) { + this.complexity = 3; + } + + } + + public TC_ResearchItem_Wrapper(String key, String category, TC_AspectList_Wrapper tags, int col, int row, int complex, ItemStack icon) { + this.key = key; + this.category = category; + this.tags = tags; + this.icon_item = icon; + this.icon_resource = null; + this.displayColumn = col; + this.displayRow = row; + this.complexity = complex; + if (this.complexity < 1) { + this.complexity = 1; + } + + if (this.complexity > 3) { + this.complexity = 3; + } + + } + + public TC_ResearchItem_Wrapper setSpecial() { + this.isSpecial = true; + return this; + } + + public TC_ResearchItem_Wrapper setStub() { + this.isStub = true; + return this; + } + + public TC_ResearchItem_Wrapper setLost() { + this.isLost = true; + return this; + } + + public TC_ResearchItem_Wrapper setConcealed() { + this.isConcealed = true; + return this; + } + + public TC_ResearchItem_Wrapper setHidden() { + this.isHidden = true; + return this; + } + + public TC_ResearchItem_Wrapper setVirtual() { + this.isVirtual = true; + return this; + } + + public TC_ResearchItem_Wrapper setParents(String... par) { + this.parents = par; + return this; + } + + public TC_ResearchItem_Wrapper setParentsHidden(String... par) { + this.parentsHidden = par; + return this; + } + + public TC_ResearchItem_Wrapper setSiblings(String... sib) { + this.siblings = sib; + return this; + } + + public TC_ResearchItem_Wrapper setPages(Object... par) { + this.pages = par; + return this; + } + + public Object[] getPages() { + return this.pages; + } + + public TC_ResearchItem_Wrapper setItemTriggers(ItemStack... par) { + this.itemTriggers = par; + return this; + } + + public TC_ResearchItem_Wrapper setEntityTriggers(String... par) { + this.entityTriggers = par; + return this; + } + + public TC_ResearchItem_Wrapper setAspectTriggers(TC_Aspect_Wrapper... par) { + this.aspectTriggers = par; + return this; + } + + public ItemStack[] getItemTriggers() { + return this.itemTriggers; + } + + public String[] getEntityTriggers() { + return this.entityTriggers; + } + + public TC_Aspect_Wrapper[] getAspectTriggers() { + return this.aspectTriggers; + } + + public TC_ResearchItem_Wrapper registerResearchItem() { + ThaumcraftUtils.addResearch(this); + return this; + } + + public String getName() { + return StatCollector.translateToLocal("tc.research_name." + this.key); + } + + public String getText() { + return StatCollector.translateToLocal("tc.research_text." + this.key); + } + + public boolean isSpecial() { + return this.isSpecial; + } + + public boolean isStub() { + return this.isStub; + } + + public boolean isLost() { + return this.isLost; + } + + public boolean isConcealed() { + return this.isConcealed; + } + + public boolean isHidden() { + return this.isHidden; + } + + public boolean isVirtual() { + return this.isVirtual; + } + + public boolean isAutoUnlock() { + return this.isAutoUnlock; + } + + public TC_ResearchItem_Wrapper setAutoUnlock() { + this.isAutoUnlock = true; + return this; + } + + public boolean isRound() { + return this.isRound; + } + + public TC_ResearchItem_Wrapper setRound() { + this.isRound = true; + return this; + } + + public boolean isSecondary() { + return this.isSecondary; + } + + public TC_ResearchItem_Wrapper setSecondary() { + this.isSecondary = true; + return this; + } + + public int getComplexity() { + return this.complexity; + } + + public TC_ResearchItem_Wrapper setComplexity(int complexity) { + this.complexity = complexity; + return this; + } + + public TC_Aspect_Wrapper getResearchPrimaryTag() { + //TODO + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchNoteData_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchNoteData_Wrapper.java new file mode 100644 index 0000000000..5adf0150d9 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchNoteData_Wrapper.java @@ -0,0 +1,14 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.research; + +public class TC_ResearchNoteData_Wrapper { + + public TC_ResearchNoteData_Wrapper(Object researchNoteData) { + // TODO Auto-generated constructor stub + } + + public Object getResearchNoteData() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchPage_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchPage_Wrapper.java new file mode 100644 index 0000000000..998f37bf8c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/objects/wrapper/research/TC_ResearchPage_Wrapper.java @@ -0,0 +1,228 @@ +package gtPlusPlus.xmod.thaumcraft.objects.wrapper.research; + +import java.util.List; + +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_AspectList_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_CrucibleRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_IArcaneRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionEnchantmentRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionRecipe_Wrapper; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class TC_ResearchPage_Wrapper { + public TC_PageType_Wrapper type; + public String text; + public String research; + public ResourceLocation image; + public TC_AspectList_Wrapper aspects; + public Object recipe; + public ItemStack recipeOutput; + + public TC_ResearchPage_Wrapper(String text) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.TEXT; + this.text = text; + } + + public TC_ResearchPage_Wrapper(String research, String text) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.TEXT_CONCEALED; + this.research = research; + this.text = text; + } + + public TC_ResearchPage_Wrapper(IRecipe recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.NORMAL_CRAFTING; + this.recipe = recipe; + this.recipeOutput = recipe.getRecipeOutput(); + } + + public TC_ResearchPage_Wrapper(IRecipe[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.NORMAL_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(TC_IArcaneRecipe_Wrapper[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.ARCANE_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(TC_CrucibleRecipe_Wrapper[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.CRUCIBLE_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(TC_InfusionRecipe_Wrapper[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.INFUSION_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(List recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.COMPOUND_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(TC_IArcaneRecipe_Wrapper recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.ARCANE_CRAFTING; + this.recipe = recipe; + this.recipeOutput = recipe.getRecipeOutput(); + } + + public TC_ResearchPage_Wrapper(TC_CrucibleRecipe_Wrapper recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.CRUCIBLE_CRAFTING; + this.recipe = recipe; + this.recipeOutput = recipe.getRecipeOutput(); + } + + public TC_ResearchPage_Wrapper(ItemStack input) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.SMELTING; + this.recipe = input; + this.recipeOutput = FurnaceRecipes.smelting().getSmeltingResult(input); + } + + public TC_ResearchPage_Wrapper(TC_InfusionRecipe_Wrapper recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.INFUSION_CRAFTING; + this.recipe = recipe; + if (recipe.getRecipeOutput() instanceof ItemStack) { + this.recipeOutput = (ItemStack) recipe.getRecipeOutput(); + } else { + this.recipeOutput = recipe.getRecipeInput(); + } + + } + + public TC_ResearchPage_Wrapper(TC_InfusionEnchantmentRecipe_Wrapper recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.INFUSION_ENCHANTMENT; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(ResourceLocation image, String caption) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.IMAGE; + this.image = image; + this.text = caption; + } + + public TC_ResearchPage_Wrapper(TC_AspectList_Wrapper as) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.ASPECTS; + this.aspects = as; + } + + public String getTranslatedText() { + String ret = ""; + if (this.text != null) { + ret = StatCollector.translateToLocal(this.text); + if (ret.isEmpty()) { + ret = this.text; + } + } + + return ret; + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java b/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java index 2f5400e5f2..8beaa8df5e 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/util/ThaumcraftUtils.java @@ -1,63 +1,59 @@ package gtPlusPlus.xmod.thaumcraft.util; import static gtPlusPlus.xmod.thaumcraft.HANDLER_Thaumcraft.sItemsToGetAspects; -import static gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectCompat.getAspectList_Ex; -import java.util.*; - -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.world.World; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; -import gregtech.api.enums.TC_Aspects.TC_AspectStack; +import gregtech.api.enums.TC_Aspects; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.thaumcraft.HANDLER_Thaumcraft; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects.TC_AspectStack_Ex; -import gtPlusPlus.xmod.thaumcraft.objects.ResearchNoteDataWrapper; -import thaumcraft.api.ThaumcraftApi; -import thaumcraft.api.ThaumcraftApiHelper; -import thaumcraft.api.aspects.Aspect; -import thaumcraft.api.aspects.AspectList; -import thaumcraft.api.crafting.*; -import thaumcraft.api.research.*; -import thaumcraft.common.lib.research.ResearchManager; -import thaumcraft.common.lib.research.ResearchNoteData; -import thaumcraft.common.lib.utils.HexUtils; +import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_AspectStack; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_AspectList_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.aspect.TC_Aspect_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_CrucibleRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_IArcaneRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionEnchantmentRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.recipe.TC_InfusionRecipe_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.research.TC_ResearchCategories_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.research.TC_ResearchCategoryList_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.research.TC_ResearchItem_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.research.TC_ResearchNoteData_Wrapper; +import gtPlusPlus.xmod.thaumcraft.objects.wrapper.research.TC_ResearchPage_Wrapper; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.world.World; public class ThaumcraftUtils { - public static boolean addAspectToItem(ItemStack item, Aspect aspect, int amount) { - return addAspectToItem(item, getEnumAspect(aspect.getName()), amount); - } - /*public static boolean addAspectToItem(ItemStack item, Aspect[] aspects, int amount) { - return addAspectToItem(item, getEnumAspect(aspect.getName()), amount); - }*/ + private static Class mClass_Aspect; + private static Field mField_Aspects; - public static boolean addAspectToItem(ItemStack item, GTPP_Aspects aspect, int amount) { - return addAspectToItem(item, new GTPP_Aspects[] {aspect}, new Integer[] {amount}); + public static boolean addAspectToItem(ItemStack item, TC_Aspect_Wrapper aspect, int amount) { + return addAspectToItem(item, new TC_Aspect_Wrapper[] {aspect}, new Integer[] {amount}); } - public static boolean addAspectToItem(ItemStack item, GTPP_Aspects[] aspect, Integer[] amounts) { - TC_AspectStack_Ex[] aspects = new TC_AspectStack_Ex[aspect.length]; + public static boolean addAspectToItem(ItemStack item, TC_Aspect_Wrapper[] aspect, Integer[] amounts) { + GTPP_AspectStack[] aspects = new GTPP_AspectStack[aspect.length]; for (int g=0;g<aspect.length;g++) { if (amounts[g] != null && amounts[g] > 0) { - aspects[g] = new TC_AspectStack_Ex(aspect[g], amounts[g]); + //aspects[g] = new GTPP_AspectStack(aspect[g], amounts[g]); } } - Pair<ItemStack, TC_AspectStack_Ex[]> k = new Pair<ItemStack, TC_AspectStack_Ex[]>(item, aspects); + Pair<ItemStack, GTPP_AspectStack[]> k = new Pair<ItemStack, GTPP_AspectStack[]>(item, aspects); int mSizeA = sItemsToGetAspects.size(); sItemsToGetAspects.put(k); if (sItemsToGetAspects.size() > mSizeA) { @@ -70,58 +66,50 @@ public class ThaumcraftUtils { } - public static Aspect getAspect(String name) { - GTPP_Aspects r = getAspectEnum(name); - return (r == null ? null : r.mAspect); - } - - public static GTPP_Aspects getEnumAspect(String name) { - GTPP_Aspects r = getAspectEnum(name); - return (r == null ? null : r); + public static TC_Aspect_Wrapper getAspect(String name) { + return TC_Aspect_Wrapper.getAspect(name); } - private static GTPP_Aspects getAspectEnum(String name) { - GTPP_Aspects h = null; - for (GTPP_Aspects f : GTPP_Aspects.values()) { - if (f.mAspect.getName().toLowerCase().contains(name.toLowerCase())) { - h = f; - } - } - return h; + public static TC_Aspects getEnumAspect(String name) { + TC_Aspect_Wrapper r = getAspect(name); + return r.mGtEnumField; } + + - public static Object addResearch(String aResearch, String aName, String aText, String[] aParentResearches, String aCategory, ItemStack aIcon, int aComplexity, int aType, int aX, int aY, List<TC_AspectStack_Ex> aAspects, ItemStack[] aResearchTriggers, Object[] aPages) { + public static Object addResearch(String aResearch, String aName, String aText, String[] aParentResearches, String aCategory, ItemStack aIcon, int aComplexity, int aType, int aX, int aY, List<GTPP_AspectStack> aAspects, ItemStack[] aResearchTriggers, Object[] aPages) { if (!GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.researches, aResearch, true)) { return null; } - ResearchCategoryList tCategory = ResearchCategories.getResearchList(aCategory); + TC_ResearchCategoryList_Wrapper tCategory = TC_ResearchCategories_Wrapper.getResearchList(aCategory); if (tCategory == null) { return null; } - for (Iterator<ResearchItem> i$ = tCategory.research.values().iterator(); i$.hasNext(); ) { - ResearchItem tResearch = (ResearchItem) i$.next(); + for (Iterator<TC_ResearchItem_Wrapper> i$ = tCategory.research.values().iterator(); i$.hasNext(); ) { + TC_ResearchItem_Wrapper tResearch = (TC_ResearchItem_Wrapper) i$.next(); if ((tResearch.displayColumn == aX) && (tResearch.displayRow == aY)) { aX += (aX > 0 ? 5 : -5); aY += (aY > 0 ? 5 : -5); } } - ResearchItem rResearch = new ResearchItem(aResearch, aCategory, getAspectList_Ex(aAspects), aX, aY, aComplexity, aIcon); - ArrayList<ResearchPage> tPages = new ArrayList<ResearchPage>(aPages.length); + TC_ResearchItem_Wrapper rResearch = new TC_ResearchItem_Wrapper(aResearch, aCategory, getAspectList_Ex(aAspects), aX, aY, aComplexity, aIcon); + ArrayList<Object> tPages = new ArrayList<Object>(aPages.length); GT_LanguageManager.addStringLocalization("tc.research_name." + aResearch, aName); GT_LanguageManager.addStringLocalization("tc.research_text." + aResearch, "[GT++] " + aText); for (Object tPage : aPages) { if ((tPage instanceof String)) { - tPages.add(new ResearchPage((String) tPage)); + tPages.add(new TC_ResearchPage_Wrapper((String) tPage)); } else if ((tPage instanceof IRecipe)) { - tPages.add(new ResearchPage((IRecipe) tPage)); - } else if ((tPage instanceof IArcaneRecipe)) { - tPages.add(new ResearchPage((IArcaneRecipe) tPage)); - } else if ((tPage instanceof CrucibleRecipe)) { - tPages.add(new ResearchPage((CrucibleRecipe) tPage)); - } else if ((tPage instanceof InfusionRecipe)) { - tPages.add(new ResearchPage((InfusionRecipe) tPage)); - } else if ((tPage instanceof InfusionEnchantmentRecipe)) { - tPages.add(new ResearchPage((InfusionEnchantmentRecipe) tPage)); + tPages.add(new TC_ResearchPage_Wrapper((IRecipe) tPage)); + } + else if ((tPage instanceof TC_IArcaneRecipe_Wrapper)) { + tPages.add(new TC_ResearchPage_Wrapper((TC_IArcaneRecipe_Wrapper) tPage)); + } else if ((tPage instanceof TC_CrucibleRecipe_Wrapper)) { + tPages.add(new TC_ResearchPage_Wrapper((TC_CrucibleRecipe_Wrapper) tPage)); + } else if ((tPage instanceof TC_InfusionRecipe_Wrapper)) { + tPages.add(new TC_ResearchPage_Wrapper((TC_InfusionRecipe_Wrapper) tPage)); + } else if ((tPage instanceof TC_InfusionEnchantmentRecipe_Wrapper)) { + tPages.add(new TC_ResearchPage_Wrapper((TC_InfusionEnchantmentRecipe_Wrapper) tPage)); } } if ((aType & 0x40) != 0) { @@ -161,58 +149,58 @@ public class ThaumcraftUtils { rResearch.setItemTriggers(aResearchTriggers); rResearch.setHidden(); } - rResearch.setPages((ResearchPage[]) tPages.toArray(new ResearchPage[tPages.size()])); + rResearch.setPages((TC_ResearchPage_Wrapper[]) tPages.toArray(new TC_ResearchPage_Wrapper[tPages.size()])); return rResearch.registerResearchItem(); } public static Object addCrucibleRecipe(final String aResearch, final Object aInput, final ItemStack aOutput, - final List<TC_AspectStack_Ex> aAspects) { + final List<GTPP_AspectStack> aAspects) { if (GT_Utility.isStringInvalid((Object) aResearch) || aInput == null || aOutput == null || aAspects == null || aAspects.isEmpty()) { return null; } - return ThaumcraftApi.addCrucibleRecipe(aResearch, GT_Utility.copy(new Object[]{aOutput}), + return addCrucibleRecipe(aResearch, GT_Utility.copy(new Object[]{aOutput}), (aInput instanceof ItemStack || aInput instanceof ArrayList) ? aInput : aInput.toString(), getAspectList_Ex(aAspects)); } public static Object addInfusionRecipe(final String aResearch, final ItemStack aMainInput, final ItemStack[] aSideInputs, - final ItemStack aOutput, final int aInstability, final List<TC_AspectStack_Ex> aAspects) { + final ItemStack aOutput, final int aInstability, final List<GTPP_AspectStack> aAspects) { if (GT_Utility.isStringInvalid((Object) aResearch) || aMainInput == null || aSideInputs == null || aOutput == null || aAspects == null || aAspects.isEmpty()) { return null; } - return ThaumcraftApi.addInfusionCraftingRecipe(aResearch, (Object) GT_Utility.copy(new Object[]{aOutput}), + return addInfusionCraftingRecipe(aResearch, (Object) GT_Utility.copy(new Object[]{aOutput}), aInstability, getAspectList_Ex(aAspects), aMainInput, aSideInputs); } public static boolean registerThaumcraftAspectsToItem(final ItemStack aExampleStack, - final List<TC_AspectStack_Ex> aAspects, final String aOreDict) { + final List<GTPP_AspectStack> aAspects, final String aOreDict) { if (aAspects.isEmpty()) { return false; } - ThaumcraftApi.registerObjectTag(aOreDict, getAspectList_Ex(aAspects)); + registerObjectTag(aOreDict, getAspectList_Ex(aAspects)); return true; } public static boolean registerThaumcraftAspectsToItem(final ItemStack aStack, - final List<TC_AspectStack_Ex> aAspects, final boolean aAdditive) { + final List<GTPP_AspectStack> aAspects, final boolean aAdditive) { try { if (aAspects.isEmpty()) { return false; } - AspectList h = getAspectList_Ex(aAspects); + TC_AspectList_Wrapper h = getAspectList_Ex(aAspects); if (aAdditive && (h != null && h.size() > 0)) { - ThaumcraftApi.registerComplexObjectTag(aStack, getAspectList_Ex(aAspects)); + registerComplexObjectTag(aStack, getAspectList_Ex(aAspects)); return true; } else { Logger.MATERIALS("[Aspect] Failed adding aspects to "+aStack.getDisplayName()+"."); } - final AspectList tAlreadyRegisteredAspects = ThaumcraftApiHelper.getObjectAspects(aStack); + final TC_AspectList_Wrapper tAlreadyRegisteredAspects = getObjectAspects(aStack); if (tAlreadyRegisteredAspects == null || tAlreadyRegisteredAspects.size() <= 0) { - ThaumcraftApi.registerObjectTag(aStack, getAspectList_Ex(aAspects)); + registerObjectTag(aStack, getAspectList_Ex(aAspects)); } return true; } @@ -222,44 +210,168 @@ public class ThaumcraftUtils { return false; } } + - public static boolean registerPortholeBlacklistedBlock(final Block aBlock) { - ThaumcraftApi.portableHoleBlackList.add(aBlock); - return true; + private static final Class mClass_ThaumcraftApi; + private static final Class mClass_ThaumcraftApiHelper; + private static final Class mClass_AspectList; + private static final Class mClass_ResearchManager; + private static final Method mMethod_registerObjectTag1; + private static final Method mMethod_registerObjectTag2; + private static final Method mMethod_registerComplexObjectTag; + private static final Method mMethod_addInfusionCraftingRecipe; + private static final Method mMethod_addCrucibleRecipe; + private static final Method mMethod_getObjectAspects; + private static final Method mMethod_updateData; + private static final Method mMethod_getData; + + private static final Field mField_PortholeBlacklist; + static { + /* + * Classes + */ + mClass_ThaumcraftApi = ReflectionUtils.getClass("thaumcraft.api.ThaumcraftApi"); + mClass_ThaumcraftApiHelper = ReflectionUtils.getClass("thaumcraft.api.ThaumcraftApiHelper"); + mClass_AspectList = ReflectionUtils.getClass("thaumcraft.api.aspects.AspectList"); + mClass_ResearchManager = ReflectionUtils.getClass("thaumcraft.common.lib.research.ResearchManager"); + + /* + * Methods + */ + mMethod_registerObjectTag1 = ReflectionUtils.getMethod(mClass_ThaumcraftApi, "registerObjectTag", + ItemStack.class, mClass_AspectList); + + mMethod_registerObjectTag2 = ReflectionUtils.getMethod(mClass_ThaumcraftApi, "registerObjectTag", String.class, + mClass_AspectList); + + mMethod_registerComplexObjectTag = ReflectionUtils.getMethod(mClass_ThaumcraftApi, "registerComplexObjectTag", + ItemStack.class, mClass_AspectList); + + mMethod_addInfusionCraftingRecipe = ReflectionUtils.getMethod(mClass_ThaumcraftApi, "addInfusionCraftingRecipe", + String.class, Object.class, int.class, mClass_AspectList, ItemStack.class, ItemStack[].class); + + mMethod_addCrucibleRecipe = ReflectionUtils.getMethod(mClass_ThaumcraftApi, "addCrucibleRecipe", String.class, + ItemStack.class, Object.class, mClass_AspectList); + + + mMethod_getObjectAspects = ReflectionUtils.getMethod(mClass_ThaumcraftApiHelper, "getObjectAspects", ItemStack.class); + + + mMethod_updateData = ReflectionUtils.getMethod(mClass_ResearchManager, "updateData", ItemStack.class, ReflectionUtils.getClass("thaumcraft.common.lib.research.ResearchNoteData")); + mMethod_getData = ReflectionUtils.getMethod(mClass_ResearchManager, "getData", ItemStack.class); + + /* + * Fields + */ + mField_PortholeBlacklist = ReflectionUtils.getField(mClass_ThaumcraftApi, "portableHoleBlackList"); + + } + + public static void registerObjectTag(ItemStack aStack, TC_AspectList_Wrapper aAspectList) { + try { + mMethod_registerObjectTag1.invoke(null, aStack, aAspectList.getVanillaAspectList()); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } } - public static TC_AspectStack_Ex convertAspectStack(TC_AspectStack gtType) { - TC_AspectStack_Ex g = null; - if (gtType == null) { - return null; + public static void registerObjectTag(String aOreDict, TC_AspectList_Wrapper aAspectList) { + try { + mMethod_registerObjectTag2.invoke(null, aOreDict, aAspectList.getVanillaAspectList()); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); } - else { - String oldName = gtType.mAspect.name().toLowerCase(); - long oldAmount = gtType.mAmount; - for (GTPP_Aspects r : GTPP_Aspects.values()) { - if (r.mAspect.getName().toLowerCase().contains(oldName)) { - g = new TC_AspectStack_Ex(r, oldAmount); - break; - } - } - } - return g; } + + public static void registerComplexObjectTag(ItemStack aStack, TC_AspectList_Wrapper aAspectList) { + try { + mMethod_registerComplexObjectTag.invoke(null, aStack, aAspectList.getVanillaAspectList()); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } + + + public static TC_AspectList_Wrapper getObjectAspects(ItemStack aStack) { + try { + return new TC_AspectList_Wrapper(mMethod_getObjectAspects.invoke(null, aStack)); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + return null; + } + + - public static List<TC_AspectStack_Ex> convertAspectStack(List<TC_AspectStack> p5) { - List<TC_AspectStack_Ex> list = new ArrayList<TC_AspectStack_Ex>(); - for (TC_AspectStack h : p5) { - list.add(convertAspectStack(h)); + public static Object addCrucibleRecipe(String aResearch, ItemStack copy, Object aOutput, + TC_AspectList_Wrapper aAspectList) { + try { + return mMethod_addCrucibleRecipe.invoke(null, aResearch, copy, aOutput, aAspectList); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + return null; + } + + public static Object addInfusionCraftingRecipe(String aResearch, Object copy, int aInstability, + TC_AspectList_Wrapper aAspectList, ItemStack aMainInput, ItemStack[] aSideInputs) { + try { + return mMethod_addInfusionCraftingRecipe.invoke(null, aResearch, copy, aInstability, aAspectList, aMainInput, aSideInputs); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + return null; + } + + + public static boolean registerPortholeBlacklistedBlock(final Block aBlock) { + try { + ((ArrayList<Block>) mField_PortholeBlacklist.get(null)).add(aBlock); + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + return false; } - return list; + return true; } + - public static void updateResearchNote(ItemStack a, ResearchNoteData b) { - updateResearchNote(a, new ResearchNoteDataWrapper(b)); + public static String getTagFromAspectObject(Object aAspect) { + try { + Field aTagF = ReflectionUtils.getField(mClass_Aspect, "tag"); + if (aTagF == null) { + return null; + } + String aTafB = (String) aTagF.get(aAspect); + if (aTafB == null) { + return null; + } + String aTag = aTafB.toLowerCase(); + return aTag; + } catch (IllegalArgumentException | IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return "error"; + } } + - public static void updateResearchNote(ItemStack a, ResearchNoteDataWrapper b) { - ResearchManager.updateData(a, b); + public static void updateResearchNote(ItemStack a, TC_ResearchNoteData_Wrapper b) { + //updateData(a, b.getResearchNoteData()); + try { + mMethod_updateData.invoke(a, b.getResearchNoteData()); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } + + public static Object getResearchNoteData(ItemStack a) { + //getData(a); + try { + return mMethod_getData.invoke(a); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + return null; } public static boolean isItemResearchNotes(ItemStack aStack) { @@ -276,16 +388,16 @@ public class ThaumcraftUtils { return false; } - public static ResearchNoteDataWrapper gatherResults(ItemStack note) { - ResearchNoteDataWrapper research = null; + public static TC_ResearchNoteData_Wrapper gatherResults(ItemStack note) { + TC_ResearchNoteData_Wrapper research = null; if (isItemResearchNotes(note)) { - research = new ResearchNoteDataWrapper(ResearchManager.getData(note)); + research = new TC_ResearchNoteData_Wrapper(getResearchNoteData(note)); } return research; } - public static void placeAspectIntoResearchNote(ItemStack note, World aWorld, final int q, final int r, final Aspect aspect) { - ResearchNoteDataWrapper data = gatherResults(note); + public static void placeAspectIntoResearchNote(ItemStack note, World aWorld, final int q, final int r, final TC_Aspect_Wrapper aspect) { + /*TC_ResearchNoteData_Wrapper data = gatherResults(note); String mGTPP = CORE.gameProfile.getName(); EntityPlayer player = CORE.getFakePlayer(aWorld); @@ -315,7 +427,7 @@ public class ThaumcraftUtils { if (!aWorld.isRemote && ResearchManager.checkResearchCompletion(note, data, player.getCommandSenderName())) { note.setItemDamage(64); } - } + }*/ } public static void completeResearchNote(World aWorld, ItemStack aStack) { @@ -325,4 +437,17 @@ public class ThaumcraftUtils { } } } + + public static synchronized final TC_AspectList_Wrapper getAspectList_Ex(final List<GTPP_AspectStack> aAspects) { + final TC_AspectList_Wrapper rAspects = new TC_AspectList_Wrapper(); + for (final GTPP_AspectStack tAspect : aAspects) { + rAspects.add(tAspect.mAspect, tAspect.mAmount); + } + return rAspects; + } + + public static void addResearch(TC_ResearchItem_Wrapper tc_ResearchItem_Wrapper) { + // TODO Auto-generated method stub + + } } diff --git a/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java b/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java index 501fe6579a..3b2bcba5dd 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java @@ -6,6 +6,7 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.tinkers.material.BaseTinkersMaterial; import gtPlusPlus.xmod.tinkers.util.TinkersUtils; import net.minecraft.block.Block; import net.minecraftforge.fluids.Fluid; @@ -13,6 +14,8 @@ import net.minecraftforge.fluids.FluidRegistry; public class HANDLER_Tinkers { + public static AutoMap<BaseTinkersMaterial> mTinkerMaterials = new AutoMap<BaseTinkersMaterial>(); + public static final void preInit() { if (LoadedMods.TiCon) { @@ -31,9 +34,14 @@ public class HANDLER_Tinkers { } } - public static final void postInit() { + public static final void postInit() { if (LoadedMods.TiCon) { - Class aTinkersSmeltery = ReflectionUtils.getClassByName("tconstruct.smeltery.TinkerSmeltery"); + + for (BaseTinkersMaterial y : mTinkerMaterials) { + //y.generate(); + } + + Class aTinkersSmeltery = ReflectionUtils.getClass("tconstruct.smeltery.TinkerSmeltery"); AutoMap<Fluid> aTweakedFluids = new AutoMap<Fluid>(); if (aTinkersSmeltery != null) { try { @@ -84,7 +92,7 @@ public class HANDLER_Tinkers { } } } - } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { } } } diff --git a/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java new file mode 100644 index 0000000000..6f47909a01 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java @@ -0,0 +1,274 @@ +package gtPlusPlus.xmod.tinkers.material; + +import static gtPlusPlus.core.util.math.MathUtils.safeCast_LongToInt; + +import java.util.HashMap; + +import cpw.mods.fml.common.event.FMLInterModComms; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.tinkers.HANDLER_Tinkers; +import gtPlusPlus.xmod.tinkers.util.TinkersUtils; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.Fluid; + +public class BaseTinkersMaterial { + + + + private static HashMap<String, Integer> aInternalMaterialIdMap = new HashMap<String, Integer>(); + private static int aNextFreeID; + + public final String mLocalName; + + private final String mUnlocalName; + private final int mID; + private final Material mMaterial; + + static { + aNextFreeID = (Short.MAX_VALUE/2)+420; + } + + public BaseTinkersMaterial(Material aMaterial) { + mLocalName = aMaterial.getLocalizedName(); + mUnlocalName = "material.gtpp."+Utils.sanitizeString(mLocalName); + mMaterial = aMaterial; + mID = aNextFreeID++; + Logger.INFO("[TiCon] Assigning ID "+mID+" to "+mLocalName+"."); + aInternalMaterialIdMap.put(mUnlocalName, mID); + HANDLER_Tinkers.mTinkerMaterials.put(this); + } + + public String getUnlocalName() { + return mUnlocalName; + } + + private static int calcDurability(Material aMaterial) { + return safeCast_LongToInt(aMaterial.vDurability); + } + + private static int calcMiningSpeed(Material aMaterial) { + return (aMaterial.vHarvestLevel * 2)+aMaterial.vTier; + } + + private static int calcHarvestLevel(Material aMaterial) { + return aMaterial.vHarvestLevel; + } + + private static int calcAttack(Material aMaterial) { + return aMaterial.vHarvestLevel+aMaterial.vTier+aMaterial.vRadiationLevel; + } + + private static float calcHandleModifier(Material aMaterial) { + return 1f; + } + + private static int calcReinforced(Material aMaterial) { + return aMaterial.getMeltingPointC()/3600; + } + + private static int calcBowProjectileSpeed(Material aMaterial) { + return aMaterial.vHarvestLevel+2; + } + + private static int calcBowDrawSpeed(Material aMaterial) { + return aMaterial.vHarvestLevel+8; + } + + private static float calcProjectileMass(Material aMaterial) { + return (aMaterial.getMeltingPointC()/1800)*0.1f; + } + + private static float calcProjectileFragility(Material aMaterial) { + return 0f; + } + + private static String calcStyle(Material aMaterial) { + String aReturn = "" + EnumChatFormatting.WHITE; + int aTemp = aMaterial.getMeltingPointC(); + if (aTemp < 3600) { + aReturn = "" + EnumChatFormatting.WHITE; + } + else if (aTemp >= 3600) { + aReturn = "" + EnumChatFormatting.YELLOW; + } + else if (aTemp >= (3600*2)) { + aReturn = "" + EnumChatFormatting.GREEN; + } + else if (aTemp >= (3600*3)) { + aReturn = "" + EnumChatFormatting.RED; + } + else if (aTemp >= (3600*4)) { + aReturn = "" + EnumChatFormatting.DARK_RED; + } + else { + aReturn = "" + EnumChatFormatting.GOLD; + } + return aReturn; + } + + private static int calcColour(Material aMaterial) { + return aMaterial.getRgbAsHex(); + } + + public Object generateToolMaterial(Material aMaterial) { + int level, dura, speed, dmg, reinf, primColour; + float handle, stonebound; + level = calcHarvestLevel(aMaterial); + dura = calcDurability(aMaterial); + speed = calcMiningSpeed(aMaterial); + dmg = calcAttack(aMaterial); + reinf = calcReinforced(aMaterial); + primColour = calcColour(aMaterial); + handle = calcHandleModifier(aMaterial); + //stonebound = calcHarvestLevel(aMaterial); + stonebound = 0; + return TinkersUtils.generateToolMaterial(aMaterial.getLocalizedName(), aMaterial.getUnlocalizedName(), level, dura, speed, dmg, handle, reinf, stonebound, calcStyle(aMaterial), primColour); + } + + public void generate() { + + Logger.INFO("[TiCon] Trying to generate Material: "+mLocalName); + int id = mID; + if (id > 0) { + + //Object aTinkersCustomMaterial = generateToolMaterial(mMaterial); + //Logger.INFO("[TiCon] Created Material: "+mLocalName); + + //TinkersUtils.addToolMaterial(id, aTinkersCustomMaterial); + //TinkersUtils.addDefaultToolPartMaterial(id); + //TinkersUtils.addBowMaterial(id, calcBowDrawSpeed(mMaterial), 1.0F); + //TinkersUtils.addArrowMaterial(id, calcProjectileMass(mMaterial), calcProjectileFragility(mMaterial)); + + NBTTagCompound tag = new NBTTagCompound(); + tag.setInteger("Id", id); + tag.setString("Name", mUnlocalName); + tag.setString("localizationString", mLocalName); + tag.setInteger("Durability", calcDurability(mMaterial)); // 97 + tag.setInteger("MiningSpeed", calcMiningSpeed(mMaterial)); // 150 + tag.setInteger("HarvestLevel", calcHarvestLevel(mMaterial)); // 1 + tag.setInteger("Attack", calcAttack(mMaterial)); // 0 + tag.setFloat("HandleModifier", calcHandleModifier(mMaterial)); // 1.0f + tag.setInteger("Reinforced", calcReinforced(mMaterial)); // 0 + tag.setFloat("Bow_ProjectileSpeed", calcBowProjectileSpeed(mMaterial)); // 3.0f + tag.setInteger("Bow_DrawSpeed", calcBowDrawSpeed(mMaterial)); // 18 + tag.setFloat("Projectile_Mass", calcProjectileMass(mMaterial)); // 0.69f + tag.setFloat("Projectile_Fragility", calcProjectileFragility(mMaterial)); // 0.2f + tag.setString("Style", calcStyle(mMaterial)); + tag.setInteger("Color", calcColour(mMaterial)); + + + boolean generate = generateRecipes(mMaterial, id); + + if (generate) { + Logger.INFO("[TiCon] Sending IMC: addMaterial - "+mLocalName+"."); + FMLInterModComms.sendMessage("TConstruct", "addMaterial", tag); + + ItemStack itemstack = mMaterial.getIngot(1); + tag = new NBTTagCompound(); + tag.setInteger("MaterialId", id); + NBTTagCompound item = new NBTTagCompound(); + itemstack.writeToNBT(item); + tag.setTag("Item", item); + tag.setInteger("Value", 2); // What is value for? + + Logger.INFO("[TiCon] Sending IMC: addPartBuilderMaterial - "+mLocalName+"."); + FMLInterModComms.sendMessage("TConstruct", "addPartBuilderMaterial", tag); + + tag = new NBTTagCompound(); + tag.setInteger("MaterialId", id); + tag.setInteger("Value", 2); // What is value for? + item = new NBTTagCompound(); + itemstack.writeToNBT(item); + tag.setTag("Item", item); + + Logger.INFO("[TiCon] Sending IMC: addMaterialItem - "+mLocalName+"."); + FMLInterModComms.sendMessage("TConstruct", "addMaterialItem", tag); + } + + + } + + } + + private boolean generateRecipes(Material aMaterial, int aID) { + + Block aMatBlock; + Integer aMelt; + Fluid aFluid; + + try { + aMatBlock = aMaterial.getBlock(); + aMelt = aMaterial.getMeltingPointC(); + aFluid = aMaterial.getFluid(0).getFluid(); + } + catch (Throwable t) { + return false; + } + + if (aMatBlock == null || aMelt == null || aFluid == null) { + return false; + } + + + //Smeltery.addMelting(new ItemStack(ExtraUtils.unstableIngot, 1, 0), ExtraUtils.decorative1, 5, 850, aMaterial.getFluid(72)); + TinkersUtils.registerFluidType(mLocalName, aMatBlock, 0, aMelt, aFluid, true); + TinkersUtils.addMelting(aMaterial.getBlock(1), aMatBlock, 0, aMelt, aMaterial.getFluid(144*9)); + TinkersUtils.addMelting(aMaterial.getIngot(1), aMatBlock, 0, aMelt, aMaterial.getFluid(144)); + if (aMelt <= 3600) { + ItemStack ingotcast = TinkersUtils.getPattern(1); + TinkersUtils.addBasinRecipe(aMaterial.getBlock(1), + aMaterial.getFluid(144*9), (ItemStack) null, true, 100); + TinkersUtils.addCastingTableRecipe(aMaterial.getIngot(1), + aMaterial.getFluid(144), ingotcast, false, 50); + } + + boolean extended = TinkersUtils.generateCastingRecipes(aMaterial, aID); + + + + + + + //TConstructRegistry.getBasinCasting().addCastingRecipe(new ItemStack(ExtraUtils.decorative1, 1, 5), new FluidStack(unstable, 1296), (ItemStack)null, true, 100); + + + + + + + + + + + + + + + + + + + + + + + + + + + + return true; + } + + + + + + + +} diff --git a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java index aed5b46e0a..f0c6d76b7c 100644 --- a/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java +++ b/src/Java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java @@ -1,48 +1,99 @@ package gtPlusPlus.xmod.tinkers.util; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; + +import gregtech.api.enums.Materials; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; public class TinkersUtils { - private static Object mSmelteryInstance; - private static Class mSmelteryClassInstance; + private static final Class mClass_Smeltery; + private static final Class mClass_TConstructRegistry; + private static final Class mClass_ToolMaterial; + private static final Class mClass_IPattern; + private static final Class mClass_DynamicToolPart; + private static final Class mClass_FluidType; + private static final Class mClass_CastingRecipe; + private static final Class mClass_TinkerSmeltery; + + private static final Field mField_MoltenIronFluid; + + private static final Method mMethod_getFluidType; + private static final Method mMethod_getCastingRecipes; - public static Object getSmelteryInstance() { + private static Object mSmelteryInstance; + private static Object mTinkersRegistryInstance; + + private static final HashMap<String, Method> mMethodCache = new LinkedHashMap<String, Method>(); + + + static { + mClass_Smeltery = ReflectionUtils.getClass("tconstruct.library.crafting.Smeltery"); + mClass_TConstructRegistry = ReflectionUtils.getClass("tconstruct.library.TConstructRegistry"); + + mClass_ToolMaterial = ReflectionUtils.getClass("tconstruct.library.tools.ToolMaterial"); + mClass_IPattern = ReflectionUtils.getClass("tconstruct.library.util.IPattern"); + mClass_DynamicToolPart = ReflectionUtils.getClass("tconstruct.library.tools.DynamicToolPart"); + mClass_FluidType = ReflectionUtils.getClass("tconstruct.library.crafting.FluidType"); + mClass_CastingRecipe = ReflectionUtils.getClass("tconstruct.library.crafting.CastingRecipe"); + mClass_TinkerSmeltery = ReflectionUtils.getClass("tconstruct.smeltery.TinkerSmeltery"); + + mField_MoltenIronFluid = ReflectionUtils.getField(mClass_TinkerSmeltery, "moltenIronFluid"); + + mMethod_getFluidType = ReflectionUtils.getMethod(mClass_FluidType, "getFluidType", String.class); + mMethod_getCastingRecipes = ReflectionUtils.getMethod(getCastingInstance(0), "getCastingRecipes", new Class[] {}); + } + + + /** + * + * @param aSwitch - The Registry to return + */ + private static void setTiConDataInstance() { if (!LoadedMods.TiCon) { - return null; - } - else { - if (mSmelteryInstance == null || mSmelteryClassInstance == null) { - if (mSmelteryClassInstance == null) { + return; + } else { + if (mSmelteryInstance == null) { + if (mClass_Smeltery != null) { try { - mSmelteryClassInstance = Class.forName("tconstruct.library.crafting.Smeltery"); + mSmelteryInstance = ReflectionUtils.getField(mClass_Smeltery, "instance").get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { } - catch (ClassNotFoundException e) {} } - if (mSmelteryClassInstance != null) { + } + if (mTinkersRegistryInstance == null) { + if (mClass_TConstructRegistry != null) { try { - mSmelteryInstance = ReflectionUtils.getField(mSmelteryClassInstance, "instance").get(null); - } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + mTinkersRegistryInstance = ReflectionUtils.getField(mClass_TConstructRegistry, "instance").get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { } } - } - } - if (mSmelteryInstance != null) { - return mSmelteryInstance; - } - return null; + } + } } public static final boolean isTiConFirstInOD() { if (LoadedMods.TiCon) { try { - return (boolean) ReflectionUtils.getField(Class.forName("PHConstruct"), "tconComesFirst").get(null); - } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | ClassNotFoundException e) { + return (boolean) ReflectionUtils.getField(ReflectionUtils.getClass("PHConstruct"), "tconComesFirst").get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { } } return false; @@ -51,8 +102,8 @@ public class TinkersUtils { public static final boolean stopTiconLoadingFirst() { if (isTiConFirstInOD()) { try { - ReflectionUtils.setFieldValue(Class.forName("PHConstruct"), "tconComesFirst", false); - if ((boolean) ReflectionUtils.getField(Class.forName("PHConstruct"), "tconComesFirst").get(null) == false) { + ReflectionUtils.setFinalFieldValue(ReflectionUtils.getClass("PHConstruct"), "tconComesFirst", false); + if ((boolean) ReflectionUtils.getField(ReflectionUtils.getClass("PHConstruct"), "tconComesFirst").get(null) == false) { return true; } //Did not work, let's see where TiCon uses this and prevent it. @@ -72,28 +123,400 @@ public class TinkersUtils { * @param duration How long one "portion" of liquid fuels the smeltery. Lava is 10. */ public static void addSmelteryFuel (Fluid fluid, int power, int duration){ - ReflectionUtils.invokeVoid(getSmelteryInstance(), "addSmelteryFuel", new Class[] {Fluid.class, int.class, int.class}, new Object[] {fluid, power, duration}); + setTiConDataInstance(); + ReflectionUtils.invokeVoid(mSmelteryInstance, "addSmelteryFuel", new Class[] {Fluid.class, int.class, int.class}, new Object[] {fluid, power, duration}); } /** * Returns true if the liquid is a valid smeltery fuel. */ public static boolean isSmelteryFuel (Fluid fluid){ - return ReflectionUtils.invoke(getSmelteryInstance(), "isSmelteryFuel", new Class[] {Fluid.class}, new Object[] {fluid}); + setTiConDataInstance(); + return ReflectionUtils.invoke(mSmelteryInstance, "isSmelteryFuel", new Class[] {Fluid.class}, new Object[] {fluid}); } /** * Returns the power of a smeltery fuel or 0 if it's not a fuel. */ public static int getFuelPower (Fluid fluid){ - return (int) ReflectionUtils.invokeNonBool(getSmelteryInstance(), "getFuelPower", new Class[] {Fluid.class}, new Object[] {fluid}); + setTiConDataInstance(); + return (int) ReflectionUtils.invokeNonBool(mSmelteryInstance, "getFuelPower", new Class[] {Fluid.class}, new Object[] {fluid}); } /** * Returns the duration of a smeltery fuel or 0 if it's not a fuel. */ public static int getFuelDuration (Fluid fluid){ - return (int) ReflectionUtils.invokeNonBool(getSmelteryInstance(), "getFuelDuration", new Class[] {Fluid.class}, new Object[] {fluid}); + setTiConDataInstance(); + return (int) ReflectionUtils.invokeNonBool(mSmelteryInstance, "getFuelDuration", new Class[] {Fluid.class}, new Object[] {fluid}); + } + + + + + + + + public static boolean registerFluidType(String name, Block block, int meta, int baseTemperature, Fluid fluid, boolean isToolpart) { + if (mMethodCache.get("registerFluidType") == null) { + Method m = ReflectionUtils.getMethod(ReflectionUtils.getClass("tconstruct.library.crafting.FluidType"), "registerFluidType", String.class, Block.class, int.class, int.class, Fluid.class, boolean.class); + mMethodCache.put("registerFluidType", m); + } + try { + mMethodCache.get("registerFluidType").invoke(null, name, block, meta, baseTemperature, fluid, isToolpart); + return true; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } + + + + + + + + + public static boolean addBaseMeltingRecipes(Material aMaterial) { + return addMelting(aMaterial.getBlock(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144*9)) && + addMelting(aMaterial.getIngot(1), aMaterial.getBlock(), 0, aMaterial.getMeltingPointC(), aMaterial.getFluid(144)); + } + + public static boolean addMelting(ItemStack input, Block block, int metadata, int temperature, FluidStack liquid) { + if (mMethodCache.get("addMelting") == null) { + Method m = ReflectionUtils.getMethod(mClass_Smeltery, "addMelting", ItemStack.class, Block.class, int.class, int.class, FluidStack.class); + mMethodCache.put("addMelting", m); + } + try { + mMethodCache.get("addMelting").invoke(null, input, block, metadata, temperature, liquid); + return true; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } + + public static boolean addMelting(Object type, ItemStack input, int temperatureDifference, int fluidAmount) { + if (mMethodCache.get("addMelting") == null) { + Method m = ReflectionUtils.getMethod(mClass_Smeltery, "addMelting", mClass_FluidType, ItemStack.class, int.class, int.class); + mMethodCache.put("addMelting", m); + } + try { + mMethodCache.get("addMelting").invoke(null, type, input, temperatureDifference, fluidAmount); + return true; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } + + + + + + + + + + + + public static boolean addBaseBasinRecipes(Material aMaterial) { + return addBasinRecipe(aMaterial.getBlock(1), aMaterial.getFluid(144*9), (ItemStack) null, true, 100); + } + + public static boolean addBasinRecipe(ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay) { + if (mMethodCache.get("addBasinRecipe") == null) { + Method m = ReflectionUtils.getMethod(ReflectionUtils.getClass("tconstruct.library.crafting.LiquidCasting"), "addCastingRecipe", ItemStack.class, FluidStack.class, ItemStack.class, boolean.class, int.class); + mMethodCache.put("addBasinRecipe", m); + } + try { + mMethodCache.get("addBasinRecipe").invoke(getCastingInstance(0), output, metal, cast, consume, delay); + return true; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } + + + + + + + + public static boolean addBaseCastingRecipes(Material aMaterial) { + ItemStack ingotcast = getPattern(1); + return addCastingTableRecipe(aMaterial.getIngot(1), aMaterial.getFluid(144), ingotcast, false, 50); + } + + public static boolean addCastingTableRecipe(ItemStack output, FluidStack metal, ItemStack cast, boolean consume, int delay) { + if (mMethodCache.get("addCastingTableRecipe") == null) { + Method m = ReflectionUtils.getMethod(ReflectionUtils.getClass("tconstruct.library.crafting.LiquidCasting"), "addCastingRecipe", ItemStack.class, FluidStack.class, ItemStack.class, boolean.class, int.class); + mMethodCache.put("addCastingTableRecipe", m); + } + try { + mMethodCache.get("addCastingTableRecipe").invoke(getCastingInstance(1), output, metal, cast, consume, delay); + return true; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + return false; + } + } + + + + + + + + /** + * 0 For Table, 1 For Basin. + * @param aType - Casting Type + * @return - The casting instance. + */ + public static Object getCastingInstance(int aType) { + + setTiConDataInstance(); + + Method m = null; + if (aType == 0) { + m = ReflectionUtils.getMethod(mTinkersRegistryInstance, "getTableCasting", new Class[] {}); + //return ReflectionUtils.invokeVoid(getTiConDataInstance(1), "getTableCasting", new Class[] {}, new Object[] {}); + } + else if (aType == 1) { + m = ReflectionUtils.getMethod(mTinkersRegistryInstance, "getBasinCasting", new Class[] {}); + //return ReflectionUtils.invokeVoid(getTiConDataInstance(1), "getBasinCasting", new Class[] {}, new Object[] {}); + } + else { + //return null; + } + + if (m != null) { + try { + return m.invoke(mTinkersRegistryInstance, new Object[] {}); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + } + return null; + } + + + private static Item mTinkerMetalPattern; + public static ItemStack getPattern(int aType) { + if (mTinkerMetalPattern == null) { + Field m = ReflectionUtils.getField(mClass_TinkerSmeltery, "metalPattern"); + if (m != null) { + try { + mTinkerMetalPattern = (Item) m.get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } + } + if (mTinkerMetalPattern != null) { + ItemStack ingotCast = new ItemStack(mTinkerMetalPattern, aType, 0); + return ingotCast; + } + return ItemUtils.getErrorStack(1, "Bad Tinkers Pattern"); + + + + + + + + } + + /** + * Generates Tinkers {@link ToolMaterial}'s reflectively. + * @param name + * @param localizationString + * @param level + * @param durability + * @param speed + * @param damage + * @param handle + * @param reinforced + * @param stonebound + * @param style + * @param primaryColor + * @return + */ + public static Object generateToolMaterial(String name, String localizationString, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, int primaryColor) { + try { + Constructor constructor = mClass_ToolMaterial.getConstructor(String.class, String.class, int.class, int.class, int.class, int.class, float.class, int.class, float.class, String.class, int.class); + Object myObject = constructor.newInstance(name, localizationString, level, durability, speed, damage, handle, reinforced, stonebound, style, primaryColor); + return myObject; + } catch (Throwable t) { + t.printStackTrace(); + return null; + } + } + + + + + + + + + + + + public static void addToolMaterial(int id, Object aToolMaterial) { + if (mMethodCache.get("addToolMaterial") == null) { + Method m = ReflectionUtils.getMethod(mClass_TConstructRegistry, "addtoolMaterial", int.class, mClass_ToolMaterial); + mMethodCache.put("addToolMaterial", m); + } + try { + mMethodCache.get("addToolMaterial").invoke(mClass_TConstructRegistry, id, aToolMaterial); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + + } + } + + public static void addDefaultToolPartMaterial(int id) { + if (mMethodCache.get("addDefaultToolPartMaterial") == null) { + Method m = ReflectionUtils.getMethod(mClass_TConstructRegistry, "addDefaultToolPartMaterial", int.class); + mMethodCache.put("addDefaultToolPartMaterial", m); + } + try { + mMethodCache.get("addDefaultToolPartMaterial").invoke(mClass_TConstructRegistry, id); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } + } + + public static void addBowMaterial(int id, int drawspeed, float maxSpeed) { + if (mMethodCache.get("addBowMaterial") == null) { + Method m = ReflectionUtils.getMethod(mClass_TConstructRegistry, "addBowMaterial", int.class, int.class, float.class); + mMethodCache.put("addBowMaterial", m); + } + try { + mMethodCache.get("addBowMaterial").invoke(mClass_TConstructRegistry, id, drawspeed, maxSpeed); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } + } + + public static void addArrowMaterial(int id, float mass, float fragility) { + if (mMethodCache.get("addArrowMaterial") == null) { + Method m = ReflectionUtils.getMethod(mClass_TConstructRegistry, "addArrowMaterial", int.class, float.class, float.class); + mMethodCache.put("addArrowMaterial", m); + } + try { + mMethodCache.get("addArrowMaterial").invoke(mClass_TConstructRegistry, id, mass, fragility); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } + } + + public static List getTableCastingRecipes(){ + Object aCastingTableHandlerInstance = getCastingInstance(0); + List aTemp; + try { + aTemp = (List) mMethod_getCastingRecipes.invoke(aCastingTableHandlerInstance, new Object[] {}); + return aTemp; + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + } + return new ArrayList(); + } + + public static boolean generateCastingRecipes(Material aMaterial, int aID) { + + List newRecipies = new LinkedList(); + + + Iterator iterator1 = getTableCastingRecipes().iterator(); + Fluid aMoltenIron = null; + if (aMoltenIron == null) { + try { + aMoltenIron = (Fluid) mField_MoltenIronFluid.get(null); + } catch (IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + aMoltenIron = Materials.Iron.getMolten(0).getFluid(); + } + } + while (iterator1.hasNext()) { + CastingRecipeHandler recipe = new CastingRecipeHandler(iterator1.next()); + if (recipe == null || !recipe.valid) { + continue; + } + try { + if (recipe.castingMetal.getFluid() == aMoltenIron && recipe.cast != null + && mClass_IPattern.isInstance(recipe.cast.getItem()) && mClass_DynamicToolPart.isInstance(recipe.getResult().getItem())) { + newRecipies.add(recipe); + } + } catch (IllegalArgumentException e) { + e.printStackTrace(); + return false; + } + } + + + Object ft; + try { + ft = mMethod_getFluidType.invoke(null, aMaterial.getLocalizedName()); + Iterator iterator2 = newRecipies.iterator(); + while (iterator2.hasNext()) { + CastingRecipeHandler recipe = new CastingRecipeHandler(iterator2.next()); + if (!recipe.valid){ + continue; + } + //CastingRecipe recipe = (CastingRecipe) i$.next(); + ItemStack output = recipe.getResult().copy(); + output.setItemDamage(aID); + FluidStack liquid2 = new FluidStack(aMaterial.getFluid(0).getFluid(), recipe.castingMetal.amount); + addCastingTableRecipe(output, liquid2, recipe.cast, recipe.consumeCast, recipe.coolTime); + addMelting(ft, output, 0, liquid2.amount / 2); + } + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + return false; + } + + return true; + } + + private static class CastingRecipeHandler { + + public ItemStack output; + public FluidStack castingMetal; + public ItemStack cast; + public boolean consumeCast; + public int coolTime; + + public boolean valid; + + public CastingRecipeHandler(Object aCastingRecipe) { + if (mClass_CastingRecipe.isInstance(aCastingRecipe)) { + try { + Field aF_output = ReflectionUtils.getField(mClass_CastingRecipe, "output"); + Field aF_castingMetal = ReflectionUtils.getField(mClass_CastingRecipe, "castingMetal"); + Field aF_cast = ReflectionUtils.getField(mClass_CastingRecipe, "cast"); + Field aF_consumeCast = ReflectionUtils.getField(mClass_CastingRecipe, "consumeCast"); + Field aF_coolTime = ReflectionUtils.getField(mClass_CastingRecipe, "coolTime"); + + output = (ItemStack) aF_output.get(aCastingRecipe); + castingMetal = (FluidStack) aF_castingMetal.get(aCastingRecipe); + cast = (ItemStack) aF_cast.get(aCastingRecipe); + consumeCast = (boolean) aF_consumeCast.get(aCastingRecipe); + coolTime = (int) aF_coolTime.get(aCastingRecipe); + valid = true; + } + catch (Throwable t) { + t.printStackTrace(); + valid = false; + } + } + else { + valid = false; + } + } + + public boolean matches(FluidStack metal, ItemStack inputCast) { + return this.castingMetal.isFluidEqual(metal) && (this.cast != null && this.cast.getItemDamage() == 32767 + && inputCast.getItem() == this.cast.getItem() || ItemStack.areItemStacksEqual(this.cast, inputCast)); + } + + public ItemStack getResult() { + return this.output.copy(); + } + } } diff --git a/src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java b/src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java index b28ccdaa9b..9e5efb452c 100644 --- a/src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java +++ b/src/Java/gtPlusPlus/xmod/witchery/WitchUtils.java @@ -67,20 +67,17 @@ public class WitchUtils { } } - public static Field getField(String aClassName, String aFieldName) { - Class c; - try { - c = Class.forName(aClassName); - if (c != null) { - Field f = ReflectionUtils.getField(c, aFieldName); - if (f != null) { - return f; - } - } - } catch (ClassNotFoundException | NoSuchFieldException e) { + public static Field getField(String aClassName, String aFieldName) { + Class c; + c = ReflectionUtils.getClass(aClassName); + if (c != null) { + Field f = ReflectionUtils.getField(c, aFieldName); + if (f != null) { + return f; + } } return null; - } + } public static boolean isEqual(final GameProfile a, final GameProfile b) { return a != null && b != null && a.getId() != null && b.getId() != null && a.getId().equals(b.getId()); diff --git a/src/Java/vswe/stevescarts/ModuleData/GppModuleData.java b/src/Java/vswe/stevescarts/ModuleData/GppModuleData.java index 0b605fb8c1..eb8a8f319f 100644 --- a/src/Java/vswe/stevescarts/ModuleData/GppModuleData.java +++ b/src/Java/vswe/stevescarts/ModuleData/GppModuleData.java @@ -41,7 +41,7 @@ public class GppModuleData extends ModuleData { validModules.put(ID_ExoticSeedAddon, true); - } catch (NoSuchFieldException | IllegalAccessException e) { + } catch (IllegalAccessException e) { e.printStackTrace(); } } |