diff --git a/dependencies.gradle b/dependencies.gradle index 686bc508d10..ee1ded31a41 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -99,6 +99,7 @@ dependencies { compileOnly("com.github.GTNewHorizons:BloodMagic:1.6.5:dev") { transitive = false } compileOnly("com.github.GTNewHorizons:CraftTweaker:3.4.0:dev") { transitive = false } compileOnly("com.github.GTNewHorizons:BetterLoadingScreen:1.7.0-GTNH:dev") { transitive = false } + compileOnly rfg.deobf("curse.maven:biomes-o-plenty-220318:2499612") compileOnly('com.github.GTNewHorizons:SC2:2.2.0:dev') {transitive=false} compileOnly('com.github.GTNewHorizons:Binnie:2.4.1:dev') {transitive = false} diff --git a/src/main/java/bwcrossmod/galacticgreg/MTEVoidMinerBase.java b/src/main/java/bwcrossmod/galacticgreg/MTEVoidMinerBase.java index 1eb6d8e312a..3744d26aa46 100644 --- a/src/main/java/bwcrossmod/galacticgreg/MTEVoidMinerBase.java +++ b/src/main/java/bwcrossmod/galacticgreg/MTEVoidMinerBase.java @@ -290,10 +290,10 @@ private void handleOutputs() { final List inputOres = this.getStoredInputs() .stream() .filter(GTUtility::isOre) - .collect(Collectors.toList());; + .collect(Collectors.toList()); final ItemStack output = this.nextOre(); output.stackSize = multiplier; - if (inputOres.size() == 0 || this.mBlacklist && inputOres.stream() + if (inputOres.isEmpty() || this.mBlacklist && inputOres.stream() .noneMatch(is -> GTUtility.areStacksEqual(is, output)) || !this.mBlacklist && inputOres.stream() .anyMatch(is -> GTUtility.areStacksEqual(is, output))) diff --git a/src/main/java/goodgenerator/blocks/tileEntity/MTEYottaFluidTank.java b/src/main/java/goodgenerator/blocks/tileEntity/MTEYottaFluidTank.java index 1d8620ad4d1..ccac1e3fb6b 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/MTEYottaFluidTank.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/MTEYottaFluidTank.java @@ -472,7 +472,7 @@ public boolean onRunningTick(ItemStack aStack) { if (tFluid == null) continue; if (isFluidLocked) { if (mLockedFluid != null) { - if (!tFluid.isFluidEqual(mLockedFluid)) continue;; + if (!tFluid.isFluidEqual(mLockedFluid)) continue; } else { mLockedFluid = tFluid.copy(); mLockedFluid.amount = 1; diff --git a/src/main/java/gregtech/GTMod.java b/src/main/java/gregtech/GTMod.java index 87b5b154d9f..4b3bae4056b 100644 --- a/src/main/java/gregtech/GTMod.java +++ b/src/main/java/gregtech/GTMod.java @@ -238,7 +238,7 @@ public class GTMod implements IGTMod { clientSide = "gregtech.common.GTClient", serverSide = "gregtech.common.GTServer") public static GTProxy gregtechproxy; - public static final boolean DEBUG = Boolean.getBoolean("gt.debug");; + public static final boolean DEBUG = Boolean.getBoolean("gt.debug"); public static int MAX_IC2 = 2147483647; public static GTAchievements achievements; diff --git a/src/main/java/gregtech/api/enums/SoundResource.java b/src/main/java/gregtech/api/enums/SoundResource.java index e2a6b2630a0..edd8e5c6a34 100644 --- a/src/main/java/gregtech/api/enums/SoundResource.java +++ b/src/main/java/gregtech/api/enums/SoundResource.java @@ -65,11 +65,14 @@ public enum SoundResource { GT_MACHINES_WATER_PUMP_LOOP(234, GregTech.ID, "machines.WaterPumpLoop"), GT_MACHINES_STEAM_CENTRIFUGE_LOOP(235, GregTech.ID, "machines.SteamCentrifugeLoop"), - GT_MACHINES_PURIFICATIONPLANT_LOOP(233, GregTech.ID, "machines.PurificationPlantLoop"), - GT_MACHINES_PURIFICATION_PH_LOOP(234, GregTech.ID, "machines.PurificationPhLoop"), - GT_MACHINES_COAGULATION_LOOP(235, GregTech.ID, "machines.PurificationCoagulationLoop"), - GT_MACHINES_OZONATION_LOOP(236, GregTech.ID, "machines.PurificationOzonationLoop"), - GT_MACHINES_PURIFICATION_PLASMA_LOOP(237, "machines.PurificationPlasmaLoop"), + GT_MACHINES_PURIFICATIONPLANT_LOOP(236, GregTech.ID, "machines.PurificationPlantLoop"), + GT_MACHINES_PURIFICATION_PH_LOOP(237, GregTech.ID, "machines.PurificationPhLoop"), + GT_MACHINES_COAGULATION_LOOP(238, GregTech.ID, "machines.PurificationCoagulationLoop"), + GT_MACHINES_OZONATION_LOOP(239, GregTech.ID, "machines.PurificationOzonationLoop"), + GT_MACHINES_PURIFICATION_PLASMA_LOOP(240, "machines.PurificationPlasmaLoop"), + + GT_MACHINES_MULTI_LATHE_LOOP(241, GregTech.ID, "machines.MultiLatheLoop"), + GT_MACHINES_MULTI_AUTOCLAVE_LOOP(242, GregTech.ID, "machines.MultiAutoclaveLoop"), GUI_BUTTON_DOWN(-1, GregTech.ID, "gui.buttonDown"), GUI_BUTTON_UP(-1, GregTech.ID, "gui.buttonUp"), diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEWirelessEnergy.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEWirelessEnergy.java index e195b4ab087..517fa18636e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEWirelessEnergy.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEWirelessEnergy.java @@ -134,7 +134,7 @@ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { // UUID of the owner. owner_uuid = aBaseMetaTileEntity.getOwnerUuid(); - SpaceProjectManager.checkOrCreateTeam(owner_uuid);; + SpaceProjectManager.checkOrCreateTeam(owner_uuid); tryFetchingEnergy(); } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiAutoclave.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiAutoclave.java index 65d4bc93d37..9dcb7d0ca77 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiAutoclave.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiAutoclave.java @@ -32,6 +32,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -44,9 +45,12 @@ import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTechAPI; import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.enums.Materials; +import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -289,6 +293,12 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu return build; } + @SideOnly(Side.CLIENT) + @Override + protected ResourceLocation getActivitySoundLoop() { + return SoundResource.GT_MACHINES_MULTI_AUTOCLAVE_LOOP.resourceLocation; + } + @Override public boolean isCorrectMachinePart(ItemStack aStack) { return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiLathe.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiLathe.java index 3b01d0ec1e1..5beda2d038a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiLathe.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiLathe.java @@ -25,6 +25,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -37,7 +38,10 @@ import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTechAPI; +import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -265,6 +269,12 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu return build; } + @SideOnly(Side.CLIENT) + @Override + protected ResourceLocation getActivitySoundLoop() { + return SoundResource.GT_MACHINES_MULTI_LATHE_LOOP.resourceLocation; + } + private int mCasingAmount; private void onCasingAdded() { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiSolidifier.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiSolidifier.java index 471815f1f97..d77c6a9e53e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiSolidifier.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTEMultiSolidifier.java @@ -1,10 +1,6 @@ package gregtech.common.tileentities.machines.multi; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; import static gregtech.api.enums.GTValues.AuthorFourIsTheNumber; import static gregtech.api.enums.GTValues.AuthorOmdaCZ; import static gregtech.api.enums.GTValues.authorBaps; @@ -17,48 +13,34 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_CANNER_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_CANNER_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_CANNER_GLOW; -import static gregtech.api.util.GTUtility.filterValidMTEs; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; -import net.minecraft.block.Block; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.NotNull; -import com.google.common.collect.ImmutableList; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import bartworks.API.BorosilicateGlass; import gregtech.api.GregTechAPI; import gregtech.api.enums.Textures; +import gregtech.api.enums.VoltageIndex; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.logic.ProcessingLogic; -import gregtech.api.metatileentity.GregTechTileClientEvents; -import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase; -import gregtech.api.metatileentity.implementations.MTEHatch; -import gregtech.api.metatileentity.implementations.MTEHatchEnergy; import gregtech.api.metatileentity.implementations.MTEHatchInput; import gregtech.api.metatileentity.implementations.MTEHatchInputBus; -import gregtech.api.metatileentity.implementations.MTEHatchMaintenance; -import gregtech.api.metatileentity.implementations.MTEHatchMuffler; -import gregtech.api.metatileentity.implementations.MTEHatchOutput; -import gregtech.api.metatileentity.implementations.MTEHatchOutputBus; -import gregtech.api.multitileentity.multiblock.casing.Glasses; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.RecipeMaps; import gregtech.api.recipe.check.CheckRecipeResult; @@ -66,18 +48,14 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; -import gregtech.api.util.HatchElementBuilder; import gregtech.api.util.MultiblockTooltipBuilder; -import gregtech.common.blocks.BlockCasings1; import gregtech.common.blocks.BlockCasings10; import gregtech.common.tileentities.machines.IDualInputHatch; import gregtech.common.tileentities.machines.IDualInputInventory; import gregtech.common.tileentities.machines.MTEHatchCraftingInputME; -import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.MTEHatchSolidifier; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; -import tectech.thing.metaTileEntity.hatch.MTEHatchEnergyMulti; public class MTEMultiSolidifier extends MTEExtendedPowerMultiBlockBase implements ISurvivalConstructable { @@ -86,46 +64,7 @@ public class MTEMultiSolidifier extends MTEExtendedPowerMultiBlockBase> tieredFluidSolidifierCasings = new HashMap<>() { - - { - // Solidifier Casing - put(13, Pair.of(GregTechAPI.sBlockCasings10, 0)); - // Laurenium Casing - put(2, Pair.of(ModBlocks.blockCustomMachineCasings, 1)); - // Dimensionally Transcendent Casing - put(12, Pair.of(GregTechAPI.sBlockCasings1, 2)); - - } - }; - - private final Map> tieredPipeCasings = new HashMap<>() { - - { - // Solidifier Radiator - put(14, Pair.of(GregTechAPI.sBlockCasings10, 0)); - // Cinobite Pipe Casing - put(13, Pair.of(ModBlocks.blockCustomPipeGearCasings, 1)); - // Abyssal Pipe Casing - put(15, Pair.of(ModBlocks.blockCustomPipeGearCasings, 2)); - - } - }; - - private final List casingIndices = new ArrayList<>( - Arrays.asList(SOLIDIFIER_CASING_INDEX, 84, DTPF_CASING_INDEX)); + private byte glassTier = 0; private final String STRUCTURE_PIECE_MAIN = "main"; private final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition @@ -153,53 +92,21 @@ public class MTEMultiSolidifier extends MTEExtendedPowerMultiBlockBase te.glassTier = t, te -> te.glassTier)) .addElement( 'B', - HatchElementBuilder.builder() - .atLeast(InputBus, OutputBus, Maintenance, Energy, InputHatch) - .adder(MTEMultiSolidifier::addToSolidifierList) - .casingIndex(SOLIDIFIER_CASING_INDEX) + buildHatchAdder(MTEMultiSolidifier.class).atLeast(InputBus, InputHatch, OutputBus, Maintenance, Energy) + .casingIndex(((BlockCasings10) GregTechAPI.sBlockCasings10).getTextureIndex(13)) .dot(1) .buildAndChain( - withChannel( - "casing", - onElementPass( - x -> x.casingAmount++, - ofBlocksTiered( - this::casingTierExtractor, - ImmutableList.of( - Pair.of(GregTechAPI.sBlockCasings10, 13), - Pair.of(ModBlocks.blockCustomMachineCasings, 2), - Pair.of(GregTechAPI.sBlockCasings1, 12)), - -1, - MTEMultiSolidifier::setCasingTier, - MTEMultiSolidifier::getCasingTier))))) - .addElement( - 'C', - onElementPass( - x -> x.pipeCasingAmount++, - ofBlocksTiered( - this::pipeTierExtractor, - ImmutableList.of( - Pair.of(GregTechAPI.sBlockCasings10, 14), - Pair.of(ModBlocks.blockCustomPipeGearCasings, 13), - Pair.of(ModBlocks.blockCustomPipeGearCasings, 15)), - -1, - MTEMultiSolidifier::setPipeCasingTier, - MTEMultiSolidifier::getPipeCasingTier))) + onElementPass(MTEMultiSolidifier::onCasingAdded, ofBlock(GregTechAPI.sBlockCasings10, 13)))) + + .addElement('C', ofBlock(GregTechAPI.sBlockCasings10, 14)) .addElement('F', ofBlock(GregTechAPI.sBlockCasings1, 11)) - /* - * TinkerConstruct.isModLoaded()// maybe temporary if someone makes textures for new special decorative block - * ? ofChain(ofBlock(Block.getBlockFromName("TConstruct:SearedBlock"), 0)) - * : ofChain(ofBlock(Blocks.cauldron, 0))) - */ .addElement('D', ofBlock(GregTechAPI.sBlockCasings4, 1)) - /* - * BuildCraftFactory.isModLoaded()// maybe temporary if someone makes textures for new special decorative block - * ? ofChain(ofBlock(Block.getBlockFromName("BuildCraft|Factory:blockHopper"), 10)) - * : ofChain(ofBlock(Blocks.hopper, 0))) - */ .build(); public MTEMultiSolidifier(final int aID, final String aName, final String aNameRegional) { @@ -224,10 +131,11 @@ public boolean isCorrectMachinePart(ItemStack aStack) { public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, int colorIndex, boolean aActive, boolean redstoneLevel) { ITexture[] rTexture; - int casingIndex = casingTier > -1 ? casingIndices.get(casingTier) : SOLIDIFIER_CASING_INDEX; if (side == aFacing) { if (aActive) { - rTexture = new ITexture[] { Textures.BlockIcons.getCasingTextureForId(casingIndex), + rTexture = new ITexture[] { + Textures.BlockIcons + .getCasingTextureForId(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings10, 13)), TextureFactory.builder() .addIcon(OVERLAY_FRONT_MULTI_CANNER_ACTIVE) .extFacing() @@ -238,7 +146,9 @@ public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirect .glow() .build() }; } else { - rTexture = new ITexture[] { Textures.BlockIcons.getCasingTextureForId(casingIndex), + rTexture = new ITexture[] { + Textures.BlockIcons + .getCasingTextureForId(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings10, 13)), TextureFactory.builder() .addIcon(OVERLAY_FRONT_MULTI_CANNER) .extFacing() @@ -262,8 +172,9 @@ protected MultiblockTooltipBuilder createTooltip() { tt.addMachineType("Fluid Solidifier") .addInfo("Controller Block for the Fluid Shaper") .addInfo("Speeds up to a maximum of 300% faster than singleblock machines while running") - .addInfo("Has 4 parallels by default") - .addInfo("Gains an additional 10 parallels per width expansion") + .addInfo("Starts with 4 Parallels") + .addInfo("Gain 1.5 Parallels per Width Expansion and Multiplied by Voltage Tier") + .addInfo("Energy Hatch Based on Glass Tier, UMV Glass Unlocks all") .addInfo(EnumChatFormatting.BLUE + "Pretty Ⱄⱁⰾⰻⰴ, isn't it") .addInfo( AuthorOmdaCZ + " with help of " @@ -275,20 +186,15 @@ protected MultiblockTooltipBuilder createTooltip() { .addSeparator() .beginVariableStructureBlock(17, 33, 5, 5, 5, 5, true) .addController("Front Center bottom") - .addCasingInfoMin("Tier 1: Solidifier Casing", 146, true) - .addCasingInfoMin("Tier 2: Laurenium Casing", 146, true) - .addCasingInfoMin("Tier 3: DTPF Casing", 146, true) - .addCasingInfoMin("Tier 1: Radiator Casing", 18, true) - .addCasingInfoMin("Tier 2: Cinobite Pipe Casing", 18, true) - .addCasingInfoMin("Tier 3: Abyssal Alloy Pipe Casing", 18, true) + .addCasingInfoMin("Solidifier Casing", 146, true) + .addCasingInfoMin("Radiator Casing", 18, true) .addCasingInfoMin("Heat Proof Casing", 4, false) .addCasingInfoMin("Solid Steel Casing", 4, false) - .addInfo("Tier limits maximal width 2; 4; 6") - .addInputBus("Any Tiered Casing", 1) - .addOutputBus("Any Tiered Casing", 1) - .addInputHatch("Any Tiered Casing", 1) - .addEnergyHatch("Any Tiered Casing", 1) - .addMaintenanceHatch("Any Tiered Casing", 1) + .addInputBus("Any Casing", 1) + .addOutputBus("Any Casing", 1) + .addInputHatch("Any Casing", 1) + .addEnergyHatch("Any Casing", 1) + .addMaintenanceHatch("Any Casing", 1) .toolTipFinisher("GregTech"); return tt; } @@ -296,7 +202,7 @@ protected MultiblockTooltipBuilder createTooltip() { @Override public void construct(ItemStack stackSize, boolean hintsOnly) { buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 3, 4, 0); - // max Width, minimal mid pieces to build on each side + // max Width, minimal mid-pieces to build on each side int tTotalWidth = Math.min(6, stackSize.stackSize + 3); for (int i = 1; i < tTotalWidth - 1; i++) { // horizontal offset 3 from controller and number of pieces times width of each piece @@ -309,7 +215,6 @@ public void construct(ItemStack stackSize, boolean hintsOnly) { buildPiece(MS_END, stackSize, hintsOnly, (-tTotalWidth - 2) * 2 + 4, 4, 0); } - protected final List> mOutputHatchesByLayer = new ArrayList<>(); protected int mWidth; protected int nWidth; @@ -320,7 +225,7 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu nWidth = 0; int built = survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 3, 4, 0, elementBudget, env, false, true); if (built >= 0) return built; - int tTotalWidth = Math.min(3 + machineTier, stackSize.stackSize + 3); + int tTotalWidth = Math.min(stackSize.stackSize + 1, 6); for (int i = 1; i < tTotalWidth - 1; i++) { mWidth = i; nWidth = i; @@ -351,44 +256,23 @@ else return survivialBuildPiece( true); } - private int mCasingAmount; - - int mTier; - { - if (casingTier > pipeCasingTier) { - mTier = pipeCasingTier; - } else if (casingTier <= pipeCasingTier) { - mTier = casingTier; - } - - } - - private void onCasingAdded() { - mCasingAmount++; - } - @Override public IStructureDefinition getStructureDefinition() { return STRUCTURE_DEFINITION; } - protected boolean mTopLayerFound; protected int mCasing; + private int mCasingAmount; - protected void onCasingFound() { - mCasing++; - } - - protected void onTopLayerFound(boolean aIsCasing) { - mTopLayerFound = true; - if (aIsCasing) onCasingFound(); + private void onCasingAdded() { + mCasingAmount++; } @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mWidth = 0; - casingTier = -1; - pipeCasingTier = -1; + mCasingAmount = 0; + if (checkPiece(STRUCTURE_PIECE_MAIN, 3, 4, 0)) { while (mWidth < (6)) { if (checkPiece(MS_RIGHT_MID, (-2 * (mWidth + 1)) - 2, 4, 0) @@ -400,20 +284,11 @@ && checkPiece(MS_LEFT_MID, (2 * (mWidth + 1)) + 3, 4, 0)) { if (!checkPiece(MS_END, (-2 * mWidth) - 4, 4, 0) || !checkPiece(MS_END, (mWidth * 2) + 4, 4, 0)) { return false; } - if (casingAmount < (100 + mWidth * 23)) { - casingAmount = 0; - return false; - } else casingAmount = 0; - machineTier = Math.min(pipeCasingTier, casingTier); - if (mWidth > (2 * (machineTier + 1))) { - return false; - } - if (casingTier > -1) { - updateHatchTextures(casingIndices.get(casingTier)); - getBaseMetaTileEntity().sendBlockEvent(GregTechTileClientEvents.CHANGE_CUSTOM_DATA, getUpdateData()); - } - return true; + if (glassTier >= VoltageIndex.UMV) return true; + for (int i = 0; i < this.mEnergyHatches.size(); ++i) + if (this.mEnergyHatches.get(i).mTier > glassTier) return false; + return mCasingAmount >= (100 + mWidth * 23); } @Override @@ -442,121 +317,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { } public int getMaxParallelRecipes() { - return 4 + (mWidth * 10); - } - - private void setCasingTier(int tier) { - casingTier = tier; - } - - private int getCasingTier() { - return casingTier; - } - - private void setPipeCasingTier(int tier) { - pipeCasingTier = tier; - } - - private int getPipeCasingTier() { - return pipeCasingTier; - } - - @Override - public byte getUpdateData() { - return (byte) casingTier; - } - - @Override - public void receiveClientEvent(byte aEventID, byte aValue) { - super.receiveClientEvent(aEventID, aValue); - if (aEventID == GregTechTileClientEvents.CHANGE_CUSTOM_DATA) { - casingTier = aValue; - } - } - - private int casingTierExtractor(Block block, int meta) { - if (!tieredFluidSolidifierCasings.containsKey(meta) || !(tieredFluidSolidifierCasings.get(meta) - .getLeft() == block)) { - return -1; - } - return tieredFluidSolidifierCasings.get(meta) - .getRight(); - } - - private int pipeTierExtractor(Block block, int meta) { - if (!tieredPipeCasings.containsKey(meta) || !(tieredPipeCasings.get(meta) - .getLeft() == block)) { - return -1; - } - return tieredPipeCasings.get(meta) - .getRight(); - } - - private boolean addToSolidifierList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false; - } - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof MTEHatchInput hatch) { - return mInputHatches.add(hatch); - } - if (aMetaTileEntity instanceof IDualInputHatch hatch) { - return mDualInputHatches.add(hatch); - } - if (aMetaTileEntity instanceof MTEHatchInputBus hatch) { - return mInputBusses.add(hatch); - } - if (aMetaTileEntity instanceof MTEHatchOutput hatch) { - return mOutputHatches.add(hatch); - } - if (aMetaTileEntity instanceof MTEHatchOutputBus hatch) { - return mOutputBusses.add(hatch); - } - if (aMetaTileEntity instanceof MTEHatchEnergy hatch) { - return mEnergyHatches.add(hatch); - } - if (aMetaTileEntity instanceof MTEHatchMaintenance hatch) { - return mMaintenanceHatches.add(hatch); - } - if (aMetaTileEntity instanceof MTEHatchMuffler hatch) { - return mMufflerHatches.add(hatch); - } - if (aMetaTileEntity instanceof MTEHatchEnergyMulti hatch) { - return mExoticEnergyHatches.add(hatch); - } - return false; - } - - private void updateHatchTextures(int texture) { - for (IDualInputHatch hatch : mDualInputHatches) { - if (((MetaTileEntity) hatch).isValid()) { - hatch.updateTexture(texture); - } - } - for (MTEHatch hatch : filterValidMTEs(mInputHatches)) { - hatch.updateTexture(texture); - } - for (MTEHatch hatch : filterValidMTEs(mInputBusses)) { - hatch.updateTexture(texture); - } - for (MTEHatch hatch : filterValidMTEs(mOutputHatches)) { - hatch.updateTexture(texture); - } - for (MTEHatch hatch : filterValidMTEs(mOutputBusses)) { - hatch.updateTexture(texture); - } - for (MTEHatch hatch : filterValidMTEs(mEnergyHatches)) { - hatch.updateTexture(texture); - } - for (MTEHatch hatch : filterValidMTEs(mMaintenanceHatches)) { - hatch.updateTexture(texture); - } - for (MTEHatch hatch : filterValidMTEs(mMufflerHatches)) { - hatch.updateTexture(texture); - } - for (MTEHatch hatch : filterValidMTEs(mExoticEnergyHatches)) { - hatch.updateTexture(texture); - } + return 4 + (mWidth * 3 / 2) * GTUtility.getTier(this.getMaxInputVoltage()); } @Override @@ -573,7 +334,6 @@ public int getRecipeCatalystPriority() { public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { super.getWailaBody(itemStack, currentTip, accessor, config); - final NBTTagCompound tag = accessor.getNBTData(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/purification/MTEPurificationPlant.java b/src/main/java/gregtech/common/tileentities/machines/multi/purification/MTEPurificationPlant.java index 6933a18dc29..9c0b5301644 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/purification/MTEPurificationPlant.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/purification/MTEPurificationPlant.java @@ -680,7 +680,7 @@ private Widget makeUnitStatusWidget(LinkedPurificationUnit unit) { .widget( unit.metaTileEntity() .makeSyncerWidgets()) - .widget(new FakeSyncWidget.BooleanSyncer(unit::isActive, unit::setActive));; + .widget(new FakeSyncWidget.BooleanSyncer(unit::isActive, unit::setActive)); return row; } diff --git a/src/main/java/gregtech/loaders/preload/GTPreLoad.java b/src/main/java/gregtech/loaders/preload/GTPreLoad.java index efeba9fe894..34fcfe86d35 100644 --- a/src/main/java/gregtech/loaders/preload/GTPreLoad.java +++ b/src/main/java/gregtech/loaders/preload/GTPreLoad.java @@ -533,7 +533,7 @@ public static void loadConfig() { // ore_drop_behavior try { GTLog.out.println("Trying to set it to: " + ConfigOreDropBehavior.setting); - GTMod.gregtechproxy.oreDropSystem = GTProxy.OreDropSystem.valueOf(ConfigOreDropBehavior.setting);; + GTMod.gregtechproxy.oreDropSystem = GTProxy.OreDropSystem.valueOf(ConfigOreDropBehavior.setting); } catch (IllegalArgumentException e) { GTLog.err.println(e); GTMod.gregtechproxy.oreDropSystem = GTProxy.OreDropSystem.FortuneItem; diff --git a/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java b/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java index a3551326c21..4de2e9ab786 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java @@ -41,13 +41,13 @@ public AutoMap(Map defaultMapType) { /** * Generates an AutoMap from the List. - * + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(List aList) { mInternalMap = new LinkedHashMap<>(); mInternalNameMap = new LinkedHashMap<>(); - if (aList != null && aList.size() > 0) { + if (aList != null && !aList.isEmpty()) { for (V obj : aList) { add(obj); } @@ -56,13 +56,13 @@ public AutoMap(List aList) { /** * Generates an AutoMap from a Set. - * + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(Set aList) { mInternalMap = new LinkedHashMap<>(); mInternalNameMap = new LinkedHashMap<>(); - if (aList != null && aList.size() > 0) { + if (aList != null && !aList.isEmpty()) { for (V obj : aList) { add(obj); } @@ -71,13 +71,13 @@ public AutoMap(Set aList) { /** * Generates an AutoMap from a Collection. - * + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(Collection aList) { mInternalMap = new LinkedHashMap<>(); mInternalNameMap = new LinkedHashMap<>(); - if (aList != null && aList.size() > 0) { + if (aList != null && !aList.isEmpty()) { for (V obj : aList) { add(obj); } @@ -86,13 +86,13 @@ public AutoMap(Collection aList) { /** * Generates an AutoMap from a Array. - * + * * @param aArray - Data to be inserted into the AutoMap. */ public AutoMap(V[] aArray) { mInternalMap = new LinkedHashMap<>(); mInternalNameMap = new LinkedHashMap<>(); - if (aArray != null && aArray.length > 0) { + if (aArray != null) { for (V obj : aArray) { add(obj); } @@ -107,12 +107,8 @@ public Iterator iterator() { public synchronized boolean setValue(V object) { int mOriginalID = this.mInternalID; put(object); - if (this.mInternalMap.get(mOriginalID) - .equals(object) || mOriginalID > this.mInternalID) { - return true; - } else { - return false; - } + return this.mInternalMap.get(mOriginalID) + .equals(object) || mOriginalID > this.mInternalID; } public synchronized V put(V object) { @@ -168,7 +164,6 @@ public synchronized void clear() { this.mInternalID = 0; this.mInternalMap.clear(); this.mInternalNameMap.clear(); - return; } @Override @@ -322,7 +317,6 @@ public int indexOf(Object o) { for (V of : mInternalMap.values()) { if (of != o) { aCount++; - continue; } else { return aCount; } @@ -353,9 +347,7 @@ public List subList(int fromIndex, int toIndex) { AutoMap aNewSubList = new AutoMap<>(); for (int slot = fromIndex; slot <= toIndex; slot++) { V obj = mInternalMap.get(slot); - if (obj == null) { - continue; - } else { + if (obj != null) { aNewSubList.put(obj); } } diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java index b0ee1c0c777..7ba3e7e4746 100644 --- a/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -1,6 +1,5 @@ package gtPlusPlus.core.block.base; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Random; @@ -21,7 +20,6 @@ import gregtech.GTMod; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; import gregtech.api.util.GTOreDictUnificator; import gtPlusPlus.api.interfaces.ITexturedBlock; @@ -30,7 +28,6 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.objects.GTPPCopiedBlockTexture; import gtPlusPlus.xmod.gregtech.api.objects.GTPPRenderedTexture; @@ -100,13 +97,6 @@ public IIcon getIcon(int ordinalSide, int aMeta) { return Blocks.stone.getIcon(0, 0); } - /** - * GT Texture Handler - */ - - // .08 compat - public static IIconContainer[] hiddenTextureArray; - @Override public ITexture[] getTexture(ForgeDirection side) { return getTexture(null, side); @@ -120,21 +110,8 @@ public ITexture[] getTexture(Block block, ForgeDirection side) { this.blockMaterial.getRGBA()); return new ITexture[] { new GTPPCopiedBlockTexture(Blocks.stone, 0, 0), aIconSet }; } - - if (hiddenTextureArray == null) { - try { - Field o = ReflectionUtils.getField(Textures.BlockIcons.class, "STONES"); - if (o != null) { - hiddenTextureArray = (IIconContainer[]) o.get(Textures.BlockIcons.class); - } - if (hiddenTextureArray == null) { - hiddenTextureArray = new IIconContainer[6]; - } - } catch (IllegalArgumentException | IllegalAccessException e) { - hiddenTextureArray = new IIconContainer[6]; - } - } - return new ITexture[] { new GTPPRenderedTexture(hiddenTextureArray[0], new short[] { 240, 240, 240, 0 }) }; + return new ITexture[] { + new GTPPRenderedTexture(Textures.BlockIcons.STONES[0], new short[] { 240, 240, 240, 0 }) }; } @Override diff --git a/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java b/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java index 26e7d907d3c..8f549364c12 100644 --- a/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java +++ b/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java @@ -31,13 +31,7 @@ public boolean isFocused() { } public boolean isBackgroundDrawingEnabled() { - Field enableBackgroundDrawing = ReflectionUtils.getField( - GuiTextField.class, - !PreloaderCore.DEV_ENVIRONMENT ? "field_146215_m" : "enableBackgroundDrawing"); - if (enableBackgroundDrawing != null) { - return ReflectionUtils.getFieldValue(enableBackgroundDrawing, this); - } - return true; + return this.getEnableBackgroundDrawing(); } public int getLineScrollOffset() { diff --git a/src/main/java/gtPlusPlus/core/handler/PacketHandler.java b/src/main/java/gtPlusPlus/core/handler/PacketHandler.java index 735d381706a..9c5d6b25d2c 100644 --- a/src/main/java/gtPlusPlus/core/handler/PacketHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/PacketHandler.java @@ -22,7 +22,7 @@ public class PacketHandler { private static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(GTPlusPlus.ID); - public static final void init() { + public static void init() { registerMessage(PacketVolumetricFlaskGui.class, PacketVolumetricFlaskGui.class); registerMessage(PacketVolumetricFlaskGui2.class, PacketVolumetricFlaskGui2.class); } @@ -50,30 +50,29 @@ private static void registerMessage(Class handlerClass, Class messageClass, Side /** * Send this message to the specified player. See {@link SimpleNetworkWrapper#sendTo(IMessage, EntityPlayerMP)} */ - public static final void sendTo(IMessage message, EntityPlayerMP player) { + public static void sendTo(IMessage message, EntityPlayerMP player) { INSTANCE.sendTo(message, player); } /** * Send this message to everyone within a certain range of a point. See - * {@link SimpleNetworkWrapper#sendToDimension(IMessage, NetworkRegistry.TargetPoint)} + * {@link SimpleNetworkWrapper#sendToAllAround(IMessage, NetworkRegistry.TargetPoint)} */ - public static final void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { + public static void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { INSTANCE.sendToAllAround(message, point); } /** * Sends a message to everyone within a certain range of the coordinates in the same dimension. */ - public static final void sendToAllAround(IMessage message, int dimension, double x, double y, double z, - double range) { + public static void sendToAllAround(IMessage message, int dimension, double x, double y, double z, double range) { sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range)); } /** * Sends a message to everyone within a certain range of the player provided. */ - public static final void sendToAllAround(IMessage message, EntityPlayer player, double range) { + public static void sendToAllAround(IMessage message, EntityPlayer player, double range) { sendToAllAround(message, player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, range); } @@ -81,14 +80,14 @@ public static final void sendToAllAround(IMessage message, EntityPlayer player, * Send this message to everyone within the supplied dimension. See * {@link SimpleNetworkWrapper#sendToDimension(IMessage, int)} */ - public static final void sendToDimension(IMessage message, int dimensionId) { + public static void sendToDimension(IMessage message, int dimensionId) { INSTANCE.sendToDimension(message, dimensionId); } /** * Send this message to the server. See {@link SimpleNetworkWrapper#sendToServer(IMessage)} */ - public static final void sendToServer(IMessage message) { + public static void sendToServer(IMessage message) { INSTANCE.sendToServer(message); } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java b/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java index 4bbf29c88f6..4c7dc05804a 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java @@ -1,7 +1,6 @@ package gtPlusPlus.core.item.chemistry; import static gregtech.api.enums.Mods.BiomesOPlenty; -import static gregtech.api.enums.Mods.Forestry; import static gregtech.api.enums.Mods.TinkerConstruct; import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; import static gregtech.api.recipe.RecipeMaps.compressorRecipes; @@ -12,7 +11,6 @@ import static gtPlusPlus.api.recipe.GTPPRecipeMaps.chemicalDehydratorRecipes; import static gtPlusPlus.api.recipe.GTPPRecipeMaps.semiFluidFuels; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; @@ -23,8 +21,12 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import forestry.core.items.ItemForestryBonemeal; +import forestry.core.items.ItemRegistryCore; +import forestry.plugins.PluginCore; import gregtech.api.enums.GTValues; import gregtech.api.enums.Materials; +import gregtech.api.enums.Mods; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TierEU; import gregtech.api.util.GTOreDictUnificator; @@ -37,7 +39,6 @@ import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.plugin.agrichem.BioRecipes; import gtPlusPlus.plugin.agrichem.item.algae.ItemAgrichemBase; import gtPlusPlus.plugin.agrichem.item.algae.ItemAlgaeBase; @@ -543,33 +544,19 @@ private static void addMiscRecipes() { ItemStack aManureByprod = ItemUtils.getSimpleStack(dustManureByproducts, 1); // Dehydrate Organise Fert to Normal Fert. + if (Mods.Forestry.isModLoaded()) { + ItemRegistryCore aItemRegInstance = PluginCore.items; + if (aItemRegInstance != null) { + ItemForestryBonemeal fertilizerCompound = aItemRegInstance.fertilizerCompound; + aFertForestry = ItemUtils.getSimpleStack(fertilizerCompound); - /* - * Forestry Support - */ - if (Forestry.isModLoaded()) { - Field aItemField = ReflectionUtils - .getField(ReflectionUtils.getClass("forestry.plugins.PluginCore"), "items"); - try { - Object aItemRegInstance = aItemField != null ? aItemField.get(aItemField) : null; - if (aItemRegInstance != null) { - Field aFertField = ReflectionUtils.getField(aItemRegInstance.getClass(), "fertilizerCompound"); - Object aItemInstance = aFertField.get(aItemRegInstance); - if (aItemInstance instanceof Item aForestryFert) { - aFertForestry = ItemUtils.getSimpleStack((Item) aItemInstance); - - GTValues.RA.stdBuilder() - .itemInputs( - GTUtility.getIntegratedCircuit(11), - ItemUtils.getSimpleStack(aDustOrganicFert, 4)) - .itemOutputs(ItemUtils.getSimpleStack(aForestryFert, 3), aManureByprod, aManureByprod) - .outputChances(100_00, 20_00, 20_00) - .eut(240) - .duration(20 * SECONDS) - .addTo(chemicalDehydratorRecipes); - } - } - } catch (IllegalArgumentException | IllegalAccessException e) { + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(11), ItemUtils.getSimpleStack(aDustOrganicFert, 4)) + .itemOutputs(ItemUtils.getSimpleStack(fertilizerCompound, 3), aManureByprod, aManureByprod) + .outputChances(100_00, 20_00, 20_00) + .eut(240) + .duration(20 * SECONDS) + .addTo(chemicalDehydratorRecipes); } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java b/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java index 078dcdee883..4909d269cc5 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java @@ -14,6 +14,8 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; +import biomesoplenty.api.content.BOPCBlocks; +import biomesoplenty.api.content.BOPCItems; import gregtech.api.enums.GTValues; import gregtech.api.enums.Materials; import gregtech.api.enums.TierEU; @@ -33,7 +35,6 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; -import gtPlusPlus.xmod.bop.BiomesOPlentyHandler; import gtPlusPlus.xmod.bop.blocks.BOPBlockRegistrator; import gtPlusPlus.xmod.gregtech.common.helpers.FlotationRecipeHandler; @@ -654,10 +655,10 @@ private void addPineOilExtraction() { aPinecones.add(ItemUtils.getSimpleStack(AgriculturalChem.mPinecone, 1)); if (BiomesOPlenty.isModLoaded()) { - aLogs.add(BiomesOPlentyHandler.getStack(BiomesOPlentyHandler.logs4, 0, 1)); - aLeaves.add(BiomesOPlentyHandler.getStack(BiomesOPlentyHandler.colorizedLeaves2, 1, 1)); - aSaplings.add(BiomesOPlentyHandler.getStack(BiomesOPlentyHandler.colorizedSaplings, 5, 1)); - aPinecones.add(ItemUtils.simpleMetaStack(BiomesOPlentyHandler.mPineCone, 13, 1)); + aLogs.add(ItemUtils.simpleMetaStack(BOPCBlocks.logs4, 0, 1)); + aLeaves.add(ItemUtils.simpleMetaStack(BOPCBlocks.colorizedLeaves2, 1, 1)); + aSaplings.add(ItemUtils.simpleMetaStack(BOPCBlocks.colorizedSaplings, 5, 1)); + aPinecones.add(ItemUtils.simpleMetaStack(BOPCItems.misc, 13, 1)); } if (Forestry.isModLoaded()) { ItemStack aForestryLog = ItemUtils.getItemStackFromFQRN("Forestry:logs", 1); diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/ItemGregtechPump.java b/src/main/java/gtPlusPlus/core/item/tool/misc/ItemGregtechPump.java index 082f74ad2b9..1c896e84972 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/ItemGregtechPump.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/ItemGregtechPump.java @@ -1238,7 +1238,7 @@ public FluidStack getStoredFluidOfGTMachine(IGregTechTileEntity aTileEntity) { if (aTileEntity == null) { return null; } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();; + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null || aMetaTileEntity instanceof MTEHatchMultiInput) { // blacklist multiinput hatch as it's too complex return null; diff --git a/src/main/java/gtPlusPlus/core/lib/GTPPCore.java b/src/main/java/gtPlusPlus/core/lib/GTPPCore.java index c78d734cb65..af6bedfa61f 100644 --- a/src/main/java/gtPlusPlus/core/lib/GTPPCore.java +++ b/src/main/java/gtPlusPlus/core/lib/GTPPCore.java @@ -6,23 +6,17 @@ import java.util.Map; import java.util.Random; import java.util.UUID; -import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Supplier; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - -import com.mojang.authlib.GameProfile; import cpw.mods.fml.common.FMLCommonHandler; import gregtech.GT_Version; import gregtech.api.objects.XSTR; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.preloader.PreloaderCore; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.MTETesseractGenerator; @@ -30,8 +24,6 @@ public class GTPPCore { - public static Map PlayerCache; - // Math Related public static final float PI = (float) Math.PI; public static volatile Random RANDOM = new XSTR(); @@ -48,11 +40,6 @@ public class GTPPCore { public static int turbineCutoffBase = 75000; - // GT++ Fake Player Profile - public static final GameProfile gameProfile = new GameProfile( - UUID.nameUUIDFromBytes("gtplusplus.core".getBytes()), - "[GT++]"); - public static final WeakHashMap fakePlayerCache = new WeakHashMap<>(); // Tooltips; public static final Supplier GT_Tooltip = () -> StatCollector.translateToLocal("GTPP.core.GT_Tooltip"); public static final Supplier GT_Tooltip_Builder = () -> StatCollector @@ -202,34 +189,19 @@ public static class Everglades { public static final String VERSION = GT_Version.VERSION; } - public static final void crash() { + public static void crash() { crash("Generic Crash"); } - public static final void crash(String aReason) { + public static void crash(String aReason) { try { Logger.INFO("=========================================================="); Logger.INFO("[GT++ CRASH]"); Logger.INFO("=========================================================="); Logger.INFO("Oooops..."); - Logger.INFO("This should only happy in a development environment or when something really bad happens."); + Logger.INFO("This should only happen in a development environment or when something really bad happens."); Logger.INFO("Reason: " + aReason); Logger.INFO("=========================================================="); - Logger.INFO("Called from: " + ReflectionUtils.getMethodName(1)); - Logger.INFO(ReflectionUtils.getMethodName(2)); - Logger.INFO(ReflectionUtils.getMethodName(3)); - Logger.INFO(ReflectionUtils.getMethodName(4)); - Logger.INFO(ReflectionUtils.getMethodName(5)); - Logger.INFO(ReflectionUtils.getMethodName(6)); - Logger.INFO(ReflectionUtils.getMethodName(7)); - Logger.INFO(ReflectionUtils.getMethodName(8)); - Logger.INFO(ReflectionUtils.getMethodName(9)); - Logger.INFO(ReflectionUtils.getMethodName(10)); - Logger.INFO(ReflectionUtils.getMethodName(11)); - Logger.INFO(ReflectionUtils.getMethodName(12)); - Logger.INFO(ReflectionUtils.getMethodName(13)); - Logger.INFO(ReflectionUtils.getMethodName(14)); - Logger.INFO(ReflectionUtils.getMethodName(15)); } catch (Throwable t) { t.printStackTrace(); } diff --git a/src/main/java/gtPlusPlus/core/material/MaterialStack.java b/src/main/java/gtPlusPlus/core/material/MaterialStack.java index d4d11781c5b..aeb23a94557 100644 --- a/src/main/java/gtPlusPlus/core/material/MaterialStack.java +++ b/src/main/java/gtPlusPlus/core/material/MaterialStack.java @@ -8,7 +8,6 @@ import gregtech.api.enums.OrePrefixes; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.bartworks.BWUtils; public class MaterialStack { @@ -69,11 +68,7 @@ public ItemStack getUnificatedDustStack(final int amount) { public Material getStackMaterial() { if (this.stackMaterial == null) { - Logger.MATERIALS("Tried getStackMaterial, got an invalid material."); - Logger.MATERIALS(ReflectionUtils.getMethodName(0)); - Logger.MATERIALS(ReflectionUtils.getMethodName(1)); - Logger.MATERIALS(ReflectionUtils.getMethodName(2)); - Logger.MATERIALS(ReflectionUtils.getMethodName(3)); + Logger.modLogger.error("Tried getStackMaterial, got an invalid material.", new Exception()); return null; } return this.stackMaterial; diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java index 66378f0f7a9..c91476f556f 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.tileentities.machines; -import static gregtech.api.enums.Mods.Forestry; - import java.util.ArrayList; import java.util.List; @@ -27,6 +25,8 @@ import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.oredict.OreDictionary; +import forestry.lepidopterology.entities.EntityButterfly; +import gregtech.api.enums.Mods; import gregtech.api.util.GTUtility; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BTF_FluidTank; @@ -36,7 +36,6 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; public class TileEntityPestKiller extends TileEntity implements ISidedInventory, IFluidHandler { @@ -56,8 +55,8 @@ public class TileEntityPestKiller extends TileEntity implements ISidedInventory, static { mEntityMap.put(EntityBat.class); - if (Forestry.isModLoaded()) { - mEntityMap.put(ReflectionUtils.getClass("forestry.lepidopterology.entities.EntityButterfly")); + if (Mods.Forestry.isModLoaded()) { + mEntityMap.put(EntityButterfly.class); } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 1e211290cdc..26d7783b781 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -46,7 +46,6 @@ import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.preloader.PreloaderCore; import gtPlusPlus.xmod.gregtech.api.items.GTMetaTool; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; @@ -309,11 +308,7 @@ public static ItemStack getItemStackOfAmountFromOreDict(String oredictName, fina public static ItemStack getItemStackOfAmountFromOreDictNoBroken(String oredictName, final int amount) { if (PreloaderCore.DEBUG_MODE) { - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(1)); - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(2)); - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(3)); - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(4)); - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(5)); + Logger.modLogger.warn("Looking up: " + oredictName + " - from : ", new Exception()); } try { diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java index 16e5652e828..8845409da9b 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java @@ -2,10 +2,14 @@ import java.util.HashMap; +import gregtech.api.enums.Mods; import gregtech.common.WorldgenGTOreLayer; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import micdoodle8.mods.galacticraft.core.util.ConfigManagerCore; +import micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids; +import micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars; public class MiningUtils { @@ -48,42 +52,17 @@ public static void iterateAllOreTypes() { public static boolean findAndMapOreTypesFromGT() { // Gets Moon ID - boolean aEndAsteroids; - try { - 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); + if (Mods.GalacticraftCore.isModLoaded()) { + if (mMoonID == -99) { + mMoonID = ConfigManagerCore.idDimensionMoon; } - } catch (IllegalArgumentException | IllegalAccessException ignored) {} - - // Gets Mars ID - try { - 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); + if (mMarsID == -99) { + mMarsID = ConfigManagerMars.dimensionIDMars; } - } catch (IllegalArgumentException | IllegalAccessException ignored) {} - - // Get Comets ID - try { - 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); + if (mCometsID == -99) { + mCometsID = ConfigManagerAsteroids.dimensionIDAsteroids; } - } catch (IllegalArgumentException | IllegalAccessException ignored) {} + } // Clear Cache Ores_Overworld.clear(); @@ -91,32 +70,23 @@ public static boolean findAndMapOreTypesFromGT() { Ores_End.clear(); Ores_Misc.clear(); - for (WorldgenGTOreLayer x : WorldgenGTOreLayer.sList) { - if (x.mEnabled) { - - try { - aEndAsteroids = ReflectionUtils.getField(WorldgenGTOreLayer.class, "mEndAsteroid") - .getBoolean(x); - } catch (IllegalArgumentException | IllegalAccessException e) { - aEndAsteroids = false; + for (WorldgenGTOreLayer gtOreLayer : WorldgenGTOreLayer.sList) { + if (gtOreLayer.mEnabled) { + if (gtOreLayer.mOverworld) { + Ores_Overworld.put(gtOreLayer); } - - if (x.mOverworld) { - Ores_Overworld.put(x); - } - if (x.mNether) { - Ores_Nether.put(x); + if (gtOreLayer.mNether) { + Ores_Nether.put(gtOreLayer); } - if (x.mEnd || aEndAsteroids) { - Ores_End.put(x); + if (gtOreLayer.mEnd || gtOreLayer.mEndAsteroid) { + Ores_End.put(gtOreLayer); } - if (x.mOverworld || x.mNether || (x.mEnd || aEndAsteroids)) { + if (gtOreLayer.mOverworld || gtOreLayer.mNether || (gtOreLayer.mEnd || gtOreLayer.mEndAsteroid)) { continue; } - - Ores_Misc.put(x); + Ores_Misc.put(gtOreLayer); } else { - Ores_Comets.put(x); + Ores_Comets.put(gtOreLayer); } } diff --git a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 078cef6ea8c..576c236de63 100644 --- a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -126,7 +126,7 @@ private static void cacheConstructor(Class aClass, Constructor aConstructo /** * Returns a cached {@link Constructor} object. - * + * * @param aClass - Class containing the Constructor. * @param aTypes - Varags Class Types for objects constructor. * @return - Valid, non-final, {@link Method} object, or {@link null}. @@ -155,7 +155,7 @@ public static Constructor getConstructor(Class aClass, Class... aTypes) /** * Returns a cached {@link Class} object. - * + * * @param aClassCanonicalName - The canonical name of the underlying class. * @return - Valid, {@link Class} object, or {@link null}. */ @@ -176,7 +176,7 @@ public static Class getClass(String aClassCanonicalName) { /** * 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. @@ -188,7 +188,7 @@ public static Method getMethod(Object aObject, String aMethodName, Class[] aType /** * 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. @@ -217,7 +217,7 @@ public static Method getMethod(Class aClass, String aMethodName, Class... /** * 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}. @@ -246,7 +246,7 @@ public static Field getField(final Class aClass, final String aFieldName) { /** * 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}. @@ -286,7 +286,7 @@ public static void makeMethodAccessible(final Method field) { /** * Get the method name for a depth in call stack.
* Utility function - * + * * @param depth depth in the call stack (0 means current method, 1 means call method, ...) * @return Method name */ @@ -323,14 +323,6 @@ public static boolean dynamicallyLoadClassesInPackage(String aPackageName) { return loaded > 0; } - public static void loadClass(String aClassName) { - try { - Class.forName(aClassName, true, ReflectionUtils.class.getClassLoader()); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { Class clazz; if (object instanceof Class) { diff --git a/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java b/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java index 8a6d189898f..b7784580fd3 100644 --- a/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java +++ b/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java @@ -2,12 +2,9 @@ import static gregtech.api.enums.Mods.GTPlusPlus; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -23,7 +20,6 @@ import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.OreDictUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; public class ItemAgrichemBase extends Item { @@ -150,24 +146,6 @@ public void registerIcons(final IIconRegister u) { } } - private boolean isTextureValid(String aPath) { - if (aPath == null) { - return false; - } else if (aPath.indexOf(92) == -1) { - Constructor aTextureAtlasSprite = ReflectionUtils.getConstructor(TextureAtlasSprite.class, String.class); - if (aTextureAtlasSprite != null) { - try { - TextureAtlasSprite aTestAtlas = (TextureAtlasSprite) aTextureAtlasSprite.newInstance(aPath); - if (aTestAtlas != null) { - return true; - } - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) {} - } - } - return false; - } - @Override public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { return this.base[damage]; diff --git a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java b/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java index bf69ead5e29..31c0a2e41c2 100644 --- a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java +++ b/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java @@ -15,6 +15,7 @@ import gtPlusPlus.plugin.fixes.interfaces.IBugFix; import gtPlusPlus.preloader.PreloaderCore; +// TODO move this as a mixin in hodgepodge public class VanillaBedHeightFix implements IBugFix { private final Method mSleepInBedAt; diff --git a/src/main/java/gtPlusPlus/xmod/bop/BiomesOPlentyHandler.java b/src/main/java/gtPlusPlus/xmod/bop/BiomesOPlentyHandler.java index b1e97782afc..272b2dacf56 100644 --- a/src/main/java/gtPlusPlus/xmod/bop/BiomesOPlentyHandler.java +++ b/src/main/java/gtPlusPlus/xmod/bop/BiomesOPlentyHandler.java @@ -1,178 +1,27 @@ package gtPlusPlus.xmod.bop; -import static gregtech.api.enums.Mods.BiomesOPlenty; - -import java.lang.reflect.Field; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import biomesoplenty.api.content.BOPCItems; +import gregtech.api.enums.Mods; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.bop.blocks.BOPBlockRegistrator; public class BiomesOPlentyHandler { - public static Item mPineCone; - - public static Block logs1; - public static Block logs2; - public static Block logs3; - public static Block logs4; - - public static Block leaves1; - public static Block leaves2; - public static Block leaves3; - public static Block leaves4; - - public static Block colorizedLeaves1; - public static Block colorizedLeaves2; - - public static Block saplings; - public static Block colorizedSaplings; - public static void preInit() { BOPBlockRegistrator.run(); - if (BiomesOPlenty.isModLoaded()) { - setFields(); - registerPineconeToOreDict(); + if (Mods.BiomesOPlenty.isModLoaded()) { + if (BOPCItems.misc != null) { + ItemStack aPinecone = ItemUtils.simpleMetaStack(BOPCItems.misc, 13, 1); + if (aPinecone != null) { + ItemUtils.addItemToOreDictionary(aPinecone, "pinecone"); + } + } } } public static void postInit() { BOPBlockRegistrator.recipes(); } - - private static void registerPineconeToOreDict() { - if (mPineCone != null) { - ItemStack aPinecone = ItemUtils.simpleMetaStack(mPineCone, 13, 1); - if (aPinecone != null) { - ItemUtils.addItemToOreDictionary(aPinecone, "pinecone"); - } - } - } - - public static ItemStack getStack(Block aBlock, int aMeta, int aSize) { - return ItemUtils.simpleMetaStack(aBlock, aMeta, aSize); - } - - // BOPCBlocks.logs4 - 0 - // BOPCBlocks.colorizedLeaves2 - 1 - - private static void setFields() { - Field aBopMiscItem = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCItems"), "misc"); - - Field aBopBlock1 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs1"); - Field aBopBlock2 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs2"); - Field aBopBlock3 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs3"); - Field aBopBlock4 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs4"); - - Field aBopLeaves1 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves1"); - Field aBopLeaves2 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves2"); - Field aBopLeaves3 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves3"); - Field aBopLeaves4 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves4"); - - Field aBopColouredLeaves1 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedLeaves1"); - Field aBopColouredLeaves2 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedLeaves2"); - - Field aBopSapling = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "saplings"); - Field aBopColouredSapling = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedSaplings"); - - if (aBopMiscItem != null) { - Item aMiscItem = ReflectionUtils.getFieldValue(aBopMiscItem); - if (aMiscItem != null) { - mPineCone = aMiscItem; - } - } - - if (aBopBlock1 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopBlock1); - if (aBlock != null) { - logs1 = aBlock; - } - } - if (aBopBlock2 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopBlock2); - if (aBlock != null) { - logs2 = aBlock; - } - } - if (aBopBlock3 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopBlock3); - if (aBlock != null) { - logs3 = aBlock; - } - } - if (aBopBlock4 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopBlock4); - if (aBlock != null) { - logs4 = aBlock; - } - } - - if (aBopLeaves1 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves1); - if (aBlock != null) { - leaves1 = aBlock; - } - } - if (aBopLeaves2 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves2); - if (aBlock != null) { - leaves2 = aBlock; - } - } - if (aBopLeaves3 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves3); - if (aBlock != null) { - leaves3 = aBlock; - } - } - if (aBopLeaves4 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves4); - if (aBlock != null) { - leaves4 = aBlock; - } - } - - if (aBopColouredLeaves1 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopColouredLeaves1); - if (aBlock != null) { - colorizedLeaves1 = aBlock; - } - } - if (aBopColouredLeaves2 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopColouredLeaves2); - if (aBlock != null) { - colorizedLeaves2 = aBlock; - } - } - - if (aBopSapling != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopSapling); - if (aBlock != null) { - saplings = aBlock; - } - } - if (aBopColouredSapling != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopColouredSapling); - if (aBlock != null) { - colorizedSaplings = aBlock; - } - } - } } diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BeeDefinition.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BeeDefinition.java index 11397e3ef39..95813e45bdb 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BeeDefinition.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BeeDefinition.java @@ -8,7 +8,6 @@ import static forestry.api.core.EnumHumidity.ARID; import static gregtech.api.enums.Mods.Forestry; -import java.lang.reflect.Field; import java.util.Arrays; import java.util.Locale; import java.util.function.Consumer; @@ -47,7 +46,6 @@ import gtPlusPlus.core.material.MaterialsElements.STANDALONE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.MaterialUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.forestry.bees.handler.GTPPCombType; public enum GTPP_BeeDefinition implements IBeeDefinition { @@ -65,7 +63,11 @@ public enum GTPP_BeeDefinition implements IBeeDefinition { AlleleHelper.instance.set(template, TEMPERATURE_TOLERANCE, Tolerance.BOTH_3); AlleleHelper.instance.set(template, HUMIDITY_TOLERANCE, Tolerance.BOTH_3); }, dis -> { - IBeeMutationCustom tMutation = dis.registerMutation("DRAGONESSENCE", "NEUTRONIUM", 2); + IBeeMutationCustom tMutation = dis.registerMutation( + GTBeeDefinition.DRAGONESSENCE.getSpecies(), + GTBeeDefinition.NEUTRONIUM.getSpecies(), + 2, + 1f); tMutation.restrictHumidity(ARID); tMutation.requireResource(STANDALONE.DRAGON_METAL.getBlock(), 1); tMutation.addMutationCondition(new GTBees.DimensionMutationCondition(1, "End")); // End Dim @@ -84,7 +86,8 @@ public enum GTPP_BeeDefinition implements IBeeDefinition { AlleleHelper.instance.set(template, TEMPERATURE_TOLERANCE, Tolerance.BOTH_1); AlleleHelper.instance.set(template, HUMIDITY_TOLERANCE, Tolerance.BOTH_1); }, dis -> { - IBeeMutationCustom tMutation = dis.registerMutation("STEEL", "GOLD", 10); + IBeeMutationCustom tMutation = dis + .registerMutation(GTBeeDefinition.STEEL.getSpecies(), GTBeeDefinition.GOLD.getSpecies(), 10, 1f); tMutation.restrictHumidity(ARID); tMutation.restrictBiomeType(BiomeDictionary.Type.HOT); }),; @@ -185,15 +188,15 @@ private static IAlleleBeeSpecies getSpecies(byte modid, String name) { return ret; } - private final void setSpeciesProperties(GTPPAlleleBeeSpecies species2) { + private void setSpeciesProperties(GTPPAlleleBeeSpecies species2) { this.mSpeciesProperties.accept(species2); } - private final void setAlleles(IAllele[] template) { + private void setAlleles(IAllele[] template) { this.mAlleles.accept(template); } - private final void registerMutations() { + private void registerMutations() { this.mMutations.accept(this); } @@ -209,59 +212,47 @@ private void init() { BeeManager.beeRoot.registerTemplate(template); } - private final IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, IAlleleBeeSpecies parent2, - int chance) { + private IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, IAlleleBeeSpecies parent2, int chance) { return registerMutation(parent1, parent2, chance, 1f); } - private final IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, IAlleleBeeSpecies parent2, - int chance) { + private IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, IAlleleBeeSpecies parent2, int chance) { return registerMutation(parent1, parent2, chance, 1f); } - private final IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, GTPP_BeeDefinition parent2, - int chance) { + private IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, GTPP_BeeDefinition parent2, int chance) { return registerMutation(parent1, parent2, chance, 1f); } - private final IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, GTPP_BeeDefinition parent2, - int chance) { + private IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, GTPP_BeeDefinition parent2, int chance) { return registerMutation(parent1, parent2, chance, 1f); } - private final IBeeMutationCustom registerMutation(String parent1, String parent2, int chance) { - return registerMutation(getGregtechBeeType(parent1), getGregtechBeeType(parent2), chance, 1f); - } - /** * Diese neue Funtion erlaubt Mutationsraten unter 1%. Setze dazu die Mutationsrate als Bruch mit chance / * chancedivider This new function allows Mutation percentages under 1%. Set them as a fraction with chance / * chancedivider */ - private final IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, IAlleleBeeSpecies parent2, int chance, + private IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, IAlleleBeeSpecies parent2, int chance, float chancedivider) { return new GTPPBeeMutation(parent1, parent2, this.getTemplate(), chance, chancedivider); } - private final IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, IAlleleBeeSpecies parent2, int chance, + private IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, IAlleleBeeSpecies parent2, int chance, float chancedivider) { return registerMutation(parent1.species, parent2, chance, chancedivider); } - private final IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, GTPP_BeeDefinition parent2, int chance, + private IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, GTPP_BeeDefinition parent2, int chance, float chancedivider) { return registerMutation(parent1, parent2.species, chance, chancedivider); } - private final IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, GTPP_BeeDefinition parent2, - int chance, float chancedivider) { + private IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, GTPP_BeeDefinition parent2, int chance, + float chancedivider) { return registerMutation(parent1.species, parent2, chance, chancedivider); } - private final IBeeMutationCustom registerMutation(String parent1, String parent2, int chance, float chancedivider) { - return registerMutation(getGregtechBeeType(parent1), getGregtechBeeType(parent2), chance, chancedivider); - } - @Override public final IAllele[] getTemplate() { return Arrays.copyOf(template, template.length); @@ -285,16 +276,4 @@ public final ItemStack getMemberStack(EnumBeeType beeType) { public final IBeeDefinition getRainResist() { return new BeeVariation.RainResist(this); } - - public static IAlleleBeeSpecies getGregtechBeeType(String name) { - try { - // This is still cursed, but the species field is private and I don't want to go modify that right now - GTBeeDefinition aBeeObject = GTBeeDefinition.valueOf(name); - Field gtBeesField = ReflectionUtils.getField(GTBeeDefinition.class, "species"); - return ReflectionUtils.getFieldValue(gtBeesField, aBeeObject); - } catch (Throwable t) { - t.printStackTrace(); - return null; - } - } } diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bees.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bees.java index bfdddcca8b0..7ba5bc326a4 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bees.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bees.java @@ -7,7 +7,6 @@ import gregtech.GTMod; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.forestry.bees.handler.GTPPCombType; import gtPlusPlus.xmod.forestry.bees.handler.GTPPDropType; import gtPlusPlus.xmod.forestry.bees.handler.GTPPPollenType; @@ -45,7 +44,12 @@ public GTPP_Bees() { combs = new GTPPComb(); Logger.BEES("Loading types."); - initTypes(); + // call values() to force initialization of enum entries + GTPP_BeeDefinition.values(); + GTPPCombType.values(); + GTPPDropType.values(); + GTPPPollenType.values(); + GTPPPropolisType.values(); Logger.BEES("Adding recipes."); GTPPDrop.initDropsRecipes(); @@ -58,13 +62,4 @@ public GTPP_Bees() { Logger.BEES("Done!"); } } - - private static void initTypes() { - // This is stupid - ReflectionUtils.loadClass(GTPP_BeeDefinition.class.getName()); - ReflectionUtils.loadClass(GTPPCombType.class.getName()); - ReflectionUtils.loadClass(GTPPDropType.class.getName()); - ReflectionUtils.loadClass(GTPPPollenType.class.getName()); - ReflectionUtils.loadClass(GTPPPropolisType.class.getName()); - } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchNaquadah.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchNaquadah.java index 43e43a1d4e7..90db739be72 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchNaquadah.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchNaquadah.java @@ -120,30 +120,26 @@ public String[] getDescription() { private static String[] aDescCache = new String[3]; - private String formatFluidString(FluidStack f) { - FluidStack mLockedStack = f; - Integer mLockedTemp = 0;; - String mTempMod = "" + EnumChatFormatting.RESET; - mLockedTemp = mLockedStack.getFluid() + private String formatFluidString(FluidStack fluidStack) { + String mTempMod = EnumChatFormatting.RESET.toString(); + int mLockedTemp = fluidStack.getFluid() .getTemperature(); - if (mLockedTemp != null) { - if (mLockedTemp <= -3000) { - mTempMod = "" + EnumChatFormatting.DARK_PURPLE; - } else if (mLockedTemp >= -2999 && mLockedTemp <= -500) { - mTempMod = "" + EnumChatFormatting.DARK_BLUE; - } else if (mLockedTemp >= -499 && mLockedTemp <= -50) { - mTempMod = "" + EnumChatFormatting.BLUE; - } else if (mLockedTemp >= 30 && mLockedTemp <= 300) { - mTempMod = "" + EnumChatFormatting.AQUA; - } else if (mLockedTemp >= 301 && mLockedTemp <= 800) { - mTempMod = "" + EnumChatFormatting.YELLOW; - } else if (mLockedTemp >= 801 && mLockedTemp <= 1500) { - mTempMod = "" + EnumChatFormatting.GOLD; - } else if (mLockedTemp >= 1501) { - mTempMod = "" + EnumChatFormatting.RED; - } + if (mLockedTemp <= -3000) { + mTempMod = "" + EnumChatFormatting.DARK_PURPLE; + } else if (mLockedTemp <= -500) { + mTempMod = "" + EnumChatFormatting.DARK_BLUE; + } else if (mLockedTemp <= -50) { + mTempMod = "" + EnumChatFormatting.BLUE; + } else if (mLockedTemp >= 30 && mLockedTemp <= 300) { + mTempMod = "" + EnumChatFormatting.AQUA; + } else if (mLockedTemp >= 301 && mLockedTemp <= 800) { + mTempMod = "" + EnumChatFormatting.YELLOW; + } else if (mLockedTemp >= 801 && mLockedTemp <= 1500) { + mTempMod = "" + EnumChatFormatting.GOLD; + } else if (mLockedTemp >= 1501) { + mTempMod = "" + EnumChatFormatting.RED; } - return mTempMod + mLockedStack.getLocalizedName(); + return mTempMod + fluidStack.getLocalizedName(); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java index 738afb0d90a..b1af2451aa8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java @@ -2,7 +2,6 @@ import static gregtech.api.util.GTUtility.filterValidMTEs; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -208,7 +207,7 @@ public String[] getInfoData() { + ": " + EnumChatFormatting.YELLOW + GTValues.VN[GTUtility.getTier(getMaxInputVoltage())] - + EnumChatFormatting.RESET));; + + EnumChatFormatting.RESET)); } if (!this.mAllDynamoHatches.isEmpty()) { long storedEnergy = getStoredEnergyInAllDynamoHatches(); @@ -843,43 +842,11 @@ public boolean updateTexture(final IGregTechTileEntity aTileEntity, int aCasingI * Enable Texture Casing Support if found in GT 5.09 */ public boolean updateTexture(final IMetaTileEntity aTileEntity, int aCasingID) { - try { // gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch.updateTexture(int) - - final IMetaTileEntity aMetaTileEntity = aTileEntity; - if (aMetaTileEntity == null) { - return false; - } - Method mProper = ReflectionUtils.getMethod(MTEHatch.class, "updateTexture", int.class); - if (mProper != null) { - if (MTEHatch.class.isInstance(aMetaTileEntity)) { - mProper.setAccessible(true); - mProper.invoke(aMetaTileEntity, aCasingID); - // log("Good Method Call for updateTexture."); - return true; - } - } else { - log("Bad Method Call for updateTexture."); - if (MTEHatch.class.isInstance(aMetaTileEntity)) { - if (aCasingID <= Byte.MAX_VALUE) { - ((MTEHatch) aTileEntity).updateTexture(aCasingID); - log( - "Good Method Call for updateTexture. Used fallback method of setting mMachineBlock as casing id was <= 128."); - return true; - } else { - log("updateTexture returning false. 1.2"); - } - } else { - log("updateTexture returning false. 1.3"); - } - } - log("updateTexture returning false. 1"); - return false; - } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - log("updateTexture returning false."); - log("updateTexture returning false. 2"); - e.printStackTrace(); - return false; + if (aTileEntity instanceof MTEHatch mteHatch) { + mteHatch.updateTexture(aCasingID); + return true; } + return false; } /** diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenFluidCanning.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenFluidCanning.java index c9f627c0d51..a334fd7de4b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenFluidCanning.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenFluidCanning.java @@ -13,7 +13,6 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.GTPPCore; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; public class RecipeGenFluidCanning implements Runnable { @@ -206,13 +205,7 @@ private void addFluidCannerRecipe(GTRecipe aRecipe) { } private void dumpStack() { - int parents = 2; - for (int i = 0; i < 6; i++) { - Logger.INFO( - (disableOptional ? "EXTRACTING" : "CANNING") + " DEBUG | " - + (i == 0 ? "Called from: " : "Parent: ") - + ReflectionUtils.getMethodName(i + parents)); - } + Logger.modLogger.info((disableOptional ? "EXTRACTING" : "CANNING") + " DEBUG ", new Exception()); } private int getMapSize(RecipeMap aMap) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenRecycling.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenRecycling.java index 8fe051dd71a..305422ccea7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenRecycling.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenRecycling.java @@ -28,7 +28,6 @@ import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; public class RecipeGenRecycling implements Runnable { @@ -252,11 +251,7 @@ public static ItemStack get(final OrePrefixes aPrefix, final Material aMaterial, public static ItemStack get(final Object aName, final ItemStack aReplacement, final long aAmount, final boolean aMentionPossibleTypos, final boolean aNoInvalidAmounts) { if (aNoInvalidAmounts && (aAmount < 1L)) { - Logger.WARNING("Returning Null. Method: " + ReflectionUtils.getMethodName(0)); - Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(1)); - Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(2)); - Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(3)); - Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(4)); + Logger.modLogger.warn("Returning Null. Method: ", new Exception()); return null; } if (!mNameMap.containsKey(aName.toString()) && aMentionPossibleTypos) { @@ -269,11 +264,7 @@ public static ItemStack get(final Object aName, final ItemStack aReplacement, fi public static ItemStack getFirstOre(final Object aName, final long aAmount) { if (GTUtility.isStringInvalid(aName)) { - Logger.WARNING("Returning Null. Method: " + ReflectionUtils.getMethodName(0)); - Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(1)); - Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(2)); - Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(3)); - Logger.WARNING("Called from method: " + ReflectionUtils.getMethodName(4)); + Logger.modLogger.warn("Returning Null. Method: ", new Exception()); return null; } final ItemStack tStack = mNameMap.get(aName.toString()); diff --git a/src/main/java/gtPlusPlus/xmod/tinkers/HandlerTinkers.java b/src/main/java/gtPlusPlus/xmod/tinkers/HandlerTinkers.java index 5dbde334932..faa94542b98 100644 --- a/src/main/java/gtPlusPlus/xmod/tinkers/HandlerTinkers.java +++ b/src/main/java/gtPlusPlus/xmod/tinkers/HandlerTinkers.java @@ -1,10 +1,9 @@ package gtPlusPlus.xmod.tinkers; -import static gregtech.api.enums.Mods.TinkerConstruct; - import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; +import gregtech.api.enums.Mods; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.xmod.tinkers.material.BaseTinkersMaterial; import gtPlusPlus.xmod.tinkers.util.TinkersDryingRecipe; @@ -15,7 +14,7 @@ public class HandlerTinkers { public static AutoMap mTinkerMaterials = new AutoMap<>(); public static void postInit() { - if (TinkerConstruct.isModLoaded()) { + if (Mods.TinkerConstruct.isModLoaded()) { Fluid pyrotheumFluid = FluidRegistry.getFluid("pyrotheum"); if (pyrotheumFluid != null) { diff --git a/src/main/java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java b/src/main/java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java index 5a4984a898a..68685b7b8b2 100644 --- a/src/main/java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java +++ b/src/main/java/gtPlusPlus/xmod/tinkers/material/BaseTinkersMaterial.java @@ -165,20 +165,12 @@ public void generate() { private boolean generateRecipes(Material aMaterial, int aID) { - Block aMatBlock; - Integer aMelt; - Fluid aFluid; - - try { - aMatBlock = aMaterial.getBlock(); - aMelt = aMaterial.getMeltingPointC(); - aFluid = aMaterial.getFluidStack(0) - .getFluid(); - } catch (Throwable t) { - return false; - } + Block aMatBlock = aMaterial.getBlock(); + int aMelt = aMaterial.getMeltingPointC(); + Fluid aFluid = aMaterial.getFluidStack(0) + .getFluid(); - if (aMatBlock == null || aMelt == null || aFluid == null) { + if (aMatBlock == null || aFluid == null) { return false; } @@ -192,7 +184,6 @@ private boolean generateRecipes(Material aMaterial, int aID) { TinkersUtils .addCastingTableRecipe(aMaterial.getIngot(1), aMaterial.getFluidStack(144), ingotcast, false, 50); } - TinkersUtils.generateCastingRecipes(aMaterial, aID); return true; diff --git a/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersDryingRecipe.java b/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersDryingRecipe.java index 4adac363e88..4136b543099 100644 --- a/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersDryingRecipe.java +++ b/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersDryingRecipe.java @@ -1,9 +1,7 @@ package gtPlusPlus.xmod.tinkers.util; -import static gregtech.api.enums.Mods.TinkerConstruct; import static gtPlusPlus.api.recipe.GTPPRecipeMaps.chemicalDehydratorRecipes; -import java.lang.reflect.Field; import java.util.List; import net.minecraft.item.ItemStack; @@ -14,7 +12,7 @@ import gregtech.api.util.GTUtility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.util.reflect.ReflectionUtils; +import tconstruct.library.crafting.DryingRackRecipes; public class TinkersDryingRecipe { @@ -24,20 +22,25 @@ public class TinkersDryingRecipe { public final ItemStack input; public final ItemStack result; + public TinkersDryingRecipe(final ItemStack input, final int time, final ItemStack result) { + this.time = time; + this.input = input; + this.result = result; + Logger.INFO( + "Generating Drying Recipe. Input: " + input.getDisplayName() + ", Output: " + result.getDisplayName()); + } + public static void generateAllDryingRecipes() { - List aRecipes = TinkersUtils.getDryingRecipes(); - if (aRecipes != null && aRecipes.size() > 0) { - for (Object o : aRecipes) { + List aRecipes = TinkersDryingRecipe.getDryingRecipes(); + if (!aRecipes.isEmpty()) { + for (DryingRackRecipes.DryingRecipe recipe : aRecipes) { Logger.INFO( - "Trying to generate recipe using object of type " + o.getClass() + "Trying to generate recipe using object of type " + recipe.getClass() .getSimpleName()); - generateFromTinkersRecipeObject(o); + generateFromTinkersRecipe(recipe); } } else { - Logger.INFO( - "Error generating Drying recipes, map was either null or empty. Null? " + (aRecipes != null) - + ", Size: " - + aRecipes.size()); + Logger.INFO("Error generating Drying recipes, map was empty. Size: " + aRecipes.size()); } if (!recipes.isEmpty()) { Logger.INFO("Adding " + recipes.size() + " drying rack recipes to the dehydrator."); @@ -52,61 +55,19 @@ public static void generateAllDryingRecipes() { } } - public static TinkersDryingRecipe generateFromTinkersRecipeObject(Object o) { - Field aTime; - Field aInput; - Field aOutput; - Class aTinkerClass = ReflectionUtils.getClass("tconstruct.library.crafting.DryingRackRecipes.DryingRecipe"); // o.getClass(); - if (aTinkerClass == null || TinkerConstruct.isModLoaded()) { - Logger.INFO( - "Error generating Drying Recipe, could not find class. Exists? " - + ReflectionUtils.doesClassExist("tconstruct.library.crafting.DryingRackRecipes.DryingRecipe")); - Class clazz = ReflectionUtils.getClass("tconstruct.library.crafting.DryingRackRecipes"); - Class[] y = clazz.getDeclaredClasses(); - if (y == null || y.length <= 0) { - Logger.INFO("No hidden inner classes."); - return null; - } else { - boolean found = false; - for (Class h : y) { - Logger.INFO("Found hidden inner class: " + h.getCanonicalName()); - if (h.getSimpleName() - .toLowerCase() - .equals("dryingrecipe")) { - Logger.INFO("Found correct recipe. Caching at correct location."); - ReflectionUtils.mCachedClasses - .put("tconstruct.library.crafting.DryingRackRecipes.DryingRecipe", h); - aTinkerClass = h; - found = true; - break; - } - } - if (!found) { - return null; - } - } - } - aTime = ReflectionUtils.getField(aTinkerClass, "time"); - aInput = ReflectionUtils.getField(aTinkerClass, "input"); - aOutput = ReflectionUtils.getField(aTinkerClass, "result"); - try { - int time_internal = aTime.getInt(o); - ItemStack input_internal = (ItemStack) aInput.get(o); - ItemStack result_internal = (ItemStack) aOutput.get(o); - return new TinkersDryingRecipe(input_internal, time_internal, result_internal); - } catch (Throwable b) { - b.printStackTrace(); - } - return null; + private static void generateFromTinkersRecipe(DryingRackRecipes.DryingRecipe recipe) { + recipes.add(new TinkersDryingRecipe(recipe.input, recipe.time, recipe.result)); } - public TinkersDryingRecipe(final ItemStack input, final int time, final ItemStack result) { - this.time = time; - this.input = input; - this.result = result; - Logger.INFO( - "Generating Drying Recipe. Input: " + input.getDisplayName() + ", Output: " + result.getDisplayName()); - recipes.add(this); + private static List getDryingRecipes() { + AutoMap aData = new AutoMap<>(); + int aCount = 0; + for (DryingRackRecipes.DryingRecipe recipe : DryingRackRecipes.recipes) { + aData.put(recipe); + aCount++; + } + Logger.INFO("Found " + aCount + " Tinkers drying rack recipes."); + return aData; } public boolean matches(ItemStack input) { diff --git a/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java b/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java index 8b173d5b624..09633f58106 100644 --- a/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java +++ b/src/main/java/gtPlusPlus/xmod/tinkers/util/TinkersUtils.java @@ -1,339 +1,89 @@ package gtPlusPlus.xmod.tinkers.util; -import static gregtech.api.enums.Mods.TinkerConstruct; - -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 net.minecraft.block.Block; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -import gregtech.api.enums.Materials; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; +import tconstruct.library.TConstructRegistry; +import tconstruct.library.crafting.CastingRecipe; +import tconstruct.library.crafting.FluidType; +import tconstruct.library.crafting.LiquidCasting; +import tconstruct.library.crafting.Smeltery; +import tconstruct.library.tools.DynamicToolPart; +import tconstruct.library.util.IPattern; +import tconstruct.smeltery.TinkerSmeltery; public class TinkersUtils { - 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; - - private static Object mSmelteryInstance; - private static Object mTinkersRegistryInstance; - - private static final HashMap mMethodCache = new LinkedHashMap<>(); - - 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[] {}); - } - - private static void setTiConDataInstance() { - if (!TinkerConstruct.isModLoaded()) { - return; - } - - if (mSmelteryInstance == null) { - if (mClass_Smeltery != null) { - try { - mSmelteryInstance = ReflectionUtils.getField(mClass_Smeltery, "instance") - .get(null); - } catch (IllegalArgumentException | IllegalAccessException ignored) {} - } - } - if (mTinkersRegistryInstance == null) { - if (mClass_TConstructRegistry != null) { - try { - mTinkersRegistryInstance = ReflectionUtils.getField(mClass_TConstructRegistry, "instance") - .get(null); - } catch (IllegalArgumentException | IllegalAccessException ignored) {} - } - } - } - /** * Add a new fluid as a valid Smeltery fuel. - * + * * @param fluid The fluid. * @param power The temperature of the fluid. This also influences the melting speed. Lava is 1000. * @param duration How long one "portion" of liquid fuels the smeltery. Lava is 10. */ public static void addSmelteryFuel(Fluid fluid, int power, int duration) { - setTiConDataInstance(); - ReflectionUtils.invokeVoid( - mSmelteryInstance, - "addSmelteryFuel", - new Class[] { Fluid.class, int.class, int.class }, - new Object[] { fluid, power, duration }); + Smeltery.addSmelteryFuel(fluid, power, duration); } 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; - } + FluidType.registerFluidType(name, block, meta, baseTemperature, fluid, isToolpart); + return true; } public static void 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); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {} + Smeltery.addMelting(input, block, metadata, temperature, liquid); } - public static void 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); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {} + public static void addMelting(FluidType type, ItemStack input, int temperatureDifference, int fluidAmount) { + Smeltery.addMelting(type, input, temperatureDifference, fluidAmount); } public static void 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); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {} + LiquidCasting tableCasting = TConstructRegistry.getTableCasting(); + tableCasting.addCastingRecipe(output, metal, cast, consume, delay); } public static void 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); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored) {} + LiquidCasting basinCasting = TConstructRegistry.getBasinCasting(); + basinCasting.addCastingRecipe(output, metal, cast, consume, delay); } - /** - * 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[] {}); - } else if (aType == 1) { - m = ReflectionUtils.getMethod(mTinkersRegistryInstance, "getBasinCasting", new Class[] {}); - } // 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 ignored) {} - } - } - if (mTinkerMetalPattern != null) { - return new ItemStack(mTinkerMetalPattern, aType, 0); - } - return ItemUtils.getErrorStack(1, "Bad Tinkers Pattern"); - } - - private static AutoMap mDryingRackRecipes; - - public static List getDryingRecipes() { - if (mDryingRackRecipes != null) { - return mDryingRackRecipes; - } - AutoMap aData = new AutoMap<>(); - int aCount = 0; - try { - ArrayList recipes = (ArrayList) ReflectionUtils - .getField(ReflectionUtils.getClass("tconstruct.library.crafting.DryingRackRecipes"), "recipes") - .get(null); - if (recipes != null) { - for (Object o : recipes) { - aData.put(o); - aCount++; - } - Logger.INFO("Found " + aCount + " Tinkers drying rack recipes."); - } else { - Logger.INFO("Failed to find any Tinkers drying rack recipes."); - } - } catch (IllegalArgumentException | IllegalAccessException e) { - Logger.INFO("Failed to find any Tinkers drying rack recipes."); - } - mDryingRackRecipes = aData; - return aData; - } - - 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 List getTableCastingRecipes() { + LiquidCasting tableCasting = TConstructRegistry.getTableCasting(); + return tableCasting.getCastingRecipes(); } public static void 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; - } - } - - Object ft; - try { - ft = mMethod_getFluidType.invoke(null, aMaterial.getLocalizedName()); - for (CastingRecipeHandler newRecipy : newRecipies) { - CastingRecipeHandler recipe = new CastingRecipeHandler(newRecipy); - if (!recipe.valid) { - continue; - } - // CastingRecipe recipe = (CastingRecipe) i$.next(); - ItemStack output = recipe.getResult() + Fluid aMoltenIron = TinkerSmeltery.moltenIronFluid; + FluidType fluidType = FluidType.getFluidType(aMaterial.getLocalizedName()); + for (CastingRecipe recipe : getTableCastingRecipes()) { + CastingRecipeHandler newRecipe = new CastingRecipeHandler(recipe); + if (newRecipe.castingMetal.getFluid() == aMoltenIron && newRecipe.cast != null + && newRecipe.cast.getItem() instanceof IPattern + && newRecipe.getResult() + .getItem() instanceof DynamicToolPart) { + ItemStack output = newRecipe.getResult() .copy(); output.setItemDamage(aID); - FluidStack liquid2 = new FluidStack( + FluidStack liquid = new FluidStack( aMaterial.getFluidStack(0) .getFluid(), - recipe.castingMetal.amount); - addCastingTableRecipe(output, liquid2, recipe.cast, recipe.consumeCast, recipe.coolTime); - addMelting(ft, output, 0, liquid2.amount / 2); + newRecipe.castingMetal.amount); + addCastingTableRecipe(output, liquid, newRecipe.cast, newRecipe.consumeCast, newRecipe.coolTime); + addMelting(fluidType, output, 0, liquid.amount / 2); } - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - e.printStackTrace(); } + } + public static ItemStack getPattern(int aType) { + return new ItemStack(TinkerSmeltery.metalPattern, aType, 0); } private static class CastingRecipeHandler { @@ -344,30 +94,12 @@ private static class CastingRecipeHandler { 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 CastingRecipeHandler(CastingRecipe castingRecipe) { + this.output = castingRecipe.output; + this.castingMetal = castingRecipe.castingMetal; + this.cast = castingRecipe.cast; + this.consumeCast = castingRecipe.consumeCast; + this.coolTime = castingRecipe.coolTime; } public ItemStack getResult() { diff --git a/src/main/java/gtnhlanth/common/tileentity/MTELINAC.java b/src/main/java/gtnhlanth/common/tileentity/MTELINAC.java index 78ea9c78468..94571d10e0e 100644 --- a/src/main/java/gtnhlanth/common/tileentity/MTELINAC.java +++ b/src/main/java/gtnhlanth/common/tileentity/MTELINAC.java @@ -213,7 +213,7 @@ protected MultiblockTooltipBuilder createTooltip() { .addOtherStructurePart("Beamline Input Hatch", addDotText(3)) .addOtherStructurePart("Beamline Output Hatch", addDotText(4)) - .toolTipFinisher("GTNH: Lanthanides");; + .toolTipFinisher("GTNH: Lanthanides"); return tt; } diff --git a/src/main/resources/assets/gregtech/sounds.json b/src/main/resources/assets/gregtech/sounds.json index 2d33d116da2..c8ea3bc8eea 100644 --- a/src/main/resources/assets/gregtech/sounds.json +++ b/src/main/resources/assets/gregtech/sounds.json @@ -123,5 +123,23 @@ "stream": false } ] + }, + "machines.MultiLatheLoop": { + "category": "block", + "sounds": [ + { + "name": "MultiLatheLoop", + "stream": false + } + ] + }, + "machines.MultiAutoclaveLoop": { + "category": "block", + "sounds": [ + { + "name": "MultiAutoclaveLoop", + "stream": false + } + ] } } diff --git a/src/main/resources/assets/gregtech/sounds/MultiAutoclaveLoop.ogg b/src/main/resources/assets/gregtech/sounds/MultiAutoclaveLoop.ogg new file mode 100644 index 00000000000..035b7c94f81 Binary files /dev/null and b/src/main/resources/assets/gregtech/sounds/MultiAutoclaveLoop.ogg differ diff --git a/src/main/resources/assets/gregtech/sounds/MultiLatheLoop.ogg b/src/main/resources/assets/gregtech/sounds/MultiLatheLoop.ogg new file mode 100644 index 00000000000..cafebe66e49 Binary files /dev/null and b/src/main/resources/assets/gregtech/sounds/MultiLatheLoop.ogg differ