diff options
44 files changed, 1767 insertions, 189 deletions
@@ -10,8 +10,14 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> + <nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature> </natures> </projectDescription> diff --git a/src/Java/gregtech/api/enums/TAE.java b/src/Java/gregtech/api/enums/TAE.java index c6fc8c7790..248722269b 100644 --- a/src/Java/gregtech/api/enums/TAE.java +++ b/src/Java/gregtech/api/enums/TAE.java @@ -1,16 +1,22 @@ package gregtech.api.enums; +import java.lang.reflect.Field; + +import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; import gregtech.api.objects.GT_CopiedBlockTexture; import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; public class TAE { //TAE stands for Texture Array Expansion. - + public static int gtTexturesArrayStartOrigin; - public static int gtPPLastUsedIndex = 96; + public static int gtPPLastUsedIndex = 64; + public static int secondaryIndex = 0; public static boolean hasArrayBeenExpanded = false; public static boolean hookGtTextures() { @@ -42,22 +48,51 @@ public class TAE { }*/ public static boolean registerTextures(GT_CopiedBlockTexture gt_CopiedBlockTexture) { - Textures.BlockIcons.CASING_BLOCKS[gtPPLastUsedIndex] = gt_CopiedBlockTexture; - gtPPLastUsedIndex++; - //Just so I know registration is done. - return true; + try { + + //Handle page 2. + if (gtPPLastUsedIndex >= 128) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 30) { + Field x = ReflectionUtils.getField(Textures.BlockIcons.class, "casingTexturePages"); + if (x != null) { + ITexture[][] h = (ITexture[][]) x.get(null); + if (h != null) { + h[64][secondaryIndex++] = gt_CopiedBlockTexture; + x.set(null, h); + return true; + } + } + } + } + + //set to page 1. + else { + Textures.BlockIcons.CASING_BLOCKS[gtPPLastUsedIndex] = gt_CopiedBlockTexture; + gtPPLastUsedIndex++; + return true; + } + } + catch (Throwable t) { + t.printStackTrace(); + } + return false; } - + public static ITexture getTexture(int index){ - if (!hasArrayBeenExpanded){ - return null; - } - else { - return Textures.BlockIcons.CASING_BLOCKS[(96+index)]; + if (gtPPLastUsedIndex >= 128) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 30) { + return Textures.BlockIcons.CASING_BLOCKS[((64*128)+index)]; + } } + return Textures.BlockIcons.CASING_BLOCKS[(64+index)]; } - + public static int GTPP_INDEX(int ID){ - return (96+ID); + if (gtPPLastUsedIndex >= 128) { + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 30) { + return (ID); + } + } + return (64+ID); } } diff --git a/src/Java/gregtech/api/util/FishPondFakeRecipe.java b/src/Java/gregtech/api/util/FishPondFakeRecipe.java new file mode 100644 index 0000000000..5aef1bcd8a --- /dev/null +++ b/src/Java/gregtech/api/util/FishPondFakeRecipe.java @@ -0,0 +1,75 @@ +package gregtech.api.util; + +import java.util.ArrayList; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.array.AutoMap; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandomFishable; +import net.minecraftforge.common.FishingHooks; +import net.minecraftforge.fluids.FluidStack; + +public class FishPondFakeRecipe { + + public static ArrayList<WeightedRandomFishable> fish = new ArrayList<WeightedRandomFishable>(); + public static ArrayList<WeightedRandomFishable> junk = new ArrayList<WeightedRandomFishable>(); + public static ArrayList<WeightedRandomFishable> treasure = new ArrayList<WeightedRandomFishable>(); + + @SuppressWarnings("unchecked") + public static boolean generateFishPondRecipes() { + + try { + fish = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "fish").get(null); + 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) { + Logger.INFO("Error generating Fish Pond Recipes. [1]"); + e.printStackTrace(); + } + + AutoMap<ArrayList<WeightedRandomFishable>> mega = new AutoMap<ArrayList<WeightedRandomFishable>>(); + mega.put(fish); + mega.put(junk); + mega.put(treasure); + + int mType = 14; + for (ArrayList<WeightedRandomFishable> f : mega.values()) { + for (int e=0;e<f.size();e++) { + if (f.get(e) != null) { + WeightedRandomFishable u = f.get(e); + try { + 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) { + Logger.INFO("Error generating Fish Pond Recipes. [2]"); + e1.printStackTrace(); + } + } + } + mType++; + } + + return true; + } + + public static void addNewFishPondLoot(int circuit, ItemStack[] outputItems, int[] chances) { + GT_Recipe x = new GT_Recipe( + true, + new ItemStack[]{CI.getNumberedCircuit(circuit)}, + outputItems, + null, + chances, + new FluidStack[]{null}, + new FluidStack[]{null}, + 100, //1 Tick + 0, //No Eu produced + 0 //Magic Number + ); + Recipe_GT.Gregtech_Recipe_Map.sFishPondRecipes.addRecipe(x); + } + +} diff --git a/src/Java/gregtech/api/util/Recipe_GT.java b/src/Java/gregtech/api/util/Recipe_GT.java index 351814f386..342add5b63 100644 --- a/src/Java/gregtech/api/util/Recipe_GT.java +++ b/src/Java/gregtech/api/util/Recipe_GT.java @@ -281,6 +281,8 @@ public class Recipe_GT extends GT_Recipe{ //Component Assembler public static final GT_Recipe_Map sComponentAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<GT_Recipe>(300), "gt.recipe.componentassembler", "Component Assembler", null, RES_PATH_GUI + "basicmachines/Assembler", 6, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sFishPondRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(3), "gt.recipe.fishpond", "Zhuhai - Fishing Port", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 1, 0, 0, 1, E, 1, E, true, true); + /** diff --git a/src/Java/gtPlusPlus/api/objects/Logger.java b/src/Java/gtPlusPlus/api/objects/Logger.java index 6e2e9f6107..1ecdaa9e86 100644 --- a/src/Java/gtPlusPlus/api/objects/Logger.java +++ b/src/Java/gtPlusPlus/api/objects/Logger.java @@ -75,7 +75,7 @@ public class Logger { // ASM Comments public static void LOG_ASM(final String s) { - FMLRelaunchLog.info("", s); + FMLRelaunchLog.info("[Special ASM Logging] ", s); } diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index 24e589ad97..04ada83922 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -23,6 +23,7 @@ import gtPlusPlus.core.block.machine.Machine_WorkbenchAdvanced; import gtPlusPlus.core.fluids.FluidRegistryHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks3; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraftforge.fluids.Fluid; @@ -39,6 +40,7 @@ public final class ModBlocks { public static Block blockGriefSaver; public static Block blockCasingsMisc; public static Block blockCasings2Misc; + public static Block blockCasings3Misc; public static Block blockMetaTileEntity; public static Block blockHeliumGenerator; public static Block blockNHG; diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index c6aff47c5b..953d32f138 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -44,19 +44,14 @@ public class COMPAT_HANDLER { //Free IDs /* - 829 --- - //837 - //to - //839 - --- - 851 + 859 to 868 --- - 890 + 899 to - 950 + 945 */ new RECIPES_LaserEngraver(); @@ -102,6 +97,8 @@ public class COMPAT_HANDLER { GregtechMiniRaFusion.run(); GregtechComponentAssembler.run(); GregtechTeslaTower.run(); + GregtechSuperTanks.run(); + GregtechIndustrialFishPond.run(); //New Horizons Content NewHorizonsAccelerator.run(); diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index 5197b2e34b..eca3c595ec 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -348,7 +348,7 @@ public class Material { sets.put(r.getStackMaterial()); } } - TextureSet mostUsedTypeTextureSet = (TextureSet) MaterialUtils.getMostCommonTextureSet(new ArrayList(sets.values())); + TextureSet mostUsedTypeTextureSet = (TextureSet) MaterialUtils.getMostCommonTextureSet(new ArrayList<Material>(sets.values())); if (mostUsedTypeTextureSet != null && mostUsedTypeTextureSet instanceof TextureSet) { Logger.MATERIALS("Set textureset for "+this.localizedName+" to be "+mostUsedTypeTextureSet.mSetName+"."); return mostUsedTypeTextureSet; @@ -611,6 +611,10 @@ public class Material { } private final short getComponentCount(final MaterialStack[] inputs){ + + if (inputs == null || inputs.length < 1) { + return 1; + } int counterTemp = 0; for (final MaterialStack m : inputs){ if (m.getStackMaterial() != null){ @@ -729,7 +733,7 @@ public class Material { } final Materials isValid = Materials.get(this.getLocalizedName()); - Logger.INFO("Is "+this.getLocalizedName()+" a Gregtech material? "+(isValid != null && isValid != Materials._NULL)+" | Found "+isValid.mDefaultLocalName); + //Logger.MATERIALS("Is "+this.getLocalizedName()+" a Gregtech material? "+(isValid != null && isValid != Materials._NULL)+" | Found "+isValid.mDefaultLocalName); if (isValid != Materials._NULL){ for (Materials m : invalidMaterials.values()){ if (isValid == m){ @@ -800,7 +804,7 @@ public class Material { //Generate a Cell if we need to if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("cell"+this.getUnlocalizedName(), 1) == null){ if (this.vGenerateCells){ - final Item temp = new BaseItemCell(this); + new BaseItemCell(this); Logger.INFO("Generated a cell for "+this.getUnlocalizedName()); } else { diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 653094cdda..a460d7ca59 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -7,6 +7,7 @@ import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.recipe.RecipeUtils; @@ -141,6 +142,7 @@ public class RECIPES_Machines { public static ItemStack EV_MACHINE_Wiremill; public static ItemStack HV_MACHINE_Macerator; public static ItemStack EV_MACHINE_Macerator; + public static ItemStack EV_MACHINE_Cutter; public static ItemStack EV_MACHINE_MassFabricator; @@ -213,6 +215,7 @@ public class RECIPES_Machines { EV_MACHINE_Macerator= ItemList.Machine_EV_Macerator.get(1); EV_MACHINE_MassFabricator= ItemList.Machine_EV_Massfab.get(1); EV_MACHINE_Centrifuge= ItemList.Machine_EV_Centrifuge.get(1); + EV_MACHINE_Cutter = ItemList.Machine_EV_Cutter.get(1); } @@ -1083,6 +1086,21 @@ public class RECIPES_Machines { ItemUtils.getSimpleStack(ModBlocks.blockProjectTable)); } + if (CORE.ConfigSwitches.enableMultiblock_IndustrialCuttingMachine){ + ItemStack plate = ALLOY.MARAGING300.getPlate(1); + RecipeUtils.recipeBuilder( + plate, CI.craftingToolHammer_Hard, plate, + "plateStellite", "frameGtTalonite", "plateStellite", + plate, CI.craftingToolWrench, plate, + GregtechItemList.Casing_CuttingFactoryFrame.get(Casing_Amount)); + + RecipeUtils.recipeBuilder( + plate,CI.getTieredCircuit(3),plate, + "wireFinePlatinum", EV_MACHINE_Cutter, "wireFinePlatinum", + plate,CI.getTieredCircuit(4),plate, + GregtechItemList.Industrial_CuttingFactoryController.get(1)); + } + //Wireless Chargers RecipeUtils.addShapedGregtechRecipe( CI.emitter_LV, CI.circuitTier1, CI.emitter_LV, diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java index 89c41452d5..c6edd94238 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java @@ -2,168 +2,108 @@ package gtPlusPlus.preloader.asm.transformers; import static org.objectweb.asm.Opcodes.*; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; import org.apache.logging.log4j.Level; import org.objectweb.asm.*; -import org.objectweb.asm.commons.GeneratorAdapter; import cpw.mods.fml.relauncher.FMLRelaunchLog; import gregtech.api.GregTech_API; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.common.blocks.GT_Block_Machines; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.core.util.array.BlockPos; import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.core.util.nbt.NBTUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; public class Preloader_ClassTransformer2 { - private final static Class<BaseMetaTileEntity> customTransformer2 = BaseMetaTileEntity.class; + /** + * + * So what I'd try is something like patch a new field into BaseMetaTileEntity to hold the ItemNBT, + * then patch GT_Block_Machines.breakBlock to store the ItemNBT into that field by calling setItemNBT, + * and then patch BaseMetaTileEntity.getDrops to retrieve that field instead of calling setItemNBT + * But there's probably a simpler solution if all you want to do is fix this + * for your super tanks rather than for all GT machines + * (which would only include saving the output count for chest buffers and item distributors...) + * + */ - public static ArrayList<ItemStack> getDrops(BaseMetaTileEntity o) { - Logger.INFO("DROP!"); - try { - short tID = (short) ReflectionUtils.getField(customTransformer2, "mID").get(o); - NBTTagCompound tRecipeStuff = (NBTTagCompound) ReflectionUtils.getField(customTransformer2, "mRecipeStuff").get(o); - boolean tMuffler = (boolean) ReflectionUtils.getField(customTransformer2, "mMuffler").get(o); - boolean tLockUpgrade = (boolean) ReflectionUtils.getField(customTransformer2, "mLockUpgrade").get(o); - boolean tSteamConverter = (boolean) ReflectionUtils.getField(customTransformer2, "mSteamConverter").get(o); - byte tColor = (byte) ReflectionUtils.getField(customTransformer2, "mColor").get(o); - byte tOtherUpgrades = (byte) ReflectionUtils.getField(customTransformer2, "mOtherUpgrades").get(o); - byte tStrongRedstone = (byte) ReflectionUtils.getField(customTransformer2, "mStrongRedstone").get(o); - int[] tCoverSides = (int[]) ReflectionUtils.getField(customTransformer2, "mCoverSides").get(o); - int[] tCoverData = (int[]) ReflectionUtils.getField(customTransformer2, "mCoverData").get(o); - FluidStack tFluid = null; - if (GT_MetaTileEntity_BasicTank.class.isInstance(o)) { - try { - tFluid = (FluidStack) ReflectionUtils.getField(GT_MetaTileEntity_BasicTank.class, "mFluid").get(o); - } - catch (Throwable t) { - Logger.REFLECTION("mFluid was not set."); - } - } - else { - Logger.REFLECTION("mFluid was not found."); - } - BaseMetaTileEntity tMetaTileEntity = o; - - Logger.REFLECTION("tID: "+(tID != 0)); - Logger.REFLECTION("tRecipeStuff: "+(tRecipeStuff != null)); - Logger.REFLECTION("tMuffler: "+(tMuffler != false)); - Logger.REFLECTION("tLockUpgrade: "+(tLockUpgrade != false)); - Logger.REFLECTION("tSteamConverter: "+(tSteamConverter != false)); - Logger.REFLECTION("tColor: "+(tColor != 0)); - Logger.REFLECTION("tOtherUpgrades: "+(tOtherUpgrades != 0)); - Logger.REFLECTION("tCoverSides: "+(tCoverSides != null)); - Logger.REFLECTION("tCoverData: "+(tCoverData != null)); - Logger.REFLECTION("tMetaTileEntity: "+(tMetaTileEntity != null)); - - ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, tID); - NBTTagCompound tNBT = new NBTTagCompound(); - if (tRecipeStuff != null && !tRecipeStuff.hasNoTags()) tNBT.setTag("GT.CraftingComponents", tRecipeStuff); - if (tMuffler) tNBT.setBoolean("mMuffler", tMuffler); - if (tLockUpgrade) tNBT.setBoolean("mLockUpgrade", tLockUpgrade); - if (tSteamConverter) tNBT.setBoolean("mSteamConverter", tSteamConverter); - if (tColor > 0) tNBT.setByte("mColor", tColor); - //if (tFluid != null) tFluid.writeToNBT(tNBT); - if (tFluid != null) tNBT.setTag("mFluid", tFluid.tag); - if (tOtherUpgrades > 0) tNBT.setByte("mOtherUpgrades", tOtherUpgrades); - if (tStrongRedstone > 0) tNBT.setByte("mStrongRedstone", tStrongRedstone); - for (byte i = 0; i < tCoverSides.length; i++) { - if (tCoverSides[i] != 0) { - tNBT.setIntArray("mCoverData", tCoverData); - tNBT.setIntArray("mCoverSides", tCoverSides); - break; - } - } - - //Set Item NBT - if (!o.isInvalid()){ - ((IMetaTileEntity) tMetaTileEntity).setItemNBT(tNBT); //Valid? Idk - } - else { - try { - Logger.REFLECTION("Trying to set NBT data to Itemstack from invalid tile, World might explode."); - ((IMetaTileEntity) tMetaTileEntity).setItemNBT(tNBT); //Valid? Idk - } - catch (Throwable t){ - Logger.REFLECTION("getDropsHack1"); - t.printStackTrace(); - } - } - - //Set stack NBT - if (!tNBT.hasNoTags()) rStack.setTagCompound(tNBT); - return new ArrayList<ItemStack>(Arrays.asList(rStack)); - } - catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException a){ - Logger.REFLECTION("getDropsHack2"); - a.printStackTrace(); - } - ArrayList<ItemStack> u = new ArrayList<ItemStack>(Arrays.asList(new ItemStack[]{ItemUtils.getSimpleStack(Blocks.bedrock)})); - return u; - } + public static boolean mHasSetField = false; + private final static Class<BaseMetaTileEntity> customTransformer2 = BaseMetaTileEntity.class; public static final class GT_MetaTile_Visitor extends ClassVisitor { + private boolean isGt_Block_Machines = false; - public GT_MetaTile_Visitor(ClassVisitor cv) { + public GT_MetaTile_Visitor(ClassVisitor cv, boolean isGt_Block_Machines) { super(ASM5, cv); + this.isGt_Block_Machines = isGt_Block_Machines; + } + + @Override + public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { + FieldVisitor j = super.visitField(access, name, desc, signature, value); + |
