diff options
author | GlodBlock <1356392126@qq.com> | 2021-07-27 19:44:12 +0800 |
---|---|---|
committer | GlodBlock <1356392126@qq.com> | 2021-07-27 19:44:12 +0800 |
commit | 744e920770c6a9a81c8275ec528000085d601131 (patch) | |
tree | 6d0296c57944f3221a7b778a859078b41401bb90 | |
parent | e1bc1013d5fa8a579d509da6e97901b6410959e0 (diff) | |
download | GT5-Unofficial-744e920770c6a9a81c8275ec528000085d601131.tar.gz GT5-Unofficial-744e920770c6a9a81c8275ec528000085d601131.tar.bz2 GT5-Unofficial-744e920770c6a9a81c8275ec528000085d601131.zip |
add LargeEssentiaGenerator structure and fix some bug
5 files changed, 184 insertions, 19 deletions
diff --git a/src/main/java/GoodGenerator/Blocks/TEs/FuelRefineFactory.java b/src/main/java/GoodGenerator/Blocks/TEs/FuelRefineFactory.java index 2c759af2d9..3cfbf01fdf 100644 --- a/src/main/java/GoodGenerator/Blocks/TEs/FuelRefineFactory.java +++ b/src/main/java/GoodGenerator/Blocks/TEs/FuelRefineFactory.java @@ -166,7 +166,7 @@ public class FuelRefineFactory extends GT_MetaTileEntity_MultiblockBase_EM imple @Override public String[] getDescription(){ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Naquadah Fuel Refine Factory") + tt.addMachineType("Naquadah Fuel Refinery") .addInfo("Controller block for the Naquadah Fuel Refine Factory") .addInfo("But at what cost?") .addInfo("Produce the endgame naquadah fuel.") @@ -230,6 +230,13 @@ public class FuelRefineFactory extends GT_MetaTileEntity_MultiblockBase_EM imple @Override public boolean checkRecipe_EM(ItemStack aStack){ + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + ArrayList<FluidStack> tFluids = getStoredFluids(); ArrayList<ItemStack> tItems = getStoredInputs(); Collection<GT_Recipe> tRecipes = MyRecipeAdder.instance.FRF.mRecipeList; diff --git a/src/main/java/GoodGenerator/Blocks/TEs/LargeEssentiaGenerator.java b/src/main/java/GoodGenerator/Blocks/TEs/LargeEssentiaGenerator.java index 5c2a76170e..818d31c715 100644 --- a/src/main/java/GoodGenerator/Blocks/TEs/LargeEssentiaGenerator.java +++ b/src/main/java/GoodGenerator/Blocks/TEs/LargeEssentiaGenerator.java @@ -1,32 +1,45 @@ package GoodGenerator.Blocks.TEs; +import GoodGenerator.Loader.Loaders; import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti; import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.mechanics.structure.IStructureDefinition; import com.github.technus.tectech.mechanics.structure.StructureDefinition; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyTunnel; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Log; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; import thaumcraft.api.aspects.AspectSourceHelper; +import thaumcraft.api.aspects.IAspectContainer; +import thaumcraft.common.config.ConfigBlocks; import java.util.ArrayList; import java.util.List; +import java.util.Set; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.transpose; +import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; public class LargeEssentiaGenerator extends GT_MetaTileEntity_MultiblockBase_EM implements TecTechEnabledMulti, IConstructable { private IStructureDefinition<LargeEssentiaGenerator> multiDefinition = null; - protected List<Aspect> mAvailableAspects; - protected final int MAX_RANGE = 20; + protected List<Aspect> mAvailableAspects = new ArrayList<>(Aspect.aspects.size()); + protected final int MAX_RANGE = 16; protected final int ENERGY_PER_ESSENTIA = 512; + protected int mStableValue = 0; public LargeEssentiaGenerator(String name){ super(name); @@ -53,7 +66,25 @@ public class LargeEssentiaGenerator extends GT_MetaTileEntity_MultiblockBase_EM @Override public void construct(ItemStack itemStack, boolean b) { + structureBuild_EM(mName, 4, 0, 4, b, itemStack); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mStableValue = 0; + return structureCheck_EM(mName, 4, 0, 4); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT){ + super.loadNBTData(aNBT); + this.mStableValue = aNBT.getInteger("mStableValue"); + } + @Override + public void saveNBTData(NBTTagCompound aNBT){ + super.saveNBTData(aNBT); + aNBT.setInteger("mStableValue", this.mStableValue); } @Override @@ -63,35 +94,138 @@ public class LargeEssentiaGenerator extends GT_MetaTileEntity_MultiblockBase_EM .<LargeEssentiaGenerator>builder() .addShape(mName, transpose(new String[][]{ - {}, - {}, - {}, - {}, - {}, - {}, - {} + {"A A"," "," "," "," ~ "," "," "," ","A A"}, + {"T C T"," CEC "," CEEEC "," CEEEEEC ","CEEEEEEEC"," CEEEEEC "," CEEEC "," CEC ","T C T"}, + {"T TXT T"," TCCCT "," TCCCCCT ","TCCCCCCCT","XCCCCCCCX","TCCCCCCCT"," TCCCCCT "," TCCCT ","T TXT T"} }) + ).addElement( + 'A', + ofBlock( + ConfigBlocks.blockCosmeticOpaque, 1 + ) + ).addElement( + 'T', + ofBlock( + ConfigBlocks.blockCosmeticSolid, 7 + ) + ).addElement( + 'C', + ofBlock( + Loaders.magicCasing, 0 + ) + ).addElement( + 'E', + ofChain( + onElementPass( + x -> ++x.mStableValue, + ofBlock( + Loaders.essentiaCell, 0 + ) + ), + onElementPass( + x -> x.mStableValue += 2, + ofBlock( + Loaders.essentiaCell, 1 + ) + ), + onElementPass( + x -> x.mStableValue += 5, + ofBlock( + Loaders.essentiaCell, 2 + ) + ) + ) + ).addElement( + 'X', + ofChain( + ofHatchAdder( + LargeEssentiaGenerator::addLargeEssentiaGeneratorList,1536, + 1 + ), + ofBlock( + Loaders.magicCasing, 0 + ) + ) ) .build(); } return multiDefinition; } + public final boolean addLargeEssentiaGeneratorList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input){ + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance)aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo){ + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo)aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti){ + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti)aMetaTileEntity); + } + } + return false; + } + List<Aspect> getAvailableAspects() { return mAvailableAspects; } + public void scanAvailableAspects() { + IGregTechTileEntity tBaseMetaTileEntity = this.getBaseMetaTileEntity(); + if (tBaseMetaTileEntity.isInvalidTileEntity()) return; + int tRange = MAX_RANGE; + int tY = tBaseMetaTileEntity.getYCoord(); + int tMaxY = tBaseMetaTileEntity.getWorld().getHeight()-1; + int rYMin = (tY - tRange >= 0) ? -tRange : -(tY); + int rYMax = (((tY + tRange) <= tMaxY)? tRange : tMaxY - tY); + mAvailableAspects.clear(); + for (int rX = -tRange; rX <= tRange; rX++) { + for (int rZ = -tRange; rZ <= tRange; rZ++) { + for (int rY = rYMin; rY < rYMax; rY++) { + TileEntity tTile = tBaseMetaTileEntity.getTileEntityOffset(rX, rY, rZ); + if (tTile instanceof IAspectContainer) { + AspectList tAspectList = ((IAspectContainer) tTile).getAspects(); + if (tAspectList == null || tAspectList.aspects.isEmpty()) continue; + Set<Aspect> tAspects = tAspectList.aspects.keySet(); + mAvailableAspects.addAll(tAspects); + } + } + } + } + } + + @Override + public boolean checkRecipe_EM(ItemStack aStack) { + this.mEfficiency = 10000; + this.mMaxProgresstime = 1; + scanAvailableAspects(); + this.mEUt = (int)absorbFromEssentiaContainers(); + return true; + } + + @Override + public int getMaxEfficiency(ItemStack aStack) { + return 10000; + } + private long absorbFromEssentiaContainers() { long tEU = 0; - long tEUtoGen = getBaseMetaTileEntity().getEUCapacity() - getBaseMetaTileEntity().getUniversalEnergyStored(); + long tEUtoGen = 8192; List<Aspect> mAvailableEssentiaAspects = getAvailableAspects(); - for (int i = mAvailableEssentiaAspects.size() - 1; i >= 0 && tEUtoGen > 0; i--) { Aspect aspect = mAvailableEssentiaAspects.get(i); - long tAspectEU = (ENERGY_PER_ESSENTIA * mEfficiency) / 100; + long tAspectEU = ENERGY_PER_ESSENTIA; if (tAspectEU <= tEUtoGen - && AspectSourceHelper.drainEssentia((TileEntity) getBaseMetaTileEntity(), aspect, ForgeDirection.UNKNOWN, MAX_RANGE)) { + && AspectSourceHelper.drainEssentia((TileEntity) this.getBaseMetaTileEntity(), aspect, ForgeDirection.UNKNOWN, MAX_RANGE)) { tEUtoGen -= tAspectEU; tEU += tAspectEU; } @@ -108,4 +242,14 @@ public class LargeEssentiaGenerator extends GT_MetaTileEntity_MultiblockBase_EM public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new LargeEssentiaGenerator(this.mName); } + + @Override + @SuppressWarnings("ALL") + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if(aSide == aFacing) { + if(aActive) return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(1536), new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_DRAGONEGG), TextureFactory.builder().addIcon(Textures.BlockIcons.MACHINE_CASING_DRAGONEGG_GLOW).glow().build()}; + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(1536), new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_DRAGONEGG)}; + } + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(1536)}; + } } diff --git a/src/main/java/GoodGenerator/Blocks/TEs/MultiNqGenerator.java b/src/main/java/GoodGenerator/Blocks/TEs/MultiNqGenerator.java index f2f9279b37..cf38e0b221 100644 --- a/src/main/java/GoodGenerator/Blocks/TEs/MultiNqGenerator.java +++ b/src/main/java/GoodGenerator/Blocks/TEs/MultiNqGenerator.java @@ -275,7 +275,7 @@ public class MultiNqGenerator extends GT_MetaTileEntity_MultiblockBase_EM implem else this.mOutputFluids = null; if (tFluids.contains(Materials.LiquidAir.getFluid(120)) && tFluids.get(tFluids.indexOf(Materials.LiquidAir.getFluid(120))).amount >= 120){ depleteInput(Materials.LiquidAir.getFluid(120)); - addAutoEnergy((long)(((long)outputEU)*(times*booster))); + addAutoEnergy((((long)outputEU)*times)*(int)(booster*100)/100); this.mEUt = (int)(outputEU*times*booster); } else{ diff --git a/src/main/java/GoodGenerator/Loader/Loaders.java b/src/main/java/GoodGenerator/Loader/Loaders.java index 32af1052d6..5f3a2c1fdc 100644 --- a/src/main/java/GoodGenerator/Loader/Loaders.java +++ b/src/main/java/GoodGenerator/Loader/Loaders.java @@ -11,6 +11,10 @@ import GoodGenerator.Items.MyItems; import GoodGenerator.Main.GoodGenerator; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Log; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -19,6 +23,7 @@ import net.minecraftforge.oredict.OreDictionary; public class Loaders { public static final int IDOffset = 32001; + public static final byte GoodGeneratorTexturePage = 12; public static final Item radiationProtectionPlate = new MyItems("radiationProtectionPlate", GoodGenerator.GG); public static final Item wrappedUraniumIngot = new MyItems("wrappedUraniumIngot", GoodGenerator.GG); @@ -83,11 +88,11 @@ public class Loaders { Loaders.MAR = new MultiNqGenerator(12732, "NaG", "Large Naquadah Reactor").getStackForm(1L); Loaders.FRF = new FuelRefineFactory(16999, "FRF", "Naquadah Fuel Refinery").getStackForm(1L); Loaders.UCFE = new UniversalChemicalFuelEngine(IDOffset, "UniversalChemicalFuelEngine", "Universal Chemical Fuel Engine").getStackForm(1L); - /*if (Loader.isModLoaded("Thaumcraft")){ + if (Loader.isModLoaded("Thaumcraft")){ GameRegistry.registerBlock(magicCasing, MyItemBlocks.class, "magicCasing"); GameRegistry.registerBlock(essentiaCells[0], MyItemBlocks.class, "essentiaCell"); Loaders.LEG = new LargeEssentiaGenerator(IDOffset + 1, "LargeEssentiaGenerator", "Large Essentia Generator").getStackForm(1L); - }*/ + } } public static void addOreDic(){ @@ -95,4 +100,11 @@ public class Loaders { OreDictionary.registerOre("blockGlassZPM", fieldRestrictingGlass); OreDictionary.registerOre("dustAluminumNitride", aluminumNitride); } + + public static void addTexturePage(){ + if (Textures.BlockIcons.casingTexturePages[GoodGeneratorTexturePage] == null){ + Textures.BlockIcons.casingTexturePages[GoodGeneratorTexturePage] = new ITexture[128]; + Textures.BlockIcons.casingTexturePages[GoodGeneratorTexturePage][0] = TextureFactory.of(magicCasing); + } + } } diff --git a/src/main/java/GoodGenerator/Main/GoodGenerator.java b/src/main/java/GoodGenerator/Main/GoodGenerator.java index 79f2529734..d4f47cab8f 100644 --- a/src/main/java/GoodGenerator/Main/GoodGenerator.java +++ b/src/main/java/GoodGenerator/Main/GoodGenerator.java @@ -17,6 +17,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.Loader; import static GoodGenerator.Loader.Loaders.addOreDic; +import static GoodGenerator.Loader.Loaders.addTexturePage; @SuppressWarnings("ALL") @Mod(modid = GoodGenerator.MOD_ID, version = GoodGenerator.VERSION, @@ -42,6 +43,7 @@ public final class GoodGenerator { new FluidsBuilder(); Loaders.Register(); addOreDic(); + addTexturePage(); proxy.preInit(event); } @Mod.EventHandler |