From 1b820de08a05070909a267e17f033fcf58ac8710 Mon Sep 17 00:00:00 2001 From: NotAPenguin Date: Mon, 2 Sep 2024 23:17:17 +0200 Subject: The Great Renaming (#3014) * move kekztech to a single root dir * move detrav to a single root dir * move gtnh-lanthanides to a single root dir * move tectech and delete some gross reflection in gt++ * remove more reflection inside gt5u * delete more reflection in gt++ * fix imports * move bartworks and bwcrossmod * fix proxies * move galactigreg and ggfab * move gtneioreplugin * try to fix gt++ bee loader * apply the rename rules to BW * apply rename rules to bwcrossmod * apply rename rules to detrav scanner mod * apply rename rules to galacticgreg * apply rename rules to ggfab * apply rename rules to goodgenerator * apply rename rules to gtnh-lanthanides * apply rename rules to gt++ * apply rename rules to kekztech * apply rename rules to kubatech * apply rename rules to tectech * apply rename rules to gt apply the rename rules to gt * fix tt import * fix mui hopefully * fix coremod except intergalactic * rename assline recipe class * fix a class name i stumbled on * rename StructureUtility to GTStructureUtility to prevent conflict with structurelib * temporary rename of GTTooltipDataCache to old name * fix gt client/server proxy names --- .../GT_MetaTileEntity_DieselGenerator.java | 278 ------- .../generators/GT_MetaTileEntity_GasTurbine.java | 207 ------ .../generators/GT_MetaTileEntity_LightningRod.java | 169 ----- .../GT_MetaTileEntity_MagicEnergyConverter.java | 173 ----- .../GT_MetaTileEntity_MagicalEnergyAbsorber.java | 805 --------------------- .../GT_MetaTileEntity_NaquadahReactor.java | 201 ----- .../GT_MetaTileEntity_PlasmaGenerator.java | 142 ---- .../generators/GT_MetaTileEntity_SteamTurbine.java | 238 ------ .../generators/MTEDieselGenerator.java | 278 +++++++ .../tileentities/generators/MTEGasTurbine.java | 201 +++++ .../tileentities/generators/MTELightningRod.java | 168 +++++ .../generators/MTEMagicEnergyConverter.java | 167 +++++ .../generators/MTEMagicalEnergyAbsorber.java | 803 ++++++++++++++++++++ .../generators/MTENaquadahReactor.java | 200 +++++ .../generators/MTEPlasmaGenerator.java | 142 ++++ .../tileentities/generators/MTESteamTurbine.java | 238 ++++++ 16 files changed, 2197 insertions(+), 2213 deletions(-) delete mode 100644 src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java delete mode 100644 src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_GasTurbine.java delete mode 100644 src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_LightningRod.java delete mode 100644 src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicEnergyConverter.java delete mode 100644 src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java delete mode 100644 src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_NaquadahReactor.java delete mode 100644 src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_PlasmaGenerator.java delete mode 100644 src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SteamTurbine.java create mode 100644 src/main/java/gregtech/common/tileentities/generators/MTEDieselGenerator.java create mode 100644 src/main/java/gregtech/common/tileentities/generators/MTEGasTurbine.java create mode 100644 src/main/java/gregtech/common/tileentities/generators/MTELightningRod.java create mode 100644 src/main/java/gregtech/common/tileentities/generators/MTEMagicEnergyConverter.java create mode 100644 src/main/java/gregtech/common/tileentities/generators/MTEMagicalEnergyAbsorber.java create mode 100644 src/main/java/gregtech/common/tileentities/generators/MTENaquadahReactor.java create mode 100644 src/main/java/gregtech/common/tileentities/generators/MTEPlasmaGenerator.java create mode 100644 src/main/java/gregtech/common/tileentities/generators/MTESteamTurbine.java (limited to 'src/main/java/gregtech/common/tileentities/generators') diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java deleted file mode 100644 index 10138bdfc2..0000000000 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_DieselGenerator.java +++ /dev/null @@ -1,278 +0,0 @@ -package gregtech.common.tileentities.generators; - -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BACK; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BACK_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_FRONT; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_FRONT_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_FRONT_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_FRONT_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_SIDE; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_SIDE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_TOP; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_TOP_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; -import static gregtech.api.objects.XSTR.XSTR_INSTANCE; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.GT_Mod; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.ParticleFX; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.RecipeMaps; -import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; - -public class GT_MetaTileEntity_DieselGenerator extends GT_MetaTileEntity_BasicGenerator { - - public int mEfficiency; - - public GT_MetaTileEntity_DieselGenerator(int aID, String aName, String aNameRegional, int aTier) { - super( - aID, - aName, - aNameRegional, - aTier, - new String[] { "Requires liquid Fuel", - "Causes " - + (int) (GT_Mod.gregtechproxy.mPollutionBaseDieselGeneratorPerSecond - * GT_Mod.gregtechproxy.mPollutionDieselGeneratorReleasedByTier[aTier]) - + " Pollution per second" }); - onConfigLoad(); - } - - public GT_MetaTileEntity_DieselGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - onConfigLoad(); - } - - public GT_MetaTileEntity_DieselGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - onConfigLoad(); - } - - @Override - public boolean isOutputFacing(ForgeDirection side) { - return side == getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_DieselGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.dieselFuels; - } - - @Override - public int getCapacity() { - return 16000; - } - - public void onConfigLoad() { - this.mEfficiency = (100 - this.mTier * 5); - } - - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public int getFuelValue(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack) || getRecipeMap() == null) return 0; - long rValue = super.getFuelValue(aStack); - if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { - rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3L); - } - if (rValue > Integer.MAX_VALUE) { - throw new ArithmeticException("Integer LOOPBACK!"); - } - return (int) rValue; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aTick % 100 == 0 && mFluid != null && mFluid.amount > this.getCapacity()) { - GT_Log.err.println( - "Dupe Abuse: " + aBaseMetaTileEntity.getOwnerName() - + " Coords: " - + aBaseMetaTileEntity.getXCoord() - + " " - + aBaseMetaTileEntity.getYCoord() - + " " - + aBaseMetaTileEntity.getZCoord()); - aBaseMetaTileEntity.setToFire(); - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - /** - * Draws random smoke particles on top when active - * - * @param aBaseMetaTileEntity The entity that will handle the {@link Block#randomDisplayTick} - */ - @SideOnly(Side.CLIENT) - @Override - public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { - if (aBaseMetaTileEntity.isActive()) { - - if (aBaseMetaTileEntity.getCoverIDAtSide(ForgeDirection.UP) == 0 - && !aBaseMetaTileEntity.getOpacityAtSide(ForgeDirection.UP)) { - - final double x = aBaseMetaTileEntity.getOffsetX(ForgeDirection.UP, 1) + 2D / 16D - + XSTR_INSTANCE.nextFloat() * 14D / 16D; - final double y = aBaseMetaTileEntity.getOffsetY(ForgeDirection.UP, 1) + 1D / 32D; - final double z = aBaseMetaTileEntity.getOffsetZ(ForgeDirection.UP, 1) + 2D / 16D - + XSTR_INSTANCE.nextFloat() * 14D / 16D; - - new ParticleEventBuilder().setMotion(0D, 0D, 0D) - .setPosition(x, y, z) - .setWorld(getBaseMetaTileEntity().getWorld()) - .setIdentifier(ParticleFX.SMOKE) - .run(); - } - } - } - - @Override - public ITexture[] getFront(byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], - TextureFactory.of( - TextureFactory.of(DIESEL_GENERATOR_FRONT), - TextureFactory.builder() - .addIcon(DIESEL_GENERATOR_FRONT_GLOW) - .glow() - .build()), - OVERLAYS_ENERGY_OUT[this.mTier] }; - } - - @Override - public ITexture[] getBack(byte aColor) { - return new ITexture[] { super.getBack(aColor)[0], - TextureFactory.of( - TextureFactory.of(DIESEL_GENERATOR_BACK), - TextureFactory.builder() - .addIcon(DIESEL_GENERATOR_BACK_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[] { super.getBottom(aColor)[0], - TextureFactory.of( - TextureFactory.of(DIESEL_GENERATOR_BOTTOM), - TextureFactory.builder() - .addIcon(DIESEL_GENERATOR_BOTTOM_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getTop(byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], - TextureFactory.of( - TextureFactory.of(DIESEL_GENERATOR_TOP), - TextureFactory.builder() - .addIcon(DIESEL_GENERATOR_TOP_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[] { super.getSides(aColor)[0], - TextureFactory.of( - TextureFactory.of(DIESEL_GENERATOR_SIDE), - TextureFactory.builder() - .addIcon(DIESEL_GENERATOR_SIDE_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(DIESEL_GENERATOR_FRONT_ACTIVE), - TextureFactory.builder() - .addIcon(DIESEL_GENERATOR_FRONT_ACTIVE_GLOW) - .glow() - .build()), - OVERLAYS_ENERGY_OUT[this.mTier] }; - } - - @Override - public ITexture[] getBackActive(byte aColor) { - return new ITexture[] { super.getBackActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(DIESEL_GENERATOR_BACK_ACTIVE), - TextureFactory.builder() - .addIcon(DIESEL_GENERATOR_BACK_ACTIVE_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[] { super.getBottomActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(DIESEL_GENERATOR_BOTTOM_ACTIVE), - TextureFactory.builder() - .addIcon(DIESEL_GENERATOR_BOTTOM_ACTIVE_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getTopActive(byte aColor) { - return new ITexture[] { super.getTopActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(DIESEL_GENERATOR_TOP_ACTIVE), - TextureFactory.builder() - .addIcon(DIESEL_GENERATOR_TOP_ACTIVE_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[] { super.getSidesActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(DIESEL_GENERATOR_SIDE_ACTIVE), - TextureFactory.builder() - .addIcon(DIESEL_GENERATOR_SIDE_ACTIVE_GLOW) - .glow() - .build()) }; - } - - @Override - public int getPollution() { - return (int) (GT_Mod.gregtechproxy.mPollutionBaseDieselGeneratorPerSecond - * GT_Mod.gregtechproxy.mPollutionDieselGeneratorReleasedByTier[mTier]); - } -} diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_GasTurbine.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_GasTurbine.java deleted file mode 100644 index ca0a5d6958..0000000000 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_GasTurbine.java +++ /dev/null @@ -1,207 +0,0 @@ -package gregtech.common.tileentities.generators; - -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BACK; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BACK_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BACK_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BACK_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BOTTOM; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BOTTOM_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BOTTOM_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BOTTOM_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_FRONT; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_FRONT_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_FRONT_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_FRONT_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_SIDE; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_SIDE_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_SIDE_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_SIDE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_TOP; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_TOP_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_TOP_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_TOP_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; - -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.GT_Mod; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.RecipeMaps; -import gregtech.api.render.TextureFactory; - -public class GT_MetaTileEntity_GasTurbine extends GT_MetaTileEntity_BasicGenerator { - - public int mEfficiency; - - public GT_MetaTileEntity_GasTurbine(int aID, String aName, String aNameRegional, int aTier, int mEfficiency) { - super( - aID, - aName, - aNameRegional, - aTier, - new String[] { "Requires flammable Gasses", - "Causes " - + (int) (GT_Mod.gregtechproxy.mPollutionBaseGasTurbinePerSecond - * GT_Mod.gregtechproxy.mPollutionGasTurbineReleasedByTier[aTier]) - + " Pollution per second" }); - this.mEfficiency = mEfficiency; - } - - public GT_MetaTileEntity_GasTurbine(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, - int mEfficiency) { - super(aName, aTier, aDescription, aTextures); - this.mEfficiency = mEfficiency; - } - - @Override - public boolean isOutputFacing(ForgeDirection side) { - return side == getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_GasTurbine( - this.mName, - this.mTier, - this.mDescriptionArray, - this.mTextures, - this.mEfficiency); - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.gasTurbineFuels; - } - - @Override - public int getCapacity() { - return 16000; - } - - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public ITexture[] getFront(byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], - TextureFactory.of( - TextureFactory.of(GAS_TURBINE_FRONT), - TextureFactory.builder() - .addIcon(GAS_TURBINE_FRONT_GLOW) - .glow() - .build()), - OVERLAYS_ENERGY_OUT[this.mTier] }; - } - - @Override - public ITexture[] getBack(byte aColor) { - return new ITexture[] { super.getBack(aColor)[0], - TextureFactory.of( - TextureFactory.of(GAS_TURBINE_BACK), - TextureFactory.builder() - .addIcon(GAS_TURBINE_BACK_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[] { super.getBottom(aColor)[0], - TextureFactory.of( - TextureFactory.of(GAS_TURBINE_BOTTOM), - TextureFactory.builder() - .addIcon(GAS_TURBINE_BOTTOM_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getTop(byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], - TextureFactory.of( - TextureFactory.of(GAS_TURBINE_TOP), - TextureFactory.builder() - .addIcon(GAS_TURBINE_TOP_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[] { super.getSides(aColor)[0], - TextureFactory.of( - TextureFactory.of(GAS_TURBINE_SIDE), - TextureFactory.builder() - .addIcon(GAS_TURBINE_SIDE_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(GAS_TURBINE_FRONT_ACTIVE), - TextureFactory.builder() - .addIcon(GAS_TURBINE_FRONT_ACTIVE_GLOW) - .glow() - .build()), - OVERLAYS_ENERGY_OUT[this.mTier] }; - } - - @Override - public ITexture[] getBackActive(byte aColor) { - return new ITexture[] { super.getBackActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(GAS_TURBINE_BACK_ACTIVE), - TextureFactory.builder() - .addIcon(GAS_TURBINE_BACK_ACTIVE_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[] { super.getBottomActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(GAS_TURBINE_BOTTOM_ACTIVE), - TextureFactory.builder() - .addIcon(GAS_TURBINE_BOTTOM_ACTIVE_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getTopActive(byte aColor) { - return new ITexture[] { super.getTopActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(GAS_TURBINE_TOP_ACTIVE), - TextureFactory.builder() - .addIcon(GAS_TURBINE_TOP_ACTIVE_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[] { super.getSidesActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(GAS_TURBINE_SIDE_ACTIVE), - TextureFactory.builder() - .addIcon(GAS_TURBINE_SIDE_ACTIVE_GLOW) - .glow() - .build()) }; - } - - @Override - public int getPollution() { - return (int) (GT_Mod.gregtechproxy.mPollutionBaseGasTurbinePerSecond - * GT_Mod.gregtechproxy.mPollutionGasTurbineReleasedByTier[mTier]); - } -} diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_LightningRod.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_LightningRod.java deleted file mode 100644 index 9809dba278..0000000000 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_LightningRod.java +++ /dev/null @@ -1,169 +0,0 @@ -package gregtech.common.tileentities.generators; - -import static gregtech.api.objects.XSTR.XSTR_INSTANCE; - -import net.minecraft.entity.effect.EntityLightningBolt; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.Textures.BlockIcons; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; -import gregtech.api.render.TextureFactory; - -public class GT_MetaTileEntity_LightningRod extends GT_MetaTileEntity_TieredMachineBlock { - - public GT_MetaTileEntity_LightningRod(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 0, "Generates EU From Lightning Bolts"); - } - - public GT_MetaTileEntity_LightningRod(String aName, int aTier, int aInvSlotCount, String aDescription, - ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GT_MetaTileEntity_LightningRod(String aName, int aTier, int aInvSlotCount, String[] aDescription, - ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, - ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { - if (sideDirection != ForgeDirection.UP) { - return new ITexture[] { BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1], - BlockIcons.OVERLAYS_ENERGY_OUT_POWER[mTier] }; - } - if (!active) return new ITexture[] { BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1], - TextureFactory.of(BlockIcons.MACHINE_CASING_FUSION_GLASS) }; - return new ITexture[] { BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1], - TextureFactory.of(BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW), TextureFactory.builder() - .addIcon(BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return null; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_LightningRod( - this.mName, - this.mTier, - this.mInventory.length, - this.mDescriptionArray, - this.mTextures); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - World aWorld = aBaseMetaTileEntity.getWorld(); - if (!aWorld.isRemote) { - if (aBaseMetaTileEntity.getStoredEU() > 0) { - aBaseMetaTileEntity.setActive(true); - aBaseMetaTileEntity.decreaseStoredEnergyUnits(aBaseMetaTileEntity.getStoredEU() / 100 + 1, false); - } else { - aBaseMetaTileEntity.setActive(false); - } - - if (aTick % 256 == 0 && (aWorld.isThundering() || (aWorld.isRaining() && XSTR_INSTANCE.nextInt(10) == 0))) { - int aRodValue = 0; - boolean isRodValid = true; - int aX = aBaseMetaTileEntity.getXCoord(); - int aY = aBaseMetaTileEntity.getYCoord(); - int aZ = aBaseMetaTileEntity.getZCoord(); - - for (int i = aBaseMetaTileEntity.getYCoord() + 1; i < aWorld.getHeight() - 1; i++) { - if (isRodValid && aBaseMetaTileEntity.getBlock(aX, i, aZ) - .getUnlocalizedName() - .equals("blockFenceIron")) { - aRodValue++; - } else { - isRodValid = false; - if (aBaseMetaTileEntity.getBlock(aX, i, aZ) != Blocks.air) { - aRodValue = 0; - break; - } - } - } - if (!aWorld.isThundering() && ((aY + aRodValue) < 128)) aRodValue = 0; - if (XSTR_INSTANCE.nextInt(4 * aWorld.getHeight()) < (aRodValue * (aY + aRodValue))) { - aBaseMetaTileEntity - .increaseStoredEnergyUnits(maxEUStore() - aBaseMetaTileEntity.getStoredEU(), false); - aWorld.addWeatherEffect(new EntityLightningBolt(aWorld, aX, aY + aRodValue, aZ)); - // randomly break a rod - if (aWorld.isThundering()) { - aWorld.setBlockToAir(aX, aY + XSTR_INSTANCE.nextInt(aRodValue) + 1, aZ); - } - } - } - } - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - return false; - } - - @Override - public boolean isSimpleMachine() { - return false; - } - - @Override - public boolean isFacingValid(ForgeDirection facing) { - return facing == ForgeDirection.UP; - } - - @Override - public boolean isOutputFacing(ForgeDirection side) { - return true; - } - - @Override - public boolean isEnetOutput() { - return true; - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public long maxEUStore() { - return 50000000; - } - - @Override - public long maxEUOutput() { - return GT_Values.V[mTier]; - } - - @Override - public long maxAmperesOut() { - return 512; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) {} - - @Override - public void loadNBTData(NBTTagCompound aNBT) {} -} diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicEnergyConverter.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicEnergyConverter.java deleted file mode 100644 index 647aa504e5..0000000000 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicEnergyConverter.java +++ /dev/null @@ -1,173 +0,0 @@ -package gregtech.common.tileentities.generators; - -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; - -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.RecipeMaps; -import gregtech.api.render.TextureFactory; - -public class GT_MetaTileEntity_MagicEnergyConverter extends GT_MetaTileEntity_BasicGenerator { - - public int mEfficiency; - - public GT_MetaTileEntity_MagicEnergyConverter(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, "Put your strange stuff in here"); - onConfigLoad(); - } - - public GT_MetaTileEntity_MagicEnergyConverter(String aName, int aTier, String aDescription, - ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - onConfigLoad(); - } - - public GT_MetaTileEntity_MagicEnergyConverter(String aName, int aTier, String[] aDescription, - ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - onConfigLoad(); - } - - @Override - public boolean isOutputFacing(ForgeDirection side) { - return side == getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_MagicEnergyConverter( - this.mName, - this.mTier, - this.mDescriptionArray, - this.mTextures); - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.magicFuels; - } - - @Override - public int getCapacity() { - return 16000; - } - - public void onConfigLoad() { - this.mEfficiency = 100 - this.mTier * 5; - } - - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public ITexture[] getFront(byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_GLOW) - .glow() - .build(), - OVERLAYS_ENERGY_OUT[mTier] }; - } - - @Override - public ITexture[] getBack(byte aColor) { - return new ITexture[] { super.getBack(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_FRONT), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_FRONT_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[] { super.getBottom(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getTop(byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[] { super.getSides(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) - .glow() - .build(), - OVERLAYS_ENERGY_OUT[mTier] }; - } - - @Override - public ITexture[] getBackActive(byte aColor) { - return new ITexture[] { super.getBackActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_FRONT_ACTIVE), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_FRONT_ACTIVE_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[] { super.getBottomActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getTopActive(byte aColor) { - return new ITexture[] { super.getTopActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[] { super.getSidesActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) - .glow() - .build() }; - } - - @Override - public int getPollution() { - return 0; - } -} diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java deleted file mode 100644 index 3245607ac2..0000000000 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_MagicalEnergyAbsorber.java +++ /dev/null @@ -1,805 +0,0 @@ -package gregtech.common.tileentities.generators; - -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.Mods.Thaumcraft; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_DRAGONEGG; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_DRAGONEGG_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; -import static gregtech.api.objects.XSTR.XSTR_INSTANCE; -import static net.minecraft.util.EnumChatFormatting.GRAY; -import static net.minecraft.util.EnumChatFormatting.GREEN; -import static net.minecraft.util.EnumChatFormatting.LIGHT_PURPLE; -import static net.minecraft.util.EnumChatFormatting.RESET; -import static net.minecraft.util.EnumChatFormatting.UNDERLINE; -import static net.minecraft.util.EnumChatFormatting.YELLOW; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockDragonEgg; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.item.EntityEnderCrystal; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemEnchantedBook; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.common.util.ForgeDirection; - -import com.google.common.base.Enums; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.enums.ParticleFX; -import gregtech.api.enums.TC_Aspects; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.RecipeMaps; -import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; -import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; -import gregtech.common.config.machinestats.ConfigMachines; -import thaumcraft.api.aspects.Aspect; -import thaumcraft.api.aspects.AspectList; -import thaumcraft.api.aspects.AspectSourceHelper; -import thaumcraft.api.aspects.IAspectContainer; -import thaumcraft.api.visnet.VisNetHandler; - -interface MagicalEnergyBBListener { - - void onMagicalEnergyBBUpdate(); -} - -public class GT_MetaTileEntity_MagicalEnergyAbsorber extends GT_MetaTileEntity_BasicGenerator - implements MagicalEnergyBBListener { - - private static final ConcurrentHashMap sSubscribedCrystals = new ConcurrentHashMap<>( - 4); - private static final List sPrimalAspects = (Thaumcraft.isModLoaded()) ? Aspect.getPrimalAspects() - : new ArrayList<>(); - private static final Map sAspectsEnergy = new HashMap<>(); - private static boolean sAllowMultipleEggs = false; - private static GT_MetaTileEntity_MagicalEnergyAbsorber sActiveSiphon = null; - private static int sEnergyPerEndercrystal = 512; - private static int sEnergyFromVis = 20; - private static int sEnergyPerEssentia = 320; - private static int sDragonEggEnergyPerTick = 2048; - private static int sCreeperEggEnergyPerTick = 512; - private final MagicalEnergyBB mMagicalEnergyBB = new MagicalEnergyBB(this, mTier, mTier + 2); - private int mEfficiency; - private int mMaxVisPerDrain; - private long mNextGenerateTickRate = 1; - private int mNoGenerationTicks = 0; - private boolean mUsingEssentia = true; - - public GT_MetaTileEntity_MagicalEnergyAbsorber(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, "Feasts on magic close to it:"); - onConfigLoad(); - } - - private GT_MetaTileEntity_MagicalEnergyAbsorber(String aName, int aTier, String[] aDescription, - ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - onConfigLoad(); - } - - /** - * Populates static variables dependant on config settings - */ - private static void sharedConfigLoad() { - sAllowMultipleEggs = ConfigMachines.allowMultipleEggs; - if (Thaumcraft.isModLoaded()) { - for (Aspect tAspect : Aspect.aspects.values()) { - // noinspection UnstableApiUsage - sAspectsEnergy.put( - tAspect, - Enums.getIfPresent( - TC_Aspects.class, - tAspect.getTag() - .toUpperCase(Locale.ENGLISH)) - .or(TC_Aspects.AER).mValue * sEnergyPerEssentia); - } - } - } - - private static void setActiveSiphon(GT_MetaTileEntity_MagicalEnergyAbsorber aSiphon) { - sActiveSiphon = aSiphon; - } - - public void onConfigLoad() { - sharedConfigLoad(); - mEfficiency = 100 - mTier * 10; - mMaxVisPerDrain = (int) Math.round(Math.sqrt((double) (V[mTier] * 10000) / (sEnergyFromVis * getEfficiency()))); - if (Math.pow(mMaxVisPerDrain, 2) * sEnergyFromVis * getEfficiency() < V[mTier]) { - mMaxVisPerDrain += 1; - } - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aPlayer.isSneaking()) mMagicalEnergyBB.decreaseTier(); - else mMagicalEnergyBB.increaseTier(); - GT_Utility.sendChatToPlayer( - aPlayer, - String.format( - GT_LanguageManager.addStringLocalization( - "Interaction_DESCRIPTION_MagicalEnergyAbsorber_Screwdriver", - "Absorption range: %s blocks"), - mMagicalEnergyBB.getRange(), - true)); - mMagicalEnergyBB.update(); - } - - @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - if (!aBaseMetaTileEntity.isServerSide()) return; - mMagicalEnergyBB.update(); - } - - @Override - public void onRemoval() { - super.onRemoval(); - releaseEgg(); - unsubscribeCrystals(); - } - - private void releaseEgg() { - if (sActiveSiphon == this) { - setActiveSiphon(null); - } - } - - private void unsubscribeCrystals() { - for (UUID tCrystalID : sSubscribedCrystals.keySet()) { - sSubscribedCrystals.remove(tCrystalID, this); - } - } - - /** - * Call-back from the Bounding Box when its content is updated - */ - @Override - public void onMagicalEnergyBBUpdate() { - List tCrystalIDsInRange = mMagicalEnergyBB.getLivingCrystalIDs(); - // Release unreachable Crystals subscriptions - for (UUID tSubscribedCrystalID : sSubscribedCrystals.keySet()) { - if (!tCrystalIDsInRange.contains(tSubscribedCrystalID)) { - sSubscribedCrystals.remove(tSubscribedCrystalID, this); - } - } - // Subscribe to available and not already subscribed Crystals - for (UUID tCrystalID : tCrystalIDsInRange) { - sSubscribedCrystals.putIfAbsent(tCrystalID, this); - } - } - - @Override - public String[] getDescription() { - final String LI = "- %%%"; - final String EU_PER = "%%%EU per "; - List description = new ArrayList<>(); - description - .add(UNDERLINE + "Feasts on " + LIGHT_PURPLE + UNDERLINE + "magic" + GRAY + UNDERLINE + " close to it:"); - description.add( - LI + (sAllowMultipleEggs ? "A " : "An " + YELLOW + UNDERLINE + "EXCLUSIVE" + RESET) - + GRAY - + " " - + LIGHT_PURPLE - + "Dragon Egg" - + GRAY - + " atop"); - if (sEnergyPerEndercrystal > 0) { - description.add(LI + sEnergyPerEndercrystal + EU_PER + LIGHT_PURPLE + "Ender Crystal" + GRAY + " in range"); - } - if (Thaumcraft.isModLoaded()) { - description.add(LI + mMaxVisPerDrain + "%%%CV/t from an " + LIGHT_PURPLE + "Energised Node" + GRAY); - description.add( - LI + (sEnergyPerEssentia * getEfficiency()) / 100 - + EU_PER - + LIGHT_PURPLE - + "Essentia" - + GRAY - + " Aspect-Value from containers in range"); - } - description.add(" "); - description.add(UNDERLINE + "Lookup range (Use Screwdriver to change):"); - description.add("Default: %%%" + GREEN + mMagicalEnergyBB.getDefaultRange()); - description.add("Max: %%%" + GREEN + mMagicalEnergyBB.getMaxRange()); - description.add(" "); - description - .add(UNDERLINE + "Fuels on " + LIGHT_PURPLE + UNDERLINE + "enchantments" + GRAY + UNDERLINE + " input:"); - description.add( - "- Item: %%%" + (10000 * getEfficiency()) / 100 - + EU_PER - + LIGHT_PURPLE - + "enchant" - + GRAY - + " weight × level / max"); - description.add("- Book: %%%" + 10000 + EU_PER + LIGHT_PURPLE + "enchant" + GRAY + " weight × level / max"); - description.add(" "); - description.add("Efficiency: %%%" + GREEN + getEfficiency() + "%"); - return description.toArray(new String[0]); - } - - @Override - public ITexture[] getFront(byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_GLOW) - .glow() - .build(), - OVERLAYS_ENERGY_OUT[mTier] }; - } - - @Override - public ITexture[] getBack(byte aColor) { - return new ITexture[] { super.getBack(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_FRONT), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_FRONT_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[] { super.getBottom(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getTop(byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], TextureFactory.of(MACHINE_CASING_DRAGONEGG) }; - } - - @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[] { super.getSides(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) - .glow() - .build(), - OVERLAYS_ENERGY_OUT[mTier] }; - } - - @Override - public ITexture[] getBackActive(byte aColor) { - return new ITexture[] { super.getBackActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_FRONT_ACTIVE), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_FRONT_ACTIVE_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[] { super.getBottomActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getTopActive(byte aColor) { - return new ITexture[] { super.getTopActive(aColor)[0], TextureFactory.of(MACHINE_CASING_DRAGONEGG), - TextureFactory.builder() - .addIcon(MACHINE_CASING_DRAGONEGG_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[] { super.getSidesActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), - TextureFactory.builder() - .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) - .glow() - .build() }; - } - - @Override - public boolean isOutputFacing(ForgeDirection side) { - return side == getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public long maxEUStore() { - return Math.max(getEUVar(), V[mTier] * 16000 + getMinimumStoredEU()); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (!aBaseMetaTileEntity.isServerSide()) return; - if (!aBaseMetaTileEntity.isAllowedToWork()) return; - if ((aBaseMetaTileEntity.getUniversalEnergyStored() >= aBaseMetaTileEntity.getEUCapacity())) return; - - long tGeneratedEU; - - if (aTick % 100 == 0 && mUsingEssentia) mMagicalEnergyBB.update(); - - // Adaptive EU Generation Ticking - if (aTick % mNextGenerateTickRate == 0) { - tGeneratedEU = generateEU(); - if (tGeneratedEU > 0) { - mNoGenerationTicks = 0; - if (tGeneratedEU >= 2 * V[mTier]) - mNextGenerateTickRate = (long) (1.0D / ((2.0D * (double) (V[mTier])) / (double) tGeneratedEU)); - else mNextGenerateTickRate = 1; - mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + tGeneratedEU + " EU"); - } else { - mInventory[getStackDisplaySlot()] = null; - mNoGenerationTicks += 1; - } - if (mNoGenerationTicks > 20) { - mNoGenerationTicks = 0; - mNextGenerateTickRate = 20; - } - aBaseMetaTileEntity.increaseStoredEnergyUnits(tGeneratedEU, true); - aBaseMetaTileEntity.setActive( - aBaseMetaTileEntity.isAllowedToWork() - && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); - } - } - - /** - * Draws random portal particles on top when active with an egg on top - * - * @param aBaseMetaTileEntity The entity that will handle the {@link Block#randomDisplayTick} - */ - @SideOnly(Side.CLIENT) - @Override - public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { - - if (aBaseMetaTileEntity.isActive()) { - - if (isEgg(aBaseMetaTileEntity.getBlockAtSide(ForgeDirection.UP))) { - - final double oX = aBaseMetaTileEntity.getXCoord() + 8D / 16D; - final double oY = aBaseMetaTileEntity.getYCoord() + 17D / 32D; - final double oZ = aBaseMetaTileEntity.getZCoord() + 8D / 16D; - - final ParticleEventBuilder particleEventBuilder = new ParticleEventBuilder() - .setWorld(getBaseMetaTileEntity().getWorld()) - .setIdentifier(ParticleFX.PORTAL); - - for (int i = 0; i < 9; i++) { - final double dX = (XSTR_INSTANCE.nextFloat() - 0.5D) / 2D; - final double dY = XSTR_INSTANCE.nextFloat() * 1.5; - final double dZ = (XSTR_INSTANCE.nextFloat() - 0.5D) / 2D; - - final double x = oX + dX; - final double y = oY + dY; - final double z = oZ + dZ; - - final double mX = dX * 4D; - final double dXZ = Math.sqrt(dX * dX + dZ * dZ); - final double mY = -(dXZ * dY) / 4D; - final double mZ = dZ * 4D; - - particleEventBuilder.setMotion(mX, mY, mZ) - .setPosition(x, y, z) - .run(); - } - } - } - } - - @Override - public int getPollution() { - return 0; - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.magicFuels; - } - - @Override - public int getEfficiency() { - return mEfficiency; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - // Restrict input to disenchantable items or enchanted books - return (isDisenchantableItem(aStack) || isEnchantedBook(aStack)); - } - - @Override - public int getCapacity() { - return 16000; - } - - private boolean isDisenchantableItem(ItemStack aStack) { - return ((aStack.isItemEnchanted()) && (aStack.getItem() - .getItemEnchantability() > 0)); - } - - private boolean isEnchantedBook(ItemStack aStack) { - return (aStack.getItem() instanceof ItemEnchantedBook); - } - - private long generateEU() { - long tEU; - - mUsingEssentia = false; - if ((tEU = absorbFromEgg()) > 0) return tEU; - if ((tEU = absorbFromEnderCrystals()) > 0) return tEU; - if ((tEU = absorbFromEnchantedItems()) > 0) return tEU; - if ((tEU = absorbFromVisNet()) > 0) return tEU; - mUsingEssentia = true; - if ((tEU = absorbFromEssentiaContainers()) > 0) return tEU; - return 0; - } - - private long absorbFromEnchantedItems() { - ItemStack tStack = getBaseMetaTileEntity().getStackInSlot(getInputSlot()); - if (tStack == null) return 0; - if (tStack.stackSize == 0) return 0; - if (!(isDisenchantableItem(tStack) || isEnchantedBook(tStack))) return 0; - long tEU = 0; - // Convert enchantments to their EU Value - Map tMap = EnchantmentHelper.getEnchantments(tStack); - for (Map.Entry e : tMap.entrySet()) { - if ((Integer) e.getKey() < Enchantment.enchantmentsList.length) { - Enchantment tEnchantment = Enchantment.enchantmentsList[(Integer) e.getKey()]; - Integer tLevel = (Integer) e.getValue(); - tEU += 1000000L * tLevel / tEnchantment.getMaxLevel() / tEnchantment.getWeight(); - } - } - - ItemStack tOutputStack = GT_Utility.copyAmount(1, tStack); - if (tOutputStack != null) { - if (isDisenchantableItem(tOutputStack)) { - tEU = tEU * getEfficiency() / 100; - EnchantmentHelper.setEnchantments(new HashMap<>(), tOutputStack); - } else if (isEnchantedBook(tOutputStack)) { - tOutputStack = new ItemStack(Items.book, 1); - } - } - - // Only consume input when it can store EU and push output - if ((getBaseMetaTileEntity().getStoredEU() + tEU) < getBaseMetaTileEntity().getEUCapacity() - && getBaseMetaTileEntity().addStackToSlot(getOutputSlot(), tOutputStack)) { - decrStackSize(getInputSlot(), 1); - } else { - tEU = 0; - } - return tEU; - } - - private boolean hasEgg() { - Block above = getBaseMetaTileEntity().getBlockOffset(0, 1, 0); - return isEgg(above); - } - - private long absorbFromEgg() { - if (!hasEgg()) return 0; - if (!sAllowMultipleEggs) { - if (sActiveSiphon != null && sActiveSiphon != this - && sActiveSiphon.getBaseMetaTileEntity() != null - && !sActiveSiphon.getBaseMetaTileEntity() - .isInvalidTileEntity() - && sActiveSiphon.isChunkLoaded() - && sActiveSiphon.hasEgg()) { - getBaseMetaTileEntity().doExplosion(Integer.MAX_VALUE); - } else { - setActiveSiphon(this); - } - } - Block egg = getBaseMetaTileEntity().getBlockOffset(0, 1, 0); - if (egg == Blocks.dragon_egg) { - return sDragonEggEnergyPerTick; - } else if (egg.getUnlocalizedName() - .contains("creeperEgg")) { - return sCreeperEggEnergyPerTick; - } - return 0; - } - - private long absorbFromEnderCrystals() { - if (sEnergyPerEndercrystal <= 0) return 0; - long tEU = 0; - for (GT_MetaTileEntity_MagicalEnergyAbsorber tSubscriber : sSubscribedCrystals.values()) { - if (tSubscriber == this) { // This Crystal is for me - tEU += sEnergyPerEndercrystal; - } - } - return tEU; - } - - private long absorbFromVisNet() { - if (!Thaumcraft.isModLoaded()) return 0; - - long tEU; - IGregTechTileEntity tBaseMetaTileEntity = getBaseMetaTileEntity(); - World tWorld = tBaseMetaTileEntity.getWorld(); - int tX = tBaseMetaTileEntity.getXCoord(); - int tY = tBaseMetaTileEntity.getYCoord(); - int tZ = tBaseMetaTileEntity.getZCoord(); - - // Attempt to drain as much Vis as needed for max EU/t, from all primal aspects. - int toDrain = mMaxVisPerDrain; - - for (int i = sPrimalAspects.size() - 1; i >= 0 && toDrain > 0; i--) { - toDrain -= VisNetHandler.drainVis(tWorld, tX, tY, tZ, sPrimalAspects.get(i), toDrain); - } - - int drained = mMaxVisPerDrain - toDrain; - tEU = (long) Math.min(maxEUOutput(), (Math.pow(drained, 2) * sEnergyFromVis * getEfficiency() / 10000)); - - return tEU; - } - - private long absorbFromEssentiaContainers() { - if (!Thaumcraft.isModLoaded()) return 0; - - long tEU = 0; - - long tEUtoGen = getBaseMetaTileEntity().getEUCapacity() - getBaseMetaTileEntity().getUniversalEnergyStored(); - List mAvailableEssentiaAspects = mMagicalEnergyBB.getAvailableAspects(); - - // try to drain 1 of whatever aspect available in containers within RANGE - for (int i = mAvailableEssentiaAspects.size() - 1; i >= 0 && tEUtoGen > 0; i--) { - Aspect aspect = mAvailableEssentiaAspects.get(i); - long tAspectEU = ((long) sAspectsEnergy.get(aspect) * getEfficiency()) / 100; - if (tAspectEU <= tEUtoGen && AspectSourceHelper.drainEssentia( - (TileEntity) getBaseMetaTileEntity(), - aspect, - ForgeDirection.UNKNOWN, - mMagicalEnergyBB.getRange())) { - tEUtoGen -= tAspectEU; - tEU += tAspectEU; - } - } - return tEU; - } - - private boolean isEgg(Block aBlock) { - if (aBlock == null) return false; - if (aBlock == Blocks.air) return false; - if (aBlock == Blocks.dragon_egg) return true; - if (aBlock instanceof BlockDragonEgg) return true; - return (aBlock.getUnlocalizedName() - .equals("tile.dragonEgg")); - } - - private boolean isChunkLoaded() { - IGregTechTileEntity tBaseMetaTileEntity = getBaseMetaTileEntity(); - int tX = tBaseMetaTileEntity.getXCoord(); - int tY = tBaseMetaTileEntity.getYCoord(); - World tWorld = tBaseMetaTileEntity.getWorld(); - Chunk tChunk = tWorld.getChunkFromBlockCoords(tX, tY); - return tChunk.isChunkLoaded; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_MagicalEnergyAbsorber(mName, mTier, mDescriptionArray, mTextures); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setInteger("mMagicalEnergyBBTier", mMagicalEnergyBB.getTier()); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mMagicalEnergyBB.setTier(aNBT.getInteger("mMagicalEnergyBBTier")); - } - - /** - * Handles Bounding Box ranged operations for Magic sources - */ - static class MagicalEnergyBB { - - private final GT_MetaTileEntity_MagicalEnergyAbsorber mAbsorber; - private final MagicalEnergyBBListener mListener; - private final int mDefaultTier; - private int mTier; - private final int mMaxTier; - private final List mLivingCrystalIDs = new ArrayList<>(); - private List mAvailableAspects; - - /** - * @param aAbsorber user and subscriber for updated BB content - * @param aDefaultTier Initial tier value - * @param aMaxTier Maximum allowed tier - */ - MagicalEnergyBB(GT_MetaTileEntity_MagicalEnergyAbsorber aAbsorber, int aDefaultTier, int aMaxTier) { - mAbsorber = aAbsorber; - mListener = aAbsorber; - mMaxTier = Math.max(Math.max(aMaxTier, 0), Math.max(aDefaultTier, 0)); - mDefaultTier = Math.min(aDefaultTier, mMaxTier); - mTier = mDefaultTier; - if (Thaumcraft.isModLoaded()) mAvailableAspects = new ArrayList<>(Aspect.aspects.size()); - } - - int getTier() { - return mTier; - } - - /** - * Set Bounding Box Tier within allowed bounds - * - * @param aTier new tier value - * @return effective new tier - */ - int setTier(int aTier) { - if (aTier >= 0) { - mTier = Math.min(aTier, mMaxTier); - } else { - mTier = 0; - } - return mTier; - } - - int getRange() { - return getRange(mTier); - } - - int getRange(int aTier) { - return 1 << aTier; - } - - int getDefaultTier() { - return mDefaultTier; - } - - int getDefaultRange() { - return getRange(getDefaultTier()); - } - - int getMaxTier() { - return mMaxTier; - } - - int getMaxRange() { - return getRange(getMaxTier()); - } - - private AxisAlignedBB getAxisAlignedBB() { - double tRange = getRange(); - IGregTechTileEntity tBaseMetaTileEntity = mAbsorber.getBaseMetaTileEntity(); - double tX = tBaseMetaTileEntity.getXCoord(); - double tY = tBaseMetaTileEntity.getYCoord(); - double tZ = tBaseMetaTileEntity.getZCoord(); - return AxisAlignedBB - .getBoundingBox(tX - tRange, tY - tRange, tZ - tRange, tX + tRange, tY + tRange, tZ + tRange); - } - - private void scanLivingCrystals() { - World tWorld = mAbsorber.getBaseMetaTileEntity() - .getWorld(); - mLivingCrystalIDs.clear(); - for (EntityEnderCrystal o : tWorld.getEntitiesWithinAABB(EntityEnderCrystal.class, getAxisAlignedBB())) { - if (o.isEntityAlive()) { - mLivingCrystalIDs.add(o.getPersistentID()); - } - } - } - - private void scanAvailableAspects() { - if (!Thaumcraft.isModLoaded()) return; - IGregTechTileEntity tBaseMetaTileEntity = mAbsorber.getBaseMetaTileEntity(); - if (tBaseMetaTileEntity.isInvalidTileEntity()) return; - int tRange = getRange(); - int tY = tBaseMetaTileEntity.getYCoord(); - int tMaxY = tBaseMetaTileEntity.getWorld() - .getHeight() - 1; - // Make sure relative Y range stays between 0 and world max Y - int rYMin = (tY - tRange >= 0) ? -tRange : -(tY); - int rYMax = (((tY + tRange) <= tMaxY) ? tRange : tMaxY - tY); - mAvailableAspects.clear(); - for (int rX = -tRange; rX <= tRange; rX++) { - for (int rZ = -tRange; rZ <= tRange; rZ++) { - // rY < rYMax is not a bug. See: thaumcraft.common.lib.events.EssentiaHandler.getSources() - for (int rY = rYMin; rY < rYMax; rY++) { - TileEntity tTile = tBaseMetaTileEntity.getTileEntityOffset(rX, rY, rZ); - if (tTile instanceof IAspectContainer) { - AspectList tAspectList = ((IAspectContainer) tTile).getAspects(); - if (tAspectList == null || tAspectList.aspects.isEmpty()) continue; - Set tAspects = tAspectList.aspects.keySet(); - mAvailableAspects.addAll(tAspects); - } - } - } - } - } - - /** - * @return List of Living Ender Crystal Entity IDs in range - */ - List getLivingCrystalIDs() { - return mLivingCrystalIDs; - } - - /** - * @return List of drainable Essentia Aspects from containers in range - */ - List getAvailableAspects() { - return mAvailableAspects; - } - - /** - * Scan range for magic sources - */ - void update() { - if (mAbsorber == null) return; - if (mAbsorber.getBaseMetaTileEntity() == null) return; - if (mAbsorber.getBaseMetaTileEntity() - .isInvalidTileEntity()) return; - if (mAbsorber.getBaseMetaTileEntity() - .getWorld() == null) return; - scanLivingCrystals(); - scanAvailableAspects(); - if (mListener != null) { - mListener.onMagicalEnergyBBUpdate(); - } - } - - void increaseTier() { - offsetTier(1); - } - - void decreaseTier() { - offsetTier(-1); - } - - /** - * Change the Bounding Box tier relatively to offset with wrapping at tier limits - * - * @param aOffset relative tier change - */ - void offsetTier(int aOffset) { - int tNumTiers = mMaxTier + 1; - int tTier = (mTier + aOffset + tNumTiers) % tNumTiers; - int tTrueTier = setTier(tTier); - if (tTier != tTrueTier) { - GT_Log.out.format("Absorber's BB Tier set to %d was capped to %d", tTier, tTrueTier); - } - } - } -} diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_NaquadahReactor.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_NaquadahReactor.java deleted file mode 100644 index 1dd378e746..0000000000 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_NaquadahReactor.java +++ /dev/null @@ -1,201 +0,0 @@ -package gregtech.common.tileentities.generators; - -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BACK; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BACK_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BACK_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BACK_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BOTTOM; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BOTTOM_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BOTTOM_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BOTTOM_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_SIDE; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_SIDE_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_SIDE_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_SIDE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_GLOW; - -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.RecipeMaps; -import gregtech.api.render.TextureFactory; - -public class GT_MetaTileEntity_NaquadahReactor extends GT_MetaTileEntity_BasicGenerator { - - private int mEfficiency; - - public GT_MetaTileEntity_NaquadahReactor(int aID, String aName, String[] aDescription, String aNameRegional, - int aTier) { - super(aID, aName, aNameRegional, aTier, aDescription); - if (aTier > 8 || aTier < 4) { - new Exception("Tier without Recipe Map!").printStackTrace(); - } - mEfficiency = getBaseEff(); - } - - public GT_MetaTileEntity_NaquadahReactor(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - if (aTier > 8 || aTier < 4) { - new Exception("Tier without Recipe Map!").printStackTrace(); - } - mEfficiency = getBaseEff(); - } - - @Override - public boolean isOutputFacing(ForgeDirection side) { - if (side == ForgeDirection.UNKNOWN) return false; - return ((side.flag & (ForgeDirection.UP.flag | ForgeDirection.DOWN.flag)) == 0) - && (side != getBaseMetaTileEntity().getFrontFacing()) - && (side != getBaseMetaTileEntity().getBackFacing()); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_NaquadahReactor(mName, mTier, mDescriptionArray, mTextures); - } - - @Override - public RecipeMap getRecipeMap() { - RecipeMap ret; - switch (mTier) { - case 4 -> ret = RecipeMaps.smallNaquadahReactorFuels; - case 5 -> ret = RecipeMaps.largeNaquadahReactorFuels; - case 6 -> ret = RecipeMaps.hugeNaquadahReactorFuels; - case 7 -> ret = RecipeMaps.extremeNaquadahReactorFuels; - case 8 -> ret = RecipeMaps.ultraHugeNaquadahReactorFuels; - default -> ret = null; - } - return ret; - } - - @Override - public int getCapacity() { - return getRecipeMap() != null ? getRecipeMap().getBackend() - .getProperties().minFluidInputs > 0 ? 8000 * (mTier + 1) : 0 : 0; - } - - @Override - public int getEfficiency() { - return mEfficiency; - } - - private int getBaseEff() { - return mTier == 4 ? 80 : 100 + (50 * (mTier - 5)); - } - - @Override - public ITexture[] getFront(byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], - TextureFactory.of( - TextureFactory.of(NAQUADAH_REACTOR_SOLID_FRONT), - TextureFactory.builder() - .addIcon(NAQUADAH_REACTOR_SOLID_FRONT_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getBack(byte aColor) { - return new ITexture[] { super.getBack(aColor)[0], - TextureFactory.of( - TextureFactory.of(NAQUADAH_REACTOR_SOLID_BACK), - TextureFactory.builder() - .addIcon(NAQUADAH_REACTOR_SOLID_BACK_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[] { super.getBottom(aColor)[0], - TextureFactory.of( - TextureFactory.of(NAQUADAH_REACTOR_SOLID_BOTTOM), - TextureFactory.builder() - .addIcon(NAQUADAH_REACTOR_SOLID_BOTTOM_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getTop(byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], - TextureFactory.of( - TextureFactory.of(NAQUADAH_REACTOR_SOLID_TOP), - TextureFactory.builder() - .addIcon(NAQUADAH_REACTOR_SOLID_TOP_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[] { super.getSides(aColor)[0], - TextureFactory.of( - TextureFactory.of(NAQUADAH_REACTOR_SOLID_SIDE), - TextureFactory.builder() - .addIcon(NAQUADAH_REACTOR_SOLID_SIDE_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], TextureFactory.of(NAQUADAH_REACTOR_SOLID_FRONT_ACTIVE), - TextureFactory.builder() - .addIcon(NAQUADAH_REACTOR_SOLID_FRONT_ACTIVE_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getBackActive(byte aColor) { - return new ITexture[] { super.getBackActive(aColor)[0], TextureFactory.of(NAQUADAH_REACTOR_SOLID_BACK_ACTIVE), - TextureFactory.builder() - .addIcon(NAQUADAH_REACTOR_SOLID_BACK_ACTIVE_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[] { super.getBottomActive(aColor)[0], - TextureFactory.of(NAQUADAH_REACTOR_SOLID_BOTTOM_ACTIVE), TextureFactory.builder() - .addIcon(NAQUADAH_REACTOR_SOLID_BOTTOM_ACTIVE_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getTopActive(byte aColor) { - return new ITexture[] { super.getTopActive(aColor)[0], TextureFactory.of(NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), - TextureFactory.builder() - .addIcon(NAQUADAH_REACTOR_SOLID_TOP_ACTIVE_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[] { super.getSidesActive(aColor)[0], TextureFactory.of(NAQUADAH_REACTOR_SOLID_SIDE_ACTIVE), - TextureFactory.builder() - .addIcon(NAQUADAH_REACTOR_SOLID_SIDE_ACTIVE_GLOW) - .glow() - .build() }; - } - - @Override - public int getPollution() { - return 0; - } -} diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_PlasmaGenerator.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_PlasmaGenerator.java deleted file mode 100644 index fa980ce480..0000000000 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_PlasmaGenerator.java +++ /dev/null @@ -1,142 +0,0 @@ -package gregtech.common.tileentities.generators; - -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; - -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.RecipeMaps; -import gregtech.api.render.TextureFactory; - -public class GT_MetaTileEntity_PlasmaGenerator extends GT_MetaTileEntity_BasicGenerator { - - public int mEfficiency; - - public GT_MetaTileEntity_PlasmaGenerator(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, "Plasma into energy"); - setEfficiency(); - } - - public GT_MetaTileEntity_PlasmaGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - setEfficiency(); - } - - public GT_MetaTileEntity_PlasmaGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - setEfficiency(); - } - - @Override - public ITexture[] getFront(byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS), - OVERLAYS_ENERGY_OUT[mTier] }; - } - - @Override - public ITexture[] getBack(byte aColor) { - return new ITexture[] { super.getBack(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS) }; - } - - @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[] { super.getBottom(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS) }; - } - - @Override - public ITexture[] getTop(byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS) }; - } - - @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[] { super.getSides(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS) }; - } - - @Override - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS_YELLOW), - TextureFactory.builder() - .addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) - .glow() - .build(), - OVERLAYS_ENERGY_OUT[mTier] }; - } - - @Override - public ITexture[] getBackActive(byte aColor) { - return new ITexture[] { super.getBackActive(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS_YELLOW), - TextureFactory.builder() - .addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[] { super.getBottomActive(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS_YELLOW), - TextureFactory.builder() - .addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getTopActive(byte aColor) { - return new ITexture[] { super.getTopActive(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS_YELLOW), - TextureFactory.builder() - .addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) - .glow() - .build() }; - } - - @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[] { super.getSidesActive(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS_YELLOW), - TextureFactory.builder() - .addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) - .glow() - .build() }; - } - - @Override - public boolean isOutputFacing(ForgeDirection side) { - return side == getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public RecipeMap getRecipeMap() { - return RecipeMaps.plasmaFuels; - } - - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public int getCapacity() { - return 16000; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_PlasmaGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } - - public void setEfficiency() { - this.mEfficiency = Math.max(10, 10 + Math.min(90, this.mTier * 10)); - } - - @Override - public int getPollution() { - return 0; - } -} diff --git a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SteamTurbine.java b/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SteamTurbine.java deleted file mode 100644 index 9c1b8db562..0000000000 --- a/src/main/java/gregtech/common/tileentities/generators/GT_MetaTileEntity_SteamTurbine.java +++ /dev/null @@ -1,238 +0,0 @@ -package gregtech.common.tileentities.generators; - -import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BACK; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BACK_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BACK_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BACK_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BOTTOM; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BOTTOM_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BOTTOM_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BOTTOM_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_FRONT; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_FRONT_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_FRONT_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_FRONT_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_SIDE; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_SIDE_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_SIDE_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_SIDE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_TOP; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_TOP_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_TOP_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_TOP_GLOW; - -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicGenerator; -import gregtech.api.recipe.RecipeMap; -import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_ModHandler; - -public class GT_MetaTileEntity_SteamTurbine extends GT_MetaTileEntity_BasicGenerator { - - public int mEfficiency; - - public GT_MetaTileEntity_SteamTurbine(int aID, String aName, String aNameRegional, int aTier) { - super( - aID, - aName, - aNameRegional, - aTier, - new String[] { "Converts Steam into EU", "Base rate: 2L of Steam -> 1 EU" }); - this.mEfficiency = 6 + this.mTier; - } - - public GT_MetaTileEntity_SteamTurbine(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.mEfficiency = 6 + this.mTier; - } - - public GT_MetaTileEntity_SteamTurbine(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aDescription, aTextures); - this.mEfficiency = 6 + this.mTier; - } - - @Override - public boolean isOutputFacing(ForgeDirection side) { - return side == getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_SteamTurbine(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } - - @Override - public RecipeMap getRecipeMap() { - return null; - } - - @Override - public String[] getDescription() { - String[] desc = new String[mDescriptionArray.length + 2]; - System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); - desc[mDescriptionArray.length] = "Fuel Efficiency: " + (600 / getEfficiency()) + "%"; - desc[mDescriptionArray.length + 1] = String.format( - "Consumes up to %sL of Steam per second", - (int) (4000 * (8 * Math.pow(4, mTier) + Math.pow(2, Math.max(mTier - 1, 0))) / (600 / getEfficiency()))); - return desc; - } - - @Override - public int getCapacity() { - return 24000 * this.mTier; - } - - @Override - public int getEfficiency() { - return this.mEfficiency; - } - - @Override - public long getFuelValue(FluidStack aLiquid, boolean aLong) { - return getFuelValue(aLiquid); - } - - @Override - public int getFuelValue(FluidStack aLiquid) { - if (aLiquid == null) return 0; - return GT_ModHandler.isAnySteam(aLiquid) ? 3 : 0; - } - - @Override - public int consumedFluidPerOperation(FluidStack aLiquid) { - return this.mEfficiency; - } - - @Override - public ITexture[] getFront(byte aColor) { - return new ITexture[] { super.getFront(aColor)[0], - TextureFactory.of( - TextureFactory.of(STEAM_TURBINE_FRONT), - TextureFactory.builder() - .addIcon(STEAM_TURBINE_FRONT_GLOW) - .glow() - .build()), - OVERLAYS_ENERGY_OUT[this.mTier] }; - } - - @Override - public ITexture[] getBack(byte aColor) { - return new ITexture[] { super.getBack(aColor)[0], - TextureFactory.of( - TextureFactory.of(STEAM_TURBINE_BACK), - TextureFactory.builder() - .addIcon(STEAM_TURBINE_BACK_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getBottom(byte aColor) { - return new ITexture[] { super.getBottom(aColor)[0], - TextureFactory.of( - TextureFactory.of(STEAM_TURBINE_BOTTOM), - TextureFactory.builder() - .addIcon(STEAM_TURBINE_BOTTOM_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getTop(byte aColor) { - return new ITexture[] { super.getTop(aColor)[0], - TextureFactory.of( - TextureFactory.of(STEAM_TURBINE_TOP), - TextureFactory.builder() - .addIcon(STEAM_TURBINE_TOP_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getSides(byte aColor) { - return new ITexture[] { super.getSides(aColor)[0], - TextureFactory.of( - TextureFactory.of(STEAM_TURBINE_SIDE), - TextureFactory.builder() - .addIcon(STEAM_TURBINE_SIDE_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getFrontActive(byte aColor) { - return new ITexture[] { super.getFrontActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(STEAM_TURBINE_FRONT_ACTIVE), - TextureFactory.builder() - .addIcon(STEAM_TURBINE_FRONT_ACTIVE_GLOW) - .glow() - .build()), - OVERLAYS_ENERGY_OUT[this.mTier] }; - } - - @Override - public ITexture[] getBackActive(byte aColor) { - return new ITexture[] { super.getBackActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(STEAM_TURBINE_BACK_ACTIVE), - TextureFactory.builder() - .addIcon(STEAM_TURBINE_BACK_ACTIVE_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getBottomActive(byte aColor) { - return new ITexture[] { super.getBottomActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(STEAM_TURBINE_BOTTOM_ACTIVE), - TextureFactory.builder() - .addIcon(STEAM_TURBINE_BOTTOM_ACTIVE_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getTopActive(byte aColor) { - return new ITexture[] { super.getTopActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(STEAM_TURBINE_TOP_ACTIVE), - TextureFactory.builder() - .addIcon(STEAM_TURBINE_TOP_ACTIVE_GLOW) - .glow() - .build()) }; - } - - @Override - public ITexture[] getSidesActive(byte aColor) { - return new ITexture[] { super.getSidesActive(aColor)[0], - TextureFactory.of( - TextureFactory.of(STEAM_TURBINE_SIDE_ACTIVE), - TextureFactory.builder() - .addIcon(STEAM_TURBINE_SIDE_ACTIVE_GLOW) - .glow() - .build()) }; - } - - @Override - public int getPollution() { - return 0; - } - - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - if (GT_ModHandler.isSuperHeatedSteam(aFluid)) { - aFluid.amount = 0; - aFluid = null; - return false; - } - return super.isFluidInputAllowed(aFluid); - } -} diff --git a/src/main/java/gregtech/common/tileentities/generators/MTEDieselGenerator.java b/src/main/java/gregtech/common/tileentities/generators/MTEDieselGenerator.java new file mode 100644 index 0000000000..b09e2c5e1d --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/generators/MTEDieselGenerator.java @@ -0,0 +1,278 @@ +package gregtech.common.tileentities.generators; + +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BACK; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BACK_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BACK_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_BOTTOM_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_FRONT; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_FRONT_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_FRONT_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_FRONT_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_SIDE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_SIDE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_TOP; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_TOP_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.DIESEL_GENERATOR_TOP_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GTMod; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.ParticleFX; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicGenerator; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTLog; +import gregtech.api.util.GTUtility; +import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; + +public class MTEDieselGenerator extends MTEBasicGenerator { + + public int mEfficiency; + + public MTEDieselGenerator(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + new String[] { "Requires liquid Fuel", + "Causes " + + (int) (GTMod.gregtechproxy.mPollutionBaseDieselGeneratorPerSecond + * GTMod.gregtechproxy.mPollutionDieselGeneratorReleasedByTier[aTier]) + + " Pollution per second" }); + onConfigLoad(); + } + + public MTEDieselGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } + + public MTEDieselGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEDieselGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.dieselFuels; + } + + @Override + public int getCapacity() { + return 16000; + } + + public void onConfigLoad() { + this.mEfficiency = (100 - this.mTier * 5); + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public int getFuelValue(ItemStack aStack) { + if (GTUtility.isStackInvalid(aStack) || getRecipeMap() == null) return 0; + long rValue = super.getFuelValue(aStack); + if (ItemList.Fuel_Can_Plastic_Filled.isStackEqual(aStack, false, true)) { + rValue = Math.max(rValue, GameRegistry.getFuelValue(aStack) * 3L); + } + if (rValue > Integer.MAX_VALUE) { + throw new ArithmeticException("Integer LOOPBACK!"); + } + return (int) rValue; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aTick % 100 == 0 && mFluid != null && mFluid.amount > this.getCapacity()) { + GTLog.err.println( + "Dupe Abuse: " + aBaseMetaTileEntity.getOwnerName() + + " Coords: " + + aBaseMetaTileEntity.getXCoord() + + " " + + aBaseMetaTileEntity.getYCoord() + + " " + + aBaseMetaTileEntity.getZCoord()); + aBaseMetaTileEntity.setToFire(); + } + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + /** + * Draws random smoke particles on top when active + * + * @param aBaseMetaTileEntity The entity that will handle the {@link Block#randomDisplayTick} + */ + @SideOnly(Side.CLIENT) + @Override + public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.isActive()) { + + if (aBaseMetaTileEntity.getCoverIDAtSide(ForgeDirection.UP) == 0 + && !aBaseMetaTileEntity.getOpacityAtSide(ForgeDirection.UP)) { + + final double x = aBaseMetaTileEntity.getOffsetX(ForgeDirection.UP, 1) + 2D / 16D + + XSTR_INSTANCE.nextFloat() * 14D / 16D; + final double y = aBaseMetaTileEntity.getOffsetY(ForgeDirection.UP, 1) + 1D / 32D; + final double z = aBaseMetaTileEntity.getOffsetZ(ForgeDirection.UP, 1) + 2D / 16D + + XSTR_INSTANCE.nextFloat() * 14D / 16D; + + new ParticleEventBuilder().setMotion(0D, 0D, 0D) + .setPosition(x, y, z) + .setWorld(getBaseMetaTileEntity().getWorld()) + .setIdentifier(ParticleFX.SMOKE) + .run(); + } + } + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], + TextureFactory.of( + TextureFactory.of(DIESEL_GENERATOR_FRONT), + TextureFactory.builder() + .addIcon(DIESEL_GENERATOR_FRONT_GLOW) + .glow() + .build()), + OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], + TextureFactory.of( + TextureFactory.of(DIESEL_GENERATOR_BACK), + TextureFactory.builder() + .addIcon(DIESEL_GENERATOR_BACK_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], + TextureFactory.of( + TextureFactory.of(DIESEL_GENERATOR_BOTTOM), + TextureFactory.builder() + .addIcon(DIESEL_GENERATOR_BOTTOM_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], + TextureFactory.of( + TextureFactory.of(DIESEL_GENERATOR_TOP), + TextureFactory.builder() + .addIcon(DIESEL_GENERATOR_TOP_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { super.getSides(aColor)[0], + TextureFactory.of( + TextureFactory.of(DIESEL_GENERATOR_SIDE), + TextureFactory.builder() + .addIcon(DIESEL_GENERATOR_SIDE_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(DIESEL_GENERATOR_FRONT_ACTIVE), + TextureFactory.builder() + .addIcon(DIESEL_GENERATOR_FRONT_ACTIVE_GLOW) + .glow() + .build()), + OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(DIESEL_GENERATOR_BACK_ACTIVE), + TextureFactory.builder() + .addIcon(DIESEL_GENERATOR_BACK_ACTIVE_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(DIESEL_GENERATOR_BOTTOM_ACTIVE), + TextureFactory.builder() + .addIcon(DIESEL_GENERATOR_BOTTOM_ACTIVE_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(DIESEL_GENERATOR_TOP_ACTIVE), + TextureFactory.builder() + .addIcon(DIESEL_GENERATOR_TOP_ACTIVE_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { super.getSidesActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(DIESEL_GENERATOR_SIDE_ACTIVE), + TextureFactory.builder() + .addIcon(DIESEL_GENERATOR_SIDE_ACTIVE_GLOW) + .glow() + .build()) }; + } + + @Override + public int getPollution() { + return (int) (GTMod.gregtechproxy.mPollutionBaseDieselGeneratorPerSecond + * GTMod.gregtechproxy.mPollutionDieselGeneratorReleasedByTier[mTier]); + } +} diff --git a/src/main/java/gregtech/common/tileentities/generators/MTEGasTurbine.java b/src/main/java/gregtech/common/tileentities/generators/MTEGasTurbine.java new file mode 100644 index 0000000000..47976da987 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/generators/MTEGasTurbine.java @@ -0,0 +1,201 @@ +package gregtech.common.tileentities.generators; + +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BACK; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BACK_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BACK_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BACK_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BOTTOM_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BOTTOM_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_BOTTOM_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_FRONT; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_FRONT_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_FRONT_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_FRONT_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_SIDE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_SIDE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_SIDE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_TOP; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_TOP_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_TOP_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.GAS_TURBINE_TOP_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; + +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.GTMod; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicGenerator; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; + +public class MTEGasTurbine extends MTEBasicGenerator { + + public int mEfficiency; + + public MTEGasTurbine(int aID, String aName, String aNameRegional, int aTier, int mEfficiency) { + super( + aID, + aName, + aNameRegional, + aTier, + new String[] { "Requires flammable Gasses", + "Causes " + + (int) (GTMod.gregtechproxy.mPollutionBaseGasTurbinePerSecond + * GTMod.gregtechproxy.mPollutionGasTurbineReleasedByTier[aTier]) + + " Pollution per second" }); + this.mEfficiency = mEfficiency; + } + + public MTEGasTurbine(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, int mEfficiency) { + super(aName, aTier, aDescription, aTextures); + this.mEfficiency = mEfficiency; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEGasTurbine(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mEfficiency); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.gasTurbineFuels; + } + + @Override + public int getCapacity() { + return 16000; + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], + TextureFactory.of( + TextureFactory.of(GAS_TURBINE_FRONT), + TextureFactory.builder() + .addIcon(GAS_TURBINE_FRONT_GLOW) + .glow() + .build()), + OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], + TextureFactory.of( + TextureFactory.of(GAS_TURBINE_BACK), + TextureFactory.builder() + .addIcon(GAS_TURBINE_BACK_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], + TextureFactory.of( + TextureFactory.of(GAS_TURBINE_BOTTOM), + TextureFactory.builder() + .addIcon(GAS_TURBINE_BOTTOM_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], + TextureFactory.of( + TextureFactory.of(GAS_TURBINE_TOP), + TextureFactory.builder() + .addIcon(GAS_TURBINE_TOP_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { super.getSides(aColor)[0], + TextureFactory.of( + TextureFactory.of(GAS_TURBINE_SIDE), + TextureFactory.builder() + .addIcon(GAS_TURBINE_SIDE_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(GAS_TURBINE_FRONT_ACTIVE), + TextureFactory.builder() + .addIcon(GAS_TURBINE_FRONT_ACTIVE_GLOW) + .glow() + .build()), + OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(GAS_TURBINE_BACK_ACTIVE), + TextureFactory.builder() + .addIcon(GAS_TURBINE_BACK_ACTIVE_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(GAS_TURBINE_BOTTOM_ACTIVE), + TextureFactory.builder() + .addIcon(GAS_TURBINE_BOTTOM_ACTIVE_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(GAS_TURBINE_TOP_ACTIVE), + TextureFactory.builder() + .addIcon(GAS_TURBINE_TOP_ACTIVE_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { super.getSidesActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(GAS_TURBINE_SIDE_ACTIVE), + TextureFactory.builder() + .addIcon(GAS_TURBINE_SIDE_ACTIVE_GLOW) + .glow() + .build()) }; + } + + @Override + public int getPollution() { + return (int) (GTMod.gregtechproxy.mPollutionBaseGasTurbinePerSecond + * GTMod.gregtechproxy.mPollutionGasTurbineReleasedByTier[mTier]); + } +} diff --git a/src/main/java/gregtech/common/tileentities/generators/MTELightningRod.java b/src/main/java/gregtech/common/tileentities/generators/MTELightningRod.java new file mode 100644 index 0000000000..ef04bf9d0b --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/generators/MTELightningRod.java @@ -0,0 +1,168 @@ +package gregtech.common.tileentities.generators; + +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; + +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTETieredMachineBlock; +import gregtech.api.render.TextureFactory; + +public class MTELightningRod extends MTETieredMachineBlock { + + public MTELightningRod(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 0, "Generates EU From Lightning Bolts"); + } + + public MTELightningRod(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + public MTELightningRod(String aName, int aTier, int aInvSlotCount, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aInvSlotCount, aDescription, aTextures); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + if (sideDirection != ForgeDirection.UP) { + return new ITexture[] { BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1], + BlockIcons.OVERLAYS_ENERGY_OUT_POWER[mTier] }; + } + if (!active) return new ITexture[] { BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1], + TextureFactory.of(BlockIcons.MACHINE_CASING_FUSION_GLASS) }; + return new ITexture[] { BlockIcons.MACHINE_CASINGS[mTier][colorIndex + 1], + TextureFactory.of(BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW), TextureFactory.builder() + .addIcon(BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTELightningRod( + this.mName, + this.mTier, + this.mInventory.length, + this.mDescriptionArray, + this.mTextures); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + World aWorld = aBaseMetaTileEntity.getWorld(); + if (!aWorld.isRemote) { + if (aBaseMetaTileEntity.getStoredEU() > 0) { + aBaseMetaTileEntity.setActive(true); + aBaseMetaTileEntity.decreaseStoredEnergyUnits(aBaseMetaTileEntity.getStoredEU() / 100 + 1, false); + } else { + aBaseMetaTileEntity.setActive(false); + } + + if (aTick % 256 == 0 && (aWorld.isThundering() || (aWorld.isRaining() && XSTR_INSTANCE.nextInt(10) == 0))) { + int aRodValue = 0; + boolean isRodValid = true; + int aX = aBaseMetaTileEntity.getXCoord(); + int aY = aBaseMetaTileEntity.getYCoord(); + int aZ = aBaseMetaTileEntity.getZCoord(); + + for (int i = aBaseMetaTileEntity.getYCoord() + 1; i < aWorld.getHeight() - 1; i++) { + if (isRodValid && aBaseMetaTileEntity.getBlock(aX, i, aZ) + .getUnlocalizedName() + .equals("blockFenceIron")) { + aRodValue++; + } else { + isRodValid = false; + if (aBaseMetaTileEntity.getBlock(aX, i, aZ) != Blocks.air) { + aRodValue = 0; + break; + } + } + } + if (!aWorld.isThundering() && ((aY + aRodValue) < 128)) aRodValue = 0; + if (XSTR_INSTANCE.nextInt(4 * aWorld.getHeight()) < (aRodValue * (aY + aRodValue))) { + aBaseMetaTileEntity + .increaseStoredEnergyUnits(maxEUStore() - aBaseMetaTileEntity.getStoredEU(), false); + aWorld.addWeatherEffect(new EntityLightningBolt(aWorld, aX, aY + aRodValue, aZ)); + // randomly break a rod + if (aWorld.isThundering()) { + aWorld.setBlockToAir(aX, aY + XSTR_INSTANCE.nextInt(aRodValue) + 1, aZ); + } + } + } + } + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return facing == ForgeDirection.UP; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public long maxEUStore() { + return 50000000; + } + + @Override + public long maxEUOutput() { + return GTValues.V[mTier]; + } + + @Override + public long maxAmperesOut() { + return 512; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) {} + + @Override + public void loadNBTData(NBTTagCompound aNBT) {} +} diff --git a/src/main/java/gregtech/common/tileentities/generators/MTEMagicEnergyConverter.java b/src/main/java/gregtech/common/tileentities/generators/MTEMagicEnergyConverter.java new file mode 100644 index 0000000000..c741cc4457 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/generators/MTEMagicEnergyConverter.java @@ -0,0 +1,167 @@ +package gregtech.common.tileentities.generators; + +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; + +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicGenerator; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; + +public class MTEMagicEnergyConverter extends MTEBasicGenerator { + + public int mEfficiency; + + public MTEMagicEnergyConverter(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Put your strange stuff in here"); + onConfigLoad(); + } + + public MTEMagicEnergyConverter(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } + + public MTEMagicEnergyConverter(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEMagicEnergyConverter(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.magicFuels; + } + + @Override + public int getCapacity() { + return 16000; + } + + public void onConfigLoad() { + this.mEfficiency = 100 - this.mTier * 5; + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_GLOW) + .glow() + .build(), + OVERLAYS_ENERGY_OUT[mTier] }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_FRONT), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_FRONT_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { super.getSides(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) + .glow() + .build(), + OVERLAYS_ENERGY_OUT[mTier] }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_FRONT_ACTIVE), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_FRONT_ACTIVE_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { super.getSidesActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) + .glow() + .build() }; + } + + @Override + public int getPollution() { + return 0; + } +} diff --git a/src/main/java/gregtech/common/tileentities/generators/MTEMagicalEnergyAbsorber.java b/src/main/java/gregtech/common/tileentities/generators/MTEMagicalEnergyAbsorber.java new file mode 100644 index 0000000000..c49102ad61 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/generators/MTEMagicalEnergyAbsorber.java @@ -0,0 +1,803 @@ +package gregtech.common.tileentities.generators; + +import static gregtech.api.enums.GTValues.V; +import static gregtech.api.enums.Mods.Thaumcraft; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_DRAGONEGG; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_DRAGONEGG_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_FRONT_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_MAGIC_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; +import static net.minecraft.util.EnumChatFormatting.GRAY; +import static net.minecraft.util.EnumChatFormatting.GREEN; +import static net.minecraft.util.EnumChatFormatting.LIGHT_PURPLE; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.UNDERLINE; +import static net.minecraft.util.EnumChatFormatting.YELLOW; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockDragonEgg; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemEnchantedBook; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.util.ForgeDirection; + +import com.google.common.base.Enums; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.ParticleFX; +import gregtech.api.enums.TCAspects; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicGenerator; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTLog; +import gregtech.api.util.GTUtility; +import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; +import gregtech.common.config.machinestats.ConfigMachines; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.aspects.AspectSourceHelper; +import thaumcraft.api.aspects.IAspectContainer; +import thaumcraft.api.visnet.VisNetHandler; + +interface MagicalEnergyBBListener { + + void onMagicalEnergyBBUpdate(); +} + +public class MTEMagicalEnergyAbsorber extends MTEBasicGenerator implements MagicalEnergyBBListener { + + private static final ConcurrentHashMap sSubscribedCrystals = new ConcurrentHashMap<>( + 4); + private static final List sPrimalAspects = (Thaumcraft.isModLoaded()) ? Aspect.getPrimalAspects() + : new ArrayList<>(); + private static final Map sAspectsEnergy = new HashMap<>(); + private static boolean sAllowMultipleEggs = false; + private static MTEMagicalEnergyAbsorber sActiveSiphon = null; + private static int sEnergyPerEndercrystal = 512; + private static int sEnergyFromVis = 20; + private static int sEnergyPerEssentia = 320; + private static int sDragonEggEnergyPerTick = 2048; + private static int sCreeperEggEnergyPerTick = 512; + private final MagicalEnergyBB mMagicalEnergyBB = new MagicalEnergyBB(this, mTier, mTier + 2); + private int mEfficiency; + private int mMaxVisPerDrain; + private long mNextGenerateTickRate = 1; + private int mNoGenerationTicks = 0; + private boolean mUsingEssentia = true; + + public MTEMagicalEnergyAbsorber(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Feasts on magic close to it:"); + onConfigLoad(); + } + + private MTEMagicalEnergyAbsorber(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + onConfigLoad(); + } + + /** + * Populates static variables dependant on config settings + */ + private static void sharedConfigLoad() { + sAllowMultipleEggs = ConfigMachines.allowMultipleEggs; + if (Thaumcraft.isModLoaded()) { + for (Aspect tAspect : Aspect.aspects.values()) { + // noinspection UnstableApiUsage + sAspectsEnergy.put( + tAspect, + Enums.getIfPresent( + TCAspects.class, + tAspect.getTag() + .toUpperCase(Locale.ENGLISH)) + .or(TCAspects.AER).mValue * sEnergyPerEssentia); + } + } + } + + private static void setActiveSiphon(MTEMagicalEnergyAbsorber aSiphon) { + sActiveSiphon = aSiphon; + } + + public void onConfigLoad() { + sharedConfigLoad(); + mEfficiency = 100 - mTier * 10; + mMaxVisPerDrain = (int) Math.round(Math.sqrt((double) (V[mTier] * 10000) / (sEnergyFromVis * getEfficiency()))); + if (Math.pow(mMaxVisPerDrain, 2) * sEnergyFromVis * getEfficiency() < V[mTier]) { + mMaxVisPerDrain += 1; + } + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) mMagicalEnergyBB.decreaseTier(); + else mMagicalEnergyBB.increaseTier(); + GTUtility.sendChatToPlayer( + aPlayer, + String.format( + GTLanguageManager.addStringLocalization( + "Interaction_DESCRIPTION_MagicalEnergyAbsorber_Screwdriver", + "Absorption range: %s blocks"), + mMagicalEnergyBB.getRange(), + true)); + mMagicalEnergyBB.update(); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + if (!aBaseMetaTileEntity.isServerSide()) return; + mMagicalEnergyBB.update(); + } + + @Override + public void onRemoval() { + super.onRemoval(); + releaseEgg(); + unsubscribeCrystals(); + } + + private void releaseEgg() { + if (sActiveSiphon == this) { + setActiveSiphon(null); + } + } + + private void unsubscribeCrystals() { + for (UUID tCrystalID : sSubscribedCrystals.keySet()) { + sSubscribedCrystals.remove(tCrystalID, this); + } + } + + /** + * Call-back from the Bounding Box when its content is updated + */ + @Override + public void onMagicalEnergyBBUpdate() { + List tCrystalIDsInRange = mMagicalEnergyBB.getLivingCrystalIDs(); + // Release unreachable Crystals subscriptions + for (UUID tSubscribedCrystalID : sSubscribedCrystals.keySet()) { + if (!tCrystalIDsInRange.contains(tSubscribedCrystalID)) { + sSubscribedCrystals.remove(tSubscribedCrystalID, this); + } + } + // Subscribe to available and not already subscribed Crystals + for (UUID tCrystalID : tCrystalIDsInRange) { + sSubscribedCrystals.putIfAbsent(tCrystalID, this); + } + } + + @Override + public String[] getDescription() { + final String LI = "- %%%"; + final String EU_PER = "%%%EU per "; + List description = new ArrayList<>(); + description + .add(UNDERLINE + "Feasts on " + LIGHT_PURPLE + UNDERLINE + "magic" + GRAY + UNDERLINE + " close to it:"); + description.add( + LI + (sAllowMultipleEggs ? "A " : "An " + YELLOW + UNDERLINE + "EXCLUSIVE" + RESET) + + GRAY + + " " + + LIGHT_PURPLE + + "Dragon Egg" + + GRAY + + " atop"); + if (sEnergyPerEndercrystal > 0) { + description.add(LI + sEnergyPerEndercrystal + EU_PER + LIGHT_PURPLE + "Ender Crystal" + GRAY + " in range"); + } + if (Thaumcraft.isModLoaded()) { + description.add(LI + mMaxVisPerDrain + "%%%CV/t from an " + LIGHT_PURPLE + "Energised Node" + GRAY); + description.add( + LI + (sEnergyPerEssentia * getEfficiency()) / 100 + + EU_PER + + LIGHT_PURPLE + + "Essentia" + + GRAY + + " Aspect-Value from containers in range"); + } + description.add(" "); + description.add(UNDERLINE + "Lookup range (Use Screwdriver to change):"); + description.add("Default: %%%" + GREEN + mMagicalEnergyBB.getDefaultRange()); + description.add("Max: %%%" + GREEN + mMagicalEnergyBB.getMaxRange()); + description.add(" "); + description + .add(UNDERLINE + "Fuels on " + LIGHT_PURPLE + UNDERLINE + "enchantments" + GRAY + UNDERLINE + " input:"); + description.add( + "- Item: %%%" + (10000 * getEfficiency()) / 100 + + EU_PER + + LIGHT_PURPLE + + "enchant" + + GRAY + + " weight × level / max"); + description.add("- Book: %%%" + 10000 + EU_PER + LIGHT_PURPLE + "enchant" + GRAY + " weight × level / max"); + description.add(" "); + description.add("Efficiency: %%%" + GREEN + getEfficiency() + "%"); + return description.toArray(new String[0]); + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_GLOW) + .glow() + .build(), + OVERLAYS_ENERGY_OUT[mTier] }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_FRONT), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_FRONT_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], TextureFactory.of(MACHINE_CASING_DRAGONEGG) }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { super.getSides(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) + .glow() + .build(), + OVERLAYS_ENERGY_OUT[mTier] }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_FRONT_ACTIVE), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_FRONT_ACTIVE_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], TextureFactory.of(MACHINE_CASING_DRAGONEGG), + TextureFactory.builder() + .addIcon(MACHINE_CASING_DRAGONEGG_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { super.getSidesActive(aColor)[0], TextureFactory.of(MACHINE_CASING_MAGIC_ACTIVE), + TextureFactory.builder() + .addIcon(MACHINE_CASING_MAGIC_ACTIVE_GLOW) + .glow() + .build() }; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public long maxEUStore() { + return Math.max(getEUVar(), V[mTier] * 16000 + getMinimumStoredEU()); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (!aBaseMetaTileEntity.isServerSide()) return; + if (!aBaseMetaTileEntity.isAllowedToWork()) return; + if ((aBaseMetaTileEntity.getUniversalEnergyStored() >= aBaseMetaTileEntity.getEUCapacity())) return; + + long tGeneratedEU; + + if (aTick % 100 == 0 && mUsingEssentia) mMagicalEnergyBB.update(); + + // Adaptive EU Generation Ticking + if (aTick % mNextGenerateTickRate == 0) { + tGeneratedEU = generateEU(); + if (tGeneratedEU > 0) { + mNoGenerationTicks = 0; + if (tGeneratedEU >= 2 * V[mTier]) + mNextGenerateTickRate = (long) (1.0D / ((2.0D * (double) (V[mTier])) / (double) tGeneratedEU)); + else mNextGenerateTickRate = 1; + mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); + mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + tGeneratedEU + " EU"); + } else { + mInventory[getStackDisplaySlot()] = null; + mNoGenerationTicks += 1; + } + if (mNoGenerationTicks > 20) { + mNoGenerationTicks = 0; + mNextGenerateTickRate = 20; + } + aBaseMetaTileEntity.increaseStoredEnergyUnits(tGeneratedEU, true); + aBaseMetaTileEntity.setActive( + aBaseMetaTileEntity.isAllowedToWork() + && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); + } + } + + /** + * Draws random portal particles on top when active with an egg on top + * + * @param aBaseMetaTileEntity The entity that will handle the {@link Block#randomDisplayTick} + */ + @SideOnly(Side.CLIENT) + @Override + public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { + + if (aBaseMetaTileEntity.isActive()) { + + if (isEgg(aBaseMetaTileEntity.getBlockAtSide(ForgeDirection.UP))) { + + final double oX = aBaseMetaTileEntity.getXCoord() + 8D / 16D; + final double oY = aBaseMetaTileEntity.getYCoord() + 17D / 32D; + final double oZ = aBaseMetaTileEntity.getZCoord() + 8D / 16D; + + final ParticleEventBuilder particleEventBuilder = new ParticleEventBuilder() + .setWorld(getBaseMetaTileEntity().getWorld()) + .setIdentifier(ParticleFX.PORTAL); + + for (int i = 0; i < 9; i++) { + final double dX = (XSTR_INSTANCE.nextFloat() - 0.5D) / 2D; + final double dY = XSTR_INSTANCE.nextFloat() * 1.5; + final double dZ = (XSTR_INSTANCE.nextFloat() - 0.5D) / 2D; + + final double x = oX + dX; + final double y = oY + dY; + final double z = oZ + dZ; + + final double mX = dX * 4D; + final double dXZ = Math.sqrt(dX * dX + dZ * dZ); + final double mY = -(dXZ * dY) / 4D; + final double mZ = dZ * 4D; + + particleEventBuilder.setMotion(mX, mY, mZ) + .setPosition(x, y, z) + .run(); + } + } + } + } + + @Override + public int getPollution() { + return 0; + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.magicFuels; + } + + @Override + public int getEfficiency() { + return mEfficiency; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + // Restrict input to disenchantable items or enchanted books + return (isDisenchantableItem(aStack) || isEnchantedBook(aStack)); + } + + @Override + public int getCapacity() { + return 16000; + } + + private boolean isDisenchantableItem(ItemStack aStack) { + return ((aStack.isItemEnchanted()) && (aStack.getItem() + .getItemEnchantability() > 0)); + } + + private boolean isEnchantedBook(ItemStack aStack) { + return (aStack.getItem() instanceof ItemEnchantedBook); + } + + private long generateEU() { + long tEU; + + mUsingEssentia = false; + if ((tEU = absorbFromEgg()) > 0) return tEU; + if ((tEU = absorbFromEnderCrystals()) > 0) return tEU; + if ((tEU = absorbFromEnchantedItems()) > 0) return tEU; + if ((tEU = absorbFromVisNet()) > 0) return tEU; + mUsingEssentia = true; + if ((tEU = absorbFromEssentiaContainers()) > 0) return tEU; + return 0; + } + + private long absorbFromEnchantedItems() { + ItemStack tStack = getBaseMetaTileEntity().getStackInSlot(getInputSlot()); + if (tStack == null) return 0; + if (tStack.stackSize == 0) return 0; + if (!(isDisenchantableItem(tStack) || isEnchantedBook(tStack))) return 0; + long tEU = 0; + // Convert enchantments to their EU Value + Map tMap = EnchantmentHelper.getEnchantments(tStack); + for (Map.Entry e : tMap.entrySet()) { + if ((Integer) e.getKey() < Enchantment.enchantmentsList.length) { + Enchantment tEnchantment = Enchantment.enchantmentsList[(Integer) e.getKey()]; + Integer tLevel = (Integer) e.getValue(); + tEU += 1000000L * tLevel / tEnchantment.getMaxLevel() / tEnchantment.getWeight(); + } + } + + ItemStack tOutputStack = GTUtility.copyAmount(1, tStack); + if (tOutputStack != null) { + if (isDisenchantableItem(tOutputStack)) { + tEU = tEU * getEfficiency() / 100; + EnchantmentHelper.setEnchantments(new HashMap<>(), tOutputStack); + } else if (isEnchantedBook(tOutputStack)) { + tOutputStack = new ItemStack(Items.book, 1); + } + } + + // Only consume input when it can store EU and push output + if ((getBaseMetaTileEntity().getStoredEU() + tEU) < getBaseMetaTileEntity().getEUCapacity() + && getBaseMetaTileEntity().addStackToSlot(getOutputSlot(), tOutputStack)) { + decrStackSize(getInputSlot(), 1); + } else { + tEU = 0; + } + return tEU; + } + + private boolean hasEgg() { + Block above = getBaseMetaTileEntity().getBlockOffset(0, 1, 0); + return isEgg(above); + } + + private long absorbFromEgg() { + if (!hasEgg()) return 0; + if (!sAllowMultipleEggs) { + if (sActiveSiphon != null && sActiveSiphon != this + && sActiveSiphon.getBaseMetaTileEntity() != null + && !sActiveSiphon.getBaseMetaTileEntity() + .isInvalidTileEntity() + && sActiveSiphon.isChunkLoaded() + && sActiveSiphon.hasEgg()) { + getBaseMetaTileEntity().doExplosion(Integer.MAX_VALUE); + } else { + setActiveSiphon(this); + } + } + Block egg = getBaseMetaTileEntity().getBlockOffset(0, 1, 0); + if (egg == Blocks.dragon_egg) { + return sDragonEggEnergyPerTick; + } else if (egg.getUnlocalizedName() + .contains("creeperEgg")) { + return sCreeperEggEnergyPerTick; + } + return 0; + } + + private long absorbFromEnderCrystals() { + if (sEnergyPerEndercrystal <= 0) return 0; + long tEU = 0; + for (MTEMagicalEnergyAbsorber tSubscriber : sSubscribedCrystals.values()) { + if (tSubscriber == this) { // This Crystal is for me + tEU += sEnergyPerEndercrystal; + } + } + return tEU; + } + + private long absorbFromVisNet() { + if (!Thaumcraft.isModLoaded()) return 0; + + long tEU; + IGregTechTileEntity tBaseMetaTileEntity = getBaseMetaTileEntity(); + World tWorld = tBaseMetaTileEntity.getWorld(); + int tX = tBaseMetaTileEntity.getXCoord(); + int tY = tBaseMetaTileEntity.getYCoord(); + int tZ = tBaseMetaTileEntity.getZCoord(); + + // Attempt to drain as much Vis as needed for max EU/t, from all primal aspects. + int toDrain = mMaxVisPerDrain; + + for (int i = sPrimalAspects.size() - 1; i >= 0 && toDrain > 0; i--) { + toDrain -= VisNetHandler.drainVis(tWorld, tX, tY, tZ, sPrimalAspects.get(i), toDrain); + } + + int drained = mMaxVisPerDrain - toDrain; + tEU = (long) Math.min(maxEUOutput(), (Math.pow(drained, 2) * sEnergyFromVis * getEfficiency() / 10000)); + + return tEU; + } + + private long absorbFromEssentiaContainers() { + if (!Thaumcraft.isModLoaded()) return 0; + + long tEU = 0; + + long tEUtoGen = getBaseMetaTileEntity().getEUCapacity() - getBaseMetaTileEntity().getUniversalEnergyStored(); + List mAvailableEssentiaAspects = mMagicalEnergyBB.getAvailableAspects(); + + // try to drain 1 of whatever aspect available in containers within RANGE + for (int i = mAvailableEssentiaAspects.size() - 1; i >= 0 && tEUtoGen > 0; i--) { + Aspect aspect = mAvailableEssentiaAspects.get(i); + long tAspectEU = ((long) sAspectsEnergy.get(aspect) * getEfficiency()) / 100; + if (tAspectEU <= tEUtoGen && AspectSourceHelper.drainEssentia( + (TileEntity) getBaseMetaTileEntity(), + aspect, + ForgeDirection.UNKNOWN, + mMagicalEnergyBB.getRange())) { + tEUtoGen -= tAspectEU; + tEU += tAspectEU; + } + } + return tEU; + } + + private boolean isEgg(Block aBlock) { + if (aBlock == null) return false; + if (aBlock == Blocks.air) return false; + if (aBlock == Blocks.dragon_egg) return true; + if (aBlock instanceof BlockDragonEgg) return true; + return (aBlock.getUnlocalizedName() + .equals("tile.dragonEgg")); + } + + private boolean isChunkLoaded() { + IGregTechTileEntity tBaseMetaTileEntity = getBaseMetaTileEntity(); + int tX = tBaseMetaTileEntity.getXCoord(); + int tY = tBaseMetaTileEntity.getYCoord(); + World tWorld = tBaseMetaTileEntity.getWorld(); + Chunk tChunk = tWorld.getChunkFromBlockCoords(tX, tY); + return tChunk.isChunkLoaded; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEMagicalEnergyAbsorber(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mMagicalEnergyBBTier", mMagicalEnergyBB.getTier()); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mMagicalEnergyBB.setTier(aNBT.getInteger("mMagicalEnergyBBTier")); + } + + /** + * Handles Bounding Box ranged operations for Magic sources + */ + static class MagicalEnergyBB { + + private final MTEMagicalEnergyAbsorber mAbsorber; + private final MagicalEnergyBBListener mListener; + private final int mDefaultTier; + private int mTier; + private final int mMaxTier; + private final List mLivingCrystalIDs = new ArrayList<>(); + private List mAvailableAspects; + + /** + * @param aAbsorber user and subscriber for updated BB content + * @param aDefaultTier Initial tier value + * @param aMaxTier Maximum allowed tier + */ + MagicalEnergyBB(MTEMagicalEnergyAbsorber aAbsorber, int aDefaultTier, int aMaxTier) { + mAbsorber = aAbsorber; + mListener = aAbsorber; + mMaxTier = Math.max(Math.max(aMaxTier, 0), Math.max(aDefaultTier, 0)); + mDefaultTier = Math.min(aDefaultTier, mMaxTier); + mTier = mDefaultTier; + if (Thaumcraft.isModLoaded()) mAvailableAspects = new ArrayList<>(Aspect.aspects.size()); + } + + int getTier() { + return mTier; + } + + /** + * Set Bounding Box Tier within allowed bounds + * + * @param aTier new tier value + * @return effective new tier + */ + int setTier(int aTier) { + if (aTier >= 0) { + mTier = Math.min(aTier, mMaxTier); + } else { + mTier = 0; + } + return mTier; + } + + int getRange() { + return getRange(mTier); + } + + int getRange(int aTier) { + return 1 << aTier; + } + + int getDefaultTier() { + return mDefaultTier; + } + + int getDefaultRange() { + return getRange(getDefaultTier()); + } + + int getMaxTier() { + return mMaxTier; + } + + int getMaxRange() { + return getRange(getMaxTier()); + } + + private AxisAlignedBB getAxisAlignedBB() { + double tRange = getRange(); + IGregTechTileEntity tBaseMetaTileEntity = mAbsorber.getBaseMetaTileEntity(); + double tX = tBaseMetaTileEntity.getXCoord(); + double tY = tBaseMetaTileEntity.getYCoord(); + double tZ = tBaseMetaTileEntity.getZCoord(); + return AxisAlignedBB + .getBoundingBox(tX - tRange, tY - tRange, tZ - tRange, tX + tRange, tY + tRange, tZ + tRange); + } + + private void scanLivingCrystals() { + World tWorld = mAbsorber.getBaseMetaTileEntity() + .getWorld(); + mLivingCrystalIDs.clear(); + for (EntityEnderCrystal o : tWorld.getEntitiesWithinAABB(EntityEnderCrystal.class, getAxisAlignedBB())) { + if (o.isEntityAlive()) { + mLivingCrystalIDs.add(o.getPersistentID()); + } + } + } + + private void scanAvailableAspects() { + if (!Thaumcraft.isModLoaded()) return; + IGregTechTileEntity tBaseMetaTileEntity = mAbsorber.getBaseMetaTileEntity(); + if (tBaseMetaTileEntity.isInvalidTileEntity()) return; + int tRange = getRange(); + int tY = tBaseMetaTileEntity.getYCoord(); + int tMaxY = tBaseMetaTileEntity.getWorld() + .getHeight() - 1; + // Make sure relative Y range stays between 0 and world max Y + int rYMin = (tY - tRange >= 0) ? -tRange : -(tY); + int rYMax = (((tY + tRange) <= tMaxY) ? tRange : tMaxY - tY); + mAvailableAspects.clear(); + for (int rX = -tRange; rX <= tRange; rX++) { + for (int rZ = -tRange; rZ <= tRange; rZ++) { + // rY < rYMax is not a bug. See: thaumcraft.common.lib.events.EssentiaHandler.getSources() + for (int rY = rYMin; rY < rYMax; rY++) { + TileEntity tTile = tBaseMetaTileEntity.getTileEntityOffset(rX, rY, rZ); + if (tTile instanceof IAspectContainer) { + AspectList tAspectList = ((IAspectContainer) tTile).getAspects(); + if (tAspectList == null || tAspectList.aspects.isEmpty()) continue; + Set tAspects = tAspectList.aspects.keySet(); + mAvailableAspects.addAll(tAspects); + } + } + } + } + } + + /** + * @return List of Living Ender Crystal Entity IDs in range + */ + List getLivingCrystalIDs() { + return mLivingCrystalIDs; + } + + /** + * @return List of drainable Essentia Aspects from containers in range + */ + List getAvailableAspects() { + return mAvailableAspects; + } + + /** + * Scan range for magic sources + */ + void update() { + if (mAbsorber == null) return; + if (mAbsorber.getBaseMetaTileEntity() == null) return; + if (mAbsorber.getBaseMetaTileEntity() + .isInvalidTileEntity()) return; + if (mAbsorber.getBaseMetaTileEntity() + .getWorld() == null) return; + scanLivingCrystals(); + scanAvailableAspects(); + if (mListener != null) { + mListener.onMagicalEnergyBBUpdate(); + } + } + + void increaseTier() { + offsetTier(1); + } + + void decreaseTier() { + offsetTier(-1); + } + + /** + * Change the Bounding Box tier relatively to offset with wrapping at tier limits + * + * @param aOffset relative tier change + */ + void offsetTier(int aOffset) { + int tNumTiers = mMaxTier + 1; + int tTier = (mTier + aOffset + tNumTiers) % tNumTiers; + int tTrueTier = setTier(tTier); + if (tTier != tTrueTier) { + GTLog.out.format("Absorber's BB Tier set to %d was capped to %d", tTier, tTrueTier); + } + } + } +} diff --git a/src/main/java/gregtech/common/tileentities/generators/MTENaquadahReactor.java b/src/main/java/gregtech/common/tileentities/generators/MTENaquadahReactor.java new file mode 100644 index 0000000000..276fdff07c --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/generators/MTENaquadahReactor.java @@ -0,0 +1,200 @@ +package gregtech.common.tileentities.generators; + +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BACK; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BACK_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BACK_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BACK_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BOTTOM_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BOTTOM_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_BOTTOM_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_FRONT_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_SIDE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_SIDE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_SIDE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.NAQUADAH_REACTOR_SOLID_TOP_GLOW; + +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicGenerator; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; + +public class MTENaquadahReactor extends MTEBasicGenerator { + + private int mEfficiency; + + public MTENaquadahReactor(int aID, String aName, String[] aDescription, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, aDescription); + if (aTier > 8 || aTier < 4) { + new Exception("Tier without Recipe Map!").printStackTrace(); + } + mEfficiency = getBaseEff(); + } + + public MTENaquadahReactor(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + if (aTier > 8 || aTier < 4) { + new Exception("Tier without Recipe Map!").printStackTrace(); + } + mEfficiency = getBaseEff(); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + if (side == ForgeDirection.UNKNOWN) return false; + return ((side.flag & (ForgeDirection.UP.flag | ForgeDirection.DOWN.flag)) == 0) + && (side != getBaseMetaTileEntity().getFrontFacing()) + && (side != getBaseMetaTileEntity().getBackFacing()); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTENaquadahReactor(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public RecipeMap getRecipeMap() { + RecipeMap ret; + switch (mTier) { + case 4 -> ret = RecipeMaps.smallNaquadahReactorFuels; + case 5 -> ret = RecipeMaps.largeNaquadahReactorFuels; + case 6 -> ret = RecipeMaps.hugeNaquadahReactorFuels; + case 7 -> ret = RecipeMaps.extremeNaquadahReactorFuels; + case 8 -> ret = RecipeMaps.ultraHugeNaquadahReactorFuels; + default -> ret = null; + } + return ret; + } + + @Override + public int getCapacity() { + return getRecipeMap() != null ? getRecipeMap().getBackend() + .getProperties().minFluidInputs > 0 ? 8000 * (mTier + 1) : 0 : 0; + } + + @Override + public int getEfficiency() { + return mEfficiency; + } + + private int getBaseEff() { + return mTier == 4 ? 80 : 100 + (50 * (mTier - 5)); + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], + TextureFactory.of( + TextureFactory.of(NAQUADAH_REACTOR_SOLID_FRONT), + TextureFactory.builder() + .addIcon(NAQUADAH_REACTOR_SOLID_FRONT_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], + TextureFactory.of( + TextureFactory.of(NAQUADAH_REACTOR_SOLID_BACK), + TextureFactory.builder() + .addIcon(NAQUADAH_REACTOR_SOLID_BACK_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], + TextureFactory.of( + TextureFactory.of(NAQUADAH_REACTOR_SOLID_BOTTOM), + TextureFactory.builder() + .addIcon(NAQUADAH_REACTOR_SOLID_BOTTOM_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], + TextureFactory.of( + TextureFactory.of(NAQUADAH_REACTOR_SOLID_TOP), + TextureFactory.builder() + .addIcon(NAQUADAH_REACTOR_SOLID_TOP_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { super.getSides(aColor)[0], + TextureFactory.of( + TextureFactory.of(NAQUADAH_REACTOR_SOLID_SIDE), + TextureFactory.builder() + .addIcon(NAQUADAH_REACTOR_SOLID_SIDE_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], TextureFactory.of(NAQUADAH_REACTOR_SOLID_FRONT_ACTIVE), + TextureFactory.builder() + .addIcon(NAQUADAH_REACTOR_SOLID_FRONT_ACTIVE_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], TextureFactory.of(NAQUADAH_REACTOR_SOLID_BACK_ACTIVE), + TextureFactory.builder() + .addIcon(NAQUADAH_REACTOR_SOLID_BACK_ACTIVE_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], + TextureFactory.of(NAQUADAH_REACTOR_SOLID_BOTTOM_ACTIVE), TextureFactory.builder() + .addIcon(NAQUADAH_REACTOR_SOLID_BOTTOM_ACTIVE_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], TextureFactory.of(NAQUADAH_REACTOR_SOLID_TOP_ACTIVE), + TextureFactory.builder() + .addIcon(NAQUADAH_REACTOR_SOLID_TOP_ACTIVE_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { super.getSidesActive(aColor)[0], TextureFactory.of(NAQUADAH_REACTOR_SOLID_SIDE_ACTIVE), + TextureFactory.builder() + .addIcon(NAQUADAH_REACTOR_SOLID_SIDE_ACTIVE_GLOW) + .glow() + .build() }; + } + + @Override + public int getPollution() { + return 0; + } +} diff --git a/src/main/java/gregtech/common/tileentities/generators/MTEPlasmaGenerator.java b/src/main/java/gregtech/common/tileentities/generators/MTEPlasmaGenerator.java new file mode 100644 index 0000000000..2b8dafcbdf --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/generators/MTEPlasmaGenerator.java @@ -0,0 +1,142 @@ +package gregtech.common.tileentities.generators; + +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; + +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicGenerator; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; + +public class MTEPlasmaGenerator extends MTEBasicGenerator { + + public int mEfficiency; + + public MTEPlasmaGenerator(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, "Plasma into energy"); + setEfficiency(); + } + + public MTEPlasmaGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + setEfficiency(); + } + + public MTEPlasmaGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + setEfficiency(); + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS), + OVERLAYS_ENERGY_OUT[mTier] }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS) }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS) }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS) }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { super.getSides(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS) }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS_YELLOW), + TextureFactory.builder() + .addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) + .glow() + .build(), + OVERLAYS_ENERGY_OUT[mTier] }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS_YELLOW), + TextureFactory.builder() + .addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS_YELLOW), + TextureFactory.builder() + .addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS_YELLOW), + TextureFactory.builder() + .addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) + .glow() + .build() }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { super.getSidesActive(aColor)[0], TextureFactory.of(MACHINE_CASING_FUSION_GLASS_YELLOW), + TextureFactory.builder() + .addIcon(MACHINE_CASING_FUSION_GLASS_YELLOW_GLOW) + .glow() + .build() }; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public RecipeMap getRecipeMap() { + return RecipeMaps.plasmaFuels; + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public int getCapacity() { + return 16000; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEPlasmaGenerator(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + public void setEfficiency() { + this.mEfficiency = Math.max(10, 10 + Math.min(90, this.mTier * 10)); + } + + @Override + public int getPollution() { + return 0; + } +} diff --git a/src/main/java/gregtech/common/tileentities/generators/MTESteamTurbine.java b/src/main/java/gregtech/common/tileentities/generators/MTESteamTurbine.java new file mode 100644 index 0000000000..bb6138d35a --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/generators/MTESteamTurbine.java @@ -0,0 +1,238 @@ +package gregtech.common.tileentities.generators; + +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BACK; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BACK_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BACK_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BACK_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BOTTOM_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BOTTOM_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_BOTTOM_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_FRONT; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_FRONT_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_FRONT_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_FRONT_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_SIDE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_SIDE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_SIDE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_TOP; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_TOP_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_TOP_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.STEAM_TURBINE_TOP_GLOW; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicGenerator; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTModHandler; + +public class MTESteamTurbine extends MTEBasicGenerator { + + public int mEfficiency; + + public MTESteamTurbine(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + new String[] { "Converts Steam into EU", "Base rate: 2L of Steam -> 1 EU" }); + this.mEfficiency = 6 + this.mTier; + } + + public MTESteamTurbine(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.mEfficiency = 6 + this.mTier; + } + + public MTESteamTurbine(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + this.mEfficiency = 6 + this.mTier; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTESteamTurbine(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public RecipeMap getRecipeMap() { + return null; + } + + @Override + public String[] getDescription() { + String[] desc = new String[mDescriptionArray.length + 2]; + System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); + desc[mDescriptionArray.length] = "Fuel Efficiency: " + (600 / getEfficiency()) + "%"; + desc[mDescriptionArray.length + 1] = String.format( + "Consumes up to %sL of Steam per second", + (int) (4000 * (8 * Math.pow(4, mTier) + Math.pow(2, Math.max(mTier - 1, 0))) / (600 / getEfficiency()))); + return desc; + } + + @Override + public int getCapacity() { + return 24000 * this.mTier; + } + + @Override + public int getEfficiency() { + return this.mEfficiency; + } + + @Override + public long getFuelValue(FluidStack aLiquid, boolean aLong) { + return getFuelValue(aLiquid); + } + + @Override + public int getFuelValue(FluidStack aLiquid) { + if (aLiquid == null) return 0; + return GTModHandler.isAnySteam(aLiquid) ? 3 : 0; + } + + @Override + public int consumedFluidPerOperation(FluidStack aLiquid) { + return this.mEfficiency; + } + + @Override + public ITexture[] getFront(byte aColor) { + return new ITexture[] { super.getFront(aColor)[0], + TextureFactory.of( + TextureFactory.of(STEAM_TURBINE_FRONT), + TextureFactory.builder() + .addIcon(STEAM_TURBINE_FRONT_GLOW) + .glow() + .build()), + OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBack(byte aColor) { + return new ITexture[] { super.getBack(aColor)[0], + TextureFactory.of( + TextureFactory.of(STEAM_TURBINE_BACK), + TextureFactory.builder() + .addIcon(STEAM_TURBINE_BACK_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getBottom(byte aColor) { + return new ITexture[] { super.getBottom(aColor)[0], + TextureFactory.of( + TextureFactory.of(STEAM_TURBINE_BOTTOM), + TextureFactory.builder() + .addIcon(STEAM_TURBINE_BOTTOM_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getTop(byte aColor) { + return new ITexture[] { super.getTop(aColor)[0], + TextureFactory.of( + TextureFactory.of(STEAM_TURBINE_TOP), + TextureFactory.builder() + .addIcon(STEAM_TURBINE_TOP_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getSides(byte aColor) { + return new ITexture[] { super.getSides(aColor)[0], + TextureFactory.of( + TextureFactory.of(STEAM_TURBINE_SIDE), + TextureFactory.builder() + .addIcon(STEAM_TURBINE_SIDE_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getFrontActive(byte aColor) { + return new ITexture[] { super.getFrontActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(STEAM_TURBINE_FRONT_ACTIVE), + TextureFactory.builder() + .addIcon(STEAM_TURBINE_FRONT_ACTIVE_GLOW) + .glow() + .build()), + OVERLAYS_ENERGY_OUT[this.mTier] }; + } + + @Override + public ITexture[] getBackActive(byte aColor) { + return new ITexture[] { super.getBackActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(STEAM_TURBINE_BACK_ACTIVE), + TextureFactory.builder() + .addIcon(STEAM_TURBINE_BACK_ACTIVE_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getBottomActive(byte aColor) { + return new ITexture[] { super.getBottomActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(STEAM_TURBINE_BOTTOM_ACTIVE), + TextureFactory.builder() + .addIcon(STEAM_TURBINE_BOTTOM_ACTIVE_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getTopActive(byte aColor) { + return new ITexture[] { super.getTopActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(STEAM_TURBINE_TOP_ACTIVE), + TextureFactory.builder() + .addIcon(STEAM_TURBINE_TOP_ACTIVE_GLOW) + .glow() + .build()) }; + } + + @Override + public ITexture[] getSidesActive(byte aColor) { + return new ITexture[] { super.getSidesActive(aColor)[0], + TextureFactory.of( + TextureFactory.of(STEAM_TURBINE_SIDE_ACTIVE), + TextureFactory.builder() + .addIcon(STEAM_TURBINE_SIDE_ACTIVE_GLOW) + .glow() + .build()) }; + } + + @Override + public int getPollution() { + return 0; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + if (GTModHandler.isSuperHeatedSteam(aFluid)) { + aFluid.amount = 0; + aFluid = null; + return false; + } + return super.isFluidInputAllowed(aFluid); + } +} -- cgit