Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
Cleanup isValidMetaTileEntity and some more (#364)
Browse files Browse the repository at this point in the history
* updateBuildScript & updateDependencies

* Update .gitignore

* Cleanup isValidMetaTileEntity

* Remove unused and obsolete members
  • Loading branch information
miozune authored Oct 8, 2023
1 parent 56475bd commit 3b00fa0
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 429 deletions.
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.gradle
.settings
/.idea/
/.vscode/
/run/
/build/
/eclipse/
Expand All @@ -25,6 +26,13 @@ whitelist.json
*.iml
*.ipr
*.iws
src/main/resources/mixins.*.json
src/main/resources/mixins.*([!.]).json
*.bat
.vscode/
*.DS_Store
!gradlew.bat
.factorypath
addon.local.gradle
addon.local.gradle.kts
addon.late.local.gradle
addon.late.local.gradle.kts
layout.json
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1695474595
//version: 1696265388
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Expand Down Expand Up @@ -798,7 +798,7 @@ dependencies {
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
}
if (modId != 'hodgepodge') {
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.5')
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.7')
}

java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
Expand Down
6 changes: 3 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Add your dependencies here

dependencies {
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.23:dev')
api("com.github.GTNewHorizons:TecTech:5.3.3:dev")
api('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.31:dev')
api("com.github.GTNewHorizons:TecTech:5.3.5:dev")
api("com.github.GTNewHorizons:GalacticGregGT5:1.0.10:dev") {
exclude group:"com.github.GTNewHorizons", module:"bartworks"
}
api("com.github.GTNewHorizons:Avaritia:1.46:dev")
implementation("com.github.GTNewHorizons:TinkersConstruct:1.10.3-GTNH:dev")
implementation("com.github.GTNewHorizons:TinkersConstruct:1.10.5-GTNH:dev")

compileOnly("com.github.GTNewHorizons:TinkersGregworks:GTNH-1.0.24-pre:dev") {transitive = false}
compileOnly("com.github.GTNewHorizons:OpenComputers:1.9.17-GTNH:api") {transitive = false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_GLOW;
import static gregtech.api.util.GT_StructureUtility.buildHatchAdder;
import static gregtech.api.util.GT_Utility.filterValidMTEs;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -246,14 +247,12 @@ protected SoundResource getProcessStartSound() {
@Override
public ArrayList<ItemStack> getStoredInputs() {
ArrayList<ItemStack> rList = new ArrayList<>();
for (GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) {
for (GT_MetaTileEntity_Hatch_InputBus tHatch : filterValidMTEs(mInputBusses)) {
tHatch.mRecipeMap = this.getRecipeMap();
if (isValidMetaTileEntity(tHatch)) {
for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) {
if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) {
rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i));
break;
}
for (int i = 0; i < tHatch.getBaseMetaTileEntity().getSizeInventory(); i++) {
if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) {
rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i));
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose;
import static gregtech.api.enums.GT_Values.AuthorKuba;
import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
import static gregtech.api.util.GT_Utility.filterValidMTEs;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -334,8 +335,7 @@ public boolean onRunningTick(ItemStack aStack) {
this.fuelsupply,
HTGRMaterials.MATERIALS_PER_FUEL * this.fueltype + HTGRMaterials.USABLE_FUEL_INDEX);
boolean storedAll = false;
for (GT_MetaTileEntity_Hatch_OutputBus tHatch : this.mOutputBusses) {
if (!isValidMetaTileEntity(tHatch)) continue;
for (GT_MetaTileEntity_Hatch_OutputBus tHatch : filterValidMTEs(mOutputBusses)) {
if (tHatch.storeAll(iStack)) {
storedAll = true;
break;
Expand Down Expand Up @@ -365,15 +365,13 @@ public boolean onRunningTick(ItemStack aStack) {
int takecoolant = this.coolanttaking;
int drainedamount = 0;

for (GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) {
if (isValidMetaTileEntity(tHatch)) {
FluidStack tLiquid = tHatch.getFluid();
if (tLiquid != null && tLiquid.isFluidEqual(FluidRegistry.getFluidStack("ic2coolant", 1))) {
FluidStack drained = tHatch.drain(takecoolant, true);
takecoolant -= drained.amount;
drainedamount += drained.amount;
if (takecoolant <= 0) break;
}
for (GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mInputHatches)) {
FluidStack tLiquid = tHatch.getFluid();
if (tLiquid != null && tLiquid.isFluidEqual(FluidRegistry.getFluidStack("ic2coolant", 1))) {
FluidStack drained = tHatch.drain(takecoolant, true);
takecoolant -= drained.amount;
drainedamount += drained.amount;
if (takecoolant <= 0) break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose;
import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
import static gregtech.api.util.GT_Utility.filterValidMTEs;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -294,15 +295,13 @@ public boolean onRunningTick(ItemStack aStack) {
int takecoolant = this.coolanttaking;
int drainedamount = 0;

for (GT_MetaTileEntity_Hatch_Input tHatch : this.mInputHatches) {
if (isValidMetaTileEntity(tHatch)) {
FluidStack tLiquid = tHatch.getFluid();
if (tLiquid != null && tLiquid.isFluidEqual(FluidRegistry.getFluidStack("ic2coolant", 1))) {
FluidStack drained = tHatch.drain(takecoolant, true);
takecoolant -= drained.amount;
drainedamount += drained.amount;
if (takecoolant <= 0) break;
}
for (GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mInputHatches)) {
FluidStack tLiquid = tHatch.getFluid();
if (tLiquid != null && tLiquid.isFluidEqual(FluidRegistry.getFluidStack("ic2coolant", 1))) {
FluidStack drained = tHatch.drain(takecoolant, true);
takecoolant -= drained.amount;
drainedamount += drained.amount;
if (takecoolant <= 0) break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages;
import static gregtech.api.util.GT_StructureUtility.buildHatchAdder;
import static gregtech.api.util.GT_StructureUtility.ofCoil;
import static gregtech.api.util.GT_Utility.filterValidMTEs;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -337,8 +338,7 @@ public boolean addOutput(FluidStack aLiquid) {
if (isOutputPollution) {
tOutputHatches = this.mPollutionOutputHatches;
int pollutionReduction = 0;
for (GT_MetaTileEntity_Hatch_Muffler tHatch : this.mMufflerHatches) {
if (!isValidMetaTileEntity(tHatch)) continue;
for (GT_MetaTileEntity_Hatch_Muffler tHatch : filterValidMTEs(mMufflerHatches)) {
pollutionReduction = 100 - tHatch.calculatePollutionReduction(100);
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega;

import static gregtech.api.util.GT_Utility.filterValidMTEs;

import java.util.Arrays;

import net.minecraft.init.Blocks;
Expand All @@ -20,7 +22,6 @@
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.util.GT_Utility;

public abstract class GT_TileEntity_MegaMultiBlockBase<T extends GT_TileEntity_MegaMultiBlockBase<T>>
Expand Down Expand Up @@ -50,10 +51,8 @@ protected String[] getExtendedInfoData() {
protected long[] getCurrentInfoData() {
long storedEnergy = 0, maxEnergy = 0;
for (GT_MetaTileEntity_Hatch hatch : this.getExoticAndNormalEnergyHatchList()) {
if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) {
storedEnergy += hatch.getBaseMetaTileEntity().getStoredEU();
maxEnergy += hatch.getBaseMetaTileEntity().getEUCapacity();
}
storedEnergy += hatch.getBaseMetaTileEntity().getStoredEU();
maxEnergy += hatch.getBaseMetaTileEntity().getEUCapacity();
}
return new long[] { storedEnergy, maxEnergy };
}
Expand All @@ -62,21 +61,17 @@ protected long[] getCurrentInfoData() {
public String[] getInfoData() {
int mPollutionReduction = 0;

for (GT_MetaTileEntity_Hatch_Muffler tHatch : this.mMufflerHatches) {
if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction);
}
for (GT_MetaTileEntity_Hatch_Muffler tHatch : filterValidMTEs(mMufflerHatches)) {
mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction);
}

long[] ttHatches = this.getCurrentInfoData();
long storedEnergy = ttHatches[0];
long maxEnergy = ttHatches[1];

for (GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) {
if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) {
storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU();
maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity();
}
for (GT_MetaTileEntity_Hatch_Energy tHatch : filterValidMTEs(mEnergyHatches)) {
storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU();
maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity();
}

long nominalV = this.getMaxInputEu();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages;
import static gregtech.api.util.GT_StructureUtility.buildHatchAdder;
import static gregtech.api.util.GT_StructureUtility.ofCoil;
import static gregtech.api.util.GT_Utility.filterValidMTEs;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -327,38 +328,34 @@ private boolean addMiddleInputToMachineList(IGregTechTileEntity aTileEntity, int
@Override
public ArrayList<FluidStack> getStoredFluids() {
final ArrayList<FluidStack> rList = new ArrayList<>();
for (final GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) {
if (isValidMetaTileEntity(tHatch)) {
tHatch.mRecipeMap = getRecipeMap();
if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) {
for (final FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) {
if (tFluid != null && !GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tFluid)) {
rList.add(tFluid);
}
}
} else {
if (tHatch.getFillableStack() != null) {
if (!GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tHatch.getFillableStack()))
rList.add(tHatch.getFillableStack());
for (final GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mInputHatches)) {
tHatch.mRecipeMap = getRecipeMap();
if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) {
for (final FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) {
if (tFluid != null && !GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tFluid)) {
rList.add(tFluid);
}
}
} else {
if (tHatch.getFillableStack() != null) {
if (!GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tHatch.getFillableStack()))
rList.add(tHatch.getFillableStack());
}
}
}
for (final GT_MetaTileEntity_Hatch_Input tHatch : mMiddleInputHatches) {
if (isValidMetaTileEntity(tHatch)) {
tHatch.mRecipeMap = getRecipeMap();
if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) {
for (final FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) {
if (tFluid != null && GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tFluid)) {
rList.add(tFluid);
}
for (final GT_MetaTileEntity_Hatch_Input tHatch : filterValidMTEs(mMiddleInputHatches)) {
tHatch.mRecipeMap = getRecipeMap();
if (tHatch instanceof GT_MetaTileEntity_Hatch_MultiInput) {
for (final FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) {
if (tFluid != null && GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tFluid)) {
rList.add(tFluid);
}
} else {
if (tHatch.getFillableStack() != null) {
final FluidStack tStack = tHatch.getFillableStack();
if (GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tStack)) {
rList.add(tStack);
}
}
} else {
if (tHatch.getFillableStack() != null) {
final FluidStack tStack = tHatch.getFillableStack();
if (GT_Recipe.GT_Recipe_Map.sCrackingRecipes.isValidCatalystFluid(tStack)) {
rList.add(tStack);
}
}
}
Expand Down
Loading

0 comments on commit 3b00fa0

Please sign in to comment.