diff options
Diffstat (limited to 'src/main/java')
80 files changed, 1062 insertions, 5783 deletions
diff --git a/src/main/java/gregtech/api/util/GTPP_Recipe.java b/src/main/java/gregtech/api/util/GTPP_Recipe.java index f5bd29947d..9fd12eee05 100644 --- a/src/main/java/gregtech/api/util/GTPP_Recipe.java +++ b/src/main/java/gregtech/api/util/GTPP_Recipe.java @@ -682,11 +682,11 @@ public class GTPP_Recipe extends GT_Recipe { "temp4", null, "", + 1, 0, 0, 0, - 0, - 0, + 1, "", 0, "", diff --git a/src/main/java/gtPlusPlus/api/damage/DamageTeslaTower.java b/src/main/java/gtPlusPlus/api/damage/DamageTeslaTower.java deleted file mode 100644 index 0d9d4d5dc2..0000000000 --- a/src/main/java/gtPlusPlus/api/damage/DamageTeslaTower.java +++ /dev/null @@ -1,23 +0,0 @@ -package gtPlusPlus.api.damage; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.ChatComponentTranslation; -import net.minecraft.util.IChatComponent; - -import gtPlusPlus.core.world.damage.BaseCustomDamageSource; - -public class DamageTeslaTower extends BaseCustomDamageSource { - - public DamageTeslaTower(Entity transmitter) { - super("plasmabolt", transmitter, null); - this.setDamageBypassesArmor(); - this.setDamageIsAbsolute(); - } - - @Override - public IChatComponent func_151519_b(EntityLivingBase target) { - String s = "death.attack." + this.damageType; - return new ChatComponentTranslation(s, target.getCommandSenderName(), "Plasma"); - } -} diff --git a/src/main/java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java b/src/main/java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java deleted file mode 100644 index 24d2da3134..0000000000 --- a/src/main/java/gtPlusPlus/api/helpers/GregtechPlusPlus_API.java +++ /dev/null @@ -1,41 +0,0 @@ -package gtPlusPlus.api.helpers; - -import java.util.HashMap; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.api.util.SpecialBehaviourTooltipHandler; - -public class GregtechPlusPlus_API { - - public static class Multiblock_API { - - private static final HashMap<String, SpecialMultiBehaviour> mSpecialBehaviourItemMap = new HashMap<String, SpecialMultiBehaviour>(); - - /** - * Register a special behaviour for GT++ Multis to listen use. - * - * @param aBehaviour - An Object which has extended {@link SpecialMultiBehaviour}'s base implementation. - * @return - Did this behaviour register properly? - */ - public static boolean registerSpecialMultiBehaviour(SpecialMultiBehaviour aBehaviour) { - if (aBehaviour.getTriggerItem() == null || aBehaviour.getTriggerItemTooltip() == null - || aBehaviour.getTriggerItemTooltip().length() <= 0) { - Logger.INFO( - "Failed to attach custom multiblock logic to " - + ItemUtils.getItemName(aBehaviour.getTriggerItem())); - return false; - } - mSpecialBehaviourItemMap.put("UniqueKey_" + aBehaviour.hashCode(), aBehaviour); - SpecialBehaviourTooltipHandler - .addTooltipForItem(aBehaviour.getTriggerItem(), aBehaviour.getTriggerItemTooltip()); - Logger.INFO("Attached custom multiblock logic to " + ItemUtils.getItemName(aBehaviour.getTriggerItem())); - return true; - } - - public static final HashMap<String, SpecialMultiBehaviour> getSpecialBehaviourItemMap() { - return mSpecialBehaviourItemMap; - } - } -} diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoEUBonusMultiBehaviour.java b/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoEUBonusMultiBehaviour.java deleted file mode 100644 index b4ab2c9315..0000000000 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoEUBonusMultiBehaviour.java +++ /dev/null @@ -1,27 +0,0 @@ -package gtPlusPlus.api.objects.minecraft.multi; - -import net.minecraft.item.ItemStack; - -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; - -public class NoEUBonusMultiBehaviour extends SpecialMultiBehaviour { - - public NoEUBonusMultiBehaviour() { - // Used by other mods which may wish to not obtain bonus outputs on their Sifting or Maceration recipes. - } - - @Override - public ItemStack getTriggerItem() { - return GregtechItemList.Chip_MultiNerf_NoEuBonus.get(1); - } - - @Override - public String getTriggerItemTooltip() { - return "Prevents EU discounts on GT++ multiblocks when used"; - } - - @Override - public int getEUPercent() { - return 0; - } -} diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java b/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java deleted file mode 100644 index cea7e40a51..0000000000 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoOutputBonusMultiBehaviour.java +++ /dev/null @@ -1,27 +0,0 @@ -package gtPlusPlus.api.objects.minecraft.multi; - -import net.minecraft.item.ItemStack; - -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; - -public class NoOutputBonusMultiBehaviour extends SpecialMultiBehaviour { - - public NoOutputBonusMultiBehaviour() { - // Used by other mods which may wish to not obtain bonus outputs on their Sifting or Maceration recipes. - } - - @Override - public ItemStack getTriggerItem() { - return GregtechItemList.Chip_MultiNerf_NoOutputBonus.get(1); - } - - @Override - public String getTriggerItemTooltip() { - return "Prevents bonus output % on GT++ multiblocks when used"; - } - - @Override - public int getOutputChanceRoll() { - return 10000; - } -} diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoSpeedBonusMultiBehaviour.java b/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoSpeedBonusMultiBehaviour.java deleted file mode 100644 index cfe6afee66..0000000000 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/NoSpeedBonusMultiBehaviour.java +++ /dev/null @@ -1,27 +0,0 @@ -package gtPlusPlus.api.objects.minecraft.multi; - -import net.minecraft.item.ItemStack; - -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; - -public class NoSpeedBonusMultiBehaviour extends SpecialMultiBehaviour { - - public NoSpeedBonusMultiBehaviour() { - // Used by other mods which may wish to not obtain bonus outputs on their Sifting or Maceration recipes. - } - - @Override - public ItemStack getTriggerItem() { - return GregtechItemList.Chip_MultiNerf_NoSpeedBonus.get(1); - } - - @Override - public String getTriggerItemTooltip() { - return "Prevents speed bonuses on GT++ multiblocks when used"; - } - - @Override - public int getSpeedBonusPercent() { - return 0; - } -} diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java b/src/main/java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java deleted file mode 100644 index 94c87ab71b..0000000000 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/multi/SpecialMultiBehaviour.java +++ /dev/null @@ -1,45 +0,0 @@ -package gtPlusPlus.api.objects.minecraft.multi; - -import net.minecraft.item.ItemStack; - -import gregtech.api.util.GT_Utility; - -/** - * Extend this class to implement custom behaviour for multiblocks. The Trigger item when in a special slot or input - * bus, will cause the multiblock to behave as specified. Not overriding a method here will cause the default values to - * be used. - * - * @author Alkalus - * - */ -public abstract class SpecialMultiBehaviour { - - private final int mMaxParallelRecipes = Short.MIN_VALUE; - private final int mEUPercent = Short.MIN_VALUE; - private final int mSpeedBonusPercent = Short.MIN_VALUE; - private final int mOutputChanceRoll = Short.MIN_VALUE; - - public abstract ItemStack getTriggerItem(); - - public abstract String getTriggerItemTooltip(); - - public int getMaxParallelRecipes() { - return this.mMaxParallelRecipes; - } - - public int getEUPercent() { - return this.mEUPercent; - } - - public int getSpeedBonusPercent() { - return this.mSpeedBonusPercent; - } - - public int getOutputChanceRoll() { - return this.mOutputChanceRoll; - } - - public final boolean isTriggerItem(ItemStack aToMatch) { - return GT_Utility.areStacksEqual(getTriggerItem(), aToMatch, false); - } -} diff --git a/src/main/java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java b/src/main/java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java deleted file mode 100644 index be63f2d9fd..0000000000 --- a/src/main/java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java +++ /dev/null @@ -1,167 +0,0 @@ -package gtPlusPlus.core.client.renderer; - -import java.util.Random; - -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.entity.Entity; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.random.XSTR; -import gtPlusPlus.core.entity.EntityTeslaTowerLightning; - -@SideOnly(Side.CLIENT) -public class RenderPlasmaBolt extends Render { - - public RenderPlasmaBolt() { - Logger.INFO("[Render] Create custom lightning renderer."); - } - - /** - * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then - * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic - * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1, - * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. - */ - public void doRender(EntityTeslaTowerLightning p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, - float p_76986_8_, float p_76986_9_) { - Logger.INFO("Render Plasma. 1"); - Tessellator tessellator = Tessellator.instance; - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); - double[] adouble = new double[8]; - double[] adouble1 = new double[8]; - double d3 = 0.0D; - double d4 = 0.0D; - Random random = new XSTR(p_76986_1_.boltVertex); - - for (int i = 7; i >= 0; --i) { - adouble[i] = d3; - adouble1[i] = d4; - d3 += (double) (random.nextInt(11) - 5); - d4 += (double) (random.nextInt(11) - 5); - } - - for (int k1 = 0; k1 < 4; ++k1) { - Random random1 = new XSTR(p_76986_1_.boltVertex); - - for (int j = 0; j < 3; ++j) { - int k = 7; - int l = 0; - - if (j > 0) { - k = 7 - j; - } - - if (j > 0) { - l = k - 2; - } - - double d5 = adouble[k] - d3; - double d6 = adouble1[k] - d4; - - for (int i1 = k; i1 >= l; --i1) { - double d7 = d5; - double d8 = d6; - - if (j == 0) { - d5 += (double) (random1.nextInt(11) - 5); - d6 += (double) (random1.nextInt(11) - 5); - } else { - d5 += (double) (random1.nextInt(31) - 15); - d6 += (double) (random1.nextInt(31) - 15); - } - - tessellator.startDrawing(5); - float f2 = 0.5F; - tessellator.setColorRGBA_F(0.9F * f2, 0.9F * f2, 1.0F * f2, 0.3F); - double d9 = 0.1D + (double) k1 * 0.2D; - - if (j == 0) { - d9 *= (double) i1 * 0.1D + 1.0D; - } - - double d10 = 0.1D + (double) k1 * 0.2D; - - if (j == 0) { - d10 *= (double) (i1 - 1) * 0.1D + 1.0D; - } - - for (int j1 = 0; j1 < 5; ++j1) { - double d11 = p_76986_2_ + 0.5D - d9; - double d12 = p_76986_6_ + 0.5D - d9; - - if (j1 == 1 || j1 == 2) { - d11 += d9 * 2.0D; - } - - if (j1 == 2 || j1 == 3) { - d12 += d9 * 2.0D; - } - - double d13 = p_76986_2_ + 0.5D - d10; - double d14 = p_76986_6_ + 0.5D - d10; - - if (j1 == 1 || j1 == 2) { - d13 += d10 * 2.0D; - } - - if (j1 == 2 || j1 == 3) { - d14 += d10 * 2.0D; - } - - tessellator.addVertex(d13 + d5, p_76986_4_ + (double) (i1 * 16), d14 + d6); - tessellator.addVertex(d11 + d7, p_76986_4_ + (double) ((i1 + 1) * 16), d12 + d8); - } - - tessellator.draw(); - } - } - } - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. - */ - protected ResourceLocation getEntityTexture(EntityTeslaTowerLightning p_110775_1_) { - return null; - } - - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. - */ - @Override - protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - Logger.INFO("Render Plasma. 5"); - return this.getEntityTexture((EntityTeslaTowerLightning) p_110775_1_); - } - - /** - * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then - * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic - * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1, - * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. - */ - @Override - public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, - float p_76986_9_) { - Logger.INFO("Render Plasma. 2"); - this.doRender( - (EntityTeslaTowerLightning) p_76986_1_, - p_76986_2_, - p_76986_4_, - p_76986_6_, - p_76986_8_, - p_76986_9_); - } -} diff --git a/src/main/java/gtPlusPlus/core/config/ConfigHandler.java b/src/main/java/gtPlusPlus/core/config/ConfigHandler.java index fd8d317fe6..5d7a39c48f 100644 --- a/src/main/java/gtPlusPlus/core/config/ConfigHandler.java +++ b/src/main/java/gtPlusPlus/core/config/ConfigHandler.java @@ -51,7 +51,6 @@ import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_Industria import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialThermalCentrifuge; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialWashPlant; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IndustrialWireMill; -import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_IronBlastFurnace; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_LargeAutoCrafter; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_LiquidFluorideThoriumReactor; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableMultiblock_MatterFabricator; @@ -322,8 +321,6 @@ public class ConfigHandler { GregTech.ID, true, "Produces fine wire and exotic cables."); - enableMultiblock_IronBlastFurnace = config - .getBoolean("enableMultiblockIronBlastFurnace", GregTech.ID, true, "Skip the Bronze age, very slowly."); enableMultiblock_MatterFabricator = config .getBoolean("enableMultiblockMatterFabricator", GregTech.ID, true, "?FAB?RIC?ATE MA?TT?ER."); enableMultiblock_MultiTank = config.getBoolean( diff --git a/src/main/java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java b/src/main/java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java deleted file mode 100644 index 82615309b0..0000000000 --- a/src/main/java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java +++ /dev/null @@ -1,180 +0,0 @@ -package gtPlusPlus.core.entity; - -import java.util.List; -import java.util.Random; -import java.util.UUID; - -import net.minecraft.block.material.Material; -import net.minecraft.entity.Entity; -import net.minecraft.entity.effect.EntityWeatherEffect; -import net.minecraft.init.Blocks; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.MathHelper; -import net.minecraft.world.EnumDifficulty; -import net.minecraft.world.World; - -import gtPlusPlus.api.damage.DamageTeslaTower; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.random.XSTR; -import gtPlusPlus.core.util.minecraft.EntityUtils; - -public class EntityTeslaTowerLightning extends EntityWeatherEffect { - - /** Declares which state the lightning bolt is in. Whether it's in the air, hit the ground, etc. */ - private int lightningState; - /** A random long that is used to change the vertex of the lightning rendered in RenderLightningBolt */ - public long boltVertex; - /** - * Determines the time before the EntityLightningBolt is destroyed. It is a random integer decremented over time. - */ - private int boltLivingTime; - - private final UUID boltID; - private final UUID boltOwnerID; - - private final Entity boltValidDamageTarget; - - public EntityTeslaTowerLightning(World p_i1703_1_, double p_i1703_2_, double p_i1703_4_, double p_i1703_6_, - Entity valid, UUID owner) { - super(p_i1703_1_); - Logger.INFO("Plasma Bolt - Created."); - Random rand = new XSTR(p_i1703_1_.getSeed()); - this.setLocationAndAngles(p_i1703_2_, p_i1703_4_, p_i1703_6_, 0.0F, 0.0F); - this.lightningState = 2; - this.boltVertex = rand.nextLong(); - this.boltLivingTime = (1) + rand.nextInt(3) + 1; - this.boltValidDamageTarget = valid; - this.boltID = UUID.randomUUID(); - this.boltOwnerID = owner; - - // Puts fires out - if (!p_i1703_1_.isRemote && p_i1703_1_.getGameRules().getGameRuleBooleanValue("doFireTick") - && (p_i1703_1_.difficultySetting == EnumDifficulty.NORMAL - || p_i1703_1_.difficultySetting == EnumDifficulty.HARD) - && p_i1703_1_.doChunksNearChunkExist( - MathHelper.floor_double(p_i1703_2_), - MathHelper.floor_double(p_i1703_4_), - MathHelper.floor_double(p_i1703_6_), - 10)) { - Logger.INFO("Plasma Bolt - Putting out fires?."); - int i = MathHelper.floor_double(p_i1703_2_); - int j = MathHelper.floor_double(p_i1703_4_); - int k = MathHelper.floor_double(p_i1703_6_); - - if (p_i1703_1_.getBlock(i, j, k).getMaterial() == Material.fire) { - p_i1703_1_.setBlock(i, j, k, Blocks.air); - } - - for (i = 0; i < 4; ++i) { - j = MathHelper.floor_double(p_i1703_2_) + rand.nextInt(3) - 1; - k = MathHelper.floor_double(p_i1703_4_) + rand.nextInt(3) - 1; - int l = MathHelper.floor_double(p_i1703_6_) + rand.nextInt(3) - 1; - - if (p_i1703_1_.getBlock(j, k, l).getMaterial() == Material.fire) { - p_i1703_1_.setBlock(j, k, l, Blocks.air); - } - } - } - } - - /** - * Called to update the entity's position/logic. - */ - @Override - public void onUpdate() { - // Logger.INFO("Zap"); - super.onUpdate(); - Logger.INFO("Plasma Bolt - Tick."); - Random rand = new XSTR(this.worldObj.getSeed()); - - if (this.lightningState == 2) { - Logger.INFO("Plasma Bolt - Playing Sound."); - this.worldObj.playSoundEffect( - this.posX, - this.posY, - this.posZ, - "ambient.weather.thunder", - 10000.0F, - 0.8F + rand.nextFloat() * 0.2F); - } - --this.lightningState; - - if (this.lightningState >= 0) { - Logger.INFO("Plasma Bolt - state >= 0."); - if (this.worldObj.isRemote) { - Logger.INFO("Plasma Bolt - World is remote, resetting state to 2."); - this.worldObj.lastLightningBolt = 2; - } else { - Logger.INFO("Plasma Bolt - World is server side."); - double d0 = 3.0D; - List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity( - this, - AxisAlignedBB.getBoundingBox( - this.posX - d0, - this.posY - d0, - this.posZ - d0, - this.posX + d0, - this.posY + 6.0D + d0, - this.posZ + d0)); - - for (int l = 0; l < list.size(); ++l) { - Entity entity = list.get(l); - if (this.boltValidDamageTarget.getUniqueID().equals(entity.getUniqueID())) { - if (!entity.getUniqueID().equals(boltOwnerID)) { - Logger.INFO("Plasma Bolt - Hurting Entity."); - Logger.INFO("Plasma Bolt - " + entity.getCommandSenderName() + "."); - // if (!net.minecraftforge.event.ForgeEventFactory.onEntityStruckByLightning(entity, this)) - EntityUtils.doFireDamage(entity, 5); - EntityUtils.doDamage(entity, new DamageTeslaTower(entity), 20); - } - } - } - } - } - - if (this.lightningState < 0) { - Logger.INFO("Plasma Bolt - state < 0."); - if (this.boltLivingTime == 0) { - Logger.INFO("Plasma Bolt - setting dead."); - this.setDead(); - } else if (this.lightningState < -rand.nextInt(10)) { - Logger.INFO("Plasma Bolt - dunno."); - --this.boltLivingTime; - this.lightningState = 1; - this.boltVertex = rand.nextLong(); - // Puts fires out. - if (!this.worldObj.isRemote && this.worldObj.getGameRules().getGameRuleBooleanValue("doFireTick") - && this.worldObj.doChunksNearChunkExist( - MathHelper.floor_double(this.posX), - MathHelper.floor_double(this.posY), - MathHelper.floor_double(this.posZ), - 10)) { - Logger.INFO("Plasma Bolt - Putting fires out [2]."); - int i = MathHelper.floor_double(this.posX); - int j = MathHelper.floor_double(this.posY); - int k = MathHelper.floor_double(this.posZ); - - if (this.worldObj.getBlock(i, j, k).getMaterial() == Material.fire) { - this.worldObj.setBlock(i, j, k, Blocks.air); - } - } - } - } - } - - @Override - protected void entityInit() {} - - /** - * (abstract) Protected helper method to read subclass entity data from NBT. - */ - @Override - protected void readEntityFromNBT(NBTTagCompound p_70037_1_) {} - - /** - * (abstract) Protected helper method to write subclass entity data to NBT. - */ - @Override - protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {} -} diff --git a/src/main/java/gtPlusPlus/core/entity/InternalEntityRegistry.java b/src/main/java/gtPlusPlus/core/entity/InternalEntityRegistry.java index e4f82ea80e..1254d9bdff 100644 --- a/src/main/java/gtPlusPlus/core/entity/InternalEntityRegistry.java +++ b/src/main/java/gtPlusPlus/core/entity/InternalEntityRegistry.java @@ -83,8 +83,6 @@ public class InternalEntityRegistry { Utils.rgbtoHexValue(20, 200, 20), Utils.rgbtoHexValue(20, 20, 20)); - // EntityRegistry.registerGlobalEntityID(EntitySickBlaze.class, "sickBlaze", - // EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(0, 75, 0), Utils.rgbtoHexValue(75, 175, 75)); EntityRegistry .registerModEntity(EntitySickBlaze.class, "sickBlaze", mEntityID++, GTplusplus.instance, 64, 20, true); ItemCustomSpawnEgg.registerEntityForSpawnEgg( @@ -93,18 +91,6 @@ public class InternalEntityRegistry { Utils.rgbtoHexValue(40, 180, 40), Utils.rgbtoHexValue(75, 75, 75)); - // EntityRegistry.registerGlobalEntityID(EntityTeslaTowerLightning.class, "plasmaBolt", - // EntityRegistry.findGlobalUniqueEntityId(), Utils.rgbtoHexValue(255, 0, 0), Utils.rgbtoHexValue(125, 125, - // 125)); - EntityRegistry.registerModEntity( - EntityTeslaTowerLightning.class, - "plasmaBolt", - mEntityID++, - GTplusplus.instance, - 64, - 5, - true); - EntityRegistry.registerModEntity( EntityThrowableBomb.class, "EntityThrowableBomb", diff --git a/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index 0d8c9fc529..8e9a1ca330 100644 --- a/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/main/java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -72,7 +72,6 @@ import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialFishPond import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialFluidHeater; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialForgeHammer; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialFuelRefinery; -import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialGeneratorArray; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialMacerator; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialMassFabricator; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialMixer; @@ -84,7 +83,6 @@ import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialThermalC import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialTreeFarm; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialWashPlant; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialWiremill; -import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIronBlastFurnace; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIsaMill; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechLFTR; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechLargeTurbinesAndHeatExchanger; @@ -103,7 +101,6 @@ import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSolarTower; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSteamCondenser; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSteamMultis; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSuperChests; -import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechTeslaTower; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechThaumcraftDevices; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechThreadedBuffers; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechTieredChunkloaders; @@ -152,7 +149,6 @@ public class COMPAT_HANDLER { GregtechNuclearSaltProcessingPlant.run(); GregtechSteamCondenser.run(); GregtechSafeBlock.run(); - GregtechIronBlastFurnace.run(); GregtechIndustrialCentrifuge.run(); GregtechIndustrialCokeOven.run(); GregtechIndustrialPlatePress.run(); @@ -183,9 +179,7 @@ public class COMPAT_HANDLER { GregtechIndustrialWashPlant.run(); GregtechSemiFluidgenerators.run(); GregtechWirelessChargers.run(); - GregtechIndustrialGeneratorArray.run(); GregtechIndustrialCuttingFactory.run(); - GregtechTeslaTower.run(); GregtechSuperChests.run(); GregtechIndustrialFishPond.run(); GregtechTieredChunkloaders.run(); diff --git a/src/main/java/gtPlusPlus/core/lib/CORE.java b/src/main/java/gtPlusPlus/core/lib/CORE.java index b846434665..bec7c04c56 100644 --- a/src/main/java/gtPlusPlus/core/lib/CORE.java +++ b/src/main/java/gtPlusPlus/core/lib/CORE.java @@ -185,7 +185,6 @@ public class CORE { public static boolean enableMultiblock_IndustrialMacerationStack = true; public static boolean enableMultiblock_IndustrialPlatePress = true; public static boolean enableMultiblock_IndustrialWireMill = true; - public static boolean enableMultiblock_IronBlastFurnace = true; public static boolean enableMultiblock_MatterFabricator = true; public static boolean enableMultiblock_MultiTank = true; public static boolean enableMultiblock_PowerSubstation = true; diff --git a/src/main/java/gtPlusPlus/core/proxy/ClientProxy.java b/src/main/java/gtPlusPlus/core/proxy/ClientProxy.java index 65c25f9f1f..e6c441d4e8 100644 --- a/src/main/java/gtPlusPlus/core/proxy/ClientProxy.java +++ b/src/main/java/gtPlusPlus/core/proxy/ClientProxy.java @@ -43,14 +43,12 @@ import gtPlusPlus.core.client.renderer.RenderBatKing; import gtPlusPlus.core.client.renderer.RenderDecayChest; import gtPlusPlus.core.client.renderer.RenderGiantChicken; import gtPlusPlus.core.client.renderer.RenderMiningExplosivesPrimed; -import gtPlusPlus.core.client.renderer.RenderPlasmaBolt; import gtPlusPlus.core.client.renderer.RenderSickBlaze; import gtPlusPlus.core.client.renderer.RenderStaballoyConstruct; import gtPlusPlus.core.client.renderer.RenderToxinball; import gtPlusPlus.core.common.CommonProxy; import gtPlusPlus.core.common.compat.COMPAT_PlayerAPI; import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; -import gtPlusPlus.core.entity.EntityTeslaTowerLightning; import gtPlusPlus.core.entity.monster.EntityBatKing; import gtPlusPlus.core.entity.monster.EntityGiantChickenBase; import gtPlusPlus.core.entity.monster.EntitySickBlaze; @@ -152,7 +150,6 @@ public class ClientProxy extends CommonProxy implements Runnable { RenderingRegistry.registerEntityRenderingHandler( EntityHydrofluoricAcidPotion.class, new RenderSnowball(ModItems.itemHydrofluoricPotion)); - RenderingRegistry.registerEntityRenderingHandler(EntityTeslaTowerLightning.class, new RenderPlasmaBolt()); RenderingRegistry.registerEntityRenderingHandler( EntityGiantChickenBase.class, new RenderGiantChicken(new ModelGiantChicken(), 1f)); diff --git a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java index f8c673de6c..6a738158de 100644 --- a/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/main/java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -499,17 +499,6 @@ public class RECIPES_Machines { } } - private static void multiGeneratorArray() { - - GT_ModHandler.addCraftingRecipe( - GregtechItemList.Generator_Array_Controller.get(1L), - CI.bitsd, - new Object[] { "CTC", "FMF", "CBC", 'M', CI.getTieredGTPPMachineCasing(4, 1), 'B', - OrePrefixes.pipeHuge.get(Materials.StainlessSteel), 'C', - OrePrefixes.circuit.get(Materials.Data), 'F', ItemList.Electric_Pump_EV, 'T', - CI.getSensor(4, 1) }); - } - private static void multiForgeHammer() { CORE.RA.addSixSlotAssemblingRecipe( @@ -1227,54 +1216,6 @@ public class RECIPES_Machines { 20 * 60, 120); - if (CORE.ConfigSwitches.enableMultiblock_IronBlastFurnace) { - - RECIPE_IronBlastFurnace = GregtechItemList.Machine_Iron_BlastFurnace.get(1); - RECIPE_IronPlatedBricks = GregtechItemList.Casing_IronPlatedBricks.get(1); - - // Iron BF - RecipeUtils.addShapedGregtechRecipe( - "plateDoubleAnyIron", - "craftingFurnace", - "plateDoubleAnyIron", - boiler_Coal, - CI.machineCasing_ULV, - boiler_Coal, - "plateDoubleAnyIron", - "bucketLava", - "plateDoubleAnyIron", - RECIPE_IronBlastFurnace); - // Iron plated Bricks - RecipeUtils.addShapedGregtechRecipe( - "plateAnyIron", - RECIPES_Tools.craftingToolHardHammer, - "plateAnyIron", - "plateAnyIron", - blockBricks, - "plateAnyIron", - "plateAnyIron", - RECIPES_Tools.craftingToolWrench, - "plateAnyIron", - RECIPE_IronPlatedBricks); - - // Add recycle recipes for the Iron Plated Bricks - // GT_ModHandler.addPulverisationRecipe(RECIPE_IronPlatedBricks, - // ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustIron", 6), - // ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustClay", 2), true); - CORE.RA.addPulverisationRecipe( - RECIPE_IronPlatedBricks, - ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustIron", 6), - ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustClay", 2), - null); - GT_Values.RA.addArcFurnaceRecipe( - RECIPE_IronPlatedBricks, - new ItemStack[] { ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotWroughtIron", 6), - ItemUtils.getItemStackOfAmountFromOreDictNoBroken("dustAsh", 2) }, - new int[] { 0 }, - 32 * 20, - 32); - } - if (CORE.ConfigSwitches.enableMultiblock_IndustrialCentrifuge) { // Industrial Centrifuge RECIPE_IndustrialCentrifugeController = GregtechItemList.Industrial_Centrifuge.get(1); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index efddb59ffb..370b286957 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -22,11 +22,7 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gregtech.common.items.behaviors.Behaviour_DataOrb; -import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.minecraft.multi.NoEUBonusMultiBehaviour; -import gtPlusPlus.api.objects.minecraft.multi.NoOutputBonusMultiBehaviour; -import gtPlusPlus.api.objects.minecraft.multi.NoSpeedBonusMultiBehaviour; import gtPlusPlus.core.handler.COMPAT_HANDLER; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; @@ -98,11 +94,6 @@ public class HANDLER_GT { // Register custom singles to the PA AddCustomMachineToPA.register(); - // Register the No-Bonus Special Behaviour. - Multiblock_API.registerSpecialMultiBehaviour(new NoOutputBonusMultiBehaviour()); - Multiblock_API.registerSpecialMultiBehaviour(new NoSpeedBonusMultiBehaviour()); - Multiblock_API.registerSpecialMultiBehaviour(new NoEUBonusMultiBehaviour()); - // Register some custom recipe maps for any enabled multiblocks. // MultiblockRecipeMapHandler.run(); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index d1c8504e88..f7fc2712ce 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -209,11 +209,6 @@ public enum GregtechItemList implements GregtechItemContainer { Distillus_Upgrade_Chip, Maceration_Upgrade_Chip, - // Chips used to nerf my multis via custom behavioural attachments - Chip_MultiNerf_NoOutputBonus, - Chip_MultiNerf_NoSpeedBonus, - Chip_MultiNerf_NoEuBonus, - // Milling Balls Milling_Ball_Alumina, Milling_Ball_Soapstone, @@ -237,7 +232,6 @@ public enum GregtechItemList implements GregtechItemContainer { GTPP_Casing_MAX, // IronBlastFurnace Machine_Bronze_BlastFurnace - Machine_Iron_BlastFurnace, Casing_IronPlatedBricks, // Large Centrifuge @@ -363,17 +357,10 @@ public enum GregtechItemList implements GregtechItemContainer { Industrial_WashPlant, Casing_WashPlant, - // Generator Array - Generator_Array_Controller, - // Cutting Factory Controller Industrial_CuttingFactoryController, Casing_CuttingFactoryFrame, - // Tesla Tower - TelsaTower, - Casing_TeslaTower, - // Large Extruder Industrial_Extruder, Casing_Extruder, diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 9a2d6e7d81..f9af7d29a1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -7,7 +7,6 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map.Entry; @@ -27,7 +26,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; 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; @@ -59,6 +57,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ExtendedPowerMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; @@ -73,8 +72,6 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Outpu import gregtech.api.objects.GT_ItemStack; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_OverclockCalculator; -import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; @@ -82,13 +79,8 @@ import gregtech.api.util.IGT_HatchAdder; import gregtech.common.items.GT_MetaGenerated_Tool_01; import gtPlusPlus.GTplusplus; import gtPlusPlus.GTplusplus.INIT_PHASE; -import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour; -import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -112,7 +104,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex public static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true; public GT_Recipe mLastRecipe; - private boolean mInternalCircuit = false; protected long mTotalRunTime = 0; public ArrayList<GT_MetaTileEntity_Hatch_ControlCore> mControlCoreBus = new ArrayList<>(); @@ -126,9 +117,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex public ArrayList<GT_MetaTileEntity_Hatch> mAllEnergyHatches = new ArrayList<>(); public ArrayList<GT_MetaTileEntity_Hatch> mAllDynamoHatches = new ArrayList<>(); - // Custom Behaviour Map - private static final HashMap<String, SpecialMultiBehaviour> mCustomBehviours = new HashMap<>(); - public GregtechMeta_MultiBlockBase(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } @@ -153,9 +141,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex return this.mTotalRunTime; } - protected float batchMultiplier = 1.0f; - protected static final int MAX_BATCH_SIZE = 128; - public abstract String getMachineType(); public String getMachineTooltip() { @@ -301,13 +286,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex } mInfo.add( - StatCollector.translateToLocal("GTPP.CC.discount") + ": " - + EnumChatFormatting.GREEN - + (getEuDiscountForParallelism()) - + EnumChatFormatting.RESET - + "%"); - - mInfo.add( StatCollector.translateToLocal("GTPP.CC.parallel") + ": " + EnumChatFormatting.GREEN + (getMaxParallelRecipes()) @@ -407,14 +385,8 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex public static final String TAG_HIDE_POLLUTION = "TAG_HIDE_POLLUTION"; public static final String TAG_HIDE_MACHINE_TYPE = "TAG_HIDE_MACHINE_TYPE"; - public int getAmountOfOutputs() { - return 1; - } - public abstract int getMaxParallelRecipes(); - public abstract int getEuDiscountForParallelism(); - @Override public boolean isCorrectMachinePart(final ItemStack paramItemStack) { return true; @@ -430,22 +402,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex return false; } - @Override - public void startSoundLoop(final byte aIndex, final double aX, final double aY, final double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1) { - GT_Utility.doSoundAtClient(new ResourceLocation(getSound()), 10, 1.0F, aX, aY, aZ); - } - } - - public void startProcess() { - if (GT_Utility.isStringValid(getSound())) this.sendLoopStart((byte) 1); - } - - public String getSound() { - return ""; - } - /** * A Static {@link Method} object which holds the current status of logging. */ @@ -461,58 +417,10 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex } } - public boolean checkRecipeGeneric() { - return checkRecipeGeneric(1, 100, 0); - } - - public boolean checkRecipeGeneric(int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent) { - return checkRecipeGeneric(aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, 10000); - } - - public boolean checkRecipeGeneric(int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent, - int aOutputChanceRoll) { - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - return checkRecipeGeneric( - tItemInputs, - tFluidInputs, - aMaxParallelRecipes, - aEUPercent, - aSpeedBonusPercent, - aOutputChanceRoll); - } - - public boolean checkRecipeGeneric(GT_Recipe aRecipe, int aMaxParallelRecipes, long aEUPercent, - int aSpeedBonusPercent, int aOutputChanceRoll) { - if (aRecipe == null) { - return false; - } - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - return checkRecipeGeneric( - tItemInputs, - tFluidInputs, - aMaxParallelRecipes, - aEUPercent, - aSpeedBonusPercent, - aOutputChanceRoll, - aRecipe); - } - - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - return checkRecipeGeneric( - aItemInputs, - aFluidInputs, - aMaxParallelRecipes, - aEUPercent, - aSpeedBonusPercent, - aOutputChanceRoll, - null); + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(GT_Utility.roundDownVoltage(this.getMaxInputVoltage())); + logic.setAvailableAmperage(1L); } public long getMaxInputEnergy() { @@ -526,319 +434,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex return rEnergy; } - public boolean hasPerfectOverclock() { - return false; - } - - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - - GT_Recipe tRecipe = findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - return false; - } - - /* - * Check for Special Behaviours - */ - - // First populate the map if we need to. - if (mCustomBehviours.isEmpty()) { - mCustomBehviours.putAll(Multiblock_API.getSpecialBehaviourItemMap()); - } - - // We have a special slot object in the recipe - if (tRecipe.mSpecialItems != null) { - // The special slot is an item - if (tRecipe.mSpecialItems instanceof ItemStack) { - // Make an Itemstack instance of this. - ItemStack aSpecialStack = (ItemStack) tRecipe.mSpecialItems; - // Check if this item is in an input bus. - boolean aDidFindMatch = false; - for (ItemStack aInputItemsToCheck : aItemInputs) { - // If we find a matching stack, continue. - if (GT_Utility.areStacksEqual(aSpecialStack, aInputItemsToCheck, false)) { - // Iterate all special behaviour items, to see if we need to utilise one. - aDidFindMatch = true; - break; - } - } - // Try to prevent needless iteration loops if we don't have the required inputs at all. - if (aDidFindMatch) { - // Iterate all special behaviour items, to see if we need to utilise one. - for (SpecialMultiBehaviour aBehaviours : mCustomBehviours.values()) { - // Found a match, let's adjust this recipe now. - if (aBehaviours.isTriggerItem(aSpecialStack)) { - // Adjust this recipe to suit special item - aMaxParallelRecipes = aBehaviours.getMaxParallelRecipes(); - aEUPercent = aBehaviours.getEUPercent(); - aSpeedBonusPercent = aBehaviours.getSpeedBonusPercent(); - aOutputChanceRoll = aBehaviours.getOutputChanceRoll(); - break; - } - } - } - } - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setEUtModifier(aEUPercent / 100.0f).setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; - } - - /* - * Here we handle recipe boosting, which grants additional output %'s to recipes that do not have 100%. - */ - - private boolean mHasBoostedCurrentRecipe = false; - private GT_Recipe mBoostedRecipe = null; - private ItemStack[] mInputVerificationForBoosting = null; - - /** - * Does this machine boost it's output? - * - * @return - if true, gives additional % to output chances. - */ - protected boolean doesMachineBoostOutput() { - return false; - } - - private int boostOutput(int aAmount) { - if (aAmount <= 0) { - return 10000; - } - if (aAmount <= 250) { - aAmount += MathUtils.randInt(Math.max(aAmount / 2, 1), aAmount * 2); - } else if (aAmount <= 500) { - aAmount += MathUtils.randInt(Math.max(aAmount / 2, 1), aAmount * 2); - } else if (aAmount <= 750) { - aAmount += MathUtils.randInt(Math.max(aAmount / 2, 1), aAmount * 2); - } else if (aAmount <= 1000) { - aAmount = (aAmount * 2); - } else if (aAmount <= 1500) { - aAmount = (aAmount * 2); - } else if (aAmount <= 2000) { - aAmount = (int) (aAmount * 1.5); - } else if (aAmount <= 3000) { - aAmount = (int) (aAmount * 1.5); - } else if (aAmount <= 4000) { - aAmount = (int) (aAmount * 1.2); - } else if (aAmount <= 5000) { - aAmount = (int) (aAmount * 1.2); - } else if (aAmount <= 7000) { - aAmount = (int) (aAmount * 1.2); - } else if (aAmount <= 9000) { - aAmount = (int) (aAmount * 1.1); - } - return Math.min(10000, aAmount); - } - - public GT_Recipe generateAdditionalOutputForRecipe(GT_Recipe aRecipe) { - AutoMap<Integer> aNewChances = new AutoMap<>(); - for (int chance : aRecipe.mChances) { - aNewChances.put(boostOutput(chance)); - } - GT_Recipe aClone = aRecipe.copy(); - int[] aTemp = new int[aNewChances.size()]; - int slot = 0; - for (int g : aNewChances) { - aTemp[slot] = g; - slot++; - } - aClone.mChances = aTemp; - return aClone; - } - - /** - * Processes recipes but provides a bonus to the output % of items if they are < 100%. - * - * @param aItemInputs - * @param aFluidInputs - * @param aMaxParallelRecipes - * @param aEUPercent - * @param aSpeedBonusPercent - * @param aOutputChanceRoll - * @param aRecipe - * @return - */ - public boolean checkRecipeBoostedOutputs(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, - GT_Recipe aRecipe) { - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - log("Running checkRecipeGeneric(0)"); - - GT_Recipe tRecipe = aRecipe != null ? aRecipe - : findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - - log("Running checkRecipeGeneric(1)"); - - // First we check whether or not we have an input cached for boosting. - // If not, we set it to the current recipe. - // If we do, we compare it against the current recipe, if thy are the same, we try return a boosted recipe, if - // not, we boost a new recipe. - boolean isRecipeInputTheSame = false; - - // No cached recipe inputs, assume first run. - if (mInputVerificationForBoosting == null) { - mInputVerificationForBoosting = tRecipe.mInputs; - isRecipeInputTheSame = true; - } - // If the inputs match, we are good. - else { - if (tRecipe.mInputs == mInputVerificationForBoosting) { - isRecipeInputTheSame = true; - } else { - isRecipeInputTheSame = false; - } - } - - // Inputs are the same, let's see if there's a boosted version. - if (isRecipeInputTheSame) { - // Yes, let's just set that as the recipe - if (mHasBoostedCurrentRecipe && mBoostedRecipe != null) { - tRecipe = mBoostedRecipe; - } - // We have yet to generate a new boosted recipe - else { - GT_Recipe aBoostedRecipe = this.generateAdditionalOutputForRecipe(tRecipe); - if (aBoostedRecipe != null) { - mBoostedRecipe = aBoostedRecipe; - mHasBoostedCurrentRecipe = true; - tRecipe = mBoostedRecipe; - } - // Bad boost - else { - mBoostedRecipe = null; - mHasBoostedCurrentRecipe = false; - } - } - } - // We have changed inputs, so we should generate a new boosted recipe - else { - GT_Recipe aBoostedRecipe = this.generateAdditionalOutputForRecipe(tRecipe); - if (aBoostedRecipe != null) { - mBoostedRecipe = aBoostedRecipe; - mHasBoostedCurrentRecipe = true; - tRecipe = mBoostedRecipe; - } - // Bad boost - else { - mBoostedRecipe = null; - mHasBoostedCurrentRecipe = false; - } - } - - // Bad modify, let's just use the original recipe. - if (!mHasBoostedCurrentRecipe || mBoostedRecipe == null) { - tRecipe = aRecipe != null ? aRecipe - : findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - } - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - Logger.MACHINE_INFO("BAD RETURN - 2"); - return false; - } - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(mMaxProgresstime * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); - - return true; - } - public boolean isMachineRunning() { boolean aRunning = this.getBaseMetaTileEntity().isActive(); // log("Queried Multiblock is currently running: "+aRunning); @@ -899,33 +494,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex super.explodeMultiblock(); } - protected int getGUICircuit(ItemStack[] t) { - Item g = CI.getNumberedCircuit(0).getItem(); - ItemStack guiSlot = this.mInventory[1]; - int mMode = -1; - if (guiSlot != null && guiSlot.getItem() == g) { - this.mInternalCircuit = true; - return guiSlot.getItemDamage(); - } else { - this.mInternalCircuit = false; - } - - if (!this.mInternalCircuit) { - for (ItemStack j : t) { - if (j.getItem() == g) { - mMode = j.getItemDamage(); - break; - } - } - } - return mMode; - } - - protected ItemStack getGUIItemStack() { - ItemStack guiSlot = this.mInventory[1]; - return guiSlot; - } - protected boolean setGUIItemStack(ItemStack aNewGuiSlotContents) { boolean result = false; if (this.mInventory[1] == null) { @@ -937,10 +505,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex return result; } - protected boolean clearGUIItemSlot() { - return setGUIItemStack(null); - } - public ItemStack findItemInInventory(Item aSearchStack) { return findItemInInventory(aSearchStack, 0); } @@ -1882,74 +1446,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex return false; } - public boolean isValidBlockForStructure(IGregTechTileEntity aBaseMetaTileEntity, int aCasingID, boolean canBeHatch, - Block aFoundBlock, int aFoundMeta, Block aExpectedBlock, int aExpectedMeta) { - boolean isHatch = false; - if (aBaseMetaTileEntity != null) { - - // Unsure why this check exists? - /* - * if (aCasingID < 64) { aCasingID = TAE.GTPP_INDEX(aCasingID); } - */ - - isHatch = this.addToMachineList(aBaseMetaTileEntity, aCasingID); - if (isHatch) { - return true; - } else { - int aMetaTileID = aBaseMetaTileEntity.getMetaTileID(); - // Found a controller - if (aMetaTileID >= 750 && aMetaTileID < 1000 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - // Vanilla Hatches/Busses - else if (aMetaTileID >= 10 && aMetaTileID <= 99 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - // Adv Mufflers - else if (aMetaTileID >= 30001 && aMetaTileID <= 30009 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - // Control Core, Super IO - else if (aMetaTileID >= 30020 && aMetaTileID <= 30040 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - // Auto maint - else if (aMetaTileID == 111 && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } - // Data Ports - else if ((aMetaTileID == 131 || aMetaTileID == 132) && aFoundBlock == GregTech_API.sBlockMachines) { - return true; - } else { - log("Found meta Tile: " + aMetaTileID); - } - } - } - if (!isHatch) { - if (aFoundBlock == aExpectedBlock && aFoundMeta == aExpectedMeta) { - return true; - } else if (aFoundBlock != aExpectedBlock) { - if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { - log( - "A1 - Found: " + aFoundBlock.getLocalizedName() - + ":" - + aFoundMeta - + ", Expected: " - + aExpectedBlock.getLocalizedName() - + ":" - + aExpectedMeta); - // log("Loc: "+(new BlockPos(aBaseMetaTileEntity).getLocationString())); - } - return false; - } else if (aFoundMeta != aExpectedMeta) { - log("A2"); - return false; - } - } - log("A3"); - return false; - } - @Override public void onServerStart() { super.onServerStart(); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java index 2c2412d245..85a3fd4edc 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_SteamMultiBase.java @@ -2,7 +2,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; import java.util.ArrayList; import java.util.Collections; @@ -14,18 +13,16 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.ArrayUtils; - import gregtech.api.enums.Textures; import gregtech.api.interfaces.IHatchElement; 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.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_HatchElementBuilder; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gregtech.api.util.IGT_HatchAdder; import gtPlusPlus.api.objects.data.AutoMap; @@ -75,150 +72,14 @@ public abstract class GregtechMeta_SteamMultiBase<T extends GregtechMeta_SteamMu } @Override - public int getEuDiscountForParallelism() { - return 0; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override - public boolean checkRecipe(ItemStack arg0) { - - log("Running checkRecipeGeneric(0)"); - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - GT_Recipe_Map tMap = this.getRecipeMap(); - if (tMap == null) { - return false; - } - ItemStack[] aItemInputs = tItems.toArray(new ItemStack[0]); - FluidStack[] aFluidInputs = tFluids.toArray(new FluidStack[0]); - GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[1], null, null, aItemInputs); - if (tRecipe == null) { - log("BAD RETURN - 1"); - return false; - } - - int aEUPercent = 100; - int aSpeedBonusPercent = 0; - int aOutputChanceRoll = 10000; - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - log("Running checkRecipeGeneric(1)"); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - int aMaxParallelRecipes = canBufferOutputs( - tRecipe.mOutputs, - tRecipe.mFluidOutputs, - this.getMaxParallelRecipes()); - if (aMaxParallelRecipes == 0) { - log("BAD RETURN - 2"); - return false; - } - - // EU discount - float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f; - float tTotalEUt = 0.0f; - - int parallelRecipes = 0; - - log("parallelRecipes: " + parallelRecipes); - log("aMaxParallelRecipes: " + aMaxParallelRecipes); - log("tTotalEUt: " + tTotalEUt); - log("tRecipeEUt: " + tRecipeEUt); - - // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits - for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (32 - tRecipeEUt); parallelRecipes++) { - if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) { - log("Broke at " + parallelRecipes + "."); - break; - } - log("Bumped EU from " + tTotalEUt + " to " + (tTotalEUt + tRecipeEUt) + "."); - tTotalEUt += tRecipeEUt; - } - - if (parallelRecipes == 0) { - log("BAD RETURN - 3"); - return false; - } - - // -- Try not to fail after this point - inputs have already been consumed! -- - - // Convert speed bonus to duration multiplier - // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. - aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent); - float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent); - this.mMaxProgresstime = (int) (tRecipe.mDuration * tTimeFactor * 1.5f); - - this.lEUt = (long) Math.ceil(tTotalEUt * 1.33f); - - // this.mEUt = (3 * tRecipe.mEUt); - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - if (this.lEUt > 0) { - this.lEUt = (-this.lEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - // Collect fluid outputs - FluidStack[] tOutputFluids = getOutputFluids(tRecipe, parallelRecipes); - - // Collect output item types - ItemStack[] tOutputItems = getOutputItems(tRecipe); - - // Set output item stack sizes (taking output chance into account) - for (int f = 0; f < tOutputItems.length; f++) { - if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) { - for (int g = 0; g < parallelRecipes; g++) { - if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f)) - tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize; - } - } - } - - tOutputItems = removeNulls(tOutputItems); - - // Sanitize item stack size, splitting any stacks greater than max stack size - List<ItemStack> splitStacks = new ArrayList<ItemStack>(); - for (ItemStack tItem : tOutputItems) { - while (tItem.getMaxStackSize() < tItem.stackSize) { - ItemStack tmp = tItem.copy(); - tmp.stackSize = tmp.getMaxStackSize(); - tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize(); - splitStacks.add(tmp); - } - } - - if (splitStacks.size() > 0) { - ItemStack[] tmp = new ItemStack[splitStacks.size()]; - tmp = splitStacks.toArray(tmp); - tOutputItems = ArrayUtils.addAll(tOutputItems, tmp); - } - - // Strip empty stacks - List<ItemStack> tSList = new ArrayList<ItemStack>(); - for (ItemStack tS : tOutputItems) { - if (tS.stackSize > 0) tSList.add(tS); - } - tOutputItems = tSList.toArray(new ItemStack[0]); - - // Commit outputs - this.mOutputItems = tOutputItems; - this.mOutputFluids = tOutputFluids; - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - log("GOOD RETURN - 1"); - return true; + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(V[1]); + logic.setAvailableAmperage(1); } public ArrayList<FluidStack> getAllSteamStacks() { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java index 8100532ed9..047e589db1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java @@ -80,7 +80,6 @@ public class GregtechMetaCasingBlocks2 extends GregtechMetaCasingBlocksAbstract GregtechItemList.Casing_ThermalContainment.set(new ItemStack(this, 1, 11)); GregtechItemList.Casing_Autocrafter.set(new ItemStack(this, 1, 12)); GregtechItemList.Casing_CuttingFactoryFrame.set(new ItemStack(this, 1, 13)); - // GregtechItemList.Casing_TeslaTower.set(new ItemStack(this, 1, 14)); GregtechItemList.Casing_PLACEHOLDER_TreeFarmer.set(new ItemStack(this, 1, 15)); // Tree Farmer Textures } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java index 805b9acbd9..61e74fc56a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java @@ -71,7 +71,6 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs GregtechItemList.Casing_Turbine_HP.set(new ItemStack(this, 1, 2)); GregtechItemList.Casing_Turbine_Gas.set(new ItemStack(this, 1, 3)); GregtechItemList.Casing_Turbine_Plasma.set(new ItemStack(this, 1, 4)); - GregtechItemList.Casing_TeslaTower.set(new ItemStack(this, 1, 5)); GregtechItemList.Casing_SolarTower_Structural.set(new ItemStack(this, 1, 6)); GregtechItemList.Casing_SolarTower_SaltContainment.set(new ItemStack(this, 1, 7)); GregtechItemList.Casing_SolarTower_HeatContainment.set(new ItemStack(this, 1, 8)); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java index b53daf4f31..f7f935fdf1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -416,12 +416,6 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { .set(this.addItem(151, "Distillus Upgrade Chip", "Used to upgrade Distillus to Tier 2")); GregtechItemList.Maceration_Upgrade_Chip .set(this.addItem(152, "Maceration Upgrade Chip", "Used to upgrade Maceration Stack to Tier 2")); - - GregtechItemList.Chip_MultiNerf_NoOutputBonus - .set(this.addItem(160, "No-Bonus Chip", "You won't like using this")); - GregtechItemList.Chip_MultiNerf_NoSpeedBonus - .set(this.addItem(161, "No-Bonus Chip", "You won't like using this")); - GregtechItemList.Chip_MultiNerf_NoEuBonus.set(this.addItem(162, "No-Bonus Chip", "You won't like using this")); } private boolean registerComponents_ULV() { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java index c8e947fbb5..d8c46e11ce 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java @@ -10,29 +10,21 @@ import static gregtech.api.enums.GT_HatchElement.Muffler; import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import java.util.ArrayList; - import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; 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 gregtech.api.enums.GT_Values; -import gregtech.api.enums.ItemList; import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; -import gregtech.api.util.GT_ModHandler; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.api.objects.minecraft.ItemStackData; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; @@ -41,8 +33,6 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase<GMTE_AmazonPackager> implements ISurvivalConstructable { - private long mVoltage; - private byte mTier; private int mCasing; private static IStructureDefinition<GMTE_AmazonPackager> STRUCTURE_DEFINITION = null; @@ -102,11 +92,6 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase<GMTE_Amazon return tt; } - private final void initFields() { - mVoltage = getMaxInputVoltage(); - mTier = (byte) Math.max(1, GT_Utility.getTier(mVoltage)); - } - @Override protected IIconContainer getActiveOverlay() { return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; @@ -127,134 +112,10 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase<GMTE_Amazon return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes; } - private static final FluidStack[] sNoFluids = new FluidStack[] {}; - @Override - public boolean checkRecipe(ItemStack aStack) { - - // Just the best place to check this~ - initFields(); - - ArrayList<ItemStack> tItems = getStoredInputs(); - if (this.getGUIItemStack() != null) { - tItems.add(this.getGUIItemStack()); - } - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - boolean state = checkRecipeGeneric(tItemInputs, sNoFluids, getMaxParallelRecipes(), 75, 500, 10000); - - if (state) { - return true; - } else { - tItems = getStoredInputs(); - AutoMap<ItemStackData> mCompleted = new AutoMap<ItemStackData>(); - AutoMap<ItemStackData> mSchematics = new AutoMap<ItemStackData>(); - for (ItemStack tInputItem : tItems) { - if (tInputItem != null) { - if (ItemList.Schematic_1by1.isStackEqual((Object) tInputItem) - || ItemList.Schematic_2by2.isStackEqual((Object) tInputItem) - || ItemList.Schematic_3by3.isStackEqual((Object) tInputItem)) { - mSchematics.put(new ItemStackData(tInputItem)); - } - } - } - if (mSchematics.size() > 0) { - for (ItemStackData g : mSchematics) { - for (ItemStack tInputItem : tItems) { - if (tInputItem != null) { - mCompleted.put(new ItemStackData(tInputItem)); - checkRecipe(tInputItem, g.getStack()); - } - } - } - } - - return mCompleted != null && mCompleted.size() > 0; - } - } - - public boolean checkRecipe(ItemStack inputStack, ItemStack schematicStack) { - if (GT_Utility.isStackValid((Object) inputStack) && GT_Utility.isStackValid((Object) schematicStack) - && GT_Utility.getContainerItem(inputStack, true) == null) { - ItemStack tOutputStack; - if (ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) && inputStack.stackSize >= 1) { - tOutputStack = GT_ModHandler.getRecipeOutput(new ItemStack[] { inputStack }); - if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { - final ItemStack input = inputStack; - --input.stackSize; - this.lEUt = 32 * (1L << this.mTier - 1) * (1L << this.mTier - 1); - // this.mMaxProgresstime = 16 / (1 << this.mTier - 1); - this.mMaxProgresstime = 2; - this.addOutput(tOutputStack); - updateSlots(); - return true; - } - return false; - } else if (ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) && inputStack.stackSize >= 4) { - tOutputStack = GT_ModHandler - .getRecipeOutput(new ItemStack[] { inputStack, inputStack, null, inputStack, inputStack }); - if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { - final ItemStack input2 = inputStack; - input2.stackSize -= 4; - this.lEUt = 32 * (1L << this.mTier - 1) * (1L << this.mTier - 1); - // this.mMaxProgresstime = 32 / (1 << this.mTier - 1); - this.mMaxProgresstime = 4; - this.addOutput(tOutputStack); - updateSlots(); - return true; - } - return false; - } else if (ItemList.Schematic_3by3.isStackEqual((Object) schematicStack) && inputStack.stackSize >= 9) { - tOutputStack = GT_ModHandler.getRecipeOutput( - new ItemStack[] { inputStack, inputStack, inputStack, inputStack, inputStack, inputStack, - inputStack, inputStack, inputStack }); - if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { - final ItemStack input3 = inputStack; - input3.stackSize -= 9; - this.lEUt = 32 * (1L << this.mTier - 1) * (1L << this.mTier - 1); - // this.mMaxProgresstime = 64 / (1 << this.mTier - 1); - this.mMaxProgresstime = 6; - this.addOutput(tOutputStack); - updateSlots(); - return true; - } - return false; - } - } - return false; - } - - public boolean allowPutStack(final ItemStack aStack, ItemStack schematicStack) { - // If Schematic Static is not 1x1, 2x2, 3x3 - if (!ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) - && !ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) - && !ItemList.Schematic_3by3.isStackEqual((Object) schematicStack)) { - return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.containsInput(aStack); - } - // Something - if (GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.findRecipe( - (IHasWorldObjectAndCoords) this.getBaseMetaTileEntity(), - true, - GT_Values.V[this.mTier], - (FluidStack[]) null, - new ItemStack[] { GT_Utility.copyAmount(64L, new Object[] { aStack }), schematicStack }) != null) { - return true; - } - // 1x1 - if (ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) - && GT_ModHandler.getRecipeOutput(new ItemStack[] { aStack }) != null) { - return true; - } - // 2x2 - if (ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) - && GT_ModHandler.getRecipeOutput(new ItemStack[] { aStack, aStack, null, aStack, aStack }) != null) { - return true; - } - // 3x3 - if (ItemList.Schematic_3by3.isStackEqual((Object) schematicStack) && GT_ModHandler.getRecipeOutput( - new ItemStack[] { aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack }) != null) { - return true; - } - return false; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 6F).setEuModifier(0.75F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -279,11 +140,6 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase<GMTE_Amazon } @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override public void construct(ItemStack stackSize, boolean hintsOnly) { buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); } @@ -293,4 +149,9 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase<GMTE_Amazon if (mMachine) return -1; return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); } + + @Override + public boolean supportsInputSeparation() { + return true; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GregtechMTE_TeslaTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GregtechMTE_TeslaTower.java deleted file mode 100644 index e77e5b7b60..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GregtechMTE_TeslaTower.java +++ /dev/null @@ -1,503 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.misc; - -import static gregtech.api.enums.GT_Values.W; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import com.gtnewhorizon.structurelib.structure.IStructureDefinition; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.TAE; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.entity.EntityTeslaTowerLightning; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMTE_TeslaTower extends GregtechMeta_MultiBlockBase<GregtechMTE_TeslaTower> { - - private Block casingBlock; - private int casingMeta; - private int frameMeta; - private int casingTextureIndex; - - private ForgeDirection back; - - private int xLoc, yLoc, zLoc; - - protected int mRange; - - /** - * Machine Mode, {@value false} Attacks all entities, {@value true} Only attacks players. - */ - protected volatile boolean mMode = false; - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMTE_TeslaTower(mName); - } - - public GregtechMTE_TeslaTower(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - initFields(); - } - - public GregtechMTE_TeslaTower(String aName) { - super(aName); - initFields(); - } - - @Override - public String getMachineType() { - return "Weaponized Lighting Rod"; - } - - /* - * @Override public String[] getTooltip() { String casings = getCasingBlockItem().get(0).getDisplayName(); return - * new String[]{ "Controller Block for the Tesla Defence Tower Mk3200", - * "Enemies within "+this.mRange+"m are blasted with a high energy plasma.", "This uses 5,000,000EU per blast.", - * "Can screwdriver to toggle mode between Players and all Entities.", "Size(WxHxD): 3x7x3", - * "Controller (Front middle at bottom)", "3x1x3 Base of " + casings, "1x3x1 " + casings + - * " pillar (Center of base)", "1x3x1 " + MaterialUtils.getMaterialName(getFrameMaterial()) + - * " Frame Boxes (Each pillar side and on top)", "1x Maintenance Hatch (One of base casings)", "1x " + - * VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)"}; } - */ - - @Override - protected final GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()).addInfo("Controller Block for the Tesla Defence Tower Mk3200") - .addInfo("Enemies within " + this.mRange + "m are blasted with a high energy plasma.") - .addInfo("This uses 5,000,000EU per blast.") - .addInfo("Can screwdriver to toggle mode between Players and all Entities.").addSeparator() - .beginStructureBlock(1, 7, 1, false).addController("Top Middle").addCasingInfoMin("Casing", 360, false) - .addOtherStructurePart("Rotor Assembly", "Any 1 dot hint", 1).addInputBus("Any 4 dot hint (min 1)", 4) - .addInputHatch("Any 4 dot hint(min 1)", 4).addOutputHatch("Any 4 dot hint(min 1)", 4) - .addEnergyHatch("Any 4 dot hint(min 1)", 4).addMaintenanceHatch("Any 4 dot hint(min 1)", 4) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - private final void initFields() { - casingBlock = ModBlocks.blockCasings2Misc; - casingMeta = getCasingBlockItem().get(0).getItemDamage(); - casingTextureIndex = getCasingTextureIndex(); - mRange = 50; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return getCasingTextureIndex(); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("mMode", this.mMode); - aNBT.setInteger("mRange", this.mRange); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - this.mMode = aNBT.getBoolean("mMode"); - this.mRange = aNBT.getInteger("mRange"); - super.loadNBTData(aNBT); - } - - private boolean isEnergyEnough() { - if (this.getEUVar() >= 5000000) { - return true; - } - return false; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - - if (!isEnergyEnough()) { - this.mProgresstime = 0; - this.mMaxProgresstime = 20; - this.getBaseMetaTileEntity().setActive(false); - stopMachine(); - } else { - this.mProgresstime = 1; - this.mMaxProgresstime = 100; - this.getBaseMetaTileEntity().setActive(true); - } - return false; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - updateCoordinates(); - // check base layer - for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) { - for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) { - if (xOff == 0 && zOff == 0) continue; - - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff); - if (!checkCasingBlock(xOff, 0, zOff) && !addMaintenanceToMachineList(tTileEntity, casingTextureIndex) - && !addEnergyInputToMachineList(tTileEntity, casingTextureIndex)) { - Logger.INFO("bad block"); - return false; - } - } - } - if (!checkHatches()) { - Logger.INFO("bad Hatches"); - return false; - } - if (GT_Utility.getTier(getMaxInputVoltage()) < getMinTier()) { - Logger.INFO("bad Voltage"); - return false; - } - // check tower - for (int yOff = 1; yOff < 4; yOff++) { - if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX + 1, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX - 1, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX, yOff, back.offsetZ + 1) - || !checkFrameBlock(back.offsetX, yOff, back.offsetZ - 1) - || !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ)) { - Logger.INFO("bad frame?"); - return false; - } - } - Logger.INFO("good"); - return true; - } - - private void updateCoordinates() { - casingTextureIndex = getCasingTextureIndex(); - mRange = 50; - xLoc = getBaseMetaTileEntity().getXCoord(); - yLoc = getBaseMetaTileEntity().getYCoord(); - zLoc = getBaseMetaTileEntity().getZCoord(); - back = getBaseMetaTileEntity().getBackFacing(); - } - - protected boolean checkCasingBlock(int xOff, int yOff, int zOff) { - Logger.INFO("Looking For Casing."); - return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta); - } - - // meta of frame is getTileEntityBaseType; frame should be checked using its drops (possible a high weight - // operation) - protected boolean checkFrameBlock(int xOff, int yOff, int zOff) { - Logger.INFO("Looking For Frame."); - return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta); - } - - protected boolean checkBlockAndMetaOffset(int xOff, int yOff, int zOff, Block block, int meta) { - return checkBlockAndMeta(xLoc + xOff, yLoc + yOff, zLoc + zOff, block, meta); - } - - private boolean checkBlockAndMeta(int x, int y, int z, Block block, int meta) { - Logger.INFO( - "Found: " + getBaseMetaTileEntity().getBlock(x, y, z).getLocalizedName() - + " | Meta: " - + getBaseMetaTileEntity().getMetaID(x, y, z)); - Logger.INFO("Expected: " + block.getLocalizedName() + " | Meta: " + meta); - return (meta == W || getBaseMetaTileEntity().getMetaID(x, y, z) == meta) - && getBaseMetaTileEntity().getBlock(x, y, z) == block; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - protected int getMinTier() { - return 7; - } - - protected boolean checkHatches() { - return !mMaintenanceHatches.isEmpty() && !mEnergyHatches.isEmpty(); - } - - private Map<Pair<Long, Long>, Entity> mInRange = new HashMap<Pair<Long, Long>, Entity>(); - - @SuppressWarnings("unchecked") - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - try { - if (this.getBaseMetaTileEntity().isServerSide()) { - if (this.mEnergyHatches.size() > 0) { - for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { - long mHT = tHatch.getBaseMetaTileEntity().getInputVoltage(); - if (tHatch.getEUVar() >= mHT) { - for (int o = 0; o < (tHatch.getEUVar() / mHT); o++) { - // 1A - if (this.getEUVar() < (this.maxEUStore() - mHT)) { - tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mHT, false); - this.setEUVar(this.getEUVar() + mHT); - } - // 2A - if (this.getEUVar() < (this.maxEUStore() - mHT)) { - tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mHT, false); - this.setEUVar(this.getEUVar() + mHT); - } - } - } - } - } - } - - if (aTick % 10 == 0) { - if (this.getEUVar() >= 5000000) { - // Logger.INFO("Can Zap."); - this.getBaseMetaTileEntity().enableWorking(); - this.getBaseMetaTileEntity().setActive(true); - if (this.mProgresstime <= 0) { - this.mProgresstime++; - } else if (this.mProgresstime >= 100) { - this.mProgresstime = 0; - } - this.mMaxProgresstime = 10000; - } - // Logger.INFO("Allowed to be Working? "+this.getBaseMetaTileEntity().isAllowedToWork()); - // Logger.INFO("Working? "+this.getBaseMetaTileEntity().isActive()); - // Logger.INFO("Has Working just been enabled? - // "+this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()); - } - - if (aTick % 20 == 0) { - List<Object> o = aBaseMetaTileEntity.getWorld().loadedEntityList; - // Clean up old entities first - if (this.mInRange.size() > 0) { - for (Entity j : this.mInRange.values()) { - if (((Entity) j).getDistance(this.xLoc, this.yLoc, this.zLoc) > this.mRange) { - mInRange.remove( - new Pair<Long, Long>( - ((Entity) j).getUniqueID().getMostSignificantBits(), - ((Entity) j).getUniqueID().getLeastSignificantBits()), - (Entity) j); - } - } - } - // Add new entities - if (o.size() > 0) { - for (Object r : o) { - if (r instanceof Entity) { - if (!((Entity) r).getUniqueID().equals(getOwner())) { - if (((Entity) r).isEntityAlive() || r instanceof EntityLiving) { - if (((Entity) r).getDistance(this.xLoc, this.yLoc, this.zLoc) <= this.mRange) { - if (r instanceof EntityItem) { - // Do nothing - } else { - if (!this.mMode) { - mInRange.put( - new Pair<Long, Long>( - ((Entity) r).getUniqueID().getMostSignificantBits(), - ((Entity) r).getUniqueID() - .getLeastSignificantBits()), - (Entity) r); - } else { - if (r instanceof EntityPlayer) { - mInRange.put( - new Pair<Long, Long>( - ((Entity) r).getUniqueID() - .getMostSignificantBits(), - ((Entity) r).getUniqueID() - .getLeastSignificantBits()), - (Entity) r); - } - } - } - } - } - } - } - } - } - } - } - } catch (Throwable r) { - - } - super.onPreTick(aBaseMetaTileEntity, aTick); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - try { - if (this.getBaseMetaTileEntity().isServerSide()) { - // Handle Progress Time - if (this.getEUVar() >= 0 && !this.getBaseMetaTileEntity().isAllowedToWork()) { - this.mProgresstime = 20; - this.mMaxProgresstime = 40; - } else if (this.getEUVar() >= 0 && this.getBaseMetaTileEntity().isAllowedToWork()) { - this.mProgresstime = 20; - this.mMaxProgresstime = 40; - } - - if (aTick % 10 == 0) { - if (this.mInRange.size() > 0) { - if (this.getEUVar() >= 5000000) { - - for (Entity f : mInRange.values()) { - if (f instanceof EntityLiving) { - int j1 = (int) f.posX; - int l1 = (int) f.posY; - int k1 = (int) f.posZ; - World world = aBaseMetaTileEntity.getWorld(); - - if (f.isEntityAlive() && !f.getUniqueID().equals(getOwner())) { - // if (world.canLightningStrikeAt(j1, l1+1, k1)){ - // if (isEnergyEnough() && world.addWeatherEffect(new - // EntityTeslaTowerLightning(world, (double)j1, (double)l1, (double)k1))){ - if (isEnergyEnough() && world.addWeatherEffect( - new EntityTeslaTowerLightning( - world, - (double) j1, - (double) l1, - (double) k1, - f, - getOwner()))) { - if (f == null || f.isDead || !f.isEntityAlive()) { - this.mInRange.remove( - new Pair<Long, Long>( - f.getUniqueID().getMostSignificantBits(), - f.getUniqueID().getLeastSignificantBits())); - } - this.setEUVar(this.getEUVar() - 5000000); - } - // } - } - } - } - } - } - } - } - } catch (Throwable r) { - - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - protected GregtechItemList getCasingBlockItem() { - return GregtechItemList.Casing_TeslaTower; - } - - protected int getCasingTextureIndex() { - return TAE.GTPP_INDEX(30); - } - - public UUID getOwner() { - return PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public long maxAmperesIn() { - return 32; - } - - @Override - public long maxEUInput() { - return 131072; - } - - @Override - public long maxEUStore() { - return Integer.MAX_VALUE; - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mMode = Utils.invertBoolean(mMode); - this.mInRange.clear(); - if (mMode) { - PlayerUtils.messagePlayer(aPlayer, "[Tesla Tower] Now only targetting players."); - } else { - PlayerUtils.messagePlayer(aPlayer, "[Tesla Tower] Targetting all types of entities."); - } - } - - @Override - public int getMaxParallelRecipes() { - return 0; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - // TODO Auto-generated method stub - - } - - @Override - public IStructureDefinition getStructureDefinition() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean doesBindPlayerInventory() { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java index d2ec846d8f..0a8df0f104 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java @@ -11,10 +11,9 @@ import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofCoil; -import java.util.ArrayList; - import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -27,13 +26,12 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_OverclockCalculator; import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; @@ -183,98 +181,21 @@ public class GregtechMetaTileEntity_IndustrialAlloySmelter extends } @Override - public int getEuDiscountForParallelism() { - return 100; - } + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { - @Override - public boolean checkRecipe(ItemStack aStack) { - FluidStack[] tFluids = getStoredFluids().toArray(new FluidStack[0]); - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList<ItemStack> tInputs = new ArrayList<>(); - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) { - tInputs.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } + @NotNull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe, + @NotNull GT_ParallelHelper helper) { + return super.createOverclockCalculator(recipe, helper).setSpeedBoost(100F / (100F + 5F * mLevel)) + .enableHeatOC().setRecipeHeat(0) + // Need to multiply by 2 because heat OC is done only once every 1800 and this one does it once + // every + // 900 + .setMultiHeat((int) (getCoilLevel().getHeat() * 2)); } - if (tInputs.size() > 1) { - ItemStack[] tItems = tInputs.toArray(new ItemStack[0]); - if (checkRecipeGeneric(tItems, tFluids, getMaxParallelRecipes(), 100, 5 * this.mLevel, 10000)) { - return true; - } - } - } - return false; - } - - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - - GT_Recipe tRecipe = this.getRecipeMap().findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - Logger.WARNING("BAD RETURN - 1"); - return false; - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setEUtModifier(aEUPercent / 100.0f).setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .enableHeatOC().setRecipeHeat(0) - // Need to multiple by 2 because heat OC is done only once every 1800 and this one does it once every - // 900 - .setMultiHeat((int) getCoilLevel().getHeat() * 2).calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; + }.setMaxParallelSupplier(this::getMaxParallelRecipes); } public HeatingCoilLevel getCoilLevel() { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java index 8b7ced1103..1b3822ca3f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java @@ -28,6 +28,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -112,14 +113,11 @@ public class GregtechMetaTileEntity_IndustrialArcFurnace extends } private int getSizeFromHint(ItemStack stackSize) { - switch (stackSize.stackSize) { - case 1: - return 3; - case 2: - return 5; - default: - return 7; - } + return switch (stackSize.stackSize) { + case 1 -> 3; + case 2 -> 5; + default -> 7; + }; } @Override @@ -166,8 +164,8 @@ public class GregtechMetaTileEntity_IndustrialArcFurnace extends } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; } @Override @@ -192,8 +190,8 @@ public class GregtechMetaTileEntity_IndustrialArcFurnace extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return this.checkRecipeGeneric(getMaxParallelRecipes(), 100, 250); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3.5F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -202,16 +200,6 @@ public class GregtechMetaTileEntity_IndustrialArcFurnace extends } @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -222,11 +210,6 @@ public class GregtechMetaTileEntity_IndustrialArcFurnace extends } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } @@ -239,14 +222,6 @@ public class GregtechMetaTileEntity_IndustrialArcFurnace extends return 3; } - public Block getCasingBlock2() { - return ModBlocks.blockCasings3Misc; - } - - public byte getCasingMeta2() { - return 15; - } - public byte getCasingTextureIndex() { return (byte) mCasingTextureID; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java index 4e9fdacca0..44a69fd78f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java @@ -27,6 +27,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -145,8 +146,9 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(6 * GT_Utility.getTier(this.getMaxInputVoltage()), 90, 125); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setEuModifier(0.9F).setSpeedBonus(1F / 2.25F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -154,11 +156,6 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends return (6 * GT_Utility.getTier(this.getMaxInputVoltage())); } - @Override - public int getEuDiscountForParallelism() { - return 90; - } - public Block getCasingBlock() { return ModBlocks.blockCasingsMisc; } @@ -182,11 +179,6 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java index e78aa4d250..19976c8c6b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java @@ -10,26 +10,29 @@ import static gregtech.api.enums.GT_HatchElement.Muffler; import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import java.util.ArrayList; import java.util.List; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + 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 gregtech.api.enums.SoundResource; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.recipe.check.FindRecipeResult; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_OverclockCalculator; -import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.block.ModBlocks; @@ -253,7 +256,7 @@ public class GregtechMetaTileEntity_IndustrialChisel } } } else { - target = this.getGUIItemStack(); // Common buses + target = this.getControllerSlot(); // Common buses for (int i = bus.getSizeInventory() - 1; i >= 0; i--) { ItemStack itemsInSlot = bus.mInventory[i]; if (itemsInSlot != null) { @@ -270,85 +273,48 @@ public class GregtechMetaTileEntity_IndustrialChisel } @Override - public boolean checkRecipe(final ItemStack aStack) { - GT_Recipe tRecipe = getRecipe(); - if (tRecipe == null) return false; - - ArrayList<ItemStack> aItems = this.getStoredInputs(); - - // Based on the Processing Array. A bit overkill, but very flexible. - ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]); - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - long tEnergy = getMaxInputEnergy(); - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - int aMaxParallelRecipes = getMaxParallelRecipes(); - int aEUPercent = getEuDiscountForParallelism(); - int aSpeedBonusPercent = 200; - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes).enableConsumption() - .enableOutputCalculation().setEUtModifier(aEUPercent / 100.0f).setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected FindRecipeResult findRecipe(GT_Recipe.GT_Recipe_Map map) { + GT_Recipe recipe = getRecipe(); + if (recipe == null) { + return FindRecipeResult.NOT_FOUND; + } + return FindRecipeResult.ofSuccess(recipe); + } + }.setSpeedBonus(1F / 3F).setEuModifier(0.75F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override - public int getMaxParallelRecipes() { - return (16 * GT_Utility.getTier(this.getMaxInputVoltage())); + protected void sendStartMultiBlockSoundLoop() { + sendLoopStart(PROCESS_START_SOUND_INDEX); } @Override - public int getEuDiscountForParallelism() { - return 75; + public int getMaxParallelRecipes() { + return (16 * GT_Utility.getTier(this.getMaxInputVoltage())); } - private static String sChiselSound = null; + private static ResourceLocation sChiselSound = null; - private static String getChiselSound() { + private static ResourceLocation getChiselSound() { if (sChiselSound == null) { - sChiselSound = Carving.chisel.getVariationSound(Blocks.stone, 0); + sChiselSound = new ResourceLocation(Carving.chisel.getVariationSound(Blocks.stone, 0)); } return sChiselSound; } @Override - public String getSound() { - return getChiselSound(); + public void doSound(byte aIndex, double aX, double aY, double aZ) { + switch (aIndex) { + case PROCESS_START_SOUND_INDEX -> GT_Utility + .doSoundAtClient(getChiselSound(), getTimeBetweenProcessSounds(), 1.0F, 1.0F, aX, aY, aZ); + case INTERRUPT_SOUND_INDEX -> GT_Utility + .doSoundAtClient(SoundResource.IC2_MACHINES_INTERRUPT_ONE, 100, 1.0F, aX, aY, aZ); + } } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java index d725a8a3a6..9307739bf8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java @@ -25,6 +25,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -146,8 +147,8 @@ public class GregtechMetaTileEntity_IndustrialCokeOven extends } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; } @Override @@ -171,18 +172,19 @@ public class GregtechMetaTileEntity_IndustrialCokeOven extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override - public int getMaxParallelRecipes() { - return this.mLevel * 12; + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.setEuModifier((100F - (GT_Utility.getTier(getMaxInputVoltage()) * 4)) / 100F); } @Override - public int getEuDiscountForParallelism() { - return (100 - (GT_Utility.getTier(this.getMaxInputVoltage()) * 4)); + public int getMaxParallelRecipes() { + return this.mLevel * 12; } @Override @@ -196,11 +198,6 @@ public class GregtechMetaTileEntity_IndustrialCokeOven extends } @Override - public int getAmountOfOutputs() { - return 24; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java index c45621414d..dfa6eb0130 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java @@ -26,6 +26,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -135,8 +136,9 @@ public class GregtechMetaTileEntity_IndustrialCuttingMachine extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric((4 * GT_Utility.getTier(this.getMaxInputVoltage())), 75, 200); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3F).setEuModifier(0.75F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -145,11 +147,6 @@ public class GregtechMetaTileEntity_IndustrialCuttingMachine extends } @Override - public int getEuDiscountForParallelism() { - return 75; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -160,11 +157,6 @@ public class GregtechMetaTileEntity_IndustrialCuttingMachine extends } @Override - public int getAmountOfOutputs() { - return 2; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java index 6a99ff8574..c435e87938 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java @@ -17,7 +17,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -29,12 +30,14 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_OverclockCalculator; import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; @@ -174,78 +177,24 @@ public class GregtechMetaTileEntity_IndustrialDehydrator extends } @Override - public int getEuDiscountForParallelism() { - return 50; - } + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { - @Override - public boolean checkRecipe(ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 120); - } + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { + return recipe.mSpecialValue <= getCoilLevel().getHeat() ? CheckRecipeResultRegistry.SUCCESSFUL + : CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); + } - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - - GT_Recipe tRecipe = this.getRecipeMap().findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null || this.mHeatingCapacity.getHeat() < tRecipe.mSpecialValue) { - return false; - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setEUtModifier(aEUPercent / 100.0f).setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .enableHeatOC().enableHeatDiscount().setRecipeHeat(tRecipe.mSpecialValue) - .setMultiHeat((int) getCoilLevel().getHeat()).calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; + @NotNull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe, + @NotNull GT_ParallelHelper helper) { + return super.createOverclockCalculator(recipe, helper).enableHeatOC().enableHeatDiscount() + .setRecipeHeat(recipe.mSpecialValue).setMultiHeat((int) getCoilLevel().getHeat()); + } + }.setSpeedBonus(1F / 2.2F).setEuModifier(0.5F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java index b3f448d425..562ed96f52 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialElectrolyzer.java @@ -23,6 +23,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -128,8 +129,9 @@ public class GregtechMetaTileEntity_IndustrialElectrolyzer extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(2 * GT_Utility.getTier(this.getMaxInputVoltage()), 90, 180); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 2.8F).setEuModifier(0.9F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -143,11 +145,6 @@ public class GregtechMetaTileEntity_IndustrialElectrolyzer extends } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } @@ -157,8 +154,4 @@ public class GregtechMetaTileEntity_IndustrialElectrolyzer extends return 2 * GT_Utility.getTier(this.getMaxInputVoltage()); } - @Override - public int getEuDiscountForParallelism() { - return 90; - } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java index 49c4800078..06df63e08a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialExtruder.java @@ -10,11 +10,8 @@ import static gregtech.api.enums.GT_HatchElement.Muffler; import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import java.util.ArrayList; - import net.minecraft.block.Block; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -26,7 +23,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -115,8 +112,8 @@ public class GregtechMetaTileEntity_IndustrialExtruder extends } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_COMPRESSOR_OP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_COMPRESSOR_OP; } @Override @@ -140,31 +137,8 @@ public class GregtechMetaTileEntity_IndustrialExtruder extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList<ItemStack> tBusItems = new ArrayList<ItemStack>(); - tBus.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) - tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - ItemStack[] inputs = new ItemStack[tBusItems.size()]; - int slot = 0; - for (ItemStack g : tBusItems) { - inputs[slot++] = g; - } - if (inputs.length > 0) { - int para = (4 * GT_Utility.getTier(this.getMaxInputVoltage())); - log("Recipe. [" + inputs.length + "][" + para + "]"); - if (checkRecipeGeneric(inputs, new FluidStack[] {}, para, 100, 250, 10000)) { - log("Recipe 2."); - return true; - } - } - } - return false; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3.5F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -173,16 +147,6 @@ public class GregtechMetaTileEntity_IndustrialExtruder extends } @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -193,11 +157,6 @@ public class GregtechMetaTileEntity_IndustrialExtruder extends } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialFluidHeater.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialFluidHeater.java index 1fa2f99425..d6ceeffd58 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialFluidHeater.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialFluidHeater.java @@ -24,6 +24,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -148,8 +149,9 @@ public class GregtechMetaTileEntity_IndustrialFluidHeater extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 120); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 2.2F).setEuModifier(0.9F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -158,11 +160,6 @@ public class GregtechMetaTileEntity_IndustrialFluidHeater extends } @Override - public int getEuDiscountForParallelism() { - return 90; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -173,11 +170,6 @@ public class GregtechMetaTileEntity_IndustrialFluidHeater extends } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java index ceffb921f7..ad12ebb530 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialForgeHammer.java @@ -39,6 +39,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -170,8 +171,8 @@ public class GregtechMetaTileEntity_IndustrialForgeHammer extends } @Override - public String getSound() { - return SoundResource.RANDOM_ANVIL_USE.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.RANDOM_ANVIL_USE; } @Override @@ -195,18 +196,8 @@ public class GregtechMetaTileEntity_IndustrialForgeHammer extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - if (getAnvilTier() > 0) { - return checkRecipeGeneric( - getStoredInputs().toArray(new ItemStack[0]), - getCompactedFluids(), - getMaxParallelRecipes(), - 100, - 100, - 10000); - } - - return false; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1 / 2F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -215,16 +206,6 @@ public class GregtechMetaTileEntity_IndustrialForgeHammer extends } @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -235,11 +216,6 @@ public class GregtechMetaTileEntity_IndustrialForgeHammer extends } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java index ae4a227ec2..6148064783 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMacerator.java @@ -35,6 +35,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -246,8 +247,8 @@ public class GregtechMetaTileEntity_IndustrialMacerator extends } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_MACERATOR_OP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_MACERATOR_OP; } @Override @@ -298,7 +299,7 @@ public class GregtechMetaTileEntity_IndustrialMacerator extends public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); if (aTick % 20 == 0 && controllerTier == 1) { - ItemStack aGuiStack = this.getGUIItemStack(); + ItemStack aGuiStack = this.getControllerSlot(); if (aGuiStack != null) { if (GT_Utility.areStacksEqual(aGuiStack, GregtechItemList.Maceration_Upgrade_Chip.get(1))) { controllerTier = 2; @@ -366,13 +367,8 @@ public class GregtechMetaTileEntity_IndustrialMacerator extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 60, 7500); - } - - @Override - protected boolean doesMachineBoostOutput() { - return true; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 1.6F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -383,11 +379,6 @@ public class GregtechMetaTileEntity_IndustrialMacerator extends } @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -398,11 +389,6 @@ public class GregtechMetaTileEntity_IndustrialMacerator extends } @Override - public int getAmountOfOutputs() { - return 16; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java index 0b13c34053..9fe9641323 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java @@ -12,14 +12,11 @@ import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.enums.GT_HatchElement.OutputHatch; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import java.util.ArrayList; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -32,7 +29,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -138,8 +135,8 @@ public class GregtechMetaTileEntity_IndustrialMixer } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_COMPRESSOR_OP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_COMPRESSOR_OP; } @Override @@ -163,42 +160,8 @@ public class GregtechMetaTileEntity_IndustrialMixer } @Override - public boolean checkRecipe(final ItemStack aStack) { - if (inputSeparation) { - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList<ItemStack> rList = new ArrayList<>(); - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) - rList.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - - if (checkRecipeGeneric( - rList.toArray(new ItemStack[0]), - getStoredFluids().toArray(new FluidStack[0]), - getMaxParallelRecipes(), - getEuDiscountForParallelism(), - 250, - 10000)) { - return true; - } - } - - return checkRecipeGeneric( - new ItemStack[0], - getStoredFluids().toArray(new FluidStack[0]), - getMaxParallelRecipes(), - getEuDiscountForParallelism(), - 250, - 10000); - } else { - return checkRecipeGeneric( - getStoredInputs().toArray(new ItemStack[0]), - getStoredFluids().toArray(new FluidStack[0]), - getMaxParallelRecipes(), - getEuDiscountForParallelism(), - 250, - 10000); - } + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3.5F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -207,16 +170,6 @@ public class GregtechMetaTileEntity_IndustrialMixer } @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -235,11 +188,6 @@ public class GregtechMetaTileEntity_IndustrialMixer } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMolecularTransformer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMolecularTransformer.java index ca445d2332..29c9cc8095 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMolecularTransformer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMolecularTransformer.java @@ -23,6 +23,7 @@ import gregtech.api.GregTech_API; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -199,8 +200,8 @@ public class GregtechMetaTileEntity_IndustrialMolecularTransformer } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic(); } @Override @@ -209,11 +210,6 @@ public class GregtechMetaTileEntity_IndustrialMolecularTransformer } @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java index 142aba27df..4220958a6f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMultiMachine.java @@ -25,7 +25,8 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -36,18 +37,15 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.check.FindRecipeResult; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_OverclockCalculator; -import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -58,7 +56,6 @@ public class GregtechMetaTileEntity_IndustrialMultiMachine extends GregtechMeta_MultiBlockBase<GregtechMetaTileEntity_IndustrialMultiMachine> implements ISurvivalConstructable { protected int mInternalMode = 0; - protected GT_Recipe[] mLastRecipeExtended = new GT_Recipe[9]; private static final int MODE_COMPRESSOR = 0; private static final int MODE_LATHE = 1; private static final int MODE_MAGNETIC = 2; @@ -187,62 +184,11 @@ public class GregtechMetaTileEntity_IndustrialMultiMachine extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - ArrayList<FluidStack> tFluids = getStoredFluids(); - // Logger.MACHINE_INFO("1"); - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList<ItemStack> tBusItems = new ArrayList<ItemStack>(); - tBus.mRecipeMap = getRecipeMap(); - // Logger.MACHINE_INFO("2"); - if (isValidMetaTileEntity(tBus)) { - // Logger.MACHINE_INFO("3"); - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) - tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - - boolean aFoundCircuitInBus = false; - for (ItemStack aBusItem : tBusItems) { - if (ItemUtils.isControlCircuit(aBusItem)) { - aFoundCircuitInBus = true; - } - } - if (!aFoundCircuitInBus) { - continue; - } - - Object[] tempArray = tFluids.toArray(new FluidStack[] {}); - FluidStack[] properArray; - properArray = ((tempArray != null && tempArray.length > 0) ? (FluidStack[]) tempArray - : new FluidStack[] {}); - - // Logger.MACHINE_INFO("4"); - if (checkRecipeGeneric( - tBusItems.toArray(new ItemStack[] {}), - properArray, - (2 * GT_Utility.getTier(this.getMaxInputVoltage())), - 80, - 250, - 10000)) - return true; - } - return false; - - // return checkRecipeGeneric(2*GT_Utility.getTier(this.getMaxInputVoltage()), 90, 180); - } - - @Override public int getMaxParallelRecipes() { return (2 * GT_Utility.getTier(this.getMaxInputVoltage())); } @Override - public int getEuDiscountForParallelism() { - return 80; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -263,11 +209,6 @@ public class GregtechMetaTileEntity_IndustrialMultiMachine extends } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } @@ -294,11 +235,7 @@ public class GregtechMetaTileEntity_IndustrialMultiMachine extends return null; } - private final GT_Recipe.GT_Recipe_Map getRecipeMap(ItemStack circuit) { - return getRecipeMap(getCircuitID(circuit)); - } - - private static final GT_Recipe.GT_Recipe_Map getRecipeMap(int aMode) { + private static GT_Recipe.GT_Recipe_Map getRecipeMap(int aMode) { if (aMode == MODE_COMPRESSOR) { return GT_Recipe.GT_Recipe_Map.sCompressorRecipes; } else if (aMode == MODE_LATHE) { @@ -323,81 +260,23 @@ public class GregtechMetaTileEntity_IndustrialMultiMachine extends } @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - - // Based on the Processing Array. A bit overkill, but very flexible. - - // Get Circuit info for this recipe. - ItemStack tCircuit = getCircuit(aItemInputs); - if (tCircuit == null) { - return false; - } - int tCircuitID = getCircuitID(tCircuit); - - Logger.MACHINE_INFO("Mode: " + tCircuitID); - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - - GT_Recipe.GT_Recipe_Map tRecipeMap = this.getRecipeMap(tCircuit); - if (tRecipeMap == null) return false; - GT_Recipe tRecipe = tRecipeMap.findRecipe( - getBaseMetaTileEntity(), - this.mLastRecipeExtended[tCircuitID], - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - - // Remember last recipe - an optimization for findRecipe() - // this.mLastRecipe = tRecipe; //Let's not do this, it's bad. - // Instead, how about I use a array for types? - this.mLastRecipeExtended[tCircuitID] = tRecipe; - - if (tRecipe == null) { - return false; - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setEUtModifier(aEUPercent / 100.0f).setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected FindRecipeResult findRecipe(GT_Recipe.GT_Recipe_Map map) { + ItemStack circuit = getCircuit(inputItems); + if (circuit == null) { + return FindRecipeResult.NOT_FOUND; + } + GT_Recipe.GT_Recipe_Map foundMap = getRecipeMap(getCircuitID(circuit)); + if (foundMap == null) { + return FindRecipeResult.NOT_FOUND; + } + return super.findRecipe(foundMap); + } + }.setSpeedBonus(1F / 3.5F).setEuModifier(0.8F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -426,7 +305,7 @@ public class GregtechMetaTileEntity_IndustrialMultiMachine extends mode = StatCollector.translateToLocal("GTPP.multiblock.multimachine.misc"); } mInfo.add(mode); - return mInfo.toArray(new String[mInfo.size()]); + return mInfo.toArray(new String[0]); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java index 9259e1e99a..89bd7fb1a8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialPlatePress.java @@ -10,13 +10,10 @@ import static gregtech.api.enums.GT_HatchElement.Muffler; import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import java.util.ArrayList; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -27,7 +24,7 @@ import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -116,8 +113,8 @@ public class GregtechMetaTileEntity_IndustrialPlatePress extends } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_COMPRESSOR_OP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_COMPRESSOR_OP; } @Override @@ -141,27 +138,8 @@ public class GregtechMetaTileEntity_IndustrialPlatePress extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList<ItemStack> tBusItems = new ArrayList<ItemStack>(); - tBus.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) - tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - - if (checkRecipeGeneric( - tBusItems.toArray(new ItemStack[] {}), - new FluidStack[] {}, - (4 * GT_Utility.getTier(this.getMaxInputVoltage())), - 100, - 500, - 10000)) - return true; - } - return false; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 6F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -170,16 +148,6 @@ public class GregtechMetaTileEntity_IndustrialPlatePress extends } @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -191,11 +159,6 @@ public class GregtechMetaTileEntity_IndustrialPlatePress extends } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java index d714dfca6b..134d9a236d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialSifter.java @@ -26,6 +26,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -156,13 +157,9 @@ public class GregtechMetaTileEntity_IndustrialSifter } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric((4 * GT_Utility.getTier(this.getMaxInputVoltage())), 75, 400, 10000); - } - - @Override - protected boolean doesMachineBoostOutput() { - return false; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 5F).setEuModifier(0.75F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -171,11 +168,6 @@ public class GregtechMetaTileEntity_IndustrialSifter } @Override - public int getEuDiscountForParallelism() { - return 75; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -186,11 +178,6 @@ public class GregtechMetaTileEntity_IndustrialSifter } @Override - public int getAmountOfOutputs() { - return 16; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java index 9317917ad3..85981bb5c2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialThermalCentrifuge.java @@ -24,6 +24,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -134,8 +135,9 @@ public class GregtechMetaTileEntity_IndustrialThermalCentrifuge } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric((8 * GT_Utility.getTier(this.getMaxInputVoltage())), 80, 150); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 2.5F).setEuModifier(0.8F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -144,11 +146,6 @@ public class GregtechMetaTileEntity_IndustrialThermalCentrifuge } @Override - public int getEuDiscountForParallelism() { - return 80; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -159,11 +156,6 @@ public class GregtechMetaTileEntity_IndustrialThermalCentrifuge } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java index 1ce6e5e72e..da6dcc4b28 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialVacuumFreezer.java @@ -27,6 +27,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -187,8 +188,8 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return this.checkRecipeGeneric(4, 100, 100); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 2F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -197,11 +198,6 @@ public class GregtechMetaTileEntity_IndustrialVacuumFreezer extends } @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java index e51cab5a92..e80d533774 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWashPlant.java @@ -23,6 +23,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -33,6 +35,10 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -164,11 +170,18 @@ public class GregtechMetaTileEntity_IndustrialWashPlant extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - if (checkForWater()) { - return checkRecipeGeneric((4 * GT_Utility.getTier(this.getMaxInputVoltage())), 100, 400); - } - return false; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { + if (checkForWater()) { + return CheckRecipeResultRegistry.SUCCESSFUL; + } + return SimpleCheckRecipeResult.ofFailure("no_water"); + } + }.setSpeedBonus(1F / 5F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -177,11 +190,6 @@ public class GregtechMetaTileEntity_IndustrialWashPlant extends } @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -193,11 +201,6 @@ public class GregtechMetaTileEntity_IndustrialWashPlant extends } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java index 7f28808c9b..a530ee45c9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialWireMill.java @@ -10,16 +10,12 @@ import static gregtech.api.enums.GT_HatchElement.Muffler; import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import java.util.ArrayList; -import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentTranslation; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -31,7 +27,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -119,8 +115,8 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_RECYCLER_OP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_RECYCLER_OP; } @Override @@ -144,34 +140,9 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric((4 * GT_Utility.getTier(this.getMaxInputVoltage())), 75, 200); - } - - @Override - public boolean checkRecipeGeneric(int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent, - int aOutputChanceRoll) { - if (!inputSeparation) - return super.checkRecipeGeneric(aMaxParallelRecipes, aEUPercent, aSpeedBonusPercent, aOutputChanceRoll); - List<ItemStack> buffer = new ArrayList<>(16); - FluidStack[] tFluidInputs = getStoredFluids().toArray(new FluidStack[0]); - for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) { - IGregTechTileEntity inv = tHatch.getBaseMetaTileEntity(); - for (int i = inv.getSizeInventory() - 1; i >= 0; i--) { - if (inv.getStackInSlot(i) != null) buffer.add(inv.getStackInSlot(i)); - } - ItemStack[] tItemInputs = buffer.toArray(new ItemStack[0]); - if (checkRecipeGeneric( - tItemInputs, - tFluidInputs, - aMaxParallelRecipes, - aEUPercent, - aSpeedBonusPercent, - aOutputChanceRoll)) - return true; - buffer.clear(); - } - return false; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3F).setEuModifier(0.75F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -197,11 +168,6 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends } @Override - public int getEuDiscountForParallelism() { - return 75; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -212,11 +178,6 @@ public class GregtechMetaTileEntity_IndustrialWireMill extends } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IronBlastFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IronBlastFurnace.java deleted file mode 100644 index 4d122f3619..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IronBlastFurnace.java +++ /dev/null @@ -1,510 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; - -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import com.gtnewhorizons.modularui.common.widget.ProgressBar; -import com.gtnewhorizons.modularui.common.widget.SlotWidget; - -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.gui.modularui.GT_UIInfos; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.modularui.IAddUIWidgets; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.xmod.gregtech.api.gui.GTPP_UITextures; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntity_IronBlastFurnace extends MetaTileEntity implements IAddUIWidgets { - - private static final ITexture[] FACING_SIDE = { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Simple_Top) }; - private static final ITexture[] FACING_FRONT = { - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_Off) }; - private static final ITexture[] FACING_ACTIVE = { - new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Redstone_On) }; - public int mMaxProgresstime = 0; - public int mUpdate = 30; - public int mProgresstime = 0; - public boolean mMachine = false; - public ItemStack mOutputItem1; - public ItemStack mOutputItem2; - - public GregtechMetaTileEntity_IronBlastFurnace(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional, 4); - } - - public GregtechMetaTileEntity_IronBlastFurnace(final String aName) { - super(aName, 4); - } - - @Override - public String[] getDescription() { - return new String[] { "Iron is a much better furnace material!", "Can be Automated", - "Multiblock: 3x3x5 hollow with opening on top", - "Same shape as Bronze/Bricked blast furnace, except one ring of 8 taller.", - "40 Iron Plated Bricks required", }; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - if (side == facing) { - return aActive ? FACING_ACTIVE : FACING_FRONT; - } - return FACING_SIDE; - } - - @Override - public boolean isSteampowered() { - return false; - } - - @Override - public boolean isElectric() { - return false; - } - - @Override - public boolean isPneumatic() { - return false; - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public boolean isInputFacing(final ForgeDirection side) { - return false; - } - - @Override - public boolean isOutputFacing(final ForgeDirection side) { - return false; - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public boolean isFacingValid(final ForgeDirection facing) { - return facing.offsetY == 0; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public int getProgresstime() { - return this.mProgresstime; - } - - @Override - public int maxProgresstime() { - return this.mMaxProgresstime; - } - - @Override - public int increaseProgress(final int aProgress) { - this.mProgresstime += aProgress; - return this.mMaxProgresstime - this.mProgresstime; - } - - @Override - public boolean allowCoverOnSide(final ForgeDirection side, final GT_ItemStack aCoverID) { - return (GregTech_API.getCoverBehaviorNew(aCoverID.toStack()).isSimpleCover()) - && (super.allowCoverOnSide(side, aCoverID)); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntity_IronBlastFurnace(this.mName); - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) { - aNBT.setInteger("mProgresstime", this.mProgresstime); - aNBT.setInteger("mMaxProgresstime", this.mMaxProgresstime); - if (this.mOutputItem1 != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputItem1.writeToNBT(tNBT); - aNBT.setTag("mOutputItem1", tNBT); - } - if (this.mOutputItem2 != null) { - final NBTTagCompound tNBT = new NBTTagCompound(); - this.mOutputItem2.writeToNBT(tNBT); - aNBT.setTag("mOutputItem2", tNBT); - } - } - - @Override - public void loadNBTData(final NBTTagCompound aNBT) { - this.mUpdate = 30; - this.mProgresstime = aNBT.getInteger("mProgresstime"); - this.mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - this.mOutputItem1 = GT_Utility.loadItem(aNBT, "mOutputItem1"); - this.mOutputItem2 = GT_Utility.loadItem(aNBT, "mOutputItem2"); - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); - return true; - } - - private boolean checkMachine() { - final int xDir = this.getBaseMetaTileEntity().getBackFacing().offsetX; - final int zDir = this.getBaseMetaTileEntity().getBackFacing().offsetZ; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 4; j++) { // This is height - for (int k = -1; k < 2; k++) { - if (((xDir + i) != 0) || (j != 0) || ((zDir + k) != 0)) { - if ((i != 0) || (j == -1) || (k != 0)) { - if ((this.getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k) - != ModBlocks.blockCasingsMisc) - || (this.getBaseMetaTileEntity().getMetaIDOffset(xDir + i, j, zDir + k) != 10)) { - return false; - } - } else if ((!GT_Utility.arrayContains( - this.getBaseMetaTileEntity().getBlockOffset(xDir + i, j, zDir + k), - new Object[] { Blocks.lava, Blocks.flowing_lava, null })) - && (!this.getBaseMetaTileEntity().getAirOffset(xDir + i, j, zDir + k))) { - return false; - } - } - } - } - } - return true; - } - - @Override - public void onMachineBlockUpdate() { - this.mUpdate = 30; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { - if ((aBaseMetaTileEntity.isClientSide()) && (aBaseMetaTileEntity.isActive())) { - aBaseMetaTileEntity.getWorld().spawnParticle( - "cloud", - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), - aBaseMetaTileEntity.getOffsetY(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1) + Math.random(), - 0.0D, - 0.3D, - 0.0D); - } - if (aBaseMetaTileEntity.isServerSide()) { - if (this.mUpdate-- == 0) { - this.mMachine = this.checkMachine(); - } - if (this.mMachine) { - if (this.mMaxProgresstime > 0) { - if (++this.mProgresstime >= this.mMaxProgresstime) { - this.addOutputProducts(); - this.mOutputItem1 = null; - this.mOutputItem2 = null; - this.mProgresstime = 0; - this.mMaxProgresstime = 0; - try { - GT_Mod.instance.achievements.issueAchievement( - aBaseMetaTileEntity.getWorld() - .getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), - "steel"); - } catch (final Exception e) {} - } - } else if (aBaseMetaTileEntity.isAllowedToWork()) { - this.checkRecipe(); - } - } - aBaseMetaTileEntity.setActive((this.mMaxProgresstime > 0) && (this.mMachine)); - if (aBaseMetaTileEntity.isActive()) { - if (aBaseMetaTileEntity.getAir( - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { - aBaseMetaTileEntity.getWorld().setBlock( - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), - Blocks.lava, - 1, - 2); - this.mUpdate = 1; - } - if (aBaseMetaTileEntity.getAir( - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord() + 1, - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1))) { - aBaseMetaTileEntity.getWorld().setBlock( - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord() + 1, - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), - Blocks.lava, - 1, - 2); - this.mUpdate = 1; - } - } else { - if (aBaseMetaTileEntity.getBlock( - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { - aBaseMetaTileEntity.getWorld().setBlock( - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord(), - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), - Blocks.air, - 0, - 2); - this.mUpdate = 1; - } - if (aBaseMetaTileEntity.getBlock( - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord() + 1, - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1)) == Blocks.lava) { - aBaseMetaTileEntity.getWorld().setBlock( - aBaseMetaTileEntity.getOffsetX(aBaseMetaTileEntity.getBackFacing(), 1), - aBaseMetaTileEntity.getYCoord() + 1, - aBaseMetaTileEntity.getOffsetZ(aBaseMetaTileEntity.getBackFacing(), 1), - Blocks.air, - 0, - 2); - this.mUpdate = 1; - } - } - } - } - - private void addOutputProducts() { - if (this.mOutputItem1 != null) { - if (this.mInventory[2] == null) { - this.mInventory[2] = GT_Utility.copy(new Object[] { this.mOutputItem1 }); - } else if (GT_Utility.areStacksEqual(this.mInventory[2], this.mOutputItem1)) { - this.mInventory[2].stackSize = Math.min( - this.mOutputItem1.getMaxStackSize(), - this.mOutputItem1.stackSize + this.mInventory[2].stackSize); - } - } - if (this.mOutputItem2 != null) { - if (this.mInventory[3] == null) { - this.mInventory[3] = GT_Utility.copy(new Object[] { this.mOutputItem2 }); - } else if (GT_Utility.areStacksEqual(this.mInventory[3], this.mOutputItem2)) { - this.mInventory[3].stackSize = Math.min( - this.mOutputItem2.getMaxStackSize(), - this.mOutputItem2.stackSize + this.mInventory[3].stackSize); - } - } - } - - private boolean spaceForOutput(final ItemStack aStack1, final ItemStack aStack2) { - if (((this.mInventory[2] == null) || (aStack1 == null) - || (((this.mInventory[2].stackSize + aStack1.stackSize) <= this.mInventory[2].getMaxStackSize()) - && (GT_Utility.areStacksEqual(this.mInventory[2], aStack1)))) - && ((this.mInventory[3] == null) || (aStack2 == null) - || (((this.mInventory[3].stackSize + aStack2.stackSize) <= this.mInventory[3].getMaxStackSize()) - && (GT_Utility.areStacksEqual(this.mInventory[3], aStack2))))) { - return true; - } - return false; - } - - private int getProperTime(int time) { - return time / 3; - } - - private boolean checkRecipe() { - - if (!this.mMachine) { - return false; - } - if ((this.mInventory[0] != null) && (this.mInventory[1] != null) && (this.mInventory[0].stackSize >= 1)) { - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustIron")) - || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "ingotIron"))) { - if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 4) - && (this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), - this.mOutputItem2 = GT_OreDictUnificator - .get(OrePrefixes.dustTiny, Materials.DarkAsh, 4L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 4 * 3); - this.mMaxProgresstime = getProperTime(36000); - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) - && (this.mInventory[1].stackSize >= 2) - && (this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), - this.mOutputItem2 = GT_OreDictUnificator - .get(OrePrefixes.dustTiny, Materials.Ash, 4L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 2 * 3); - this.mMaxProgresstime = getProperTime(4800); - return true; - } - if ((this.mInventory[0].stackSize >= 9) - && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) - || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) - && (this.mInventory[1].stackSize >= 4) - && (this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator - .get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 9); - this.getBaseMetaTileEntity().decrStackSize(1, 4 * 3); - this.mMaxProgresstime = getProperTime(64800); - return true; - } - } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "dustSteel")) { - if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 2) - && (this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), - this.mOutputItem2 = GT_OreDictUnificator - .get(OrePrefixes.dustTiny, Materials.DarkAsh, 2L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 2 * 3); - this.mMaxProgresstime = getProperTime(3600); - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) - && (this.mInventory[1].stackSize >= 1) - && (this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 1L), - this.mOutputItem2 = GT_OreDictUnificator - .get(OrePrefixes.dustTiny, Materials.Ash, 2L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 1 * 3); - this.mMaxProgresstime = getProperTime(2400); - return true; - } - if ((this.mInventory[0].stackSize >= 9) - && ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) - || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) - && (this.mInventory[1].stackSize >= 2) - && (this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator - .get(OrePrefixes.dust, Materials.DarkAsh, 2L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 9); - this.getBaseMetaTileEntity().decrStackSize(1, 2 * 3); - this.mMaxProgresstime = getProperTime(32400); - return true; - } - } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[0], "blockIron")) { - if ((this.mInventory[1].getItem() == Items.coal) && (this.mInventory[1].stackSize >= 36) - && (this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator - .get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 64); - this.mMaxProgresstime = getProperTime(64800); - return true; - } - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "fuelCoke")) - && (this.mInventory[1].stackSize >= 18) - && (this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Ash, 4L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 18 * 3); - this.mMaxProgresstime = getProperTime(43200); - return true; - } - if (((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCoal")) - || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[1], "blockCharcoal"))) - && (this.mInventory[1].stackSize >= 4) - && (this.spaceForOutput( - this.mOutputItem1 = GT_OreDictUnificator.get(OrePrefixes.ingot, Materials.Steel, 9L), - this.mOutputItem2 = GT_OreDictUnificator - .get(OrePrefixes.dust, Materials.DarkAsh, 4L)))) { - this.getBaseMetaTileEntity().decrStackSize(0, 1); - this.getBaseMetaTileEntity().decrStackSize(1, 4 * 3); - this.mMaxProgresstime = getProperTime(64800); - return true; - } - } - } - this.mOutputItem1 = null; - this.mOutputItem2 = null; - return false; - } - - @Override - public boolean isGivingInformation() { - return false; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return aIndex > 1; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - if (aIndex < 2) {} - return !GT_Utility.areStacksEqual(aStack, this.mInventory[0]); - } - - @Override - public byte getTileEntityBaseType() { - return 0; - } - - @Override - public boolean useModularUI() { - return true; - } - - @Override - public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - builder.widget( - new SlotWidget(inventoryHandler, 0) - .setBackground(getGUITextureSet().getItemSlot(), GTPP_UITextures.OVERLAY_SLOT_INGOT) - .setPos(33, 15)) - .widget( - new SlotWidget(inventoryHandler, 1) - .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_FURNACE) - .setPos(33, 33)) - .widget( - new SlotWidget(inventoryHandler, 2).setAccess(true, false) - .setBackground(getGUITextureSet().getItemSlot(), GTPP_UITextures.OVERLAY_SLOT_INGOT) - .setPos(85, 24)) - .widget( - new SlotWidget(inventoryHandler, 3).setAccess(true, false) - .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_DUST) - .setPos(103, 24)) - .widget( - new ProgressBar().setTexture(GTPP_UITextures.PROGRESSBAR_ARROW_2, 20) - .setProgress(() -> (float) mProgresstime / mMaxProgresstime).setPos(58, 24) - .setSize(20, 18)); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java index 46a978aa3b..aef24e2f69 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java @@ -26,7 +26,8 @@ import net.minecraft.util.DamageSource; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -37,6 +38,10 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -334,11 +339,6 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase< } } - @Override - public boolean checkRecipe(ItemStack aStack) { - return checkRecipeGeneric(); - } - public Block getCasingBlock() { return ModBlocks.blockCasings5Misc; } @@ -423,11 +423,6 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase< return 1; } - @Override - public int getEuDiscountForParallelism() { - return 0; - } - /* * Milling Ball Handling */ @@ -496,55 +491,30 @@ public class GregtechMetaTileEntity_IsaMill extends GregtechMeta_MultiBlockBase< } @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - - // Based on the Processing Array. A bit overkill, but very flexible. + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; + ItemStack millingBall; - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - // checks if it has a milling ball with enough durability - ItemStack tMillingBallRecipe = findMillingBall(aItemInputs); - if (tMillingBallRecipe == null) { - return false; - } - - GT_Recipe tRecipe = findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - return false; - } - - boolean tSuccess = super.checkRecipeGeneric( - aItemInputs, - aFluidInputs, - aMaxParallelRecipes, - aEUPercent, - aSpeedBonusPercent, - aOutputChanceRoll, - tRecipe); - - // Damage Milling ball once all is said and done. - if (tSuccess) { - damageMillingBall(tMillingBallRecipe); - } + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { + millingBall = findMillingBall(inputItems); + if (millingBall == null) { + return SimpleCheckRecipeResult.ofFailure("no_milling_ball"); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } - return tSuccess; + @NotNull + @Override + public CheckRecipeResult process() { + CheckRecipeResult result = super.process(); + if (result.wasSuccessful()) { + damageMillingBall(millingBall); + } + return result; + } + }; } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_NuclearSaltProcessingPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_NuclearSaltProcessingPlant.java index 2d1ab5801b..8a67e0190a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_NuclearSaltProcessingPlant.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_NuclearSaltProcessingPlant.java @@ -10,10 +10,7 @@ import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.enums.GT_HatchElement.OutputHatch; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import java.util.ArrayList; - import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -25,8 +22,8 @@ import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -190,42 +187,8 @@ public class GregtechMetaTileEntity_NuclearSaltProcessingPlant } @Override - public boolean checkRecipe(final ItemStack itemStack) { - if (inputSeparation) { - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList<ItemStack> rList = new ArrayList<>(); - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) - rList.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - - if (checkRecipeGeneric( - rList.toArray(new ItemStack[0]), - getStoredFluids().toArray(new FluidStack[0]), - getMaxParallelRecipes(), - getEuDiscountForParallelism(), - 150, - 10000)) { - return true; - } - } - - return checkRecipeGeneric( - new ItemStack[0], - getStoredFluids().toArray(new FluidStack[0]), - getMaxParallelRecipes(), - getEuDiscountForParallelism(), - 150, - 10000); - } else { - return checkRecipeGeneric( - getStoredInputs().toArray(new ItemStack[0]), - getStoredFluids().toArray(new FluidStack[0]), - getMaxParallelRecipes(), - getEuDiscountForParallelism(), - 150, - 10000); - } + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 2.5F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -234,11 +197,6 @@ public class GregtechMetaTileEntity_NuclearSaltProcessingPlant } @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override public String[] getExtraInfoData() { final String running = (this.mMaxProgresstime > 0 ? "Salt Plant running" : "Salt Plant stopped"); final String maintenance = (this.getIdealStatus() == this.getRepairStatus() ? "No Maintenance issues" diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java index 6f12db25ba..662f0e0470 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_SpargeTower.java @@ -21,6 +21,8 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -33,6 +35,8 @@ import gregtech.api.interfaces.fluid.IFluidStore; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; @@ -189,10 +193,7 @@ public class GregtechMetaTileEntity_SpargeTower extends GregtechMeta_MultiBlockB 0); GTPP_Recipe_Map.sSpargeTowerRecipes.add(newRecipe); } - if (GTPP_Recipe_Map.sSpargeTowerRecipes.mRecipeList.isEmpty()) { - return false; - } - return true; + return !GTPP_Recipe_Map.sSpargeTowerRecipes.mRecipeList.isEmpty(); } @Override @@ -201,57 +202,36 @@ public class GregtechMetaTileEntity_SpargeTower extends GregtechMeta_MultiBlockB } @Override - public boolean checkRecipe(ItemStack aStack) { + public @NotNull CheckRecipeResult checkProcessing() { ArrayList<FluidStack> tFluidList = getStoredFluids(); long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(0, GT_Utility.getTier(tVoltage)); FluidStack[] tFluids = tFluidList.toArray(new FluidStack[0]); if (tFluids.length > 0) { - Logger.INFO( - "Found " + tFluids.length - + " input fluids. Searching " - + GTPP_Recipe_Map.sSpargeTowerRecipes.mRecipeList.size() - + " recipes."); GT_Recipe tRecipe = getRecipeMap() .findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], tFluids); if (tRecipe != null) { - Logger.INFO("Found recipe!"); FluidStack[] possibleOutputs = getPossibleByproductsOfSparge( tRecipe.mFluidInputs[0], tRecipe.mFluidInputs[1]).toArray(new FluidStack[0]); if (canOutputAll(possibleOutputs) && tRecipe.isRecipeInputEqual(true, tFluids)) { - Logger.INFO("Found recipe that matches!"); this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - // Reset outputs and progress stats - this.lEUt = 0; - this.mProgresstime = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - this.mLastRecipe = tRecipe; - calculateOverclockedNessMulti((long) tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); - int aDevProgress = this.mMaxProgresstime / 10; - this.mMaxProgresstime = Math.max(1, aDevProgress); - this.mOutputItems = new ItemStack[] {}; + mMaxProgresstime = Math.max(1, mMaxProgresstime / 10); ArrayList<FluidStack> aFluidOutputs = getByproductsOfSparge( tRecipe.mFluidInputs[0], tRecipe.mFluidInputs[1]); - this.mOutputFluids = (FluidStack[]) aFluidOutputs.toArray(new FluidStack[0]); + this.mOutputFluids = aFluidOutputs.toArray(new FluidStack[0]); updateSlots(); - Logger.INFO("Done!"); - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } - } else { - Logger.INFO("Did not find recipe!"); } } this.lEUt = 0; this.mEfficiency = 0; - Logger.INFO("Did not find recipe! (2)"); - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } private static List<FluidStack> getPossibleByproductsOfSparge(final FluidStack aSpargeGas, @@ -329,14 +309,13 @@ public class GregtechMetaTileEntity_SpargeTower extends GregtechMeta_MultiBlockB protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { if (aTileEntity == null || aTileEntity.isDead() - || !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output)) { + || !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output tHatch)) { Logger.INFO("Bad Output Hatch"); return false; } while (mOutputHatchesByLayer.size() < mHeight) { mOutputHatchesByLayer.add(new ArrayList<>()); } - GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aTileEntity.getMetaTileEntity(); tHatch.updateTexture(aBaseCasingIndex); boolean addedHatch = mOutputHatchesByLayer.get(mHeight - 1).add(tHatch); Logger.INFO("Added Hatch: " + addedHatch); @@ -480,11 +459,6 @@ public class GregtechMetaTileEntity_SpargeTower extends GregtechMeta_MultiBlockB } @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override public boolean onPlungerRightClick(EntityPlayer aPlayer, ForgeDirection side, float aX, float aY, float aZ) { int aLayerIndex = 0; PlayerUtils.messagePlayer( diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java index fa062f26b9..53ce867b6c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java @@ -38,7 +38,7 @@ import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.fluid.IFluidStore; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -364,29 +364,15 @@ public class GregtechMetaTileEntity_Adv_DistillationTower extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - // Run standard recipe handling for distillery recipes - if (mMode == Mode.Distillery) { - return this.checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 100); - } else { - ItemStack[] inputs = getCompactedInputs(); - - for (GT_MetaTileEntity_Hatch_Input hatch : mInputHatches) { - FluidStack tFluid = hatch.getFluid(); - if (tFluid != null) { - if (checkRecipeGeneric( - inputs, - new FluidStack[] { tFluid }, - getMaxParallelRecipes(), - 100, - 250, - 10000)) { - return true; - } - } - } - return false; - } + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setMaxParallelSupplier(this::getMaxParallelRecipes); + } + + @Override + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.setEuModifier(mMode == Mode.Distillery ? 0.15F : 1F); + logic.setSpeedBonus(mMode == Mode.Distillery ? 1F / 2F : 1F / 3.5F); } @Override @@ -401,11 +387,6 @@ public class GregtechMetaTileEntity_Adv_DistillationTower extends } } - @Override - public int getEuDiscountForParallelism() { - return 15; - } - private int getTierOfTower() { return mUpgraded ? 2 : 1; } @@ -429,7 +410,7 @@ public class GregtechMetaTileEntity_Adv_DistillationTower extends public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); if (aTick % 20 == 0 && !mUpgraded) { - ItemStack aGuiStack = this.getGUIItemStack(); + ItemStack aGuiStack = this.getControllerSlot(); if (aGuiStack != null) { if (GT_Utility.areStacksEqual(aGuiStack, GregtechItemList.Distillus_Upgrade_Chip.get(1))) { this.mUpgraded = true; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java index c079365b63..42e117cce9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java @@ -25,6 +25,8 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -35,7 +37,9 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_OverclockCalculator; import gregtech.api.util.GT_ParallelHelper; @@ -224,28 +228,24 @@ public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase< } @Override - public boolean checkRecipe(ItemStack aStack) { - if (inputSeparation) { - FluidStack[] tFluids = getStoredFluids().toArray(new FluidStack[0]); - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList<ItemStack> tInputs = new ArrayList<>(); - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) { - tInputs.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - } - if (tInputs.size() > 0) { - if (checkRecipeGeneric(tInputs.toArray(new ItemStack[0]), tFluids, 8, 90, 120, 10000)) { - return true; - } - } + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { + return recipe.mSpecialValue <= getCoilLevel().getHeat() ? CheckRecipeResultRegistry.SUCCESSFUL + : CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); } - return false; - } else { - return checkRecipeGeneric(8, 90, 120); - } + + @NotNull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe, + @NotNull GT_ParallelHelper helper) { + return super.createOverclockCalculator(recipe, helper).enableHeatOC().enableHeatDiscount() + .setRecipeHeat(recipe.mSpecialValue).setMultiHeat((int) getCoilLevel().getHeat()); + } + }.setSpeedBonus(1F / 2.2F).setEuModifier(0.9F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -268,70 +268,6 @@ public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase< return false; } - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - - GT_Recipe tRecipe = this.getRecipeMap().findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null || this.mHeatingCapacity.getHeat() < tRecipe.mSpecialValue) { - return false; - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setEUtModifier(aEUPercent / 100.0f).setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .enableHeatOC().enableHeatDiscount().setRecipeHeat(tRecipe.mSpecialValue) - .setMultiHeat((int) getCoilLevel().getHeat()).calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; - } - private int mGraceTimer = 2; @Override @@ -360,11 +296,6 @@ public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase< } @Override - public int getEuDiscountForParallelism() { - return 90; - } - - @Override public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { inputSeparation = !inputSeparation; aPlayer.addChatMessage( diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_HeatExchanger.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_HeatExchanger.java index 7f583a892e..5668cd40be 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_HeatExchanger.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_HeatExchanger.java @@ -14,6 +14,8 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; @@ -26,6 +28,8 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; @@ -183,8 +187,8 @@ public class GregtechMetaTileEntity_Adv_HeatExchanger } @Override - public boolean checkRecipe(ItemStack aStack) { - if (mInputHotFluidHatch.getFluid() == null) return true; + public @NotNull CheckRecipeResult checkProcessing() { + if (mInputHotFluidHatch.getFluid() == null) return CheckRecipeResultRegistry.SUCCESSFUL; int fluidAmountToConsume = mInputHotFluidHatch.getFluidAmount(); // how much fluid is in hatch @@ -219,7 +223,7 @@ public class GregtechMetaTileEntity_Adv_HeatExchanger } else { // If we're working with neither, fail out superheated_threshold = 0; - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } superheated = fluidAmountToConsume >= superheated_threshold; // set the internal superheated flag if we have @@ -237,7 +241,7 @@ public class GregtechMetaTileEntity_Adv_HeatExchanger mOutputColdFluidHatch.fill(FluidRegistry.getFluidStack("ic2coolant", fluidAmountToConsume), true); } this.mEfficiencyIncrease = 80; - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } private int useWater(float input) { @@ -404,11 +408,6 @@ public class GregtechMetaTileEntity_Adv_HeatExchanger return 0; } - @Override - public int getEuDiscountForParallelism() { - return 0; - } - private static Block sFrame; public static Block getFrame() { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java index e89830cefe..3a348f24d8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Implosion.java @@ -8,7 +8,6 @@ import static gregtech.api.GregTech_API.sBlockCasings4; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; @@ -17,6 +16,7 @@ import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; @@ -143,21 +143,13 @@ public class GregtechMetaTileEntity_Adv_Implosion } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric((GT_Utility.getTier(this.getMaxInputVoltage()) / 2 + 1), 100, 100); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 2F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 20) { - GT_Utility.doSoundAtClient(new ResourceLocation(getSound()), 10, 1.0F, aX, aY, aZ); - } - } - - @Override - public String getSound() { - return SoundResource.RANDOM_EXPLODE.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.RANDOM_EXPLODE; } @Override @@ -185,8 +177,4 @@ public class GregtechMetaTileEntity_Adv_Implosion return (GT_Utility.getTier(this.getMaxInputVoltage()) / 2 + 1); } - @Override - public int getEuDiscountForParallelism() { - return 100; - } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java index 07d81728e5..e37a6783f5 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_AutoCrafter.java @@ -11,11 +11,7 @@ import static gregtech.api.enums.GT_HatchElement.Muffler; import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import java.util.ArrayList; - -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -26,8 +22,8 @@ import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -43,8 +39,6 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase<GT4Entity private int casing; private static IStructureDefinition<GT4Entity_AutoCrafter> STRUCTURE_DEFINITION = null; - public void onRightclick(EntityPlayer player) {} - public GT4Entity_AutoCrafter(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -89,11 +83,6 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase<GT4Entity } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override protected GT_Multiblock_Tooltip_Builder createTooltip() { GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType(getMachineType()).addInfo("Highly Advanced Assembling Machine") @@ -165,31 +154,8 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase<GT4Entity } @Override - public boolean checkRecipe(final ItemStack itemStack) { - FluidStack[] properArray = getStoredFluids().toArray(new FluidStack[] {}); - - for (GT_MetaTileEntity_Hatch_InputBus bus : mInputBusses) { - ArrayList<ItemStack> tBusItems = new ArrayList<ItemStack>(); - if (isValidMetaTileEntity(bus)) { - for (int i = bus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (bus.getBaseMetaTileEntity().getStackInSlot(i) != null) { - tBusItems.add(bus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - } - - if (checkRecipeGeneric( - tBusItems.toArray(new ItemStack[] {}), - properArray, - getMaxParallelRecipes(), - 100, - 200, - 10_000)) { - return true; - } - - } - return false; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -198,11 +164,6 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase<GT4Entity } @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override public String[] getExtraInfoData() { final String running = (this.mMaxProgresstime > 0 ? "Auto-Crafter running" : "Auto-Crafter stopped"); final String maintenance = (this.getIdealStatus() == this.getRepairStatus() ? "No Maintenance issues" @@ -229,4 +190,9 @@ public class GT4Entity_AutoCrafter extends GregtechMeta_MultiBlockBase<GT4Entity AC_Helper_Utils.removeCrafter(this); super.doExplosion(aExplosionPower); } + + @Override + public boolean supportsInputSeparation() { + return true; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java index 87037e89ae..89da64852a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GT4Entity_ThermalBoiler.java @@ -18,6 +18,8 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -30,6 +32,8 @@ import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; @@ -85,7 +89,8 @@ public class GT4Entity_ThermalBoiler extends GregtechMeta_MultiBlockBase<GT4Enti private static Fluid mSolarSaltHot = null; @Override - public boolean checkRecipe(ItemStack aStack) { + public @NotNull CheckRecipeResult checkProcessing() { + ItemStack controllerStack = getControllerSlot(); this.mSuperEfficencyIncrease = 0; if (mLavaFilter == null) { @@ -102,11 +107,11 @@ public class GT4Entity_ThermalBoiler extends GregtechMeta_MultiBlockBase<GT4Enti } // Try reload new Lava Filter - if (aStack == null) { + if (controllerStack == null) { ItemStack uStack = this.findItemInInventory(mLavaFilter); if (uStack != null) { this.setGUIItemStack(uStack); - aStack = this.getGUIItemStack(); + controllerStack = this.getControllerSlot(); } } @@ -121,7 +126,7 @@ public class GT4Entity_ThermalBoiler extends GregtechMeta_MultiBlockBase<GT4Enti this.mEfficiencyIncrease = (this.mMaxProgresstime * getEfficiencyIncrease()); int loot_MAXCHANCE = 100000; - if (aStack != null && aStack.getItem() == mLavaFilter) { + if (controllerStack != null && controllerStack.getItem() == mLavaFilter) { if ((tRecipe.getOutput(0) != null) && (getBaseMetaTileEntity().getRandomNumber(loot_MAXCHANCE) < tRecipe.getOutputChance(0))) { @@ -166,7 +171,7 @@ public class GT4Entity_ThermalBoiler extends GregtechMeta_MultiBlockBase<GT4Enti this.mOutputItems = new ItemStack[] { GT_Utility.copy(tRecipe.getOutput(6)) }; } } - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } } else if (tFluid.getFluid() == mSolarSaltHot) { if (depleteInput(tFluid)) { @@ -176,14 +181,14 @@ public class GT4Entity_ThermalBoiler extends GregtechMeta_MultiBlockBase<GT4Enti for (FluidStack aOutput : tRecipe.mFluidOutputs) { this.addOutput(FluidUtils.getFluidStack(aOutput, aOutput.amount)); } - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } } } } this.mMaxProgresstime = 0; this.lEUt = 0; - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } @Override @@ -192,11 +197,6 @@ public class GT4Entity_ThermalBoiler extends GregtechMeta_MultiBlockBase<GT4Enti } @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override public boolean onRunningTick(ItemStack aStack) { if (this.lEUt > 0) { if (this.mSuperEfficencyIncrease > 0) { @@ -245,11 +245,6 @@ public class GT4Entity_ThermalBoiler extends GregtechMeta_MultiBlockBase<GT4Enti } @Override - public int getAmountOfOutputs() { - return 7; - } - - @Override protected GT_Multiblock_Tooltip_Builder createTooltip() { GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType(getMachineType()).addInfo("Thermal Boiler Controller") @@ -337,7 +332,7 @@ public class GT4Entity_ThermalBoiler extends GregtechMeta_MultiBlockBase<GT4Enti public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { // Reload Lava Filter - if (this.getGUIItemStack() == null) { + if (this.getControllerSlot() == null) { if (this.mInputBusses.size() > 0) { for (GT_MetaTileEntity_Hatch_InputBus aBus : this.mInputBusses) { for (ItemStack aStack : aBus.mInventory) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java index b9508c4fe8..4f5a9ce341 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_ElementalDuplicator.java @@ -21,6 +21,9 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; @@ -32,12 +35,12 @@ import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.objects.GT_ItemStack; +import gregtech.api.recipe.check.FindRecipeResult; import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_OverclockCalculator; -import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; @@ -273,96 +276,50 @@ public class GregtechMTE_ElementalDuplicator extends GregtechMeta_MultiBlockBase } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), 100, 100); - } - - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - GT_Recipe tRecipe = null; - - try { - ItemStack aDataOrbStack = null; - recipe: for (GT_Recipe nRecipe : this.getRecipeMap().mRecipeList) { - // log("Checking Recipe for: "+(nRecipe.mOutputs.length > 0 && nRecipe.mOutputs[0] != null ? - // nRecipe.mOutputs[0].getDisplayName() : nRecipe.mFluidOutputs[0].getLocalizedName())); - ItemStack aTempStack = getSpecialSlotStack(nRecipe); - if (aTempStack != null) { - for (ItemStack aItem : aItemInputs) { - if (nRecipe.mSpecialItems != null) { - if (GT_Utility.areStacksEqual(aTempStack, aItem, false)) { - aDataOrbStack = aTempStack; - break recipe; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected FindRecipeResult findRecipe(@Nullable GT_Recipe_Map map) { + if (map == null) { + return FindRecipeResult.NOT_FOUND; + } + try { + ItemStack aDataOrbStack = null; + recipe: for (GT_Recipe nRecipe : map.mRecipeList) { + ItemStack aTempStack = getSpecialSlotStack(nRecipe); + if (aTempStack != null) { + for (ItemStack aItem : inputItems) { + if (nRecipe.mSpecialItems != null) { + if (GT_Utility.areStacksEqual(aTempStack, aItem, false)) { + aDataOrbStack = aTempStack; + break recipe; + } + } } } } + if (aDataOrbStack != null) { + GT_Recipe recipe = GregtechMTE_ElementalDuplicator.this.findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + false, + availableVoltage, + inputFluids, + aDataOrbStack, + inputItems); + if (recipe != null) { + return FindRecipeResult.ofSuccess(recipe); + } + } + } catch (Throwable t) { + t.printStackTrace(); } + return FindRecipeResult.NOT_FOUND; } - if (aDataOrbStack != null) { - tRecipe = findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aDataOrbStack, - aItemInputs); - } - } catch (Throwable t) { - t.printStackTrace(); - } - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - return false; - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tVoltage).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setEUtModifier(aEUPercent / 100.0f).setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tVoltage) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .enablePerfectOC().calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; + }.setSpeedBonus(1F / 2F).enablePerfectOverclock().setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -371,11 +328,6 @@ public class GregtechMTE_ElementalDuplicator extends GregtechMeta_MultiBlockBase } @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java index 2ee6b4d93a..601861a6b1 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java @@ -17,7 +17,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -32,10 +33,13 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; @@ -81,8 +85,8 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase< } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; } @Override @@ -111,11 +115,6 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase< } @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override public IStructureDefinition<GregtechMTE_FrothFlotationCell> getStructureDefinition() { if (STRUCTURE_DEFINITION == null) { STRUCTURE_DEFINITION = StructureDefinition.<GregtechMTE_FrothFlotationCell>builder().addShape( @@ -169,11 +168,6 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase< } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } @@ -194,72 +188,40 @@ public class GregtechMTE_FrothFlotationCell extends GregtechMeta_MultiBlockBase< } @Override - public boolean checkRecipe(ItemStack arg0) { - return super.checkRecipeGeneric(); - } - - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - return false; - } - - /* - * Material checks Makes sure we can only ever use one type of material in this flotation cell. We used to - * depend on Alk's hash, but it's unreliable and user-hostile So we're using unlocalized name of material now. - */ - Material foundMaterial = FlotationRecipeHandler - .getMaterialOfMilledProduct(FlotationRecipeHandler.findMilledStack(tRecipe)); - String foundMaterialName = null; - if (foundMaterial != null) { - foundMaterialName = foundMaterial.getUnlocalizedName(); - } - - if (foundMaterialName == null) { - return false; - } - - // Set material locked for this controller - if (lockedMaterialName == null) { - lockedMaterialName = foundMaterialName; - } - - // Check material match - if (!Objects.equals(lockedMaterialName, foundMaterialName)) { - return false; - } - - return super.checkRecipeGeneric( - aItemInputs, - aFluidInputs, - aMaxParallelRecipes, - aEUPercent, - aSpeedBonusPercent, - aOutputChanceRoll, - tRecipe); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { + /* + * Material checks Makes sure we can only ever use one type of material in this flotation cell. We used + * to depend on Alk's hash, but it's unreliable and user-hostile So we're using unlocalized name of + * material now. + */ + Material foundMaterial = FlotationRecipeHandler + .getMaterialOfMilledProduct(FlotationRecipeHandler.findMilledStack(recipe)); + String foundMaterialName = null; + if (foundMaterial != null) { + foundMaterialName = foundMaterial.getUnlocalizedName(); + } + + if (foundMaterialName == null) { + return CheckRecipeResultRegistry.NO_RECIPE; + } + + // Set material locked for this controller + if (lockedMaterialName == null) { + lockedMaterialName = foundMaterialName; + } + + // Check material match + if (!Objects.equals(lockedMaterialName, foundMaterialName)) { + return SimpleCheckRecipeResult.ofFailure("machine_locked_to_different_recipe"); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + }; } /* diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java index 5ebdb4103b..5af1109237 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_NuclearReactor.java @@ -12,13 +12,13 @@ import static gregtech.api.enums.GT_HatchElement.OutputHatch; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import static gregtech.api.util.GT_StructureUtility.filterByMTETier; -import java.util.Collection; - import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -29,6 +29,7 @@ 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.logic.ProcessingLogic; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; @@ -36,12 +37,16 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maint import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.objects.GT_ItemStack; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.ELEMENT; @@ -324,10 +329,6 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase<Greg return true; } - public FluidStack[] getStoredFluidsAsArray() { - return getStoredFluids().toArray(new FluidStack[0]); - } - public int getStoredFuel(GT_Recipe aRecipe) { int aFuelStored = 0; FluidStack aFuelFluid = null; @@ -350,95 +351,51 @@ public class GregtechMTE_NuclearReactor extends GregtechMeta_MultiBlockBase<Greg } @Override - public boolean checkRecipe(final ItemStack aStack) { - // Warm up for 4~ minutes - Logger.WARNING("Checking LFTR recipes."); - if (mEfficiency < this.getMaxEfficiency(null)) { - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - this.mProgresstime = 0; - this.mMaxProgresstime = 1; - this.mEfficiencyIncrease = 2; - Logger.WARNING("Warming Up! " + this.mEfficiency + "/" + this.getMaxEfficiency(null)); - return true; - } - Logger.WARNING("Warmed up, checking LFTR recipes."); - - final FluidStack[] tFluids = getStoredFluidsAsArray(); - final Collection<GT_Recipe> tRecipeList = getRecipeMap().mRecipeList; - if (tFluids.length > 0 && tRecipeList != null && tRecipeList.size() > 0) { // Does input hatch have a LFTR fuel? - Logger.WARNING("Found more than one input fluid and a list of valid recipes."); - // Find a valid recipe - GT_Recipe aFuelProcessing = this - .findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, 0, tFluids, new ItemStack[] {}); - if (aFuelProcessing == null) { - Logger.WARNING("Did not find valid recipe for given inputs."); - return false; - } else { - Logger.WARNING("Found recipe? " + (aFuelProcessing != null ? "true" : "false")); - for (FluidStack aFluidInput : aFuelProcessing.mFluidInputs) { - Logger.WARNING("Using " + aFluidInput.getLocalizedName()); - } + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe, + @NotNull GT_ParallelHelper helper) { + return GT_OverclockCalculator.ofNoOverclock(recipe.mSpecialValue * 4L, recipe.mDuration); } - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - this.mLastRecipe = aFuelProcessing; - mFuelRemaining = getStoredFuel(aFuelProcessing); // Record available fuel - // Deplete Inputs - if (aFuelProcessing.mFluidInputs.length > 0) { - if (this.mFuelRemaining < 100) { - this.mEfficiency = 0; - this.lEUt = 0; - this.mLastRecipe = null; - return false; + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { + if (mFuelRemaining < 100) { + return CheckRecipeResultRegistry.NO_FUEL_FOUND; } - for (GT_MetaTileEntity_Hatch_Input aInputHatch : this.mInputHatches) { + for (GT_MetaTileEntity_Hatch_Input aInputHatch : mInputHatches) { if (aInputHatch.getFluid().getFluid().equals(NUCLIDE.Li2BeF4.getFluid()) && aInputHatch.getFluidAmount() < 200) { - this.mEfficiency = 0; - this.lEUt = 0; - this.mLastRecipe = null; - return false; + return SimpleCheckRecipeResult.ofFailure("no_li2bef4"); } } - for (FluidStack aInputToConsume : aFuelProcessing.mFluidInputs) { - Logger.WARNING( - "Depleting " + aInputToConsume.getLocalizedName() + " - " + aInputToConsume.amount + "L"); - this.depleteInput(aInputToConsume); - } + return CheckRecipeResultRegistry.SUCCESSFUL; } - // -- Try not to fail after this point - inputs have already been consumed! -- - this.mMaxProgresstime = (int) (aFuelProcessing.mDuration); - this.lEUt = aFuelProcessing.mSpecialValue * 4L; - Logger.WARNING("Outputting " + this.lEUt + "eu/t"); - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - Logger.WARNING("Recipe time: " + this.mMaxProgresstime); - mFuelRemaining = getStoredFuel(aFuelProcessing); // Record available fuel - - this.mOutputFluids = aFuelProcessing.mFluidOutputs.clone(); - updateSlots(); - Logger.WARNING("Recipe Good!"); - return true; - } - this.lEUt = 0; - this.mEfficiency = 0; - Logger.WARNING("Recipe Bad!"); - return false; + }; } @Override - public int getMaxParallelRecipes() { - return 1; + public @NotNull CheckRecipeResult checkProcessing() { + // Warm up for 4~ minutes + if (mEfficiency < this.getMaxEfficiency(null)) { + this.mMaxProgresstime = 1; + this.mEfficiencyIncrease = 2; + return SimpleCheckRecipeResult.ofSuccess("warm_up"); + } + CheckRecipeResult result = super.checkProcessing(); + if (result.wasSuccessful()) { + mFuelRemaining = getStoredFuel(mLastRecipe); + } + return result; } @Override - public int getEuDiscountForParallelism() { - return 0; + public int getMaxParallelRecipes() { + return 1; } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java deleted file mode 100644 index 1ca346d3c0..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java +++ /dev/null @@ -1,452 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.Dynamo; -import static gregtech.api.enums.GT_HatchElement.InputBus; -import static gregtech.api.enums.GT_HatchElement.InputHatch; -import static gregtech.api.enums.GT_HatchElement.Maintenance; -import static gregtech.api.enums.GT_HatchElement.Muffler; -import static gregtech.api.enums.GT_HatchElement.OutputBus; -import static gregtech.api.enums.GT_HatchElement.OutputHatch; -import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import static gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase.GTPPHatchElement.TTDynamo; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -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 gregtech.api.GregTech_API; -import gregtech.api.interfaces.IIconContainer; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GTPP_Recipe; -import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaTileEntityGeneratorArray - extends GregtechMeta_MultiBlockBase<GregtechMetaTileEntityGeneratorArray> implements ISurvivalConstructable { - - private int mCasing; - private static IStructureDefinition<GregtechMetaTileEntityGeneratorArray> STRUCTURE_DEFINITION = null; - - public GregtechMetaTileEntityGeneratorArray(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntityGeneratorArray(String aName) { - super(aName); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityGeneratorArray(this.mName); - } - - @Override - public String getMachineType() { - return "Processing Array"; - } - - @Override - protected GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()).addInfo("Controller Block for the Generator Array") - .addInfo("Runs supplied generators as if placed in the world") - .addInfo("Place up to 16 Single Block GT Generators into the Controller").addSeparator() - .beginStructureBlock(3, 3, 3, true).addController("Front center") - .addCasingInfoMin("Robust Tungstensteel Machine Casings", 10, false).addInputBus("Any casing", 1) - .addOutputBus("Any casing", 1).addInputHatch("Any Casing", 1).addOutputHatch("Any Casing", 1) - .addDynamoHatch("Any casing", 1).addMaintenanceHatch("Any casing", 1) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return 48; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - this.mMode = getModeFromInventorySlot(this.getGUIItemStack()); - if (this.mMode == MODE_NONE) { - return null; - } else if (this.mMode == MODE_STEAM) { - return GTPP_Recipe.GTPP_Recipe_Map.sSteamTurbineFuels; - } else if (this.mMode == MODE_DIESEL) { - return GT_Recipe.GT_Recipe_Map.sDieselFuels; - } else if (this.mMode == MODE_GAS) { - return GT_Recipe.GT_Recipe_Map.sTurbineFuels; - } else if (this.mMode == MODE_SEMIFLUID) { - return GTPP_Recipe.GTPP_Recipe_Map.sSemiFluidLiquidFuels; - } else if (this.mMode == MODE_GEOTHERMAL) { - return GTPP_Recipe.GTPP_Recipe_Map.sThermalFuels; - } else if (this.mMode == MODE_ROCKETFUEL) { - return GTPP_Recipe.GTPP_Recipe_Map.sRocketFuels; - } else if (this.mMode == MODE_MAGIC_A) { - return GT_Recipe.GT_Recipe_Map.sMagicFuels; - } else if (this.mMode == MODE_PLASMA) { - return GT_Recipe.GT_Recipe_Map.sPlasmaFuels; - } else if (this.mMode == MODE_NAQUADAH) { - return GT_Recipe.GT_Recipe_Map.sFluidNaquadahReactorFuels; - } - return null; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - if (aStack != null && aStack.getUnlocalizedName().startsWith("gt.blockmachines.")) { - return true; - } - return false; - } - - protected int fuelConsumption = 0; - protected int fuelValue = 0; - protected int fuelRemaining = 0; - protected boolean boostEu = false; - - int mMode = 0; - - private static final int MODE_STEAM = 0; - private static final int MODE_DIESEL = 1; - private static final int MODE_GAS = 2; - private static final int MODE_SEMIFLUID = 3; - private static final int MODE_GEOTHERMAL = 4; - private static final int MODE_ROCKETFUEL = 5; - private static final int MODE_MAGIC_A = 6; - private static final int MODE_MAGIC_B_DISABLED = 7; - private static final int MODE_PLASMA = 8; - private static final int MODE_NAQUADAH = 9; - private static final int MODE_NONE = 100; - - private static final int[] ID_STEAM = new int[] { 962, 1120, 1121, 1122 }; - private static final int[] ID_GAS = new int[] { 961, 1115, 1116, 1117 }; - private static final int[] ID_DIESEL = new int[] { 960, 1110, 1111, 1112 }; - private static final int[] ID_SEMIFLUID = new int[] { 837, 838, 839 }; - private static final int[] ID_GEOTHERMAL = new int[] { 830, 831, 832 }; - private static final int[] ID_ROCKETFUEL = new int[] { 793, 794, 795 }; - private static final int[] ID_MAGIC_A = new int[] { 1123, 1124, 1125 }; - private static final int[] ID_MAGIC_B_DISABLED = new int[] { 1127, 1128, 1129, 1130 }; - private static final int[] ID_PLASMA = new int[] { 1196, 1197, 1198 }; - private static final int[] ID_NAQUADAH = new int[] { 1190, 1191, 1192 }; - - private static final int getModeFromInventorySlot(ItemStack aStack) { - - if (aStack == null) { - return MODE_NONE; - } - - String aItemStackName = aStack == null ? "" : aStack.getUnlocalizedName(); - // Logger.INFO("Item Name: "+aItemStackName+" ("+aStack.getItemDamage()+")"); - if (aItemStackName.toLowerCase().contains("gt.blockmachines")) { - for (int g : ID_STEAM) { - if (aStack.getItemDamage() == g) { - return MODE_STEAM; - } - } - for (int g : ID_GAS) { - if (aStack.getItemDamage() == g) { - return MODE_GAS; - } - } - for (int g : ID_DIESEL) { - if (aStack.getItemDamage() == g) { - return MODE_DIESEL; - } - } - for (int g : ID_SEMIFLUID) { - if (aStack.getItemDamage() == g) { - return MODE_SEMIFLUID; - } - } - for (int g : ID_GEOTHERMAL) { - if (aStack.getItemDamage() == g) { - return MODE_GEOTHERMAL; - } - } - for (int g : ID_ROCKETFUEL) { - if (aStack.getItemDamage() == g) { - return MODE_ROCKETFUEL; - } - } - for (int g : ID_MAGIC_A) { - if (aStack.getItemDamage() == g) { - return MODE_MAGIC_A; - } - } - for (int g : ID_PLASMA) { - if (aStack.getItemDamage() == g) { - return MODE_PLASMA; - } - } - for (int g : ID_NAQUADAH) { - if (aStack.getItemDamage() == g) { - return MODE_NAQUADAH; - } - } - } - return MODE_NONE; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - return false; - - /** - * this.resetRecipeMapForAllInputHatches(); this.mMode = getModeFromInventorySlot(aStack); if (mMode == - * MODE_NONE) { Logger.INFO("Did not find valid generator."); return false; } else { Logger.INFO("Changed Mode - * to "+mMode); } int aMulti = this.getGUIItemStack() != null ? this.getGUIItemStack().stackSize : 0; if (aMulti - * > 16 || aMulti == 0) { return false; } - * - * - * - * ArrayList<FluidStack> tFluids = this.getStoredFluids(); - * - * Collection<GT_Recipe> tRecipeList = this.getRecipeMap().mRecipeList; Logger.INFO("Got Recipe Map"); if - * (tFluids.size() > 0 && tRecipeList != null) { Logger.INFO("Found Fuels for Map."); Iterator<FluidStack> arg3 - * = tFluids.iterator(); int aCount = 0; while (arg3.hasNext()) { FluidStack hatchFluid1 = (FluidStack) - * arg3.next(); Logger.INFO("Iterating Fluid Found "+(aCount++)+" | "+hatchFluid1.getLocalizedName()); - * Iterator<GT_Recipe> arg5 = tRecipeList.iterator(); - * - * int Hatch = 0; int totalFuelValue = 0; while (arg5.hasNext()) { Logger.INFO("Iterating Recipe "+(Hatch++)); - * GT_Recipe aFuel = (GT_Recipe) arg5.next(); FluidStack tLiquid; boolean addedFuelOnce = false; for (int a = 0; - * a < aMulti; a++) { if ((tLiquid = GT_Utility.getFluidForFilledItem(aFuel.getRepresentativeInput(0), true)) != - * null && hatchFluid1.isFluidEqual(tLiquid)) { this.fuelConsumption = tLiquid.amount = this.boostEu ? 4096 / - * aFuel.mSpecialValue : 2048 / aFuel.mSpecialValue; if (this.depleteInput(tLiquid)) { Logger.INFO("Depleted - * Fuel"); this.boostEu = this.depleteInput(Materials.Oxygen.getGas(2L)); - * - * /*if (!tFluids.contains(Materials.Lubricant.getFluid(1L))) { Logger.INFO("No Lube."); return false; } - */ - /** - * if (this.mRuntime % 72 == 0 || this.mRuntime == 0) { - * this.depleteInput(Materials.Lubricant.getFluid(this.boostEu ? 2L : 1L)); } Logger.INFO("ADDING POWER"); - * this.fuelRemaining = hatchFluid1.amount; totalFuelValue++; } } } //Do things after consuming Fuel if - * (totalFuelValue == aMulti) { this.fuelValue = aFuel.mSpecialValue*aMulti; this.mEUt = this.mEfficiency < 2000 - * ? 0 : aFuel.mSpecialValue*aMulti; this.mProgresstime = aMulti; this.mMaxProgresstime = aMulti; - * this.mEfficiencyIncrease = 15*aMulti; return true; } } } } - * - * this.mEUt = 0; this.mEfficiency = 0; return false; - **/ - } - - public static ItemStack[] clean(final ItemStack[] v) { - List<ItemStack> list = new ArrayList<ItemStack>(Arrays.asList(v)); - list.removeAll(Collections.singleton(null)); - return list.toArray(new ItemStack[list.size()]); - } - - @Override - public IStructureDefinition<GregtechMetaTileEntityGeneratorArray> getStructureDefinition() { - if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntityGeneratorArray>builder() - .addShape( - mName, - transpose( - new String[][] { { "CCC", "CCC", "CCC" }, { "C~C", "C-C", "CCC" }, - { "CCC", "CCC", "CCC" }, })) - .addElement( - 'C', - buildHatchAdder(GregtechMetaTileEntityGeneratorArray.class).atLeast( - InputHatch, - OutputHatch, - InputBus, - OutputBus, - Maintenance, - Dynamo.or(TTDynamo), - Muffler).casingIndex(48).dot(1).buildAndChain( - onElementPass(x -> ++x.mCasing, ofBlock(GregTech_API.sBlockCasings4, 0)))) - .build(); - } - return STRUCTURE_DEFINITION; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); - } - - @Override - public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { - if (mMachine) return -1; - return survivialBuildPiece(mName, stackSize, 1, 1, 0, elementBudget, env, false, true); - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override - public int getMaxParallelRecipes() { - return 1; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - /** - * Code from single blocks - */ - public void tryProcessFuelItems(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a) { - if (a != null - && aBaseMetaTileEntity.getUniversalEnergyStored() < this.maxEUOutput() * 20L + this.getMinimumStoredEU() - && GT_Utility.getFluidForFilledItem(a, true) == null) { - int tFuelValue; - tFuelValue = this.getFuelValue(a); - if (tFuelValue > 0) { - ItemStack tEmptyContainer1 = this.getEmptyContainer(a); - if (this.addOutput(tEmptyContainer1)) { - aBaseMetaTileEntity.increaseStoredEnergyUnits((long) tFuelValue, true); - this.depleteInput(a); - PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); - } - } - } - } - - public void tryProcessFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick, FluidStack mFluid) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick % 10L == 0L) { - int tFuelValue; - if (mFluid != null) { - tFuelValue = this.getFuelValue(mFluid); - int tEmptyContainer = this.consumedFluidPerOperation(mFluid); - if (tFuelValue > 0 && tEmptyContainer > 0 && mFluid.amount > tEmptyContainer) { - long tFluidAmountToUse = Math.min( - (long) (mFluid.amount / tEmptyContainer), - (this.maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / (long) tFuelValue); - if (tFluidAmountToUse > 0L && aBaseMetaTileEntity - .increaseStoredEnergyUnits(tFluidAmountToUse * (long) tFuelValue, true)) { - PollutionUtils.addPollution(this.getBaseMetaTileEntity(), 10 * this.getPollutionPerTick(null)); - mFluid.amount = (int) ((long) mFluid.amount - tFluidAmountToUse * (long) tEmptyContainer); - } - } - } - - // Check items - } - - if (aBaseMetaTileEntity.isServerSide()) { - aBaseMetaTileEntity.setActive( - aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() - >= this.maxEUOutput() + this.getMinimumStoredEU()); - } - } - - public boolean isFluidInputAllowed(FluidStack aFluid) { - return this.getFuelValue(aFluid) > 0; - } - - public int consumedFluidPerOperation(FluidStack aLiquid) { - return 1; - } - - public int getFuelValue(FluidStack aLiquid) { - if (aLiquid != null && this.getRecipeMap() != null) { - Collection<GT_Recipe> tRecipeList = this.getRecipeMap().mRecipeList; - if (tRecipeList != null) { - Iterator<GT_Recipe> arg3 = tRecipeList.iterator(); - - while (arg3.hasNext()) { - GT_Recipe tFuel = (GT_Recipe) arg3.next(); - FluidStack tLiquid; - if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null - && aLiquid.isFluidEqual(tLiquid)) { - return (int) ((long) tFuel.mSpecialValue * (long) this.mEfficiency - * (long) this.consumedFluidPerOperation(tLiquid) - / 100L); - } - } - } - - return 0; - } else { - return 0; - } - } - - public int getFuelValue(ItemStack aStack) { - if (!GT_Utility.isStackInvalid(aStack) && this.getRecipeMap() != null) { - GT_Recipe tFuel = this.getRecipeMap().findRecipe( - this.getBaseMetaTileEntity(), - false, - Long.MAX_VALUE, - (FluidStack[]) null, - new ItemStack[] { aStack }); - return tFuel != null ? (int) ((long) tFuel.mSpecialValue * 1000L * (long) this.mEfficiency / 100L) : 0; - } else { - return 0; - } - } - - public ItemStack getEmptyContainer(ItemStack aStack) { - if (!GT_Utility.isStackInvalid(aStack) && this.getRecipeMap() != null) { - GT_Recipe tFuel = this.getRecipeMap().findRecipe( - this.getBaseMetaTileEntity(), - false, - Long.MAX_VALUE, - (FluidStack[]) null, - new ItemStack[] { aStack }); - return tFuel != null ? GT_Utility.copy(new Object[] { tFuel.getOutput(0) }) - : GT_Utility.getContainerItem(aStack, true); - } else { - return null; - } - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index 01ae4ef3a6..087338fe95 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -37,6 +37,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -51,6 +53,9 @@ import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; @@ -173,11 +178,13 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< } @Override - public boolean checkRecipe(final ItemStack aStack) { - if (!isCorrectMachinePart(aStack) && !replaceTool()) return false; - if (!checkSapling()) return false; + public @NotNull CheckRecipeResult checkProcessing() { + final ItemStack controllerStack = getControllerSlot(); + if (!isCorrectMachinePart(controllerStack) && !replaceTool()) + return SimpleCheckRecipeResult.ofFailure("no_saw"); + if (!checkSapling()) return SimpleCheckRecipeResult.ofFailure("no_sapling"); - this.mToolType = TreeFarmHelper.isCorrectMachinePart(aStack); + this.mToolType = TreeFarmHelper.isCorrectMachinePart(controllerStack); long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); @@ -201,7 +208,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< GT_Recipe tRecipe = new GT_Recipe(null, toOutput, null, null, null, null, 0, 0, 0); GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setAvailableEUt(tVoltage) - .setController(this); + .setMachine(this); if (batchMode) { helper.enableBatchMode(128); @@ -209,7 +216,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< helper.build(); if (helper.getCurrentParallel() == 0) { - return false; + return CheckRecipeResultRegistry.OUTPUT_FULL; } if (aFert > 0 && aFert >= aOutputAmount) { @@ -230,7 +237,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< this.tryDamageTool(); this.updateSlots(); - return true; + return SimpleCheckRecipeResult.ofSuccess("growing_trees"); } @Override @@ -245,11 +252,6 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< } @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override public IStructureDefinition<GregtechMetaTileEntityTreeFarm> getStructureDefinition() { if (STRUCTURE_DEFINITION == null) { STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntityTreeFarm>builder() diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java index ee7623b386..b7f5451071 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java @@ -12,16 +12,12 @@ import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.enums.GT_HatchElement.OutputHatch; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import java.util.ArrayList; -import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -33,7 +29,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -42,7 +38,6 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; @@ -135,8 +130,8 @@ public class GregtechMetaTileEntity_AlloyBlastSmelter extends } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_INDUCTION_LOOP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_INDUCTION_LOOP; } @Override @@ -183,111 +178,8 @@ public class GregtechMetaTileEntity_AlloyBlastSmelter extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - - if (this.getBaseMetaTileEntity().isServerSide()) { - - ArrayList<ItemStack> tInputList = null; - // Get Controller Circuit - this.isUsingControllerCircuit = isCorrectMachinePart(aStack); - - final long tVoltage = this.getMaxInputVoltage(); - final byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - ItemStack[] tInputs = null; - final FluidStack[] tFluids = getCompactedFluids(); - GT_Recipe tRecipe = null; - - if (inputSeparation) { - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - tInputList = new ArrayList<>(); - tBus.mRecipeMap = getRecipeMap(); - - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) { - tInputList.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - } - tInputs = tInputList.toArray(new ItemStack[0]); - tRecipe = GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.findRecipe( - this.getBaseMetaTileEntity(), - false, - gregtech.api.enums.GT_Values.V[tTier], - tFluids, - tInputs); - if ((tRecipe != null)) { - break; - } - } - } else { - tInputList = this.getStoredInputs(); - for (int i = 0; i < (tInputList.size() - 1); i++) { - for (int j = i + 1; j < tInputList.size(); j++) { - if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { - if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { - tInputList.remove(j--); - } else { - tInputList.remove(i--); - break; - } - } - } - } - tInputs = tInputList.toArray(new ItemStack[0]); - tRecipe = GTPP_Recipe.GTPP_Recipe_Map.sAlloyBlastSmelterRecipes.findRecipe( - this.getBaseMetaTileEntity(), - false, - gregtech.api.enums.GT_Values.V[tTier], - tFluids, - tInputs); - } - - // Validity check - if ((isUsingControllerCircuit && tInputList.size() < 1) - || (!isUsingControllerCircuit && tInputList.size() < 2)) { - Logger.WARNING("Not enough inputs."); - return false; - } else if (isUsingControllerCircuit && tInputList.size() >= 1) { - tInputList.add(CI.getNumberedCircuit(this.mMode)); - } - - if (tInputList.size() > 1) { - if ((tRecipe != null) && (tRecipe.isRecipeInputEqual(true, tFluids, tInputs))) { - Logger.WARNING("Found some Valid Inputs."); - this.mEfficiency = (10000 - ((this.getIdealStatus() - this.getRepairStatus()) * 1000)); - this.mEfficiencyIncrease = 10000; - if (tRecipe.mEUt <= 16) { - this.lEUt = (tRecipe.mEUt * (1L << (tTier - 1)) * (1L << (tTier - 1))); - this.mMaxProgresstime = (tRecipe.mDuration / (1 << (tTier - 1))); - } else { - this.lEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.lEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.lEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.lEUt > 0) { - this.lEUt = (-this.lEUt); - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - this.mOutputFluids = new FluidStack[] { tRecipe.getFluidOutput(0) }; - List<ItemStack> tOutPutItems = new ArrayList<ItemStack>(); - for (ItemStack tOut : tRecipe.mOutputs) { - if (ItemUtils.checkForInvalidItems(tOut)) { - tOutPutItems.add(tOut); - } - } - if (tOutPutItems.size() > 0) - this.mOutputItems = tOutPutItems.toArray(new ItemStack[tOutPutItems.size()]); - this.updateSlots(); - return true; - } - } - } - Logger.WARNING("Failed to find some Valid Inputs or Clientside."); - return false; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic(); } @Override @@ -304,11 +196,6 @@ public class GregtechMetaTileEntity_AlloyBlastSmelter extends } @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -324,11 +211,6 @@ public class GregtechMetaTileEntity_AlloyBlastSmelter extends } @Override - public int getAmountOfOutputs() { - return 2; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java index fdc893d9df..de23a50550 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Cyclotron.java @@ -12,13 +12,12 @@ import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.enums.GT_HatchElement.OutputHatch; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import java.util.ArrayList; - import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -27,14 +26,14 @@ import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; import gregtech.api.objects.GT_ItemStack; +import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.chemistry.IonParticles; import gtPlusPlus.core.lib.CORE; @@ -202,81 +201,40 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas } @Override - public boolean checkRecipe(ItemStack aStack) { - - /* - * if (CORE.DEVENV) { return this.checkRecipeGeneric(); } - */ - this.fixAllMaintenanceIssue(); - - // log("Recipe Check."); - ArrayList<ItemStack> tItemList = getStoredInputs(); - ItemStack[] tItemInputs = tItemList.toArray(new ItemStack[tItemList.size()]); - ArrayList<FluidStack> tInputList = getStoredFluids(); - FluidStack[] tFluidInputs = tInputList.toArray(new FluidStack[tInputList.size()]); - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - - GT_Recipe tRecipe = GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes.findRecipe( - getBaseMetaTileEntity(), - false, - gregtech.api.enums.GT_Values.V[tTier], - tFluidInputs, - tItemInputs); - if (tRecipe != null) { - if (tRecipe.isRecipeInputEqual(true, tFluidInputs, tItemInputs)) { - - this.mEfficiency = (10000 - ((getIdealStatus() - getRepairStatus()) * 1000)); - this.mEfficiencyIncrease = 10000; - this.lEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - - while (this.lEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.lEUt *= 4; - this.mMaxProgresstime /= 2; - } - - if (this.lEUt > 0) { - this.lEUt = (-this.lEUt); - } - - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - - final ItemStack[] outputs = new ItemStack[tRecipe.mOutputs.length]; - for (int i = 0; i < tRecipe.mOutputs.length; i++) { - if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) { - Logger.WARNING("Adding a bonus output"); - outputs[i] = tRecipe.getOutput(i); - } else { - Logger.WARNING("Adding null output"); - outputs[i] = null; - } - } + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GTPP_Recipe.GTPP_Recipe_Map.sCyclotronRecipes; + } - for (ItemStack s : outputs) { - if (s != null) { - if (s.getItem() instanceof IonParticles) { - long aCharge = IonParticles.getChargeState(s); - if (aCharge == 0) { - IonParticles.setChargeState( - s, - MathUtils.getRandomFromArray( - new int[] { -5, -5, -4, -4, -4, -3, -3, -3, -3, -3, -2, -2, -2, -2, -2, - -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, - 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6 })); + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + public CheckRecipeResult process() { + fixAllMaintenanceIssue(); + CheckRecipeResult result = super.process(); + if (result.wasSuccessful()) { + for (ItemStack s : outputItems) { + if (s != null) { + if (s.getItem() instanceof IonParticles) { + long aCharge = IonParticles.getChargeState(s); + if (aCharge == 0) { + IonParticles.setChargeState( + s, + MathUtils.getRandomFromArray( + new int[] { -5, -5, -4, -4, -4, -3, -3, -3, -3, -3, -2, -2, -2, -2, + -2, -2, -2, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6 })); + } } } } } - - this.mOutputItems = outputs; - this.mOutputFluids = new FluidStack[] { tRecipe.getFluidOutput(0) }; - this.updateSlots(); - return true; + return result; } - } - return false; + }; } @Override @@ -285,11 +243,6 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas } @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override public boolean onRunningTick(ItemStack aStack) { if (this.mOutputBusses.size() > 0) { for (GT_MetaTileEntity_Hatch_OutputBus g : this.mOutputBusses) { @@ -354,11 +307,6 @@ public class GregtechMetaTileEntity_Cyclotron extends GregtechMeta_MultiBlockBas } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean doesBindPlayerInventory() { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java index 1f272bea8a..f0ac233b3c 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java @@ -12,7 +12,6 @@ import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls; -import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -23,6 +22,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandomFishable; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -34,6 +35,9 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.FishPondFakeRecipe; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; @@ -169,13 +173,12 @@ public class GregtechMetaTileEntity_IndustrialFishingPond extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - if (aStack != null) { - log("Found " + aStack.getDisplayName()); - if (aStack.getItem() == circuit) { + public @NotNull CheckRecipeResult checkProcessing() { + ItemStack controllerStack = getControllerSlot(); + if (controllerStack != null) { + if (controllerStack.getItem() == circuit) { this.isUsingControllerCircuit = true; - this.mMode = aStack.getItemDamage(); - log("Found Circuit!"); + this.mMode = controllerStack.getItemDamage(); } else { this.isUsingControllerCircuit = false; } @@ -183,27 +186,67 @@ public class GregtechMetaTileEntity_IndustrialFishingPond extends this.isUsingControllerCircuit = false; } if (!hasGenerateRecipes) { - log("Generating Recipes."); generateRecipes(); } if (hasGenerateRecipes) { if (!checkForWater()) { - return false; + return SimpleCheckRecipeResult.ofFailure("no_water"); + } + ItemStack[] tItemInputs = getStoredInputs().toArray(new ItemStack[0]); + FluidStack[] tFluidInputs = getStoredFluids().toArray(new FluidStack[0]); + + if (!isUsingControllerCircuit && tItemInputs.length == 0) { + return CheckRecipeResultRegistry.NO_RECIPE; + } + + long tEnergy = getMaxInputEnergy(); + + getCircuit(tItemInputs); + + ItemStack[] mFishOutput = generateLoot(this.mMode); + mFishOutput = removeNulls(mFishOutput); + GT_Recipe g = new GTPP_Recipe( + true, + new ItemStack[] {}, + mFishOutput, + null, + new int[] {}, + tFluidInputs, + mOutputFluids, + 200, + 16, + 0); + GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(g).setItemInputs(tItemInputs) + .setFluidInputs(tFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(getMaxParallelRecipes()) + .enableConsumption().enableOutputCalculation().setMachine(this); + + if (batchMode) { + helper.enableBatchMode(128); } - log("Trying to run recipe."); - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + helper.build(); - if (!isUsingControllerCircuit && tItems.size() == 0) { - return false; + if (helper.getCurrentParallel() == 0) { + return CheckRecipeResultRegistry.OUTPUT_FULL; } - return checkRecipeGeneric(tItemInputs, tFluidInputs, getMaxParallelRecipes(), 100, 80, 100); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(g.mEUt).setEUt(tEnergy) + .setDuration(g.mDuration) + .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplierDouble())) + .calculate(); + lEUt = -calculator.getConsumption(); + mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplierDouble()); + + mOutputItems = helper.getItemOutputs(); + mOutputFluids = helper.getFluidOutputs(); + updateSlots(); + + return CheckRecipeResultRegistry.SUCCESSFUL; } - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } @Override @@ -212,11 +255,6 @@ public class GregtechMetaTileEntity_IndustrialFishingPond extends } @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -227,11 +265,6 @@ public class GregtechMetaTileEntity_IndustrialFishingPond extends } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } @@ -300,19 +333,12 @@ public class GregtechMetaTileEntity_IndustrialFishingPond extends tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); if (tBlock == Blocks.water || tBlock == Blocks.flowing_water) { ++tAmount; - // log("Found Water"); } } } } - boolean isValidWater = tAmount >= 60; - if (isValidWater) { - log("Filled structure."); - } else { - log("Did not fill structure."); - } - return isValidWater; + return tAmount >= 60; } private boolean isNotStaticWater(Block block, byte meta) { @@ -443,87 +469,4 @@ public class GregtechMetaTileEntity_IndustrialFishingPond extends } return mFishOutput; } - - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - - // Control Core to control the Multiblocks behaviour. - int aControlCoreTier = getControlCoreTier(); - - // If no core, return false; - if (aControlCoreTier == 0 && CORE.ConfigSwitches.requireControlCores) { - return false; - } - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - - // Check to see if Voltage Tier > Control Core Tier - if (tTier > aControlCoreTier && CORE.ConfigSwitches.requireControlCores) { - return false; - } - - // Based on the Processing Array. A bit overkill, but very flexible. - getCircuit(aItemInputs); - - /* - * GT_Recipe tRecipe = this.getRecipeMap().findRecipe( getBaseMetaTileEntity(), mLastRecipe, false, - * gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - */ - - ItemStack[] mFishOutput = generateLoot(this.mMode); - mFishOutput = removeNulls(mFishOutput); - GT_Recipe g = new GTPP_Recipe( - true, - new ItemStack[] {}, - mFishOutput, - null, - new int[] {}, - aFluidInputs, - mOutputFluids, - 200, - 16, - 0); - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(g).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setEUtModifier(aEUPercent / 100.0f).setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(g.mEUt).setEUt(tEnergy) - .setDuration(g.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - return true; - } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java index 5167d20cec..11c6f4245b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialRockBreaker.java @@ -20,6 +20,8 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -32,6 +34,9 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_OreDictUnificator; @@ -130,8 +135,8 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_INDUCTION_LOOP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_INDUCTION_LOOP; } @Override @@ -199,7 +204,7 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends private static GT_Recipe sRecipe_SmoothStone; private static GT_Recipe sRecipe_Redstone; - private static final void generateRecipes() { + private static void generateRecipes() { sRecipe_Cobblestone = new GTPP_Recipe( false, new ItemStack[] { CI.getNumberedCircuit(1) }, @@ -237,7 +242,7 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends } @Override - public boolean checkRecipe(final ItemStack aStack) { + public @NotNull CheckRecipeResult checkProcessing() { ArrayList<FluidStack> aFluids = this.getStoredFluids(); if (!aFluids.isEmpty()) { boolean aHasWater = false; @@ -262,12 +267,15 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends } } - if (!aHasWater || !aHasLava) { - return false; + if (!aHasWater) { + return SimpleCheckRecipeResult.ofFailure("no_water"); + } + if (!aHasLava) { + return SimpleCheckRecipeResult.ofFailure("no_lava"); } - ItemStack aGuiCircuit = this.getGUIItemStack(); - if (aGuiCircuit == null || !ItemUtils.isControlCircuit(aGuiCircuit)) { - return false; + ItemStack aGuiCircuit = this.getControllerSlot(); + if (!ItemUtils.isControlCircuit(aGuiCircuit)) { + return CheckRecipeResultRegistry.NO_RECIPE; } if (sRecipe_Cobblestone == null || sRecipe_SmoothStone == null || sRecipe_Redstone == null) { @@ -278,46 +286,29 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends GT_Recipe tRecipe = null; switch (aCircuit) { - case 1: - tRecipe = sRecipe_Cobblestone; - break; - case 2: - tRecipe = sRecipe_SmoothStone; - break; - case 3: + case 1 -> tRecipe = sRecipe_Cobblestone; + case 2 -> tRecipe = sRecipe_SmoothStone; + case 3 -> { if (aHasRedstone) { tRecipe = sRecipe_Redstone; } - break; + } } if (tRecipe == null) { - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } - // Based on the Processing Array. A bit overkill, but very flexible. - ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]); + ItemStack[] aItemInputs = aItems.toArray(new ItemStack[0]); FluidStack[] aFluidInputs = new FluidStack[] {}; - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); long tEnergy = getMaxInputEnergy(); // Remember last recipe - an optimization for findRecipe() this.mLastRecipe = tRecipe; - int aMaxParallelRecipes = getMaxParallelRecipes(); - int aEUPercent = getEuDiscountForParallelism(); - int aSpeedBonusPercent = 200; - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setEUtModifier(aEUPercent / 100.0f) - .setController(this); + .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(getMaxParallelRecipes()) + .enableConsumption().enableOutputCalculation().setEUtModifier(0.75F).setMachine(this); if (batchMode) { helper.enableBatchMode(128); @@ -326,30 +317,26 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends helper.build(); if (helper.getCurrentParallel() == 0) { - return false; + return CheckRecipeResultRegistry.OUTPUT_FULL; } this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) + .setDuration(tRecipe.mDuration).setEUtDiscount(0.75F).setSpeedBoost(1F / 3F) + .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplierDouble())) .calculate(); lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); + mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplierDouble()); mOutputItems = helper.getItemOutputs(); mOutputFluids = helper.getFluidOutputs(); updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; + return CheckRecipeResultRegistry.SUCCESSFUL; } - return false; + return CheckRecipeResultRegistry.NO_RECIPE; } @Override @@ -358,11 +345,6 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends } @Override - public int getEuDiscountForParallelism() { - return 75; - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -378,11 +360,6 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends } @Override - public int getAmountOfOutputs() { - return 2; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } @@ -390,8 +367,8 @@ public class GregtechMetaTileEntity_IndustrialRockBreaker extends @Override public ArrayList<ItemStack> getStoredInputs() { ArrayList<ItemStack> aInputs = super.getStoredInputs(); - if (this.getGUIItemStack() != null) { - aInputs.add(this.getGUIItemStack()); + if (this.getControllerSlot() != null) { + aInputs.add(this.getControllerSlot()); } return aInputs; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java index 841d112156..cdc5ccf4fb 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java @@ -20,6 +20,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.google.common.collect.ImmutableMap; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -32,6 +34,9 @@ import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -231,15 +236,14 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends } @Override - public boolean checkRecipe(final ItemStack aStack) { + public @NotNull CheckRecipeResult checkProcessing() { final ArrayList<FluidStack> tFluids = this.getStoredFluids(); this.clearRecipeMapForAllInputHatches(); int aircount = getAir(); int aAirToConsume = this.euProduction / 100; if (aircount < aAirToConsume) { - log("Not Enough Air to Run " + aircount); criticalStopMachine(); - return false; + return SimpleCheckRecipeResult.ofFailure("no_air"); } else { int aTotalAir = 0; for (GT_MetaTileEntity_Hatch_AirIntake aAirHatch : this.mAirIntakes) { @@ -247,18 +251,15 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends aTotalAir += aAirHatch.getFluidAmount(); } } - log("Total Air: " + aTotalAir); if (aTotalAir >= aAirToConsume) { int aSplitAmount = (aAirToConsume / this.mAirIntakes.size()); if (aSplitAmount > 0) { for (GT_MetaTileEntity_Hatch_AirIntake aAirHatch : mAirIntakes) { boolean hasIntakeAir = aAirHatch.drain(aSplitAmount, true) != null; if (!hasIntakeAir) { - log("Could not consume Air to run " + aSplitAmount); this.freeFuelTicks = 0; - return false; + return SimpleCheckRecipeResult.ofFailure("no_air"); } - log("Consumed Air to run " + aSplitAmount); } } } @@ -266,39 +267,12 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends // reset fuel ticks in case it does not reset when it stops if (this.freeFuelTicks != 0 && this.mProgresstime == 0 && this.mEfficiency == 0) this.freeFuelTicks = 0; - log("Running " + aircount); - log("looking at hatch"); - if (tFluids.size() > 0 && getRecipeMap() != null) { - FluidStack aCO2 = MISC_MATERIALS.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1); - FluidStack aCO2Fallback = FluidUtils.getWildcardFluidStack("carbondioxide", (this.boostEu ? 3 : 1)); - - boolean aHasCO2 = false; - for (FluidStack aFluid : tFluids) { - if (aCO2 != null && aFluid.isFluidEqual(aCO2)) { - log("Found CO2 (1)"); - aHasCO2 = true; - break; - } - if (aCO2Fallback != null && aFluid.isFluidEqual(aCO2Fallback)) { - log("Found CO2 (2)"); - aHasCO2 = true; - break; + if (this.mRuntime % 72 == 0) { + if (!consumeCO2()) { + this.freeFuelTicks = 0; + return SimpleCheckRecipeResult.ofFailure("no_co2"); } - log("Found: " + aFluid.getUnlocalizedName()); - } - if (aHasCO2) { - if (this.mRuntime % 72 == 0 || this.mRuntime == 0) { - if (!consumeCO2()) { - this.freeFuelTicks = 0; - log("Bad Return 1"); - return false; - } - } - } else { - this.freeFuelTicks = 0; - log("Bad Return 2 | " + aHasCO2 + " | " + (aCO2 != null) + " | " + (aCO2Fallback != null)); - return false; } if (this.freeFuelTicks == 0) { this.boostEu = consumeLOH(); @@ -321,7 +295,7 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends this.mProgresstime = 1; this.mMaxProgresstime = 1; this.mEfficiencyIncrease = this.euProduction / 2000; - return true; + return CheckRecipeResultRegistry.GENERATING; } } } else { @@ -330,15 +304,14 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends this.lEUt = ((this.mEfficiency < 1000) ? 0 : GT_Values.V[5] << 1); this.mProgresstime = 1; this.mMaxProgresstime = 1; - return true; + return CheckRecipeResultRegistry.GENERATING; } } } this.lEUt = 0; this.mEfficiency = 0; this.freeFuelTicks = 0; - log("Bad Return 3"); - return false; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; } /** @@ -383,12 +356,8 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends } public boolean consumeCO2() { - if (this.depleteInput(MISC_MATERIALS.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1)) - || this.depleteInput(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 3 : 1)))) { - return true; - } else { - return false; - } + return this.depleteInput(MISC_MATERIALS.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1)) + || this.depleteInput(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 3 : 1))); } public boolean consumeLOH() { @@ -587,11 +556,6 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends } @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override public boolean doesBindPlayerInventory() { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java index 32f18d5841..85fd1398d7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeSemifluidGenerator.java @@ -17,6 +17,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -32,6 +34,9 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynam import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GTPP_Recipe.GTPP_Recipe_Map; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -96,7 +101,7 @@ public class GregtechMetaTileEntity_LargeSemifluidGenerator extends } @Override - public boolean checkRecipe(ItemStack aStack) { + public @NotNull CheckRecipeResult checkProcessing() { ArrayList<FluidStack> tFluids = getStoredFluids(); // Check for lubricant and oxygen first, so we can compute costs ahead of time. @@ -114,7 +119,7 @@ public class GregtechMetaTileEntity_LargeSemifluidGenerator extends boostEu = oxygen.amount >= 4L; long lubricantCost = boostEu ? 2L : 1L; if (lubricant.amount < lubricantCost) { - return false; + return SimpleCheckRecipeResult.ofFailure("no_lubricant"); } for (FluidStack hatchFluid : tFluids) { // Loops through hatches @@ -132,13 +137,13 @@ public class GregtechMetaTileEntity_LargeSemifluidGenerator extends // But check the return values anyway just to be safe. if (boostEu) { if (!depleteInput(Materials.Oxygen.getGas(4L))) { - return false; + return SimpleCheckRecipeResult.ofFailure("no_oxygen"); } } // Deplete Lubricant. 2000L should = 1 hour of runtime (if baseEU = 2048) if (mRuntime % 72 == 0 || mRuntime == 0) { if (!depleteInput(Materials.Lubricant.getFluid(lubricantCost))) { - return false; + return SimpleCheckRecipeResult.ofFailure("no_lubricant"); } } @@ -148,13 +153,13 @@ public class GregtechMetaTileEntity_LargeSemifluidGenerator extends this.mProgresstime = 1; this.mMaxProgresstime = 1; this.mEfficiencyIncrease = 15; - return true; + return CheckRecipeResultRegistry.GENERATING; } } this.lEUt = 0; this.mEfficiency = 0; - return false; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; } @Override @@ -313,8 +318,4 @@ public class GregtechMetaTileEntity_LargeSemifluidGenerator extends return 0; } - @Override - public int getEuDiscountForParallelism() { - return 0; - } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java index 58a477b2a3..0098ed207f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java @@ -12,21 +12,18 @@ import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.enums.GT_HatchElement.OutputHatch; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import java.util.ArrayList; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + 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 com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; -import com.gtnewhorizons.modularui.common.widget.SlotWidget; -import com.gtnewhorizons.modularui.common.widget.TextWidget; import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.Materials; @@ -34,12 +31,13 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.FindRecipeResult; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_OverclockCalculator; -import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; @@ -58,12 +56,6 @@ public class GregtechMetaTileEntity_MassFabricator public static int sUUASpeedBonus = 4; public static int sDurationMultiplier = 3200; - public int mMatterProduced = 0; - public int mScrapProduced = 0; - public int mAmplifierProduced = 0; - public int mScrapUsed = 0; - public int mAmplifierUsed = 0; - public static String mCasingName1 = "Matter Fabricator Casing"; public static String mCasingName2 = "Containment Casing"; public static String mCasingName3 = "Matter Generation Coil"; @@ -74,24 +66,12 @@ public class GregtechMetaTileEntity_MassFabricator private static final int MODE_UU = 0; public static boolean sRequiresUUA = false; - private static FluidStack[] mUU = new FluidStack[2]; - private static ItemStack mScrap[] = new ItemStack[2]; + private static final FluidStack[] mUU = new FluidStack[2]; + private static final ItemStack[] mScrap = new ItemStack[2]; private int mCasing; private static IStructureDefinition<GregtechMetaTileEntity_MassFabricator> STRUCTURE_DEFINITION = null; - public int getAmplifierUsed() { - return this.mAmplifierUsed; - } - - public int getMatterProduced() { - return this.mMatterProduced; - } - - public int getScrapProduced() { - return this.mScrapProduced; - } - public GregtechMetaTileEntity_MassFabricator(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } @@ -146,16 +126,6 @@ public class GregtechMetaTileEntity_MassFabricator // Materials.UUAmplifier.mChemicalFormula = ("Mass Fabricator Eff/Speed Bonus: x" + sUUASpeedBonus); } - @Override - public boolean checkRecipe(final ItemStack aStack) { - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - init(); - return checkRecipeGeneric(tItemInputs, tFluidInputs, 4, 80, 00, 10000); - } - public static boolean sInit = false; public static void init() { @@ -227,11 +197,6 @@ public class GregtechMetaTileEntity_MassFabricator } @Override - public int getAmountOfOutputs() { - return 10; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } @@ -248,190 +213,52 @@ public class GregtechMetaTileEntity_MassFabricator public GT_Recipe_Map getRecipeMap() { return this.mMode == MODE_SCRAP ? GT_Recipe_Map.sRecyclerRecipes : GTPP_Recipe.GTPP_Recipe_Map.sMatterFab2Recipes; - // return Recipe_GT.Gregtech_Recipe_Map.sMatterFab2Recipes; } @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - if (this.mMode == MODE_SCRAP) { - return checkRecipeScrap( - aItemInputs, - aFluidInputs, - getMaxParallelRecipes(), - getEuDiscountForParallelism(), - aSpeedBonusPercent, - aOutputChanceRoll); - } else { - return checkRecipeUU( - aItemInputs, - aFluidInputs, - getMaxParallelRecipes(), - getEuDiscountForParallelism(), - aSpeedBonusPercent, - aOutputChanceRoll); - } - } - - public boolean checkRecipeScrap(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - - if (aItemInputs == null || aItemInputs.length <= 0) { - return false; - } - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - ItemStack aPotentialOutput = GT_ModHandler.getRecyclerOutput(GT_Utility.copyAmount(1, aItemInputs[0]), 0); - GT_Recipe tRecipe = new GTPP_Recipe( - false, - new ItemStack[] { GT_Utility.copyAmount(1, aItemInputs[0]) }, - aPotentialOutput == null ? null : new ItemStack[] { aPotentialOutput }, - null, - new int[] { 2000 }, - null, - null, - 40, - MaterialUtils.getVoltageForTier(1), - 0); - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setEUtModifier(aEUPercent / 100.0f) - .setMaxParallel(aMaxParallelRecipes).enableConsumption().enableOutputCalculation().setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; - } - - public boolean checkRecipeUU(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - int aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - - GT_Recipe tRecipe = findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - return false; - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setEUtModifier(aEUPercent / 100.0f).setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .enablePerfectOC().calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - - int aMatterProduced = 0; - int aAmplifierProduced = 0; - int aScrapUsed = 0; - int aAmplifierUsed = 0; - - for (int i = 0; i < helper.getCurrentParallel(); i++) { - // Logger.INFO("Trying to bump stats "+i); - for (ItemStack aInput : tRecipe.mInputs) { - if (aInput != null && GT_Utility.areStacksEqual(aInput, mScrap[0], true)) { - aScrapUsed += aInput.stackSize; - } - } - for (FluidStack aInput : tRecipe.mFluidInputs) { - if (aInput != null && GT_Utility.areFluidsEqual(aInput, mUU[0], true)) { - aAmplifierUsed += aInput.amount; - } + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + public CheckRecipeResult process() { + init(); + return super.process(); } - for (FluidStack aOutput : tRecipe.mFluidOutputs) { - if (aOutput != null && GT_Utility.areFluidsEqual(aOutput, mUU[0], true)) { - aAmplifierProduced += aOutput.amount; - } - if (aOutput != null && GT_Utility.areFluidsEqual(aOutput, mUU[1], true)) { - aMatterProduced += aOutput.amount; + + @NotNull + @Override + protected FindRecipeResult findRecipe(GT_Recipe_Map map) { + if (mMode == MODE_SCRAP) { + ItemStack aPotentialOutput = GT_ModHandler + .getRecyclerOutput(GT_Utility.copyAmount(1, inputItems[0]), 0); + GT_Recipe recipe = new GTPP_Recipe( + false, + new ItemStack[] { GT_Utility.copyAmount(1, inputItems[0]) }, + aPotentialOutput == null ? null : new ItemStack[] { aPotentialOutput }, + null, + new int[] { 2000 }, + null, + null, + 40, + MaterialUtils.getVoltageForTier(1), + 0); + return FindRecipeResult.ofSuccess(recipe); } + return super.findRecipe(map); } - } - - this.mMatterProduced += aMatterProduced; - this.mAmplifierProduced += aAmplifierProduced; - this.mScrapUsed += aScrapUsed; - this.mAmplifierUsed += aAmplifierUsed; - updateSlots(); - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; + }.setEuModifier(0.8F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override - public int getMaxParallelRecipes() { - return this.mMode == MODE_SCRAP ? 64 : 8 * (Math.max(1, GT_Utility.getTier(getMaxInputVoltage()))); + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.setOverclock(mMode == MODE_SCRAP ? 1 : 2, 2); } @Override - public int getEuDiscountForParallelism() { - return 80; + public int getMaxParallelRecipes() { + return this.mMode == MODE_SCRAP ? 64 : 8 * (Math.max(1, GT_Utility.getTier(getMaxInputVoltage()))); } @Override @@ -452,55 +279,13 @@ public class GregtechMetaTileEntity_MassFabricator @Override public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mScrapProduced", mScrapProduced); - aNBT.setInteger("mAmplifierProduced", mAmplifierProduced); - aNBT.setInteger("mMatterProduced", mMatterProduced); - aNBT.setInteger("mScrapUsed", mScrapUsed); - aNBT.setInteger("mAmplifierUsed", mAmplifierUsed); aNBT.setInteger("mMode", mMode); super.saveNBTData(aNBT); } @Override public void loadNBTData(NBTTagCompound aNBT) { - mScrapProduced = aNBT.getInteger("mScrapProduced"); - mAmplifierProduced = aNBT.getInteger("mAmplifierProduced"); - mMatterProduced = aNBT.getInteger("mMatterProduced"); - mScrapUsed = aNBT.getInteger("mScrapUsed"); - mAmplifierUsed = aNBT.getInteger("mAmplifierUsed"); mMode = aNBT.getInteger("mMode"); super.loadNBTData(aNBT); } - - @Override - protected void drawTexts(DynamicPositionedColumn screenElements, SlotWidget inventorySlot) { - super.drawTexts(screenElements, inventorySlot); - - screenElements - .widget( - TextWidget.dynamicString(() -> "Scrap Made: " + mScrapProduced) - .setDefaultColor(COLOR_TEXT_WHITE.get()).setEnabled( - widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0 - && getBaseMetaTileEntity().isActive())) - .widget( - TextWidget.dynamicString(() -> "Scrap Used: " + mScrapUsed) - .setDefaultColor(COLOR_TEXT_WHITE.get()).setEnabled( - widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0 - && getBaseMetaTileEntity().isActive())) - .widget( - TextWidget.dynamicString(() -> "UUA Made: " + mAmplifierProduced) - .setDefaultColor(COLOR_TEXT_WHITE.get()).setEnabled( - widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0 - && getBaseMetaTileEntity().isActive())) - .widget( - TextWidget.dynamicString(() -> "UUA Used: " + mAmplifierUsed) - .setDefaultColor(COLOR_TEXT_WHITE.get()).setEnabled( - widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0 - && getBaseMetaTileEntity().isActive())) - .widget( - TextWidget.dynamicString(() -> "UUM Made: " + mMatterProduced) - .setDefaultColor(COLOR_TEXT_WHITE.get()).setEnabled( - widget -> getBaseMetaTileEntity().getErrorDisplayID() == 0 - && getBaseMetaTileEntity().isActive())); - } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_QuantumForceTransformer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_QuantumForceTransformer.java index bbfab0dd97..adfd77e233 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_QuantumForceTransformer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_QuantumForceTransformer.java @@ -33,6 +33,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.NotNull; import org.lwjgl.opengl.GL11; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -52,16 +53,17 @@ import gregtech.api.interfaces.IIconContainer; 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.implementations.GT_MetaTileEntity_ExtendedPowerMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.objects.ItemData; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_OverclockCalculator; -import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.block.ModBlocks; @@ -327,7 +329,7 @@ public class GregtechMetaTileEntity_QuantumForceTransformer } public static List<Pair<Block, Integer>> getAllCraftingTiers() { - return new ArrayList<Pair<Block, Integer>>() { + return new ArrayList<>() { { add(Pair.of(ModBlocks.blockCasings5Misc, 7)); @@ -339,7 +341,7 @@ public class GregtechMetaTileEntity_QuantumForceTransformer } public static List<Pair<Block, Integer>> getAllFocusingTiers() { - return new ArrayList<Pair<Block, Integer>>() { + return new ArrayList<>() { { add(Pair.of(ModBlocks.blockCasings5Misc, 11)); @@ -356,14 +358,18 @@ public class GregtechMetaTileEntity_QuantumForceTransformer return -1; } else if (block == ModBlocks.blockCasings5Misc) { // Resonance Chambers switch (meta) { - case 7: + case 7 -> { return 1; - case 8: + } + case 8 -> { return 2; - case 9: + } + case 9 -> { return 3; - case 10: + } + case 10 -> { return 4; + } } } return -1; @@ -376,14 +382,18 @@ public class GregtechMetaTileEntity_QuantumForceTransformer return -1; } else if (block == ModBlocks.blockCasings5Misc) { // Generation Coils switch (meta) { - case 11: + case 11 -> { return 1; - case 12: + } + case 12 -> { return 2; - case 13: + } + case 13 -> { return 3; - case 14: + } + case 14 -> { return 4; + } } } return -1; @@ -428,184 +438,140 @@ public class GregtechMetaTileEntity_QuantumForceTransformer return true; } - private int mCurrentParallel = 0; - @Override - public boolean checkRecipe(final ItemStack aStack) { - mCurrentParallel = 0; - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = null; - this.mOutputFluids = null; - doFermium = false; - doNeptunium = false; - FluidStack[] tFluidList = getStoredFluids().toArray(new FluidStack[0]); - if (inputSeparation) { - ArrayList<ItemStack> tInputList = new ArrayList<>(); - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - for (int i = tBus.getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getStackInSlot(i) != null) { - tInputList.add(tBus.getStackInSlot(i)); - } - } + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { - ItemStack[] tInputs = tInputList.toArray(new ItemStack[0]); - if (processRecipe(tInputs, tFluidList, getRecipeMap(), tBus.mInventory[tBus.getCircuitSlot()])) { - return true; - } else tInputList.clear(); - } - } else { - ItemStack[] tInputList = getStoredInputs().toArray(new ItemStack[0]); - return processRecipe(tInputList, tFluidList, getRecipeMap(), aStack); - } - this.mEfficiency = 0; - this.mEfficiencyIncrease = 0; - return false; - } + private int[] chances; - private boolean processRecipe(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, - GT_Recipe.GT_Recipe_Map aRecipeMap, ItemStack aStack) { - byte tTier = (byte) Math.max(1, GT_Utility.getTier(getAverageInputVoltage())); - GT_Recipe tRecipe = aRecipeMap.findRecipe( - getBaseMetaTileEntity(), - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - - if (tRecipe != null && tRecipe.mSpecialValue <= getCraftingTier()) { - ItemStack aRecipeCatalyst = null; - for (ItemStack tItem : tRecipe.mInputs) { - if (ItemUtils.isCatalyst(tItem)) { - aRecipeCatalyst = tItem; - break; + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { + if (recipe.mSpecialValue > getCraftingTier()) { + return CheckRecipeResultRegistry.insufficientMachineTier(recipe.mSpecialValue); } - } - - if (aRecipeCatalyst == null) { - return false; - } - - int mCurrentMaxParallel = 0; - int mMaxParallel = 64; - for (ItemStack tItem : aItemInputs) { - if (ItemUtils.isCatalyst(tItem) && tItem.isItemEqual(aRecipeCatalyst)) { - mCurrentMaxParallel += tItem.stackSize; + ItemStack catalyst = null; + for (ItemStack item : recipe.mInputs) { + if (ItemUtils.isCatalyst(item)) { + catalyst = item; + break; + } } - if (mCurrentMaxParallel >= mMaxParallel) { - mCurrentMaxParallel = mMaxParallel; - break; + if (catalyst == null) { + return SimpleCheckRecipeResult.ofFailure("no_catalyst"); } - } - - if (mFermiumHatch != null && tRecipe.mSpecialValue <= getFocusingTier()) { - doFermium = mFermiumHatch.getFluid() != null - && mFermiumHatch.getFluid().isFluidEqual(new FluidStack(mFermium, 1)); - } else { - doFermium = false; - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(getMaxInputAmps() * getAverageInputVoltage()) - .setMaxParallel(mCurrentMaxParallel).setController(this).enableConsumption(); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - if (helper.getCurrentParallel() == 0) { - return false; - } + int mCurrentMaxParallel = 0; + int mMaxParallel = getMaxParallelRecipes(); + for (ItemStack item : inputItems) { + if (ItemUtils.isCatalyst(item) && item.isItemEqual(catalyst)) { + mCurrentMaxParallel += item.stackSize; + } - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt) - .setEUt(getAverageInputVoltage()).setAmperage(getMaxInputAmps()).setDuration(tRecipe.mDuration) - .setParallel(Math.min(mMaxParallel, helper.getCurrentParallel())).calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); + if (mCurrentMaxParallel >= mMaxParallel) { + mCurrentMaxParallel = mMaxParallel; + break; + } + } + maxParallel = mCurrentMaxParallel; - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; + doFermium = false; + doNeptunium = false; + final ItemStack controllerStack = getControllerSlot(); - if (mMaxProgresstime == Integer.MAX_VALUE - 1 || lEUt == Long.MAX_VALUE - 1) return false; + if (recipe.mSpecialValue < getFocusingTier()) { + if (mNeptuniumHatch != null && mNeptuniumHatch.getFluid() != null + && mNeptuniumHatch.getFluid().getFluid() != null + && mNeptuniumHatch.getFluid().getFluid().equals(mNeptunium)) { + doNeptunium = true; + } + if (mFermiumHatch != null && mFermiumHatch.getFluid() != null + && mFermiumHatch.getFluid().getFluid() != null + && mFermiumHatch.getFluid().getFluid().equals(mFermium)) { + doFermium = true; + } + } - if (this.lEUt > 0) { - this.lEUt = (-this.lEUt); - } + chances = GetChanceOutputs( + recipe, + doNeptunium && controllerStack != null ? controllerStack.getItemDamage() - 1 : -1); - int[] tChances; - if (aStack == null || aStack.getItemDamage() == 0 - || mNeptuniumHatch.getFluid() == null - || !mNeptuniumHatch.getFluid().isFluidEqual(new FluidStack(mNeptunium, 1)) - || tRecipe.mSpecialValue > getFocusingTier()) { - doNeptunium = false; - tChances = GetChanceOutputs(tRecipe, -1); - } else { - doNeptunium = true; - tChances = GetChanceOutputs(tRecipe, aStack.getItemDamage() - 1); + return CheckRecipeResultRegistry.SUCCESSFUL; } - ArrayList<ItemStack> tItemOutputs = new ArrayList<>(); - ArrayList<FluidStack> tFluidOutputs = new ArrayList<>(); - mCurrentParallel = helper.getCurrentParallel(); - - if (mFluidMode) { - for (int i = 0; i < tChances.length; i++) { - if (getBaseMetaTileEntity().getRandomNumber(10000) < tChances[i]) { - ItemData data = getAssociation(tRecipe.getOutput(i)); - Materials mat = data == null ? null : data.mMaterial.mMaterial; - if (i < tRecipe.mOutputs.length) { - if (mat != null) { - if (mat.getMolten(0) != null) { - tFluidOutputs.add( - mat.getMolten(tRecipe.getOutput(i).stackSize * 144L * mCurrentParallel)); - } else if (mat.getFluid(0) != null) { - tFluidOutputs.add( - mat.getFluid(tRecipe.getOutput(i).stackSize * 1000L * mCurrentParallel)); + @NotNull + @Override + public CheckRecipeResult process() { + CheckRecipeResult result = super.process(); + if (result.wasSuccessful()) { + List<ItemStack> generatedItems = new ArrayList<>(); + List<FluidStack> generatedFluids = new ArrayList<>(); + if (mFluidMode) { + for (int i = 0; i < chances.length; i++) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < chances[i]) { + ItemData data = getAssociation(lastRecipe.getOutput(i)); + Materials mat = data == null ? null : data.mMaterial.mMaterial; + if (i < lastRecipe.mOutputs.length) { + if (mat != null) { + if (mat.getMolten(0) != null) { + generatedFluids.add( + mat.getMolten( + lastRecipe.getOutput(i).stackSize * 144L + * calculatedParallels)); + } else if (mat.getFluid(0) != null) { + generatedFluids.add( + mat.getFluid( + lastRecipe.getOutput(i).stackSize * 1000L + * calculatedParallels)); + } else { + ItemStack aItem = lastRecipe.getOutput(i); + generatedItems.add( + GT_Utility.copyAmountUnsafe( + (long) aItem.stackSize * calculatedParallels, + aItem)); + } + } else { + ItemStack aItem = lastRecipe.getOutput(i); + generatedItems.add( + GT_Utility.copyAmountUnsafe( + (long) aItem.stackSize * calculatedParallels, + aItem)); + } } else { - ItemStack aItem = tRecipe.getOutput(i); - tItemOutputs.add( - GT_Utility.copyAmountUnsafe( - (long) aItem.stackSize * mCurrentParallel, - aItem)); + FluidStack aFluid = lastRecipe.getFluidOutput(i - lastRecipe.mOutputs.length); + generatedFluids.add(new FluidStack(aFluid, aFluid.amount * calculatedParallels)); } - } else { - ItemStack aItem = tRecipe.getOutput(i); - tItemOutputs.add( - GT_Utility.copyAmountUnsafe((long) aItem.stackSize * mCurrentParallel, aItem)); } - } else { - FluidStack aFluid = tRecipe.getFluidOutput(i - tRecipe.mOutputs.length); - tFluidOutputs.add(new FluidStack(aFluid, aFluid.amount * mCurrentParallel)); } - } - } - } else { - for (int i = 0; i < tChances.length; i++) { - if (getBaseMetaTileEntity().getRandomNumber(10000) < tChances[i]) { - if (i < tRecipe.mOutputs.length) { - ItemStack aItem = tRecipe.getOutput(i).copy(); - aItem.stackSize *= mCurrentParallel; - tItemOutputs.add(aItem); - } else { - FluidStack aFluid = tRecipe.getFluidOutput(i - tRecipe.mOutputs.length).copy(); - aFluid.amount *= mCurrentParallel; - tFluidOutputs.add(aFluid); + } else { + for (int i = 0; i < chances.length; i++) { + if (getBaseMetaTileEntity().getRandomNumber(10000) < chances[i]) { + if (i < lastRecipe.mOutputs.length) { + ItemStack aItem = lastRecipe.getOutput(i).copy(); + aItem.stackSize *= calculatedParallels; + generatedItems.add(aItem); + } else { + FluidStack aFluid = lastRecipe.getFluidOutput(i - lastRecipe.mOutputs.length) + .copy(); + aFluid.amount *= calculatedParallels; + generatedFluids.add(aFluid); + } + } } } + setOutputItems(generatedItems.toArray(new ItemStack[0])); + setOutputFluids(generatedFluids.toArray(new FluidStack[0])); } + return result; } + }; + } - mOutputItems = tItemOutputs.toArray(new ItemStack[0]); - mOutputFluids = tFluidOutputs.toArray(new FluidStack[0]); - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - updateSlots(); - - return true; - } - return false; + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(getAverageInputVoltage()); + logic.setAvailableAmperage(getMaxInputAmps()); } private byte runningTick = 0; @@ -618,12 +584,10 @@ public class GregtechMetaTileEntity_QuantumForceTransformer } if (runningTick % 20 == 0) { + int amount = (int) (getFocusingTier() * 4 * Math.sqrt(processingLogic.getCurrentParallels())); if (doFermium) { - FluidStack tFluid = new FluidStack( - mFermium, - (int) (getFocusingTier() * 4 * Math.sqrt(mCurrentParallel))); - FluidStack tLiquid = mFermiumHatch.drain(tFluid.amount, true); - if (tLiquid == null || tLiquid.amount < tFluid.amount) { + FluidStack tLiquid = mFermiumHatch.drain(amount, true); + if (tLiquid == null || tLiquid.amount < amount) { doFermium = false; criticalStopMachine(); return false; @@ -631,11 +595,8 @@ public class GregtechMetaTileEntity_QuantumForceTransformer } if (doNeptunium) { - FluidStack tFluid = new FluidStack( - mNeptunium, - (int) (getFocusingTier() * 4 * Math.sqrt(mCurrentParallel))); - FluidStack tLiquid = mNeptuniumHatch.drain(tFluid.amount, true); - if (tLiquid == null || tLiquid.amount < tFluid.amount) { + FluidStack tLiquid = mNeptuniumHatch.drain(amount, true); + if (tLiquid == null || tLiquid.amount < amount) { doNeptunium = false; criticalStopMachine(); return false; @@ -673,10 +634,6 @@ public class GregtechMetaTileEntity_QuantumForceTransformer return 0; } - public int getAmountOfOutputs() { - return 2; - } - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; @@ -690,7 +647,7 @@ public class GregtechMetaTileEntity_QuantumForceTransformer Arrays.fill(tChances, aChancePerOutput); switch (difference) { - case 0: + case 0 -> { for (int i = 0; i < tChances.length; i++) { if (doNeptunium) { if (i == aChanceIncreased) { @@ -704,8 +661,8 @@ public class GregtechMetaTileEntity_QuantumForceTransformer tChances[i] += (10000 - tChances[i]) / 4; } } - break; - case 1: + } + case 1 -> { for (int i = 0; i < tChances.length; i++) { if (doNeptunium) { if (i == aChanceIncreased) { @@ -719,9 +676,8 @@ public class GregtechMetaTileEntity_QuantumForceTransformer tChances[i] += (10000 - tChances[i]) / 3; } } - break; - case 2: - case 3: + } + case 2, 3 -> { for (int i = 0; i < tChances.length; i++) { if (doNeptunium) { if (i == aChanceIncreased) { @@ -735,27 +691,9 @@ public class GregtechMetaTileEntity_QuantumForceTransformer tChances[i] += (10000 - tChances[i]) / 2; } } - break; - } - return tChances; - } - - public boolean onWireCutterRightclick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, - float aX, float aY, float aZ) { - if (aPlayer.isSneaking()) { - batchMode = !batchMode; - if (batchMode) { - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); - } else { - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); } - return true; } - inputSeparation = !inputSeparation; - GT_Utility.sendChatToPlayer( - aPlayer, - StatCollector.translateToLocal("GT5U.machines.separatebus") + " " + inputSeparation); - return true; + return tChances; } @Override @@ -844,86 +782,86 @@ public class GregtechMetaTileEntity_QuantumForceTransformer // spotless:off Tessellator tes = Tessellator.instance; switch (side) { - case 0: - tes.addVertexWithUV(x + 3, y , z + 7, maxU, maxV); + case 0 -> { + tes.addVertexWithUV(x + 3, y, z + 7, maxU, maxV); tes.addVertexWithUV(x + 3, y + 4, z + 7, maxU, minV); tes.addVertexWithUV(x - 3, y + 4, z + 7, minU, minV); - tes.addVertexWithUV(x - 3, y , z + 7, minU, maxV); - tes.addVertexWithUV(x - 3, y , z + 7, minU, maxV); + tes.addVertexWithUV(x - 3, y, z + 7, minU, maxV); + tes.addVertexWithUV(x - 3, y, z + 7, minU, maxV); tes.addVertexWithUV(x - 3, y + 4, z + 7, minU, minV); tes.addVertexWithUV(x + 3, y + 4, z + 7, maxU, minV); - tes.addVertexWithUV(x + 3, y , z + 7, maxU, maxV); - break; - case 1: - tes.addVertexWithUV(x + 7, y , z + 4, maxU, maxV); + tes.addVertexWithUV(x + 3, y, z + 7, maxU, maxV); + } + case 1 -> { + tes.addVertexWithUV(x + 7, y, z + 4, maxU, maxV); tes.addVertexWithUV(x + 7, y + 4, z + 4, maxU, minV); tes.addVertexWithUV(x + 7, y + 4, z - 4, minU, minV); - tes.addVertexWithUV(x + 7, y , z - 4, minU, maxV); - tes.addVertexWithUV(x + 7, y , z - 4, minU, maxV); + tes.addVertexWithUV(x + 7, y, z - 4, minU, maxV); + tes.addVertexWithUV(x + 7, y, z - 4, minU, maxV); tes.addVertexWithUV(x + 7, y + 4, z - 4, minU, minV); tes.addVertexWithUV(x + 7, y + 4, z + 4, maxU, minV); - tes.addVertexWithUV(x + 7, y , z + 4, maxU, maxV); - break; - case 2: - tes.addVertexWithUV(x + 3, y , z - 7, maxU, maxV); + tes.addVertexWithUV(x + 7, y, z + 4, maxU, maxV); + } + case 2 -> { + tes.addVertexWithUV(x + 3, y, z - 7, maxU, maxV); tes.addVertexWithUV(x + 3, y + 4, z - 7, maxU, minV); tes.addVertexWithUV(x - 3, y + 4, z - 7, minU, minV); - tes.addVertexWithUV(x - 3, y , z - 7, minU, maxV); - tes.addVertexWithUV(x - 3, y , z - 7, minU, maxV); + tes.addVertexWithUV(x - 3, y, z - 7, minU, maxV); + tes.addVertexWithUV(x - 3, y, z - 7, minU, maxV); tes.addVertexWithUV(x - 3, y + 4, z - 7, minU, minV); tes.addVertexWithUV(x + 3, y + 4, z - 7, maxU, minV); - tes.addVertexWithUV(x + 3, y , z - 7, maxU, maxV); - break; - case 3: - tes.addVertexWithUV(x - 7, y , z + 4, maxU, maxV); + tes.addVertexWithUV(x + 3, y, z - 7, maxU, maxV); + } + case 3 -> { + tes.addVertexWithUV(x - 7, y, z + 4, maxU, maxV); tes.addVertexWithUV(x - 7, y + 4, z + 4, maxU, minV); tes.addVertexWithUV(x - 7, y + 4, z - 4, minU, minV); - tes.addVertexWithUV(x - 7, y , z - 4, minU, maxV); - tes.addVertexWithUV(x - 7, y , z - 4, minU, maxV); + tes.addVertexWithUV(x - 7, y, z - 4, minU, maxV); + tes.addVertexWithUV(x - 7, y, z - 4, minU, maxV); tes.addVertexWithUV(x - 7, y + 4, z - 4, minU, minV); tes.addVertexWithUV(x - 7, y + 4, z + 4, maxU, minV); - tes.addVertexWithUV(x - 7, y , z + 4, maxU, maxV); - break; - case 4: - tes.addVertexWithUV(x - 3, y , z + 7, maxU, maxV); + tes.addVertexWithUV(x - 7, y, z + 4, maxU, maxV); + } + case 4 -> { + tes.addVertexWithUV(x - 3, y, z + 7, maxU, maxV); tes.addVertexWithUV(x - 3, y + 4, z + 7, maxU, minV); tes.addVertexWithUV(x - 7, y + 4, z + 4, minU, minV); - tes.addVertexWithUV(x - 7, y , z + 4, minU, maxV); - tes.addVertexWithUV(x - 7, y , z + 4, minU, maxV); + tes.addVertexWithUV(x - 7, y, z + 4, minU, maxV); + tes.addVertexWithUV(x - 7, y, z + 4, minU, maxV); tes.addVertexWithUV(x - 7, y + 4, z + 4, minU, minV); tes.addVertexWithUV(x - 3, y + 4, z + 7, maxU, minV); - tes.addVertexWithUV(x - 3, y , z + 7, maxU, maxV); - break; - case 5: - tes.addVertexWithUV(x - 3, y , z - 7, maxU, maxV); + tes.addVertexWithUV(x - 3, y, z + 7, maxU, maxV); + } + case 5 -> { + tes.addVertexWithUV(x - 3, y, z - 7, maxU, maxV); tes.addVertexWithUV(x - 3, y + 4, z - 7, maxU, minV); tes.addVertexWithUV(x - 7, y + 4, z - 4, minU, minV); - tes.addVertexWithUV(x - 7, y , z - 4, minU, maxV); - tes.addVertexWithUV(x - 7, y , z - 4, minU, maxV); + tes.addVertexWithUV(x - 7, y, z - 4, minU, maxV); + tes.addVertexWithUV(x - 7, y, z - 4, minU, maxV); tes.addVertexWithUV(x - 7, y + 4, z - 4, minU, minV); tes.addVertexWithUV(x - 3, y + 4, z - 7, maxU, minV); - tes.addVertexWithUV(x - 3, y , z - 7, maxU, maxV); - break; - case 6: - tes.addVertexWithUV(x + 3, y , z + 7, maxU, maxV); + tes.addVertexWithUV(x - 3, y, z - 7, maxU, maxV); + } + case 6 -> { + tes.addVertexWithUV(x + 3, y, z + 7, maxU, maxV); tes.addVertexWithUV(x + 3, y + 4, z + 7, maxU, minV); tes.addVertexWithUV(x + 7, y + 4, z + 4, minU, minV); - tes.addVertexWithUV(x + 7, y , z + 4, minU, maxV); - tes.addVertexWithUV(x + 7, y , z + 4, minU, maxV); + tes.addVertexWithUV(x + 7, y, z + 4, minU, maxV); + tes.addVertexWithUV(x + 7, y, z + 4, minU, maxV); tes.addVertexWithUV(x + 7, y + 4, z + 4, minU, minV); tes.addVertexWithUV(x + 3, y + 4, z + 7, maxU, minV); - tes.addVertexWithUV(x + 3, y , z + 7, maxU, maxV); - break; - case 7: - tes.addVertexWithUV(x + 3, y , z - 7, maxU, maxV); + tes.addVertexWithUV(x + 3, y, z + 7, maxU, maxV); + } + case 7 -> { + tes.addVertexWithUV(x + 3, y, z - 7, maxU, maxV); tes.addVertexWithUV(x + 3, y + 4, z - 7, maxU, minV); tes.addVertexWithUV(x + 7, y + 4, z - 4, minU, minV); - tes.addVertexWithUV(x + 7, y , z - 4, minU, maxV); - tes.addVertexWithUV(x + 7, y , z - 4, minU, maxV); + tes.addVertexWithUV(x + 7, y, z - 4, minU, maxV); + tes.addVertexWithUV(x + 7, y, z - 4, minU, maxV); tes.addVertexWithUV(x + 7, y + 4, z - 4, minU, minV); tes.addVertexWithUV(x + 3, y + 4, z - 7, maxU, minV); - tes.addVertexWithUV(x + 3, y , z - 7, maxU, maxV); - break; + tes.addVertexWithUV(x + 3, y, z - 7, maxU, maxV); + } } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java index b3aa2ad34b..c1352ccf82 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_Refinery.java @@ -25,7 +25,7 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; @@ -97,14 +97,8 @@ public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase } @Override - public boolean checkRecipe(ItemStack aStack) { - // this.resetRecipeMapForAllInputHatches(); - for (GT_MetaTileEntity_Hatch_Input g : this.mInputHatches) { - g.mRecipeMap = null; - } - boolean ab = super.checkRecipeGeneric(); - // Logger.INFO("Did Recipe? "+ab); - return ab; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic(); } @Override @@ -113,11 +107,6 @@ public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase } @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override public boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { if (aTileEntity == null) { return false; @@ -206,11 +195,6 @@ public class GregtechMetaTileEntity_Refinery extends GregtechMeta_MultiBlockBase } @Override - public int getAmountOfOutputs() { - return 5; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java index af7a7591e1..67b8831d94 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_SolarTower.java @@ -19,6 +19,8 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -30,6 +32,8 @@ 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.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -399,8 +403,8 @@ public class GregtechMetaTileEntity_SolarTower extends GregtechMeta_MultiBlockBa } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_MAGNETIZER_LOOP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_MAGNETIZER_LOOP; } @Override @@ -520,7 +524,7 @@ public class GregtechMetaTileEntity_SolarTower extends GregtechMeta_MultiBlockBa private Fluid mHotSalt = null; @Override - public boolean checkRecipe(final ItemStack aStack) { + public @NotNull CheckRecipeResult checkProcessing() { this.mEfficiencyIncrease = 100; this.mMaxProgresstime = 200; @@ -546,24 +550,8 @@ public class GregtechMetaTileEntity_SolarTower extends GregtechMeta_MultiBlockBa if (aHeaters > 0 && w.isDaytime()) { if (w.isRaining() && this.getBaseMetaTileEntity().getBiome().rainfall > 0.0F) { this.mHeatLevel += GT_Utility.safeInt((long) ((aHeaters / 2) * aEfficiency * (10 + aTier))); - log( - "Added Heat (rain): " + aHeaters / 2 - + " * " - + aEfficiency - + " * " - + (10 + aTier) - + " = " - + (aHeaters * aEfficiency * (10 + aTier))); } else { this.mHeatLevel += GT_Utility.safeInt((long) (aHeaters * aEfficiency * (10 + aTier))); - log( - "Added Heat: " + aHeaters - + " * " - + aEfficiency - + " * " - + (10 + aTier) - + " = " - + (aHeaters * aEfficiency * (10 + aTier))); } } @@ -573,7 +561,6 @@ public class GregtechMetaTileEntity_SolarTower extends GregtechMeta_MultiBlockBa this.mHeatLevel = 100000; } else { this.mHeatLevel -= 10; - log("Removed Heat: " + 10); } } } @@ -591,7 +578,6 @@ public class GregtechMetaTileEntity_SolarTower extends GregtechMeta_MultiBlockBa int aFluidAmount = Math.min(aFluid.amount, this.mHeatLevel); this.mHeatLevel -= aFluidAmount; - log("Removed Heat: " + (aFluidAmount)); this.depleteInput(FluidUtils.getFluidStack(mColdSalt, aFluidAmount)); this.addOutput(FluidUtils.getFluidStack(mHotSalt, aFluidAmount)); this.mHeatLevel = Math.max(this.mHeatLevel, 0); @@ -600,9 +586,8 @@ public class GregtechMetaTileEntity_SolarTower extends GregtechMeta_MultiBlockBa } } } - log("Heat Level" + mHeatLevel); - return true; + return CheckRecipeResultRegistry.GENERATING; } @Override @@ -611,16 +596,6 @@ public class GregtechMetaTileEntity_SolarTower extends GregtechMeta_MultiBlockBa } @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; } @@ -631,11 +606,6 @@ public class GregtechMetaTileEntity_SolarTower extends GregtechMeta_MultiBlockBa } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java index 824de2f9c6..8b1e53fe89 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java @@ -14,6 +14,8 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -26,8 +28,12 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.FindRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; @@ -162,8 +168,8 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase<Gregt } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; } @Override @@ -195,11 +201,6 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase<Gregt return 2; } - @Override - public int getEuDiscountForParallelism() { - return 0; - } - public boolean checkForWater() { // Get Facing direction @@ -285,11 +286,6 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase<Gregt } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } @@ -310,61 +306,28 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase<Gregt } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); - } - - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - - if (this.mLevel < 0) { - return false; - } - - if (!checkForWater()) { - return false; - } - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - GT_Recipe tRecipe = RecipeLoader_AlgaeFarm.getTieredRecipeFromCache(this.mLevel, isUsingCompost(aItemInputs)); - - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - return false; - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(120).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - mMaxProgresstime = (int) Math.ceil(tRecipe.mDuration * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected FindRecipeResult findRecipe(GT_Recipe.GT_Recipe_Map map) { + GT_Recipe recipe = RecipeLoader_AlgaeFarm.getTieredRecipeFromCache(mLevel, isUsingCompost(inputItems)); + if (recipe != null) { + return FindRecipeResult.ofSuccess(recipe); + } + return FindRecipeResult.NOT_FOUND; + } - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { + if (!checkForWater()) { + return SimpleCheckRecipeResult.ofFailure("no_water"); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + }.setEuModifier(0F).setMaxParallelSupplier(this::getMaxParallelRecipes); } private boolean isUsingCompost(ItemStack[] aItemInputs) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java index b740c2e7f8..42f17d8474 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java @@ -25,6 +25,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; @@ -40,6 +42,7 @@ import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.IIconContainer; 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.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; @@ -49,13 +52,14 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maint import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_OutputBus; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_OverclockCalculator; import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Triplet; import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; @@ -428,8 +432,8 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase<Gregt } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; } @Override @@ -466,11 +470,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase<Gregt return 2 * getPipeCasingTier(); } - @Override - public int getEuDiscountForParallelism() { - return 100; - } - private int getSolidCasingTier() { return this.mSolidCasingTier; } @@ -549,11 +548,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase<Gregt } @Override - public int getAmountOfOutputs() { - return 1; - } - - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; } @@ -592,136 +586,101 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase<Gregt } } - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); + private void damageCatalyst(ItemStack aStack) { + // Awakened Draconium Coils with Tungstensteel Pipe Casings (or above) no longer consume catalysts. + if (isCatalystDamageable() + && (MathUtils.randFloat(0, 10000000) / 10000000f < (1.2f - (0.2 * this.mPipeCasingTier)))) { + int damage = getDamage(aStack) + 1; + if (damage >= getMaxCatalystDurability()) { + addOutput(CI.getEmptyCatalyst(1)); + aStack.stackSize -= 1; + } else { + setDamage(aStack, damage); + } + } } - @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), getSpeedBonus()); + private boolean isCatalystDamageable() { + return this.mCoilTier < 10 || this.mPipeCasingTier < 4; } @Override - public boolean checkRecipeGeneric(int aMaxParallelRecipes, long aEUPercent, int aSpeedBonusPercent, - int aOutputChanceRoll) { - ArrayList<ItemStack> tItems = getStoredInputs(); - ArrayList<FluidStack> tFluids = getStoredFluids(); - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); - return checkRecipeGeneric( - tItemInputs, - tFluidInputs, - aMaxParallelRecipes, - aEUPercent, - aSpeedBonusPercent, - aOutputChanceRoll); - } + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - - // GT_Recipe tRecipe = findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, - // gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs); - GT_Recipe tRecipe = findRecipe( - mLastRecipe, - gregtech.api.enums.GT_Values.V[tTier], - getSolidCasingTier(), - aItemInputs, - aFluidInputs); - - if (tRecipe == null) { - return false; - } + ItemStack catalystRecipe; + int maxParallelCatalyst; - // checks if it has a catalyst - ItemStack tCatalystRecipe = null; - boolean aDoesRecipeNeedCatalyst = false; - for (ItemStack aInputItem : tRecipe.mInputs) { - if (ItemUtils.isCatalyst(aInputItem)) { - aDoesRecipeNeedCatalyst = true; - break; - } - } - if (aDoesRecipeNeedCatalyst) { - tCatalystRecipe = findCatalyst(aItemInputs, tRecipe.mInputs); - if (tCatalystRecipe == null) { - return false; - } - if (mCatalystBuses.size() != 1) { - return false; - } - } - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe.mSpecialValue > this.mSolidCasingTier) { - return false; - } - - // checks if it has enough catalyst durability - ArrayList<ItemStack> tCatalysts = null; - int tMaxParallelCatalyst = aMaxParallelRecipes; - if (tCatalystRecipe != null) { - tCatalysts = new ArrayList<ItemStack>(); - tMaxParallelCatalyst = getCatalysts(aItemInputs, tCatalystRecipe, aMaxParallelRecipes, tCatalysts); - } - - if (tMaxParallelCatalyst == 0) { - return false; - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(tMaxParallelCatalyst) - .enableConsumption().enableOutputCalculation().setController(this); + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { + if (recipe.mSpecialValue > mSolidCasingTier) { + return CheckRecipeResultRegistry.insufficientMachineTier(recipe.mSpecialValue); + } + // checks if it has a catalyst - if (batchMode) { - helper.enableBatchMode(128); - } + boolean needsCalayst = false; + for (ItemStack item : recipe.mInputs) { + if (ItemUtils.isCatalyst(item)) { + needsCalayst = true; + break; + } + } + if (needsCalayst) { + catalystRecipe = findCatalyst(inputItems, recipe.mInputs); + if (catalystRecipe == null || mCatalystBuses.size() != 1) { + return SimpleCheckRecipeResult.ofFailure("no_catalyst"); + } + } - helper.build(); + // checks if it has enough catalyst durability + maxParallelCatalyst = maxParallel; + if (catalystRecipe != null) { + maxParallelCatalyst = getCatalysts(inputItems, catalystRecipe, maxParallel); + } + maxParallel = Math.min(maxParallel, maxParallelCatalyst); + return CheckRecipeResultRegistry.SUCCESSFUL; + } - if (helper.getCurrentParallel() == 0) { - return false; - } + @NotNull + @Override + protected GT_ParallelHelper createParallelHelper(@NotNull GT_Recipe recipe) { + return new GT_ParallelHelper() { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; + @Override + protected boolean tryConsumeRecipeInputs(GT_Recipe recipe, FluidStack[] fluids, ItemStack[] items) { + if (catalystRecipe != null && getDamage(catalystRecipe) >= getMaxCatalystDurability()) { + return false; + } + boolean hasInputs = super.tryConsumeRecipeInputs(recipe, fluids, items); + if (hasInputs && catalystRecipe != null) { + damageCatalyst(catalystRecipe); + } + return true; + } + }.setRecipe(recipe).setItemInputs(inputItems).setFluidInputs(inputFluids) + .setAvailableEUt(availableVoltage * availableAmperage) + .setMachine(machine, protectItems, protectFluids) + .setRecipeLocked(recipeLockableMachine, isRecipeLocked).setMaxParallel(maxParallel) + .setEUtModifier(euModifier).enableBatchMode(batchSize).enableConsumption() + .enableOutputCalculation(); + } + }; + } - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(100.0f / aEUPercent) - .setSpeedBoost((100.0f / aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); + @Override + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.setSpeedBonus(100F / (100F + getSpeedBonus())); + } - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); + @Override + public void updateSlots() { + super.updateSlots(); for (GT_MetaTileEntity_Hatch_Catalysts h : mCatalystBuses) { h.updateSlots(); h.tryFillUsageSlots(); } - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - - return true; } private static final HashMap<Long, AutoMap<GT_Recipe>> mTieredRecipeMap = new HashMap<Long, AutoMap<GT_Recipe>>(); @@ -779,66 +738,15 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase<Gregt } } - public GT_Recipe findRecipe(final GT_Recipe aRecipe, final long aVoltage, final long aSpecialValue, - ItemStack[] aInputs, final FluidStack[] aFluids) { - if (!mInitRecipeCache) { - initRecipeCaches(); - } - if (this.getRecipeMap().mRecipeList.isEmpty()) { - log("No Recipes in Map to search through."); - return null; - } else { - log("Checking tier " + aSpecialValue + " recipes and below. Using Input Voltage of " + aVoltage + "V."); - log("We have " + aInputs.length + " Items and " + aFluids.length + " Fluids."); - // Try check the cached recipe first - if (aRecipe != null) { - if (aRecipe.isRecipeInputEqual(false, aFluids, aInputs)) { - if (aRecipe.mEUt <= aVoltage) { - Logger.INFO("Using cached recipe."); - return aRecipe; - } - } - } - - // Get all recipes for the tier - AutoMap<AutoMap<GT_Recipe>> aMasterMap = new AutoMap<AutoMap<GT_Recipe>>(); - for (long i = 0; i <= aSpecialValue; i++) { - aMasterMap.add(mTieredRecipeMap.get(i)); - } - GT_Recipe aFoundRecipe = null; - - // Iterate the tiers recipes until we find the one with all inputs matching - master: for (AutoMap<GT_Recipe> aTieredMap : aMasterMap) { - for (GT_Recipe aRecipeToCheck : aTieredMap) { - if (aRecipeToCheck.isRecipeInputEqual(false, aFluids, aInputs)) { - log("Found recipe with matching inputs!"); - if (aRecipeToCheck.mSpecialValue <= aSpecialValue) { - if (aRecipeToCheck.mEUt <= aVoltage) { - aFoundRecipe = aRecipeToCheck; - break master; - } - } - } - } - } - - // If we found a recipe, return it - if (aFoundRecipe != null) { - log("Found valid recipe."); - return aFoundRecipe; - } + private int getCatalysts(ItemStack[] aItemInputs, ItemStack aRecipeCatalyst, int aMaxParallel) { + if (!isCatalystDamageable()) { + return getMaxParallelRecipes(); } - log("Did not find valid recipe."); - return null; - } - - private int getCatalysts(ItemStack[] aItemInputs, ItemStack aRecipeCatalyst, int aMaxParrallel, - ArrayList<ItemStack> aOutPut) { int allowedParallel = 0; for (final ItemStack aInput : aItemInputs) { if (aRecipeCatalyst.isItemEqual(aInput)) { int aDurabilityRemaining = getMaxCatalystDurability() - getDamage(aInput); - return Math.min(aMaxParrallel, aDurabilityRemaining); + return Math.min(aMaxParallel, aDurabilityRemaining); } } return allowedParallel; @@ -861,28 +769,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase<Gregt return null; } - private void damageCatalyst(ItemStack aStack, int parallelRecipes) { - for (int i = 0; i < parallelRecipes; i++) { - // Awakened Draconium Coils with Tungstensteel Pipe Casings (or above) no longer consume catalysts. - if (this.mCoilTier >= 10 && this.mPipeCasingTier >= 4) { - log("not consuming catalyst"); - } else if (MathUtils.randFloat(0, 10000000) / 10000000f < (1.2f - (0.2 * this.mPipeCasingTier))) { - int damage = getDamage(aStack) + 1; - log("damage catalyst " + damage); - if (damage >= getMaxCatalystDurability()) { - log("consume catalyst"); - addOutput(CI.getEmptyCatalyst(1)); - aStack.stackSize -= 1; - } else { - log("damaging catalyst"); - setDamage(aStack, damage); - } - } else { - log("not consuming catalyst"); - } - } - } - private int getDamage(ItemStack aStack) { return ItemGenericChemBase.getCatalystDamage(aStack); } @@ -897,8 +783,8 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase<Gregt @Override public ArrayList<ItemStack> getStoredInputs() { ArrayList<ItemStack> tItems = super.getStoredInputs(); - if (this.getGUIItemStack() != null) { - tItems.add(this.getGUIItemStack()); + if (this.getControllerSlot() != null) { + tItems.add(this.getControllerSlot()); } for (GT_MetaTileEntity_Hatch_Catalysts tHatch : mCatalystBuses) { tHatch.mRecipeMap = getRecipeMap(); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/mega/GregTechMetaTileEntity_MegaAlloyBlastSmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/mega/GregTechMetaTileEntity_MegaAlloyBlastSmelter.java index ecf28f9a76..039937ea7f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/mega/GregTechMetaTileEntity_MegaAlloyBlastSmelter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/mega/GregTechMetaTileEntity_MegaAlloyBlastSmelter.java @@ -24,11 +24,10 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; -import com.github.bartimaeusnek.bartworks.util.Pair; -import com.github.bartimaeusnek.bartworks.util.RecipeFinderForParallel; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -41,13 +40,16 @@ 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.logic.ProcessingLogic; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ExtendedPowerMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_OverclockCalculator; +import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.block.ModBlocks; @@ -60,7 +62,6 @@ public class GregTechMetaTileEntity_MegaAlloyBlastSmelter private static final int MAX_PARALLELS = 256; private HeatingCoilLevel coilLevel; private byte glassTier = -1; - private int currentParallels; private boolean hasNormalCoils; private static final IStructureDefinition<GregTechMetaTileEntity_MegaAlloyBlastSmelter> STRUCTURE_DEFINITION = StructureDefinition @@ -160,65 +161,32 @@ public class GregTechMetaTileEntity_MegaAlloyBlastSmelter } @Override - public boolean checkRecipe(ItemStack aStack) { - ItemStack[] tInputs; - FluidStack[] tFluids = this.getStoredFluids().toArray(new FluidStack[0]); - - if (inputSeparation) { - ArrayList<ItemStack> tInputList = new ArrayList<>(); - for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) { - IGregTechTileEntity tInputBus = tHatch.getBaseMetaTileEntity(); - for (int i = tInputBus.getSizeInventory() - 1; i >= 0; i--) { - if (tInputBus.getStackInSlot(i) != null) tInputList.add(tInputBus.getStackInSlot(i)); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GT_Recipe recipe) { + if (glassTier < GT_Utility.getTier(recipe.mEUt)) { + return CheckRecipeResultRegistry.insufficientMachineTier(GT_Utility.getTier(recipe.mEUt)); } - tInputs = tInputList.toArray(new ItemStack[0]); + return CheckRecipeResultRegistry.SUCCESSFUL; + } - if (processRecipe(tInputs, tFluids)) return true; - else tInputList.clear(); + @NotNull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe, + @NotNull GT_ParallelHelper helper) { + return super.createOverclockCalculator(recipe, helper) + .setSpeedBoost((float) (1.0 - getCoilDiscount(coilLevel))); } - } else { - tInputs = getStoredInputs().toArray(new ItemStack[0]); - return processRecipe(tInputs, tFluids); - } - return false; + }.setMaxParallel(MAX_PARALLELS); } - protected boolean processRecipe(ItemStack[] tItems, FluidStack[] tFluids) { - if (tItems.length <= 0 && tFluids.length <= 0) return false; - long tTotalEU = getAverageInputVoltage() * getMaxInputAmps(); - - GT_Recipe recipe = getRecipeMap().findRecipe(getBaseMetaTileEntity(), false, tTotalEU, tFluids, tItems); - if (recipe == null) return false; - - if (glassTier < GT_Utility.getTier(recipe.mEUt)) return false; - - long parallels = Math.min(MAX_PARALLELS, tTotalEU / recipe.mEUt); - currentParallels = RecipeFinderForParallel.handleParallelRecipe(recipe, tFluids, tItems, (int) parallels); - if (currentParallels <= 0) return false; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(recipe.mEUt) - .setParallel(currentParallels).setDuration(recipe.mDuration).setEUt(tTotalEU).calculate(); - - lEUt = calculator.getConsumption(); - mMaxProgresstime = calculator.getDuration(); - - Pair<ArrayList<FluidStack>, ArrayList<ItemStack>> outputs = RecipeFinderForParallel - .getMultiOutput(recipe, currentParallels); - - mMaxProgresstime -= coilLevel.getTier() < 0 ? 0 : mMaxProgresstime * getCoilDiscount(coilLevel); - - if (lEUt > 0) { - lEUt = -lEUt; - } - - mMaxProgresstime = Math.max(1, mMaxProgresstime); - mEfficiency = getCurrentEfficiency(null); - - mOutputItems = outputs.getValue().toArray(new ItemStack[0]); - mOutputFluids = outputs.getKey().toArray(new FluidStack[0]); - updateSlots(); - - return true; + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(getMaxInputEu()); + logic.setAvailableAmperage(1); } @Override @@ -271,6 +239,7 @@ public class GregTechMetaTileEntity_MegaAlloyBlastSmelter public double getCoilDiscount(HeatingCoilLevel lvl) { // Since there are only 14 tiers (starting from 0), this is what the function is. double unRounded = (lvl != null ? lvl.getTier() : 0) / 130.0D; + if (unRounded < 0) return 1F; double rounded = Math.floor(unRounded * 1000) / 1000; return Math.max(0, rounded); @@ -343,7 +312,7 @@ public class GregTechMetaTileEntity_MegaAlloyBlastSmelter public String[] getInfoData() { long storedEnergy = 0; long maxEnergy = 0; - int paras = getBaseMetaTileEntity().isActive() ? currentParallels : 0; + int paras = getBaseMetaTileEntity().isActive() ? processingLogic.getCurrentParallels() : 0; int discountP = (int) (getCoilDiscount(coilLevel) * 1000) / 10; for (GT_MetaTileEntity_Hatch tHatch : mExoticEnergyHatches) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java index 025169aa0d..ac79c96605 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java @@ -11,11 +11,15 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import gregtech.api.enums.Materials; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; @@ -75,22 +79,14 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin } @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + public @NotNull CheckRecipeResult checkProcessing() { List<FluidStack> fluids = getStoredFluids(); for (FluidStack fluid : fluids) { if (fluid != null && BLACKLIST.contains(fluid.getFluid())) { - return false; + return SimpleCheckRecipeResult.ofFailure("fuel_blacklisted"); } } - return super.checkRecipeGeneric( - aItemInputs, - aFluidInputs, - aMaxParallelRecipes, - aEUPercent, - aSpeedBonusPercent, - aOutputChanceRoll, - aRecipe); + return super.checkProcessing(); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java index 108787f958..d92d8f870b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java @@ -8,11 +8,16 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; @@ -70,13 +75,11 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur } @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { + public @NotNull CheckRecipeResult checkProcessing() { try { ArrayList<GT_MetaTileEntity_Hatch_Turbine> aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); if (aEmptyTurbineRotorHatches.size() > 0) { - log("Found " + aEmptyTurbineRotorHatches.size() + " Assemblies without Turbine."); hatch: for (GT_MetaTileEntity_Hatch_Turbine aHatch : aEmptyTurbineRotorHatches) { ArrayList<ItemStack> aTurbines = getAllBufferedTurbines(); for (ItemStack aTurbineItem : aTurbines) { @@ -85,7 +88,6 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur } if (aHatch.insertTurbine(aTurbineItem.copy())) { boolean aDidDeplete = depleteTurbineFromStock(aTurbineItem); - log("Put Turbine into Assembly - " + aDidDeplete); continue hatch; } } @@ -93,9 +95,8 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur } if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { - log("BAD RETURN - 1"); stopMachine(); - return false; + return CheckRecipeResultRegistry.NO_TURBINE_FOUND; } ArrayList<FluidStack> tFluids = getStoredFluids(); @@ -103,7 +104,7 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur if (tFluids.size() > 0) { for (FluidStack fluid : tFluids) { if (fluid != null && BLACKLIST.contains(fluid.getFluid())) { - return false; + return SimpleCheckRecipeResult.ofFailure("fuel_blacklisted"); } } if (baseEff == 0 || optFlow == 0 @@ -135,7 +136,6 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur aTotalOptimalFlow *= getSpeedMultiplier(); if (aTotalOptimalFlow < 0) { - log("Int overflow, report to issue tracker"); aTotalOptimalFlow = 100; } @@ -147,7 +147,7 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur euPerTurbine = MathUtils.roundToClosestInt(aEUPerTurbine); if (optFlow <= 0 || baseEff <= 0) { stopMachine(); // in case the turbine got removed - return false; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; } } else { counter++; @@ -182,20 +182,19 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur if (this.lEUt <= 0) { this.lEUt = 0; this.mEfficiency = 0; - log("Running checkRecipeGeneric(bad-2)"); - return false; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; } else { this.mMaxProgresstime = 20; this.mEfficiencyIncrease = 10; // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; + enableAllTurbineHatches(); + return CheckRecipeResultRegistry.GENERATING; } } catch (Throwable t) { t.printStackTrace(); } - return false; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java index 28058a3eee..b18abc2c84 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java @@ -22,6 +22,8 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -37,8 +39,9 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; @@ -426,24 +429,10 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric( - new ItemStack[] {}, - getStoredFluids().toArray(new FluidStack[] {}), - 1, - 100, - 100, - 10000); - } - - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) { - + public @NotNull CheckRecipeResult checkProcessing() { try { ArrayList<GT_MetaTileEntity_Hatch_Turbine> aEmptyTurbineRotorHatches = getEmptyTurbineAssemblies(); if (aEmptyTurbineRotorHatches.size() > 0) { - log("Found " + aEmptyTurbineRotorHatches.size() + " Assemblies without Turbine."); hatch: for (GT_MetaTileEntity_Hatch_Turbine aHatch : aEmptyTurbineRotorHatches) { ArrayList<ItemStack> aTurbines = getAllBufferedTurbines(); for (ItemStack aTurbineItem : aTurbines) { @@ -452,7 +441,6 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends } if (aHatch.insertTurbine(aTurbineItem.copy())) { boolean aDidDeplete = depleteTurbineFromStock(aTurbineItem); - log("Put Turbine into Assembly - " + aDidDeplete); continue hatch; } } @@ -460,9 +448,8 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends } if (getEmptyTurbineAssemblies().size() > 0 || !areAllTurbinesTheSame()) { - log("BAD RETURN - 1"); stopMachine(); - return false; + return CheckRecipeResultRegistry.NO_TURBINE_FOUND; } ArrayList<FluidStack> tFluids = getStoredFluids(); @@ -488,7 +475,6 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends * 50) * getSpeedMultiplier()); if (aTotalOptimalFlow < 0) { - log("Int overflow, report to issue tracker"); aTotalOptimalFlow = 100; } @@ -498,9 +484,8 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends baseEff = MathUtils.roundToClosestInt(aTotalBaseEff); optFlow = MathUtils.roundToClosestInt(aTotalOptimalFlow); if (optFlow <= 0 || baseEff <= 0) { - log("Running checkRecipeGeneric(bad-1)"); stopMachine(); // in case the turbine got removed - return false; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; } } else { counter++; @@ -526,19 +511,19 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends if (this.lEUt <= 0) { this.lEUt = 0; this.mEfficiency = 0; - return false; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; } else { this.mMaxProgresstime = 1; this.mEfficiencyIncrease = 10; // Overvoltage is handled inside the MultiBlockBase when pushing out to dynamos. no need to do it here. // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; + enableAllTurbineHatches(); + return CheckRecipeResultRegistry.GENERATING; } } catch (Throwable t) { t.printStackTrace(); } - return false; + return CheckRecipeResultRegistry.NO_FUEL_FOUND; } @Override @@ -788,12 +773,6 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends } @Override - public void startProcess() { - super.startProcess(); - enableAllTurbineHatches(); - } - - @Override public void stopMachine() { baseEff = 0; optFlow = 0; @@ -840,11 +819,6 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends } @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPreTick(aBaseMetaTileEntity, aTick); // Fix GT bug @@ -942,4 +916,9 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends public int getTurbineDamageMultiplier() { return mFastMode ? 3 : 1; } + + @Override + public boolean supportsBatchMode() { + return false; + } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java index 801fad2af1..c25bddabfd 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/storage/GregtechMetaTileEntity_PowerSubStationController.java @@ -26,6 +26,8 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.ForgeDirection; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; @@ -60,6 +62,8 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynam import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Maintenance; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; @@ -563,13 +567,13 @@ public class GregtechMetaTileEntity_PowerSubStationController } @Override - public boolean checkRecipe(final ItemStack aStack) { + public @NotNull CheckRecipeResult checkProcessing() { this.mProgresstime = 0; this.mMaxProgresstime = 200; this.lEUt = 0; this.mEfficiencyIncrease = 10000; this.fixAllMaintenanceIssue(); - return true; + return SimpleCheckRecipeResult.ofSuccess("managing_power"); } @Override @@ -577,11 +581,6 @@ public class GregtechMetaTileEntity_PowerSubStationController return 1; } - @Override - public int getEuDiscountForParallelism() { - return 0; - } - private long drawEnergyFromHatch(MetaTileEntity aHatch) { if (!isValidMetaTileEntity(aHatch)) { return 0; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialGeneratorArray.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialGeneratorArray.java deleted file mode 100644 index d612a942a2..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialGeneratorArray.java +++ /dev/null @@ -1,24 +0,0 @@ -package gtPlusPlus.xmod.gregtech.registration.gregtech; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntityGeneratorArray; - -public class GregtechIndustrialGeneratorArray { - - public static void run() { - Logger.INFO("Gregtech5u Content | Registering Industrial Generator Array Multiblock."); - // if (CORE.ConfigSwitches.enableMultiblock_IndustrialSifter) { // TODO - run1(); - // } - } - - private static void run1() { - // Industrial Maceration Stack Multiblock - GregtechItemList.Generator_Array_Controller.set( - new GregtechMetaTileEntityGeneratorArray( - 990, - "generatorarray.controller.tier.01", - "Large Generator Array").getStackForm(1L)); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIronBlastFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIronBlastFurnace.java deleted file mode 100644 index 2a1c1f68f7..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIronBlastFurnace.java +++ /dev/null @@ -1,24 +0,0 @@ -package gtPlusPlus.xmod.gregtech.registration.gregtech; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IronBlastFurnace; - -public class GregtechIronBlastFurnace { - - public static void run() { - Logger.INFO("Gregtech5u Content | Registering Iron Blast Furnace."); - if (CORE.ConfigSwitches.enableMultiblock_IronBlastFurnace) { - run1(); - } - } - - private static void run1() { - GregtechItemList.Machine_Iron_BlastFurnace.set( - new GregtechMetaTileEntity_IronBlastFurnace( - 768, - "ironmachine.blastfurnace", - "Iron Plated Blast Furnace").getStackForm(1L)); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTeslaTower.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTeslaTower.java deleted file mode 100644 index 910c0964a2..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTeslaTower.java +++ /dev/null @@ -1,14 +0,0 @@ -package gtPlusPlus.xmod.gregtech.registration.gregtech; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.misc.GregtechMTE_TeslaTower; - -public class GregtechTeslaTower { - - public static void run() { - Logger.INFO("Gregtech5u Content | Registering Tesla Tower."); - GregtechItemList.TelsaTower.set( - new GregtechMTE_TeslaTower(984, "multimachine.telsatower", "Tesla's Last Testament").getStackForm(1)); - } -} |