diff options
25 files changed, 1181 insertions, 944 deletions
diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java b/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java index 9ab0f2eefb..7c11e7232b 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java @@ -42,8 +42,16 @@ public class BlockPos implements Serializable{ this.xPos = x; this.yPos = y; this.zPos = z; - this.dim = dim.provider.dimensionId; - this.world = dim; + + if (dim != null) { + this.dim = dim.provider.dimensionId; + this.world = dim; + } + else { + this.dim = 0; + this.world = null; + } + } public BlockPos(IGregTechTileEntity b) { diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java b/src/Java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java new file mode 100644 index 0000000000..d0c1f3f040 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java @@ -0,0 +1,253 @@ +package gtPlusPlus.api.objects.minecraft; + +import java.util.HashSet; +import java.util.Set; + +import gtPlusPlus.api.objects.data.AutoMap; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; + +public class FakeBlockPos extends BlockPos { + + private static final long serialVersionUID = -6442245826092414593L; + private Block aBlockAtPos; + private int aBlockMetaAtPos = 0; + + public static FakeBlockPos generateBlockPos(String sUUID) { + String[] s2 = sUUID.split("@"); + return new FakeBlockPos(s2); + } + + public FakeBlockPos(String[] s){ + this(Integer.parseInt(s[1]), Integer.parseInt(s[2]), Integer.parseInt(s[3]), Integer.parseInt(s[0])); + } + + public FakeBlockPos(int x, int y, int z, Block aBlock, int aMeta){ + this(x, y, z, 0); + aBlockAtPos = aBlock; + aBlockMetaAtPos = aMeta; + } + + private FakeBlockPos(int x, int y, int z, int dim){ + this(x, y, z, DimensionManager.getWorld(dim)); + } + + private FakeBlockPos(int x, int y, int z, World dim){ + super(x, y, z, null); + } + + public String getLocationString() { + String S = ""+this.xPos+"@"+this.yPos+"@"+this.zPos; + return S; + } + + public String getUniqueIdentifier() { + String S = ""+this.xPos+"@"+this.yPos+"@"+this.zPos+this.aBlockAtPos.getLocalizedName()+"@"+this.aBlockMetaAtPos; + return S; + } + + @Override + public int hashCode() { + int hash = 5; + hash += (13 * this.xPos); + hash += (19 * this.yPos); + hash += (31 * this.zPos); + hash += (17 * this.dim); + return hash; + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other == this) { + return true; + } + if(!(other instanceof FakeBlockPos)) { + return false; + } + FakeBlockPos otherPoint = (FakeBlockPos) other; + return this.xPos == otherPoint.xPos && this.yPos == otherPoint.yPos && this.zPos == otherPoint.zPos; + } + + public int distanceFrom(FakeBlockPos target) { + if (target.dim != this.dim) { + return Short.MIN_VALUE; + } + return distanceFrom(target.xPos, target.yPos, target.zPos); + } + + /** + * + * @param x X coordinate of target. + * @param y Y coordinate of target. + * @param z Z coordinate of target. + * @return square of distance + */ + public int distanceFrom(int x, int y, int z) { + int distanceX = this.xPos - x; + int distanceY = this.yPos - y; + int distanceZ = this.zPos - z; + return distanceX * distanceX + distanceY * distanceY + distanceZ * distanceZ; + } + + public boolean isWithinRange(FakeBlockPos target, int range) { + if (target.dim != this.dim) { + return false; + } + return isWithinRange(target.xPos, target.yPos, target.zPos, range); + } + + public boolean isWithinRange(int x, int y, int z, int range) { + return distanceFrom(x, y, z) <= (range * range); + } + + + public FakeBlockPos getUp() { + return new FakeBlockPos(this.xPos, this.yPos+1, this.zPos, this.dim); + } + + public FakeBlockPos getDown() { + return new FakeBlockPos(this.xPos, this.yPos-1, this.zPos, this.dim); + } + + public FakeBlockPos getXPos() { + return new FakeBlockPos(this.xPos+1, this.yPos, this.zPos, this.dim); + } + + public FakeBlockPos getXNeg() { + return new FakeBlockPos(this.xPos-1, this.yPos, this.zPos, this.dim); + } + + public FakeBlockPos getZPos() { + return new FakeBlockPos(this.xPos, this.yPos, this.zPos+1, this.dim); + } + + public FakeBlockPos getZNeg() { + return new FakeBlockPos(this.xPos, this.yPos, this.zPos-1, this.dim); + } + + public AutoMap<BlockPos> getSurroundingBlocks(){ + AutoMap<BlockPos> sides = new AutoMap<BlockPos>(); + sides.put(getUp()); + sides.put(getDown()); + sides.put(getXPos()); + sides.put(getXNeg()); + sides.put(getZPos()); + sides.put(getZNeg()); + return sides; + } + + public Block getBlockAtPos() { + return getBlockAtPos(this); + } + + public Block getBlockAtPos(FakeBlockPos pos) { + return getBlockAtPos(world, pos); + } + + public Block getBlockAtPos(World world, FakeBlockPos pos) { + return aBlockAtPos; + } + + public int getMetaAtPos() { + return getMetaAtPos(this); + } + + public int getMetaAtPos(FakeBlockPos pos) { + return getMetaAtPos(world, pos); + } + + public int getMetaAtPos(World world, FakeBlockPos pos) { + return aBlockMetaAtPos; + } + + public boolean hasSimilarNeighbour() { + return hasSimilarNeighbour(false); + } + + /** + * @param strict - Does this check Meta Data? + * @return - Does this block have a neighbour that is the same? + */ + public boolean hasSimilarNeighbour(boolean strict) { + for (BlockPos g : getSurroundingBlocks().values()) { + if (getBlockAtPos(g) == getBlockAtPos()) { + if (!strict) { + return true; + } + else { + if (getMetaAtPos() == getMetaAtPos(g)) { + return true; + } + } + } + } + return false; + } + + public AutoMap<BlockPos> getSimilarNeighbour() { + return getSimilarNeighbour(false); + } + + /** + * @param strict - Does this check Meta Data? + * @return - Does this block have a neighbour that is the same? + */ + public AutoMap<BlockPos> getSimilarNeighbour(boolean strict) { + AutoMap<BlockPos> sides = new AutoMap<BlockPos>(); + for (BlockPos g : getSurroundingBlocks().values()) { + if (getBlockAtPos(g) == getBlockAtPos()) { + if (!strict) { + sides.put(g); + } + else { + if (getMetaAtPos() == getMetaAtPos(g)) { + sides.put(g); + } + } + } + } + return sides; + } + + public Set<BlockPos> getValidNeighboursAndSelf(){ + AutoMap<BlockPos> h = getSimilarNeighbour(true); + h.put(this); + Set<BlockPos> result = new HashSet<BlockPos>(); + for (BlockPos f : h.values()) { + result.add(f); + } + return result; + } + + /** + * Called when a plant grows on this block, only implemented for saplings using the WorldGen*Trees classes right now. + * Modder may implement this for custom plants. + * This does not use ForgeDirection, because large/huge trees can be located in non-representable direction, + * so the source location is specified. + * Currently this just changes the block to dirt if it was grass. + * + * Note: This happens DURING the generation, the generation may not be complete when this is called. + * + * @param world Current world + * @param x Soil X + * @param y Soil Y + * @param z Soil Z + * @param sourceX Plant growth location X + * @param sourceY Plant growth location Y + * @param sourceZ Plant growth location Z + */ + public void onPlantGrow(FakeWorld world, int x, int y, int z, int sourceX, int sourceY, int sourceZ) + { + if (getBlockAtPos() == Blocks.grass || getBlockAtPos() == Blocks.farmland) + { + this.aBlockAtPos = Blocks.dirt; + this.aBlockMetaAtPos = 0; + } + } + +} diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/FakeWorld.java b/src/Java/gtPlusPlus/api/objects/minecraft/FakeWorld.java index 38cde74317..8ee033a341 100644 --- a/src/Java/gtPlusPlus/api/objects/minecraft/FakeWorld.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/FakeWorld.java @@ -1,5 +1,173 @@ package gtPlusPlus.api.objects.minecraft; -public class FakeWorld { +import java.util.HashMap; +import gregtech.api.enums.Materials; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.math.MathUtils; +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.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class FakeWorld implements IBlockAccess { + + public static HashMap<String, FakeBlockPos> mStaticFakeWorldData; + + public HashMap<String, FakeBlockPos> mFakeWorldData = new HashMap<String, FakeBlockPos>(); + + /** + * Must be an odd number + */ + private int aWorldSize = 99; + private final int aDistanceFromOrigin; + private final int aWorldHeight; + + public FakeWorld() { + this(99); + } + + public FakeWorld(int aSize) { + if (MathUtils.isNumberEven(aSize)) { + aSize++; + } + aWorldSize = aSize; + aDistanceFromOrigin = ((aWorldSize-1)/2); + aWorldHeight = aDistanceFromOrigin >= 255 ? 255 : aDistanceFromOrigin; + Logger.WARNING("Created a Fake World with data:"); + Logger.WARNING("World Size: "+aWorldSize); + Logger.WARNING("Distance from Origin in each dir: "+aDistanceFromOrigin); + Logger.WARNING("World Height: "+aWorldHeight); + init(); + } + + public void init() { + + /*if (mStaticFakeWorldData == null) { + Logger.WARNING("Setting all Blocks in Fake World to Air."); + mStaticFakeWorldData = new HashMap<String, FakeBlockPos>(); + for (int y=0;y<=aWorldHeight;y++) { + for (int x=-aDistanceFromOrigin;x<=aDistanceFromOrigin;x++) { + for (int z=-aDistanceFromOrigin;z<=aDistanceFromOrigin;z++) { + FakeBlockPos aTempPos = new FakeBlockPos(x, y, z, Blocks.air, 0); + mStaticFakeWorldData.put(aTempPos.getLocationString(), aTempPos); + } + } + } + }*/ + //if (mStaticFakeWorldData != null) { + //Logger.WARNING(" Instancing static air world."); + mFakeWorldData = new HashMap<String, FakeBlockPos>(); + //mFakeWorldData = (HashMap<String, FakeBlockPos>) mStaticFakeWorldData.clone(); + //} + + + //Logger.WARNING("Initialisation of FakeWorld is now complete."); + } + + public FakeBlockPos getBlockAtCoords(int x, int y, int z) { + String S = ""+x+"@"+y+"@"+z; + FakeBlockPos aBlock = mFakeWorldData.get(S); + if (aBlock == null) { + return new FakeBlockPos(x, y, z, Blocks.air, 0); + } + return aBlock; + } + + public void setBlockAtCoords(int x, int y, int z, Block aBlock, int aMeta) { + FakeBlockPos aTempPos = new FakeBlockPos(x, y, z, aBlock, aMeta); + Logger.WARNING("Setting "+x+", "+y+", "+z+" to "+aBlock.getLocalizedName()+":"+aMeta); + mFakeWorldData.put(aTempPos.getLocationString(), aTempPos); + } + + public AutoMap<ItemStack> getAllBlocksStoredInFakeWorld(){ + AutoMap<ItemStack> aOutput = new AutoMap<ItemStack>(); + for (FakeBlockPos aPos : mFakeWorldData.values()) { + if (aPos == null || aPos.getBlockAtPos() == Blocks.air) { + continue; + } + else { + ItemStack aTempStack = ItemUtils.simpleMetaStack(aPos.getBlockAtPos(), aPos.getMetaAtPos(), 1); + if (ItemUtils.checkForInvalidItems(aTempStack)) { + //Logger.WARNING("Output: "+aTempStack.getDisplayName()); + aOutput.put(aTempStack); + } + } + } + return aOutput; + } + + public Block getBlock(int x, int y, int z) { + FakeBlockPos aPos = getBlockAtCoords(x, y, z); + return aPos.getBlockAtPos(); + } + + public boolean isAirBlock(int x, int y, int z) { + Block aBlock = getBlock(x, y, z); + return aBlock == Blocks.air || aBlock.getMaterial() == Material.air; + } + + + + + + + + + + + + + + @Override + public TileEntity getTileEntity(int p_147438_1_, int p_147438_2_, int p_147438_3_) { + return null; + } + + @Override + public int getLightBrightnessForSkyBlocks(int p_72802_1_, int p_72802_2_, int p_72802_3_, int p_72802_4_) { + return 0; + } + + @Override + public int getBlockMetadata(int x, int y, int z) { + return getBlockAtCoords(x, y, z).getMetaAtPos(); + } + + @Override + public int isBlockProvidingPowerTo(int p_72879_1_, int p_72879_2_, int p_72879_3_, int p_72879_4_) { + return 0; + } + + @Override + public BiomeGenBase getBiomeGenForCoords(int p_72807_1_, int p_72807_2_) { + return BiomeGenBase.plains; + } + + @Override + public int getHeight() { + return aWorldHeight; + } + + @Override + public boolean extendedLevelsInChunkCache() { + return false; + } + + @Override + public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default) { + if (!isAirBlock(x, y, z)) { + return true; + } + return false; + } + + + } diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/ThreadFakeWorldGenerator.java b/src/Java/gtPlusPlus/api/objects/minecraft/ThreadFakeWorldGenerator.java new file mode 100644 index 0000000000..393d3260b5 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ThreadFakeWorldGenerator.java @@ -0,0 +1,61 @@ +package gtPlusPlus.api.objects.minecraft; + +import gtPlusPlus.xmod.gregtech.common.helpers.treefarm.TreeGenerator; + +public class ThreadFakeWorldGenerator extends Thread { + + public boolean canRun = true; + public boolean isRunning = false; + + private static final long INIT_TIME; + private static long internalTickCounter = 0; + + public TreeGenerator mGenerator; + + private static final ThreadFakeWorldGenerator mThread; + + static { + mThread = new ThreadFakeWorldGenerator(); + INIT_TIME = (System.currentTimeMillis()); + } + + public ThreadFakeWorldGenerator() { + setName("gtpp.handler.fakeworldtrees"); + run(); + } + + public static ThreadFakeWorldGenerator getInstance() { + return mThread; + } + + public static void stopThread() { + mThread.canRun = false; + } + + + @Override + public void run() { + + if (!isRunning) { + isRunning = true; + } + else { + return; + } + + if (canRun){ + if (mGenerator == null) { + mGenerator = new TreeGenerator(); + } + } + + while (mGenerator == null) { + if (mGenerator != null) { + break; + } + } + stopThread(); + } + + +} diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java index fe3934ed10..33198e8d41 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -8,7 +8,6 @@ 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; @@ -23,8 +22,6 @@ 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.objects.wrapper.aspect.TC_Aspect_Wrapper; -import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java index 6bb0ea8be8..277114a6ae 100644 --- a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java @@ -7,16 +7,7 @@ import java.util.Map; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -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; @@ -27,8 +18,13 @@ 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.objects.wrapper.aspect.TC_Aspect_Wrapper; -import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; public class BaseOreComponent extends Item{ diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index c26b01d0f7..e9c1da024c 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -801,10 +801,10 @@ public class RECIPES_Machines { RECIPE_IndustrialSieveGrate); } - if (CORE.ConfigSwitches.enableMultiblock_TreeFarmer){/* + if (CORE.ConfigSwitches.enableMultiblock_TreeFarmer){ //Industrial Tree Farmer RECIPE_TreeFarmController = GregtechItemList.Industrial_TreeFarm.get(1); - RECIPE_TreeFarmFrame = GregtechItemList.TreeFarmer_Structural.get(Casing_Amount); + RECIPE_TreeFarmFrame = GregtechItemList.Casing_PLACEHOLDER_TreeFarmer.get(Casing_Amount); //Industrial Tree Farm Controller if (!GTNH) { RecipeUtils.addShapedGregtechRecipe( @@ -813,7 +813,7 @@ public class RECIPES_Machines { "plateEglinSteel", CI.machineCasing_MV, "plateEglinSteel", RECIPE_TreeFarmController); } - if (GTNH) { + else { RecipeUtils.addShapedGregtechRecipe( "plateEglinSteel", "rotorEglinSteel", "plateEglinSteel", "cableGt02Silver", "pipeMediumStainlessSteel", "cableGt02Silver", @@ -826,7 +826,7 @@ public class RECIPES_Machines { "plankWood", "frameGtTumbaga", "plankWood", "plankWood", "plankWood", "plankWood", RECIPE_TreeFarmFrame); - */} + } if (CORE.ConfigSwitches.enableMachine_Tesseracts){ //Tesseracts diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index d032384638..3b3ba88e88 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -31,6 +31,7 @@ import net.minecraft.util.IChatComponent; import net.minecraft.world.World; import gregtech.GT_Mod; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -959,5 +960,17 @@ public class Utils { public static long getTicksFromSeconds(long aSeconds) { return (aSeconds*20); } + + public static byte getTier(long l) { + byte i = -1; + do { + ++i; + if (i >= GT_Values.V.length) { + return i; + } + } while (l > GT_Values.V[i]); + i = (byte) MathUtils.getValueWithinRange(i, 0, 15); + return i; + } } diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index f9a4d8f548..4ba9d54271 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -692,4 +692,9 @@ public class MathUtils { return Math.max(Math.min(aInput, aMax), aMin); } + public static int getValueWithinRange(byte aInput, int aMin, int aMax) { + int aAmount = Math.max(Math.min(aInput, aMax), aMin); + return aAmount; + } + } diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java index eb33366401..da6abfe57c 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_GT_Client.java @@ -3,13 +3,13 @@ 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.INVOKESPECIAL; 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; @@ -40,16 +40,17 @@ 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_Log; 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.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.stats.StatFileWriter; @@ -58,13 +59,16 @@ public class ClassTransformer_GT_Client { private final boolean valid; private final ClassReader read; private final ClassWriter write; - private boolean mModern; + private boolean mModern = true; + private boolean mObfuscated = true; private byte[] mTooledClass; - public ClassTransformer_GT_Client(byte[] basicClass) { + public ClassTransformer_GT_Client(byte[] basicClass, boolean obfuscated) { ClassReader aTempReader = null; ClassWriter aTempWriter = null; + + mObfuscated = obfuscated; aTempReader = new ClassReader(basicClass); aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); @@ -72,12 +76,14 @@ public class ClassTransformer_GT_Client { /** * 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+"."); + //mModern = findAssemblyLineClass(); + //FMLRelaunchLog.log("[GT++ ASM] Gregtech Client Proxy Patch", Level.INFO, "Found Assembly Line? "+mModern+"."); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Client Proxy Patch", Level.INFO, "Fixing Issues in vanilla GT."); 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); + //FMLRelaunchLog.log("[GT++ ASM] Gregtech Client Proxy Patch", Level.INFO, "Patching Client handling of Assembly Line recipe visibility for GT 5.09"); + //injectMethod(aTempWriter, "onPlayerTickEventClient"); + injectMethod(aTempWriter, "onPostLoad"); if (aTempReader != null && aTempWriter != null) { valid = true; mTooledClass = aTempWriter.toByteArray(); @@ -90,7 +96,7 @@ public class ClassTransformer_GT_Client { mTooledClass = basicClass; valid = true; } - FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Valid? "+valid+"."); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Client Proxy Patch", Level.INFO, "Valid? "+valid+"."); read = aTempReader; write = aTempWriter; } @@ -114,7 +120,7 @@ public class ClassTransformer_GT_Client { 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, + FMLRelaunchLog.log("[GT++ ASM] Gregtech Client Proxy Patch", Level.INFO, "Patchable class | " + x.getResourceName()); return true; } @@ -123,7 +129,7 @@ public class ClassTransformer_GT_Client { } catch (IOException e) { } - FMLRelaunchLog.log("[GT++ ASM] Gregtech Achievements Patch", Level.INFO, "Failed to find Gregtech classes using prefered method, using backup."); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Client Proxy Patch", Level.INFO, "Failed to find Gregtech classes using prefered method, using backup."); cl = ClassLoader.getSystemClassLoader(); ImmutableMap<File, ClassLoader> g = getClassPathEntries(cl); @@ -136,7 +142,7 @@ public class ClassTransformer_GT_Client { 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); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Client Proxy Patch", Level.INFO, "Patchable class | "+aName); aGregtech = aF; } } @@ -154,7 +160,7 @@ public class ClassTransformer_GT_Client { 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()); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Client Proxy Patch", Level.INFO, "Patchable class | "+je.getName()); return true; } } @@ -163,7 +169,7 @@ public class ClassTransformer_GT_Client { } 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"); + FMLRelaunchLog.log("[GT++ ASM] Gregtech Client Proxy Patch", Level.INFO, "Failed to find Gregtech classes using backup method, probably using GT 5.08"); return false; } @@ -189,277 +195,69 @@ public class ClassTransformer_GT_Client { return ImmutableMap.copyOf(entries); } - public boolean injectMethod(ClassWriter cw) { + public boolean injectMethod(ClassWriter cw, String string) { 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); - { + FMLRelaunchLog.log("[GT++ ASM] Gregtech Client Proxy Patch", Level.INFO, "Injecting " + string + ". Obfuscated? "+mObfuscated) |
