diff options
Diffstat (limited to 'src/Java')
4 files changed, 977 insertions, 41 deletions
diff --git a/src/Java/gregtech/api/util/Recipe_GT.java b/src/Java/gregtech/api/util/Recipe_GT.java index 342add5b63..a59ac03a4a 100644 --- a/src/Java/gregtech/api/util/Recipe_GT.java +++ b/src/Java/gregtech/api/util/Recipe_GT.java @@ -278,6 +278,10 @@ public class Recipe_GT extends GT_Recipe{ "Slow Fusion Reactor", null, "gregtech:textures/gui/basicmachines/Default", 0, 0, 0, 2, 1, "Start: ", 1, " EU", true, false); + public static final GT_Recipe_Map sSlowFusion2Recipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(50), "gt.recipe.slowfusionreactor2", + "Pocket Fusion", null, "gregtech:textures/gui/basicmachines/LFTR", 2, 0, 0, 0, 4, "Start: ", 1, + " EU", true, false); + //Component Assembler public static final GT_Recipe_Map sComponentAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<GT_Recipe>(300), "gt.recipe.componentassembler", "Component Assembler", null, RES_PATH_GUI + "basicmachines/Assembler", 6, 1, 1, 0, 1, E, 1, E, true, true); diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 520cf83532..c59d37de69 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -16,6 +16,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Materials; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.Recipe_GT; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gtPlusPlus.api.analytics.SegmentAnalytics; import gtPlusPlus.api.analytics.SegmentHelper; @@ -133,6 +134,7 @@ public class GTplusplus implements ActionListener { + RegistrationHandler.recipesFailed + " |"); Logger.INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Logger.INFO("Finally, we are finished. Have some cripsy bacon as a reward."); + dumpGtRecipeMap(Recipe_GT.Gregtech_Recipe_Map.sSlowFusion2Recipes); } @EventHandler diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_PocketFusion.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_PocketFusion.java new file mode 100644 index 0000000000..fe3ad4163a --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntity_PocketFusion.java @@ -0,0 +1,695 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; + +import java.util.ArrayList; +import java.util.Random; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.*; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_DeluxeMachine; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMetaTileEntity_PocketFusion extends GT_MetaTileEntity_DeluxeMachine { + + private boolean mCanProcessRecipe = false; + private boolean mCharging = false; + private long mChargeConsumed = 0; + + private GT_Recipe mLastRecipe; + private long mEUStore; + private boolean mRunningOnLoad = false; + private boolean mMachine = false; + private int mEfficiency, mEfficiencyIncrease, mEfficiencyMax = 0; + private int mStartUpCheck = 100, mUpdate = 0; + private FluidStack[] mOutputFluids = null; + + public GregtechMetaTileEntity_PocketFusion(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, "It's like a midget Ra.", 1, 1, "PotionBrewer.png", ""); + } + + public GregtechMetaTileEntity_PocketFusion(String aName, int aTier, String aDescription, + ITexture[][][] aTextures, String aGUIName, String aNEIName) { + super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); + } + + @Override + public String[] getDescription() { + return new String[] { this.mDescription, "Not Very Fast, but not very big either.", + "Each side pair in/out puts to different slots.", "Top & Bottom Sides are Outputs.", + "Front & Back are Input Plasma 1.", "Sides are Input Plasma 2.", CORE.GT_Tooltip }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMetaTileEntity_PocketFusion(this.mName, this.mTier, this.mDescription, + this.mTextures, this.mGUIName, this.mNEIName); + } + + public int tier() { + return this.mTier; + } + + public int tierOverclock() { + return this.mTier == 6 ? 0 : this.mTier == 7 ? 1 : 2; + } + + private GT_RenderedTexture getCasingTexture() { + return new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Advanced); + } + + @Override + public ITexture[][][] getTextureSet(final ITexture[] aTextures) { + final ITexture[][][] rTextures = new ITexture[10][17][]; + for (byte i = -1; i < 16; i++) { + rTextures[0][i + 1] = this.getFront(i); + rTextures[1][i + 1] = this.getBack(i); + rTextures[2][i + 1] = this.getBottom(i); + rTextures[3][i + 1] = this.getTop(i); + rTextures[4][i + 1] = this.getSides(i); + rTextures[5][i + 1] = this.getFrontActive(i); + rTextures[6][i + 1] = this.getBackActive(i); + rTextures[7][i + 1] = this.getBottomActive(i); + rTextures[8][i + 1] = this.getTopActive(i); + rTextures[9][i + 1] = this.getSidesActive(i); + } + return rTextures; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + + 1]; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes; + } + + @Override + public boolean isOutputFacing(final byte aSide) { + return aSide == this.getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return (aFluid.getFluid().getName().contains("plasma")) || (super.isFluidInputAllowed(aFluid)); + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public void abortProcess() { + super.abortProcess(); + } + + long mFusionPoint = 20000000L; + + @Override + public int checkRecipe() { + Logger.INFO("Recipe Tick 1."); + if (!this.mCanProcessRecipe) { + Logger.INFO("Recipe Tick 1.1 - Cannot Process Recipe."); + if (this.mChargeConsumed < mFusionPoint) { + Logger.INFO("Recipe Tick 1.2 - Cannot Ignite Fusion, Charge too low."); + this.mCharging = true; + this.mCanProcessRecipe = false; + if (this.getBaseMetaTileEntity().decreaseStoredEnergyUnits((mFusionPoint / 100), false)) { + Logger.INFO("Recipe Tick 1.3 - Charging Internal storage. " + (mFusionPoint / 100) + "/" + + mFusionPoint); + mChargeConsumed += (mFusionPoint / 100); + } + } + else { + mChargeConsumed = 0; + this.mCharging = false; + this.mCanProcessRecipe = true; + + } + } + else { + Logger.INFO("Recipe Tick 1.1 - Try to Process Recipe."); + if (checkRecipeMulti()) { + Logger.INFO("Recipe Tick 1.2 - Process Recipe was Successful."); + return 2; + } + } + Logger.INFO("Recipe Tick 2. - Process Recipe failed."); + return 0; + } + + public ArrayList<FluidStack> getStoredFluids() { + ArrayList<FluidStack> mList = new ArrayList<FluidStack>(); + mList.add(this.mFluid); + mList.add(this.mFluid2); + return mList; + } + + public boolean checkRecipeMulti() { + ArrayList<FluidStack> tFluidList = getStoredFluids(); + int tFluidList_sS = tFluidList.size(); + for (int i = 0; i < tFluidList_sS - 1; i++) { + for (int j = i + 1; j < tFluidList_sS; j++) { + if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { + if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + tFluidList.remove(j--); + tFluidList_sS = tFluidList.size(); + } + else { + tFluidList.remove(i--); + tFluidList_sS = tFluidList.size(); + break; + } + } + } + } + if (tFluidList.size() > 1) { + FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); + GT_Recipe tRecipe = getRecipeList().findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, + GT_Values.V[8], tFluids, new ItemStack[] {}); + if ((tRecipe == null && !mRunningOnLoad) || (maxEUStore() < tRecipe.mSpecialValue)) { + this.mLastRecipe = null; + Logger.INFO("Just plain bad."); + return false; + } + if (mRunningOnLoad || tRecipe.isRecipeInputEqual(true, tFluids, new ItemStack[] {})) { + this.mLastRecipe = tRecipe; + this.mEUt = (this.mLastRecipe.mEUt * overclock(this.mLastRecipe.mSpecialValue)); + this.mMaxProgresstime = this.mLastRecipe.mDuration / overclock(this.mLastRecipe.mSpecialValue); + + this.mEfficiencyIncrease = 10000; + + this.mOutputFluids = this.mLastRecipe.mFluidOutputs; + mRunningOnLoad = false; + return true; + } + } + return false; + } + + public int overclock(int mStartEnergy) { + if (tierOverclock() == 1) { + return 1; + } + if (tierOverclock() == 2) { + return mStartEnergy < 160000000 ? 2 : 1; + } + return mStartEnergy < 160000000 ? 4 : mStartEnergy < 320000000 ? 2 : 1; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean doesAutoOutputFluids() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public long maxAmperesIn() { + return 16L; + } + + @Override + public long maxEUStore() { + return Long.MAX_VALUE; + } + + @Override + public void doExplosion(long aExplosionPower) { + super.doExplosion(aExplosionPower * 2); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + onRunningTickMulti(); + if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive()) + && (aBaseMetaTileEntity.getFrontFacing() != 1) && (aBaseMetaTileEntity.getCoverIDAtSide((byte) 1) == 0) + && (!aBaseMetaTileEntity.getOpacityAtSide((byte) 1))) { + if (MathUtils.randInt(0, 4) == 4) { + final Random tRandom = aBaseMetaTileEntity.getWorld().rand; + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), + aBaseMetaTileEntity.getYCoord() + 0.3f + (tRandom.nextFloat() * 0.2F), + (aBaseMetaTileEntity.getZCoord() + 1.2F) - (tRandom.nextFloat() * 1.6F), 0.0D, 0.0D, 0.0D); + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.4F) - (tRandom.nextFloat() * 0.3F), + aBaseMetaTileEntity.getYCoord() + 0.2f + (tRandom.nextFloat() * 0.1F), + (aBaseMetaTileEntity.getZCoord() + 0.8F) - (tRandom.nextFloat() * 0.6F), 0.0D, 0.0D, 0.0D); + aBaseMetaTileEntity.getWorld().spawnParticle("magicCrit", + (aBaseMetaTileEntity.getXCoord() + 0.6F) - (tRandom.nextFloat() * 0.9F), + aBaseMetaTileEntity.getYCoord() + 0.4f + (tRandom.nextFloat() * 0.3F), + (aBaseMetaTileEntity.getZCoord() + 1.8F) - (tRandom.nextFloat() * 2.6F), 0.0D, 0.0D, 0.0D); + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setBoolean("mCanProcessRecipe", this.mCanProcessRecipe); + aNBT.setBoolean("mCharging", this.mCharging); + aNBT.setLong("mChargeConsumed", this.mChargeConsumed); + aNBT.setInteger("mEfficiency", this.mEfficiency); + aNBT.setInteger("mEfficiencyIncrease", this.mEfficiencyIncrease); + aNBT.setInteger("mEfficiencyMax", this.mEfficiencyMax); + aNBT.setInteger("mStartUpCheck", this.mStartUpCheck); + aNBT.setInteger("mUpdate", mUpdate); + aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); + aNBT.setBoolean("mRunningOnLoad", this.mRunningOnLoad); + aNBT.setBoolean("mMachine", this.mMachine); + aNBT.setLong("mEUStore", this.mEUStore); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (mMaxProgresstime > 0) + mRunningOnLoad = true; + this.mCanProcessRecipe = aNBT.getBoolean("mCanProcessRecipe"); + this.mCharging = aNBT.getBoolean("mCharging"); + this.mChargeConsumed = aNBT.getLong("mChargeConsumed"); + this.mEfficiency = aNBT.getInteger("mEfficiency"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyMax = aNBT.getInteger("mEfficiencyMax"); + this.mStartUpCheck = aNBT.getInteger("mStartUpCheck"); + this.mUpdate = aNBT.getInteger("mUpdate"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); + this.mRunningOnLoad = aNBT.getBoolean("mRunningOnLoad"); + this.mMachine = aNBT.getBoolean("mMachine"); + this.mEUStore = aNBT.getLong("mEUStore"); + super.loadNBTData(aNBT); + } + + @Override + public String[] getInfoData() { + String tier = tier() == 6 ? "I" : tier() == 7 ? "II" : "III"; + float plasmaOut = 0; + String fusionName = ""; + int powerRequired = 0; + if (this.mLastRecipe != null) { + fusionName = this.mLastRecipe.mFluidOutputs[0].getLocalizedName() + " Fusion."; + powerRequired = this.mLastRecipe.mEUt; + if (this.mLastRecipe.getFluidOutput(0) != null) { + plasmaOut = (float) this.mLastRecipe.getFluidOutput(0).amount / (float) this.mLastRecipe.mDuration; + } + } + + return new String[] { "Fusion Reactor MK " + tier, "EU Required: " + powerRequired + "EU/t", + "Stored EU: " + this.getEUVar() + " / " + maxEUStore(), "Plasma Output: " + plasmaOut + "L/t", + "Current Recipe: " + fusionName }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + public ITexture[] getFront(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab) }; + } + + public ITexture[] getBack(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) }; + } + + public ITexture[] getBottom(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; + } + + public ITexture[] getTop(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS) }; + } + + public ITexture[] getSides(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Orange) }; + } + + public ITexture[] getFrontActive(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active) }; + } + + public ITexture[] getBackActive(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT) }; + } + + public ITexture[] getBottomActive(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; + } + + public ITexture[] getTopActive(final byte aColor) { + return new ITexture[] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW) }; + } + + public ITexture[] getSidesActive(final byte aColor) { + return new ITexture[] { this.getCasingTexture(), + new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Dimensional_Blue) }; + } + + @Override + public void onMachineBlockUpdate() { + this.mUpdate = 50; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + // super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + // Logger.INFO("1"); + if (mEfficiency < 0) + mEfficiency = 0; + if (mRunningOnLoad) { + Logger.INFO("2"); + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + checkRecipeMulti(); + } + if (--mUpdate == 0 || --mStartUpCheck == 0) { + Logger.INFO("3"); + mMachine = true; + } + if (mStartUpCheck < 0) { + //Logger.INFO("4"); + if (mMachine) { + //Logger.INFO("5"); + + if (aBaseMetaTileEntity.getStoredEU() + (2048 * tierOverclock()) < maxEUStore()) { + if (aBaseMetaTileEntity.increaseStoredEnergyUnits(2048 * tierOverclock(), true)) { + //Logger.INFO("5.5 A"); + } + else { + //Logger.INFO("5.5 B"); + } + } + if (this.mEUStore <= 0 && mMaxProgresstime > 0) { + Logger.INFO("6"); + stopMachine(); + this.mLastRecipe = null; + } + if (mMaxProgresstime > 0) { + Logger.INFO("7"); + this.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mEUt, true); + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { + if (mOutputFluids != null) + for (FluidStack tStack : mOutputFluids) + if (tStack != null) + addOutput(tStack); + mEfficiency = Math.max(0, (mEfficiency + mEfficiencyIncrease)); + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + if (mOutputFluids != null && mOutputFluids.length > 0) { + + } + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aBaseMetaTileEntity.isAllowedToWork()) + checkRecipeMulti(); + } + } + else { + //Logger.INFO("8"); + this.mEUStore = (int) aBaseMetaTileEntity.getStoredEU(); + if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() + || aBaseMetaTileEntity.hasInventoryBeenModified()) { + Logger.INFO("9"); + // turnCasingActive(mMaxProgresstime > 0); + if (aBaseMetaTileEntity.isAllowedToWork()) { + Logger.INFO("10"); + if (checkRecipeMulti()) { + Logger.INFO("11"); + if (this.mEUStore < this.mLastRecipe.mSpecialValue) { + Logger.INFO("12"); + mMaxProgresstime = 0; + // turnCasingActive(false); + } + aBaseMetaTileEntity.decreaseStoredEnergyUnits(this.mLastRecipe.mSpecialValue, true); + } + } + if (mMaxProgresstime <= 0) + mEfficiency = Math.max(0, mEfficiency - 1000); + } + } + } + else { + // turnCasingActive(false); + Logger.INFO("Bad"); + this.mLastRecipe = null; + stopMachine(); + } + } + Logger.INFO("Good | "+mMaxProgresstime); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + } + } + + public boolean onRunningTickMulti() { + if (this.getBaseMetaTileEntity().isServerSide()) { + if (mEUt < 0) { + if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { + this.mLastRecipe = null; + stopMachine(); + Logger.INFO("a1"); + return false; + } + } + if (this.mEUStore <= 0) { + this.mLastRecipe = null; + stopMachine(); + Logger.INFO("a2"); + return false; + } + } + return true; + } + + public boolean drainEnergyInput(long aEU) { + return false; + } + + public boolean addOutput(FluidStack aLiquid) { + if (aLiquid == null) + return false; + FluidStack copiedFluidStack = aLiquid.copy(); + this.mOutputFluid = copiedFluidStack; + return false; + } + + public void stopMachine() { + mEUt = 0; + mEfficiency = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + getBaseMetaTileEntity().disableWorking(); + } + + @Override + public boolean isLiquidInput(byte aSide) { + switch (aSide) { + case 0: + return true; + case 1: + return true; + case 2: + return true; + case 3: + return false; + case 4: + return false; + case 5: + return false; + default: + return false; + } + } + + @Override + public boolean isLiquidOutput(byte aSide) { + switch (aSide) { + case 0: + return false; + case 1: + return false; + case 2: + return false; + case 3: + return true; + case 4: + return true; + case 5: + return true; + default: + return true; + } + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + return super.fill(aFluid, doFill); + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + return super.drain(maxDrain, doDrain); + } + + @Override + public int getTankPressure() { + return 500; + } + + @Override + public boolean canFill(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return false; + } + else { + return super.canFill(aSide, aFluid); + } + } + + @Override + public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.canDrain(aSide, aFluid); + } + else { + return false; + } + } + + @Override + public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return 0; + } + else { + return super.fill_default(aSide, aFluid, doFill); + } + } + + @Override + public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.fill(aSide, aFluid, doFill); + } + else { + return 0; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.drain(aSide, aFluid, doDrain); + } + else { + return null; + } + } + + @Override + public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { + if (aSide == ForgeDirection.UP || aSide == ForgeDirection.DOWN) { + return super.drain(aSide, maxDrain, doDrain); + } + else { + return null; + } + } + + @Override + public boolean isOverclockerUpgradable() { + return true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + // TODO Auto-generated method stub + return super.onRightclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, + float aY, float aZ) { + // TODO Auto-generated method stub + return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + // TODO Auto-generated method stub + return super.getServerGUI(aID, aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + // TODO Auto-generated method stub + super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + @Override + public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { + return false; + } + + @Override + public void onExplosion() { + // TODO Auto-generated method stub + super.onExplosion(); + } + + @Override + public void startProcess() { + this.sendLoopStart((byte) 1); + } + + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 1) { + GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(212)), 10, 1.0F, aX, aY, + aZ); + } + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java index a6d9f7e7e1..b846a21a8c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java @@ -1,61 +1,296 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; -import java.util.Collection; - +import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine_GT_Recipe; import gregtech.api.util.Recipe_GT; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.fluid.FluidUtils; +import gtPlusPlus.core.item.base.cell.BaseItemCell; +import gtPlusPlus.core.material.Material; +import gtPlusPlus.core.util.array.ArrayUtils; import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntity_BasicWasher; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntity_CompactFusionReactor; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; public class GregtechMiniRaFusion { public static void run() { - //if (CORE.ConfigSwitches.enableMachine_SimpleWasher){ - generateSlowFusionRecipes(); - // Register the Simple Fusion Entity. - GregtechItemList.Miniature_Fusion - .set(new GregtechMetaTileEntity_CompactFusionReactor(993, "simplefusion.tier.00", "Ra, Sun God - Mk I", 6) - .getStackForm(1L)); - //} + //generateSlowFusionRecipes(); + // Register the Simple Fusion Entity. + //GregtechItemList.Miniature_Fusion.set(new GregtechMetaTileEntity_CompactFusionReactor(993, "simplefusion.tier.00", "Ra, Sun God - Mk I", 6).getStackForm(1L)); + GregtechItemList.Miniature_Fusion.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(993, "basicmachine.simplefusion.tier.01", "MÃmir", 8, "Universal Machine for Knowledge and Wisdom", Recipe_GT.Gregtech_Recipe_Map.sSlowFusion2Recipes, 2, 9, 64000, 0, 1, "Dehydrator.png", (String) GregTech_API.sSoundList.get(Integer.valueOf(208)), false, false, 0, "EXTRUDER", new Object[]{"CCE", "XMP", "CCE", 'M', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL, 'X', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.SENSOR, 'E', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.STICK_ELECTROMAGNETIC, 'P', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, 'C', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.FIELD_GENERATOR}).getStackForm(1L)); + run2(); + Logger.INFO("[Pocket Fusion] Generated "+mRecipeCount+" recipes for the Pocket Fusion Reactor."); + + } - private static boolean generateSlowFusionRecipes(){ - int mRecipeCount = 0; - GT_Recipe_Map r = GT_Recipe.GT_Recipe_Map.sFusionRecipes; - final Collection<GT_Recipe> x = r.mRecipeList; - Logger.INFO("Dumping " + r.mUnlocalizedName + " Recipes for Debug."); - for (final GT_Recipe newBo : x) { - if (Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes.addRecipe( - true, - newBo.mInputs, - newBo.mOutputs, - newBo.mSpecialItems, - newBo.mFluidInputs.clone(), //Fluid In - newBo.mFluidOutputs.clone(), //Fluid Out - newBo.mDuration*4, //Duration - newBo.mEUt, //Eu - newBo.mSpecialValue //Special - ) != null){ - mRecipeCount++; + private static boolean run2() { + addFusionReactorRecipe(Materials.Lithium, (16), Materials.Tungsten, (16), Materials.Iridium, (16), 32, 32768, 300000000); + addFusionReactorRecipe(Materials.Deuterium, (125), Materials.Tritium, (125), Materials.Helium.getPlasma(125), 16, 4096, 40000000); //Mark 1 Cheap // + addFusionReactorRecipe(Materials.Deuterium, (125), Materials.Helium_3, (125), Materials.Helium.getPlasma(125), 16, 2048, 60000000); //Mark 1 Expensive // + addFusionReactorRecipe(Materials.Carbon, (125), Materials.Helium_3, (125), Materials.Oxygen.getPlasma(125), 32, 4096, 80000000); //Mark 1 Expensive // + addFusionReactorRecipe(Materials.Aluminium, (16), Materials.Lithium, (16), Materials.Sulfur.getPlasma(125), 32, 10240, 240000000); //Mark 2 Cheap + addFusionReactorRecipe(Materials.Beryllium, (16), Materials.Deuterium, (375), Materials.Nitrogen.getPlasma(175), 16, 16384, 180000000); //Mark 2 Expensive // + addFusionReactorRecipe(Materials.Silicon, (16), Materials.Magnesium, (16), Materials.Iron.getPlasma(125), 32, 8192, 360000000); //Mark 3 Cheap // + addFusionReactorRecipe(Materials.Potassium, (16), Materials.Fluorine, (125), Materials.Nickel.getPlasma(125), 16, 32768, 480000000); //Mark 3 Expensive // + addFusionReactorRecipe(Materials.Beryllium, (16), Materials.Tungsten, (16), Materials.Platinum, (16), 32, 32768, 150000000); // + addFusionReactorRecipe(Materials.Neodymium, (16), Materials.Hydrogen, (48), Materials.Europium, (16), 64, 24576, 150000000); // + addFusionReactorRecipe(Materials.Lutetium, (16), Materials.Chrome, (16), Materials.Americium, (16), 96, 49152, 200000000); // + addFusionReactorRecipe(Materials.Plutonium, (16), Materials.Thorium, (16), Materials.Naquadah, (16), 64, 32768, 300000000); // + addFusionReactorRecipe(Materials.Americium, (16), Materials.Naquadria, (16), Materials.Neutronium, (1), 1200, 98304, 600000000); // + + addFusionReactorRecipe(Materials.Tungsten, (16), Materials.Helium, (16), Materials.Osmium, (16), 64, 24578, 150000000); // + addFusionReactorRecipe(Materials.Manganese, (16), Materials.Hydrogen, (16), Materials.Iron, (16), 64, 8192, 120000000); // + addFusionReactorRecipe(Materials.Mercury, (16), Materials.Magnesium, (16), Materials.Uranium, (16), 64, 49152, 240000000); // + addFusionReactorRecipe(Materials.Gold, (16), Materials.Aluminium, (16), Materials.Uranium, (16), 64, 49152, 240000000); // + addFusionReactorRecipe(Materials.Uranium, (16), Materials.Helium, (16), Materials.Plutonium, (16), 128, 49152, 480000000); // + addFusionReactorRecipe(Materials.Vanadium, (16), Materials.Hydrogen, (125), Materials.Chrome, (16), 64, 24576, 140000000); // + addFusionReactorRecipe(Materials.Gallium, (16), Materials.Radon, (125), Materials.Duranium, (16), 64, 16384, 140000000); // + addFusionReactorRecipe(Materials.Titanium, (48), Materials.Duranium, (32), Materials.Tritanium, (16), 64, 32768, 200000000); // + addFusionReactorRecipe(Materials.Gold, (16), Materials.Mercury, (16), Materials.Radon, (125), 64, 32768, 200000000); // + addFusionReactorRecipe(Materials.Tantalum, (16), Materials.Tritium, (16), Materials.Tungsten, (16), 16, 24576, 200000000); // + addFusionReactorRecipe(Materials.Silver, (16), Materials.Lithium, (16), Materials.Indium, (16), 32, 24576, 380000000); // + addFusionReactorRecipe(Materials.NaquadahEnriched, (15), Materials.Radon, (125), Materials.Naquadria, (3), 64, 49152, 400000000); // + + if (mRecipeCount > 0) + return true; + return false; + } + + private static void addFusionReactorRecipe(Materials molten, int amnt, Materials gas, int amnt2, FluidStack plasma, int i, int j, int k) { + Materials Fusion[] = new Materials[2]; + int amount[] = new int[2]; + int emptyAmount = 0; + + Fusion[0] = molten; + amount[0] = amnt; + Fusion[1] = gas; + amount[1] = amnt2; + + ItemStack[] inputs = new ItemStack[9]; + ItemStack[][] temp = new ItemStack[2][9]; + for (int r=0;r<2;r++) { + ItemStack tempCell; + ItemStack cellsA = null; + ItemStack cellsB = null; + ItemStack cellsC = null; + + if (Fusion[r].getCells(1) == null) { + Logger.INFO("[Pocket Fusion] Error trying to get a cell of "+MaterialUtils.getMaterialName(Fusion[r])+", using backup method."); + Material ju = MaterialUtils.generateMaterialFromGtENUM(Fusion[r]); + ItemStack htng = ju.getCell(1); + if (htng == null) { + Logger.INFO("[Pocket Fusion] Error trying to get a cell of "+MaterialUtils.getMaterialName(Fusion[r])+", failed using backup method."); + new BaseItemCell(ju); + tempCell = ItemUtils.getItemStackOfAmountFromOreDict("cell"+MaterialUtils.getMaterialName(Fusion[r]), 1); + //continue; + } + else { + tempCell = htng; } } - - - - if (Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes.mRecipeList.size() > mRecipeCount){ - return true; + else { + tempCell = Fusion[r].getCells(1); + } + + if (amount[r] <= 64) { + cellsA = ItemUtils.getSimpleStack(tempCell, amount[r]); + temp[r][0] = cellsA; + } + else if (amount[r] > 64 && amount[r] <= 128) { + cellsA = ItemUtils.getSimpleStack(tempCell, 64); + cellsB = ItemUtils.getSimpleStack(tempCell, amount[r]-64); + temp[r][0] = cellsA; + temp[r][1] = cellsB; + } + else if (amount[r] > 128 && amount[r] <= 192) { + cellsA = ItemUtils.getSimpleStack(tempCell, 64); + cellsA = ItemUtils.getSimpleStack(tempCell, 64); + cellsA = ItemUtils.getSimpleStack(tempCell, amount[r]-128); + temp[r][0] = cellsA; + temp[r][1] = cellsB; + temp[r][2] = cellsC; + } + emptyAmount += amount[r]; + } + + //Build Clean Stacks + int index = 0; + for (int r=0;r<2;r++) { + for (int g=0;g<9;g++) { + if (temp[r][g] != null) { + inputs[(r == 0 ? index++ : (3+index++))] = temp[r][g]; + } + } + } + + ItemStack[] outputCells = new ItemStack[9]; + int tempInt = emptyAmount; + int tempCounter = 0; + while (tempInt > 0) { + if (tempInt >= 64) { + outputCells[tempCounter++] = ItemUtils.getEmptyCell(64); + tempInt -= 64; + } + else { + outputCells[tempCounter++] = ItemUtils.getEmptyCell(tempInt); + tempInt -= tempInt; + } + } + + ItemStack[] cleanOutput = ArrayUtils.removeNulls(outputCells); + + FluidStack bigPlasma = plasma.copy(); + bigPlasma.amount = plasma.amount*1000; + + if (bigPlasma.amount > 32000) { + Logger.INFO("[Pocket Fusion] Generated recipe for "+plasma.getLocalizedName()+" had incorrect output."); + } + + if (Recipe_GT.Gregtech_Recipe_Map.sSlowFusion2Recipes.addRecipe( + true, + inputs, + cleanOutput, + null, + null, //Fluid In + new FluidStack[] {bigPlasma}, //Fluid Out + i*8, //Duration + j, //Eu + k //Special + ) != null){ + mRecipeCount++; + } + } + + + public static int mRecipeCount = 0; + private static void addFusionReactorRecipe(Materials molten, int amnt, Materials gas, int amnt2, Materials output, int amnt3, int i, int j, int k) { + Materials Fusion[] = new Materials[3]; + int amount[] = new int[3]; + int emptyAmount = 0; + int outputCells = 0; + + Fusion[0] = molten; + amount[0] = amnt; + Fusion[1] = gas; + amount[1] = amnt2; + Fusion[2] = output; + amount[2] = amnt3; + + ItemStack[] inputs = new ItemStack[9]; + ItemStack[][] temp = new ItemStack[3][9]; + ItemStack[] outputs = new ItemStack[9]; + for (int r=0;r<3;r++) { + ItemStack cellsA = null; + ItemStack cellsB = null; + ItemStack cellsC = null; + ItemStack tempCell; + + if (Fusion[r].getCells(1) == null) { + Logger.INFO("[Pocket Fusion] Error trying to get a cell of "+MaterialUtils.getMaterialName(Fusion[r])+", using backup method."); + Material ju = MaterialUtils.generateMaterialFromGtENUM(Fusion[r]); + ItemStack htng = ju.getCell(1); + if (htng == null) { + Logger.INFO("[Pocket Fusion] Error trying to get a cell of "+MaterialUtils.getMaterialName(Fusion[r])+", failed using backup method."); + new BaseItemCell(ju); + tempCell = ItemUtils.getItemStackOfAmountFromOreDict("cell"+MaterialUtils.getMaterialName(Fusion[r]), 1); + //continue; + } + else { + tempCell = htng; + } + } + else { + tempCell = Fusion[r].getCells(1); + } + + if (amount[r] <= 64) { + cellsA = ItemUtils.getSimpleStack(tempCell, amount[r]); + temp[r][0] = cellsA; + } + else if (amount[r] > 64 && amount[r] <= 128) { + cellsA = ItemUtils.getSimpleStack(tempCell, 64); + cellsB = ItemUtils.getSimpleStack(tempCell, amount[r]-64); + temp[r][0] = cellsA; + temp[r][1] = cellsB; + } + else if (amount[r] > 128 && amount[r] <= 192) { + cellsA = ItemUtils.getSimpleStack(tempCell, 64); + cellsA = ItemUtils.getSimpleStack(tempCell, 64); + cellsA = ItemUtils.getSimpleStack(tempCell, amount[r]-128); + temp[r][0] = cellsA; + temp[r][1] = cellsB; + temp[r][2] = cellsC; + } + if (r< 2) { + emptyAmount += amount[r]; + } + else { + outputCells += amount[r]; + } + } + + //Build Clean Stacks + int index = 0; + for (int r=0;r<3;r++) { + for (int g=0;g<9;g++) { + if (temp[r][g] != null) { + if (r < 2) { + inputs[(r == 0 ? index++ : (3+index++))] = temp[r][g]; + } + else { + outputs[index++] = temp[r][g]; + } + } + } + } + + ItemStack[] outputEmptyCells = new ItemStack[9]; + int tempInt = emptyAmount-outputCells; + int tempCounter = 0; + while (tempInt > 0) { + if (tempInt >= 64) { + outputEmptyCells[tempCounter++] = ItemUtils.getEmptyCell(64); + tempInt -= 64; + } + else { + outputEmptyCells[tempCounter++] = ItemUtils.getEmptyCell(tempInt); + tempInt -= tempInt; + } + } + + ItemStack[] comboOutput = new ItemStack[9]; + int jhn = 0; + for (int b=0;b<9;b++) { + + if (outputs[b] != null) { + comboOutput[b] = outputs[b]; + jhn++; + } + else { + if (outputEmptyCells[(b-jhn)] != null) { + comboOutput[b] = outputEmptyCells[(b-jhn)]; + } + } + + } + + if (Recipe_GT.Gregtech_Recipe_Map.sSlowFusion2Recipes.addRecipe( + true, + inputs, + comboOutput, + null, + null, //Fluid In + null, //Fluid Out + i*16, //Duration + j, //Eu + k //Special + ) != null){ + mRecipeCount++; } - return false; } + } |