diff options
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/boilers')
6 files changed, 1917 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java new file mode 100644 index 0000000000..6b245a9da1 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java @@ -0,0 +1,516 @@ +package gregtech.common.tileentities.boilers; + +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import gregtech.GT_Mod; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.ParticleFX; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.SteamVariant; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.gui.modularui.GUITextureSet; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.modularui.IGetTitleColor; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; +import gregtech.common.GT_Pollution; + +public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTank + implements IGetTitleColor, IAddUIWidgets { + + public static final byte SOUND_EVENT_LET_OFF_EXCESS_STEAM = 1; + public int mTemperature = 20; + public int mProcessingEnergy = 0; + public int mLossTimer = 0; + public FluidStack mSteam = null; + public boolean mHadNoWater = false; + private int mExcessWater = 0; + + public GT_MetaTileEntity_Boiler(int aID, String aName, String aNameRegional, String aDescription, + ITexture... aTextures) { + super(aID, aName, aNameRegional, 0, 4, aDescription, aTextures); + } + + public GT_MetaTileEntity_Boiler(int aID, String aName, String aNameRegional, String[] aDescription, + ITexture... aTextures) { + super(aID, aName, aNameRegional, 0, 4, aDescription, aTextures); + } + + public GT_MetaTileEntity_Boiler(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + public GT_MetaTileEntity_Boiler(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + ITexture[] tmp; + if ((sideDirection.flag & (ForgeDirection.UP.flag | ForgeDirection.DOWN.flag)) == 0) { // Horizontal + if (sideDirection != facingDirection) tmp = mTextures[2][colorIndex + 1]; + else tmp = mTextures[(byte) (active ? 4 : 3)][colorIndex + 1]; + } else { + tmp = mTextures[sideDirection.ordinal()][colorIndex + 1]; + } + if (sideDirection != facingDirection && tmp.length == 2) { + tmp = new ITexture[] { tmp[0] }; + } + return tmp; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean isFacingValid(ForgeDirection facingDirection) { + return (facingDirection.flag & (ForgeDirection.UP.flag | ForgeDirection.DOWN.flag)) == 0; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public int getProgresstime() { + return this.mTemperature; + } + + @Override + public int maxProgresstime() { + return 500; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + if (aPlayer != null) { + if (GT_Utility.areStacksEqual(aPlayer.getCurrentEquippedItem(), new ItemStack(Items.water_bucket, 1))) { + fill(Materials.Water.getFluid(1000L * (long) aPlayer.getCurrentEquippedItem().stackSize), true); + + if (!aPlayer.capabilities.isCreativeMode) { + aPlayer.getCurrentEquippedItem() + .func_150996_a(Items.bucket); + } + } else { + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + } + } + return true; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return false; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return GT_ModHandler.isWater(aFluid); + } + + @Override + public FluidStack getDrainableStack() { + return this.mSteam; + } + + @Override + public FluidStack setDrainableStack(FluidStack aFluid) { + this.mSteam = aFluid; + return this.mSteam; + } + + @Override + public boolean isDrainableStackSeparate() { + return true; + } + + @Override + public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aCover) { + return GregTech_API.getCoverBehaviorNew(aCover.toStack()) + .isSimpleCover(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mLossTimer", this.mLossTimer); + aNBT.setInteger("mTemperature", this.mTemperature); + aNBT.setInteger("mProcessingEnergy", this.mProcessingEnergy); + aNBT.setInteger("mExcessWater", this.mExcessWater); + if (this.mSteam == null) { + return; + } + try { + aNBT.setTag("mSteam", this.mSteam.writeToNBT(new NBTTagCompound())); + } catch (Throwable ignored) {} + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + this.mLossTimer = aNBT.getInteger("mLossTimer"); + this.mTemperature = aNBT.getInteger("mTemperature"); + this.mProcessingEnergy = aNBT.getInteger("mProcessingEnergy"); + this.mExcessWater = aNBT.getInteger("mExcessWater"); + this.mSteam = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mSteam")); + } + + /** + * Produce some steam. Assume water is present. + */ + protected void produceSteam(int aAmount) { + mExcessWater -= aAmount; + if (mExcessWater < 0) { + int tWaterToConsume = -mExcessWater / GT_Values.STEAM_PER_WATER; + mFluid.amount -= tWaterToConsume; + mExcessWater += GT_Values.STEAM_PER_WATER * tWaterToConsume; + } + if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += aAmount; + } else { + this.mSteam = GT_ModHandler.getSteam(aAmount); + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + pollute(aTick); + + if (isNotAllowedToWork(aBaseMetaTileEntity, aTick)) return; + + calculateCooldown(); + pushSteamToInventories(aBaseMetaTileEntity); + + if (canNotCreateSteam(aBaseMetaTileEntity, aTick)) { + pollute(aTick); + return; + } + + ventSteamIfTankIsFull(); + updateFuelTimed(aBaseMetaTileEntity, aTick); + calculateHeatUp(aBaseMetaTileEntity, aTick); + } + + private boolean isNotAllowedToWork(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + return (!aBaseMetaTileEntity.isServerSide()) || (aTick <= 20L); + } + + private void pollute(long aTick) { + if (this.mProcessingEnergy > 0 && (aTick % 20L == 0L)) { + GT_Pollution.addPollution(getBaseMetaTileEntity(), getPollution()); + } + } + + private void calculateHeatUp(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if ((this.mTemperature < getMaxTemperature()) && (this.mProcessingEnergy > 0) + && (aTick % getHeatUpRate() == 0L)) { + this.mProcessingEnergy -= getEnergyConsumption(); + this.mTemperature += getHeatUpAmount(); + } + aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + } + + private void updateFuelTimed(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork())) + updateFuel(aBaseMetaTileEntity, aTick); + } + + protected void ventSteamIfTankIsFull() { + if ((this.mSteam != null) && (this.mSteam.amount > getSteamCapacity())) { + sendSound(SOUND_EVENT_LET_OFF_EXCESS_STEAM); + this.mSteam.amount = getSteamCapacity() * 3 / 4; + } + } + + private boolean canNotCreateSteam(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aTick % 10L != 0L) { + return false; + } + + if (this.mTemperature > 100) { + if ((!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { + this.mHadNoWater = true; + } else { + if (this.mHadNoWater) { + GT_Log.exp.println("Boiler " + this.mName + " had no Water!"); + onDangerousWaterLack(aBaseMetaTileEntity, aTick); + return true; + } + produceSteam(getProductionPerSecond() / 2); + } + } else { + this.mHadNoWater = false; + } + return false; + } + + protected void onDangerousWaterLack(IGregTechTileEntity tile, long ignoredTicks) { + tile.doExplosion(2048L); + } + + /** + * Pushes Steam to a Side of this Boiler + * + * @param aBaseMetaTileEntity The tile-entity instance of this Boiler + * @param side The direction of the side to push Steam to + */ + protected final void pushSteamToSide(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side) { + if (mSteam == null || mSteam.amount == 0) return; + final IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(side); + if (tTileEntity == null) return; + GT_Utility.moveFluid(aBaseMetaTileEntity, tTileEntity, side, Math.max(1, this.mSteam.amount / 2), null); + } + + /** + * Pushes steam to Fluid inventories at all sides except Front and Bottom. + * + * @param aBaseMetaTileEntity The tile-entity instance of this Boiler + */ + protected void pushSteamToInventories(IGregTechTileEntity aBaseMetaTileEntity) { + if (mSteam == null || mSteam.amount == 0) return; + for (final ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + if (direction == aBaseMetaTileEntity.getFrontFacing() || direction == ForgeDirection.DOWN) continue; + if (this.mSteam == null) break; + pushSteamToSide(aBaseMetaTileEntity, direction); + } + } + + private void calculateCooldown() { + if (this.mTemperature <= 20) { + this.mTemperature = 20; + this.mLossTimer = 0; + } else if (++this.mLossTimer > getCooldownInterval()) { + // only loss temperature if hot + this.mTemperature -= 1; + this.mLossTimer = 0; + } + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return GT_Mod.gregtechproxy.mAllowSmallBoilerAutomation; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return GT_Mod.gregtechproxy.mAllowSmallBoilerAutomation; + } + + @Override + public void doSound(byte aIndex, double aX, double aY, double aZ) { + if (aIndex == GT_MetaTileEntity_Boiler.SOUND_EVENT_LET_OFF_EXCESS_STEAM) { + GT_Utility.doSoundAtClient(SoundResource.RANDOM_FIZZ, 2, 1.0F, aX, aY, aZ); + + new ParticleEventBuilder().setIdentifier(ParticleFX.CLOUD) + .setWorld(getBaseMetaTileEntity().getWorld()) + .setMotion(0D, 0D, 0D) + .<ParticleEventBuilder>times( + 8, + x -> x.setPosition(aX - 0.5D + XSTR_INSTANCE.nextFloat(), aY, aZ - 0.5D + XSTR_INSTANCE.nextFloat()) + .run()); + } + } + + @Override + public int getTankPressure() { + return 100; + } + + protected abstract int getPollution(); + + @Override + public int getCapacity() { + return 16000; + } + + protected int getSteamCapacity() { + return getCapacity(); + } + + protected abstract int getProductionPerSecond(); + + protected abstract int getMaxTemperature(); + + protected abstract int getEnergyConsumption(); + + protected abstract int getCooldownInterval(); + + protected int getHeatUpRate() { + return 12; + } + + protected int getHeatUpAmount() { + return 1; + } + + protected abstract void updateFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick); + + @Override + public SteamVariant getSteamVariant() { + return SteamVariant.BRONZE; + } + + protected IDrawable[] getFuelSlotBackground() { + return new IDrawable[] { getGUITextureSet().getItemSlot(), + GT_UITextures.OVERLAY_SLOT_COAL_STEAM.get(getSteamVariant()) }; + } + + protected IDrawable[] getAshSlotBackground() { + return new IDrawable[] { getGUITextureSet().getItemSlot(), + GT_UITextures.OVERLAY_SLOT_DUST_STEAM.get(getSteamVariant()) }; + } + + @Override + public boolean useModularUI() { + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new SlotWidget(inventoryHandler, 0).setPos(43, 25) + .setBackground(getGUITextureSet().getItemSlot(), getOverlaySlotIn())) + .widget( + new SlotWidget(inventoryHandler, 1).setPos(43, 61) + .setBackground(getGUITextureSet().getItemSlot(), getOverlaySlotOut())) + .widget(createFuelSlot()) + .widget(createAshSlot()) + .widget( + new ProgressBar().setProgress(() -> mSteam == null ? 0 : (float) mSteam.amount / getSteamCapacity()) + .setTexture(getProgressbarEmpty(), GT_UITextures.PROGRESSBAR_BOILER_STEAM, 10) + .setDirection(ProgressBar.Direction.UP) + .setPos(70, 25) + .setSize(10, 54)) + .widget( + new ProgressBar().setProgress(() -> mFluid == null ? 0 : (float) mFluid.amount / getCapacity()) + .setTexture(getProgressbarEmpty(), GT_UITextures.PROGRESSBAR_BOILER_WATER, 10) + .setDirection(ProgressBar.Direction.UP) + .setPos(83, 25) + .setSize(10, 54)) + .widget( + new ProgressBar().setProgress(() -> (float) mTemperature / maxProgresstime()) + .setTexture(getProgressbarEmpty(), GT_UITextures.PROGRESSBAR_BOILER_HEAT, 10) + .setDirection(ProgressBar.Direction.UP) + .setPos(96, 25) + .setSize(10, 54)) + .widget( + new ProgressBar() + // cap minimum so that one can easily see there's fuel remaining + .setProgress(() -> mProcessingEnergy > 0 ? Math.max((float) mProcessingEnergy / 1000, 1f / 5) : 0) + .setTexture(getProgressbarFuel(), 14) + .setDirection(ProgressBar.Direction.UP) + .setPos(116, 45) + .setSize(14, 14)) + .widget( + new DrawableWidget().setDrawable(getOverlaySlotCanister()) + .setPos(43, 43) + .setSize(18, 18)); + } + + protected SlotWidget createFuelSlot() { + return (SlotWidget) new SlotWidget(inventoryHandler, 2).setPos(115, 61) + .setBackground(getFuelSlotBackground()); + } + + protected SlotWidget createAshSlot() { + return (SlotWidget) new SlotWidget(inventoryHandler, 3).setAccess(true, false) + .setPos(115, 25) + .setBackground(getAshSlotBackground()); + } + + @Override + public GUITextureSet getGUITextureSet() { + return GUITextureSet.STEAM.apply(getSteamVariant()); + } + + @Override + public int getTitleColor() { + return getSteamVariant() == SteamVariant.BRONZE ? COLOR_TITLE.get() : COLOR_TITLE_WHITE.get(); + } + + // for GT++ + + protected IDrawable getOverlaySlotIn() { + return GT_UITextures.OVERLAY_SLOT_IN_STEAM.get(getSteamVariant()); + } + + protected IDrawable getOverlaySlotOut() { + return GT_UITextures.OVERLAY_SLOT_OUT_STEAM.get(getSteamVariant()); + } + + protected IDrawable getOverlaySlotCanister() { + return GT_UITextures.OVERLAY_SLOT_CANISTER_STEAM.get(getSteamVariant()); + } + + protected UITexture getProgressbarEmpty() { + return GT_UITextures.PROGRESSBAR_BOILER_EMPTY_STEAM.get(getSteamVariant()); + } + + protected UITexture getProgressbarFuel() { + return GT_UITextures.PROGRESSBAR_FUEL_STEAM.get(getSteamVariant()); + } +} diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java new file mode 100644 index 0000000000..9e746dc5e9 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java @@ -0,0 +1,311 @@ +package gregtech.common.tileentities.boilers; + +import static gregtech.api.enums.Textures.BlockIcons.BOILER_FRONT; +import static gregtech.api.enums.Textures.BlockIcons.BOILER_FRONT_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.BOILER_FRONT_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.BOILER_FRONT_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE; +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; + +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GT_Mod; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.ParticleFX; +import gregtech.api.enums.SteamVariant; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.XSTR; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; +import gregtech.common.GT_Pollution; + +public class GT_MetaTileEntity_Boiler_Bronze extends GT_MetaTileEntity_Boiler { + + public GT_MetaTileEntity_Boiler_Bronze(int aID, String aName, String aNameRegional) { + super( + aID, + aName, + aNameRegional, + new String[] { "An early way to get Steam Power", "Produces 120L of Steam per second", + "Causes " + GT_Mod.gregtechproxy.mPollutionSmallCoalBoilerPerSecond + " Pollution per second" }); + } + + public GT_MetaTileEntity_Boiler_Bronze(int aID, String aName, String aNameRegional, String[] aDescription) { + super(aID, aName, aNameRegional, aDescription); + } + + public GT_MetaTileEntity_Boiler_Bronze(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public GT_MetaTileEntity_Boiler_Bronze(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[5][17][]; + final ITexture[] texBottom = { TextureFactory.of(MACHINE_BRONZEBRICKS_BOTTOM) }, + texTop = { TextureFactory.of(MACHINE_BRONZEBRICKS_TOP), TextureFactory.of(OVERLAY_PIPE) }, + texSide = { TextureFactory.of(MACHINE_BRONZEBRICKS_SIDE), TextureFactory.of(OVERLAY_PIPE) }, + texFront = { TextureFactory.of(MACHINE_BRONZEBRICKS_SIDE), TextureFactory.of(BOILER_FRONT), + TextureFactory.builder() + .addIcon(BOILER_FRONT_GLOW) + .glow() + .build() }, + texFrontActive = { TextureFactory.of(MACHINE_BRONZEBRICKS_SIDE), TextureFactory.of(BOILER_FRONT_ACTIVE), + TextureFactory.builder() + .addIcon(BOILER_FRONT_ACTIVE_GLOW) + .glow() + .build() }; + for (int i = 0; i < 17; i++) { + rTextures[0][i] = texBottom; + rTextures[1][i] = texTop; + rTextures[2][i] = texSide; + rTextures[3][i] = texFront; + rTextures[4][i] = texFrontActive; + } + return rTextures; + } + + @Override + public int maxProgresstime() { + return 500; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_Bronze(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + /** + * Draws random flames and smoke particles in front of active boiler + * + * @param aBaseMetaTileEntity The entity that will handle the {@link Block#randomDisplayTick} + */ + @SideOnly(Side.CLIENT) + @Override + public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.isActive()) { + + final ForgeDirection frontFacing = aBaseMetaTileEntity.getFrontFacing(); + + if ((frontFacing.flag & (ForgeDirection.UP.flag | ForgeDirection.DOWN.flag)) == 0 + && aBaseMetaTileEntity.getCoverIDAtSide(frontFacing) == 0 + && !aBaseMetaTileEntity.getOpacityAtSide(frontFacing)) { + + final double oX = aBaseMetaTileEntity.getOffsetX(frontFacing, 1) + 8D / 16D; + final double oY = aBaseMetaTileEntity.getOffsetY(frontFacing, 1); + final double oZ = aBaseMetaTileEntity.getOffsetZ(frontFacing, 1) + 8D / 16D; + final double offset = -0.48D; + final double horizontal = XSTR_INSTANCE.nextFloat() * 10D / 16D - 5D / 16D; + + final double x, y, z; + + y = oY + XSTR_INSTANCE.nextFloat() * 6D / 16D; + + if (frontFacing == ForgeDirection.WEST) { + x = oX - offset; + z = oZ + horizontal; + } else if (frontFacing == ForgeDirection.EAST) { + x = oX + offset; + z = oZ + horizontal; + } else if (frontFacing == ForgeDirection.NORTH) { + x = oX + horizontal; + z = oZ - offset; + } else // if (frontFacing == ForgeDirection.SOUTH) + { + x = oX + horizontal; + z = oZ + offset; + } + + ParticleEventBuilder particleEventBuilder = (new ParticleEventBuilder()).setMotion(0D, 0D, 0D) + .setPosition(x, y, z) + .setWorld(getBaseMetaTileEntity().getWorld()); + particleEventBuilder.setIdentifier(ParticleFX.SMOKE) + .run(); + particleEventBuilder.setIdentifier(ParticleFX.FLAME) + .run(); + } + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L) + && this.mProcessingEnergy > 0 + && (aTick % 20L == 0L)) { + GT_Pollution.addPollution(getBaseMetaTileEntity(), getPollution()); + } + } + + @Override + protected int getPollution() { + return GT_Mod.gregtechproxy.mPollutionSmallCoalBoilerPerSecond; + } + + @Override + protected int getProductionPerSecond() { + return 120; + } + + @Override + protected int getMaxTemperature() { + return 500; + } + + @Override + protected int getEnergyConsumption() { + return 1; + } + + @Override + protected int getCooldownInterval() { + return 45; + } + + @Override + protected void updateFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (this.mInventory[2] == null) return; + if ((GT_Utility.isPartOfMaterials(this.mInventory[2], Materials.Coal) + && !GT_Utility.isPartOfOrePrefix(this.mInventory[2], OrePrefixes.block)) + || (GT_Utility.isPartOfMaterials(this.mInventory[2], Materials.Charcoal) + && !GT_Utility.isPartOfOrePrefix(this.mInventory[2], OrePrefixes.block)) + || (GT_Utility.isPartOfMaterials(this.mInventory[2], Materials.Lignite) + && !GT_Utility.isPartOfOrePrefix(this.mInventory[2], OrePrefixes.block)) + || (GT_Utility.isPartOfMaterials(this.mInventory[2], Materials.Diamond) + && !GT_Utility.isPartOfOrePrefix(this.mInventory[2], OrePrefixes.block)) + || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke") + || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCactusCharcoal") + || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCactusCoke") + || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelSugarCharcoal") + || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelSugarCoke")) { + if ((TileEntityFurnace.getItemBurnTime(this.mInventory[2]) / 10) > 0) { + this.mProcessingEnergy += (TileEntityFurnace.getItemBurnTime(this.mInventory[2]) / 10); + if (XSTR.XSTR_INSTANCE.nextInt( + GT_Utility.isPartOfMaterials(this.mInventory[2], Materials.Coal) + || GT_Utility.isPartOfMaterials(this.mInventory[2], Materials.Charcoal) ? 3 + : GT_Utility.isPartOfMaterials(this.mInventory[2], Materials.Lignite) ? 8 : 2) + == 0) { + aBaseMetaTileEntity.addStackToSlot( + 3, + GT_OreDictUnificator.get( + OrePrefixes.dustTiny, + (GT_Utility.isPartOfMaterials(this.mInventory[2], Materials.Lignite) + || GT_Utility.isPartOfMaterials(this.mInventory[2], Materials.Coal)) ? Materials.DarkAsh + : Materials.Ash, + 1L)); + } + aBaseMetaTileEntity.decrStackSize(2, 1); + } + } else if ( + // If its a block of the following materials + GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.block.get(Materials.Coal)) + || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.block.get(Materials.Lignite)) + || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.block.get(Materials.Charcoal)) + || GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.block.get(Materials.Diamond)) + || + + // if its either a Railcraft Coke Block or a custom GTNH compressed Coal/charcoal/lignite/coke block + (Block.getBlockFromItem(this.mInventory[2].getItem()) != null && // check if the block exists + (Block.getBlockFromItem(this.mInventory[2].getItem()) + .getUnlocalizedName() + .toLowerCase() + .contains("tile") && // check if the block is a tile -> block + ( + // If the name of the block contains these names + Block.getBlockFromItem(this.mInventory[2].getItem()) + .getUnlocalizedName() + .toLowerCase() + .contains("charcoal") + || Block.getBlockFromItem(this.mInventory[2].getItem()) + .getUnlocalizedName() + .toLowerCase() + .contains("coal") + || Block.getBlockFromItem(this.mInventory[2].getItem()) + .getUnlocalizedName() + .toLowerCase() + .contains("diamond") + || Block.getBlockFromItem(this.mInventory[2].getItem()) + .getUnlocalizedName() + .toLowerCase() + .contains("coke") + || Block.getBlockFromItem(this.mInventory[2].getItem()) + .getUnlocalizedName() + .toLowerCase() + .contains("railcraft.cube") + || Block.getBlockFromItem(this.mInventory[2].getItem()) + .getUnlocalizedName() + .toLowerCase() + .contains("lignite"))))) { + // try to add 10% of the burnvalue as Processing energy, no boost + // for coal coke here + if ((TileEntityFurnace.getItemBurnTime(this.mInventory[2]) / 10) > 0) { + this.mProcessingEnergy += (TileEntityFurnace.getItemBurnTime(this.mInventory[2]) + / 10); + aBaseMetaTileEntity.addStackToSlot( + 3, + GT_OreDictUnificator.get( + OrePrefixes.dust, + (GT_Utility.isPartOfMaterials(this.mInventory[2], Materials.Lignite) + || GT_Utility.isPartOfMaterials(this.mInventory[2], Materials.Coal) + || Block.getBlockFromItem(this.mInventory[2].getItem()) + .getUnlocalizedName() + .toLowerCase() + .contains("coal") + || Block.getBlockFromItem(this.mInventory[2].getItem()) + .getUnlocalizedName() + .toLowerCase() + .contains("lignite")) ? Materials.DarkAsh : Materials.Ash, + 1L)); + aBaseMetaTileEntity.decrStackSize(2, 1); + } + // enables every other fuel with at least 2000 burntime as a fuel, + // i.e. peat, Magic/Solid Super Fuel, Coal + // Singularities, Nitor, while bucket of creosite should be blocked + // same goes for lava + } else + if ((TileEntityFurnace.getItemBurnTime(this.mInventory[2])) >= 2000 + && !(this.mInventory[2].getUnlocalizedName() + .toLowerCase() + .contains("bucket") + || this.mInventory[2].getUnlocalizedName() + .toLowerCase() + .contains("cell"))) { + this.mProcessingEnergy += (TileEntityFurnace.getItemBurnTime(this.mInventory[2]) / 10); + // adds tiny pile of ash for burntime under 10k, small pile for + // under 100k and pile for + // bigger values + if (XSTR.XSTR_INSTANCE.nextInt(2) == 0) + aBaseMetaTileEntity.addStackToSlot( + 3, + GT_OreDictUnificator.get( + (TileEntityFurnace.getItemBurnTime(this.mInventory[2]) >= 10000 + ? TileEntityFurnace.getItemBurnTime(this.mInventory[2]) >= 100000 + ? OrePrefixes.dust + : OrePrefixes.dustSmall + : OrePrefixes.dustTiny), + Materials.Ash, + 1L)); + aBaseMetaTileEntity.decrStackSize(2, 1); + } + } + + @Override + public SteamVariant getSteamVariant() { + return SteamVariant.BRONZE; + } +} diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java new file mode 100644 index 0000000000..7fe3a3f4bb --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java @@ -0,0 +1,524 @@ +package gregtech.common.tileentities.boilers; + +import static gregtech.api.enums.Textures.BlockIcons.BOILER_LAVA_FRONT; +import static gregtech.api.enums.Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.BOILER_LAVA_FRONT_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.BOILER_LAVA_FRONT_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.FLUID_IN_SIGN; +import static gregtech.api.enums.Textures.BlockIcons.FLUID_OUT_SIGN; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_STEELBRICKS_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_STEELBRICKS_TOP; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_DRAIN; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; + +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidContainerItem; +import net.minecraftforge.fluids.IFluidHandler; +import net.minecraftforge.fluids.IFluidTank; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FluidSlotWidget; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GT_Mod; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.ParticleFX; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.SteamVariant; +import gregtech.api.gui.modularui.GT_UIInfos; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; + +public class GT_MetaTileEntity_Boiler_Lava extends GT_MetaTileEntity_Boiler { + + public static final int COOLDOWN_INTERVAL = 20; + public static final int ENERGY_PER_LAVA = 1; + public static final int CONSUMPTION_PER_HEATUP = 3; + public static final int PRODUCTION_PER_SECOND = 600; + private final FluidTank lavaTank = new LavaTank(null, getCapacity()); + private int mCooledLava = 0; + + public GT_MetaTileEntity_Boiler_Lava(int aID, String aName, String aNameRegional) { + super( + aID, + aName, + aNameRegional, + new String[] { "A Boiler running off Lava", "Produces " + PRODUCTION_PER_SECOND + "L of Steam per second", + "Causes " + GT_Mod.gregtechproxy.mPollutionHighPressureLavaBoilerPerSecond + " Pollution per second", + "Consumes " + ((double) CONSUMPTION_PER_HEATUP / ENERGY_PER_LAVA) + + "L of Lava every " + + COOLDOWN_INTERVAL + + " ticks when fully heat up" }); + } + + public GT_MetaTileEntity_Boiler_Lava(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public GT_MetaTileEntity_Boiler_Lava(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + final ForgeDirection rearDirection = facingDirection.getOpposite(); + final ITexture[] tmp; + if ((sideDirection.flag & (ForgeDirection.UP.flag | ForgeDirection.DOWN.flag)) == 0) { + if (sideDirection == facingDirection) { + if (active) tmp = mTextures[4][colorIndex + 1]; + else tmp = mTextures[3][colorIndex + 1]; + } else if (sideDirection == rearDirection) { + tmp = mTextures[5][colorIndex + 1]; + } else { + tmp = mTextures[2][colorIndex + 1]; + } + } else tmp = mTextures[sideDirection.ordinal()][colorIndex + 1]; + if (sideDirection != facingDirection && tmp.length == 2) { + return new ITexture[] { tmp[0] }; + } + return tmp; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[6][17][]; + for (byte color = -1; color < 16; color++) { + int i = color + 1; + short[] colorModulation = Dyes.getModulation(color, Dyes._NULL.mRGBa); + rTextures[0][i] = new ITexture[] { TextureFactory.of(MACHINE_STEELBRICKS_BOTTOM, colorModulation) }; + rTextures[1][i] = new ITexture[] { TextureFactory.of(MACHINE_STEELBRICKS_TOP, colorModulation), + TextureFactory.of(OVERLAY_DRAIN), TextureFactory.of(FLUID_IN_SIGN) }; + rTextures[2][i] = new ITexture[] { TextureFactory.of(MACHINE_STEELBRICKS_SIDE, colorModulation), + TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(FLUID_IN_SIGN) }; + rTextures[3][i] = new ITexture[] { TextureFactory.of(MACHINE_STEELBRICKS_SIDE, colorModulation), + TextureFactory.of(BOILER_LAVA_FRONT, colorModulation), TextureFactory.of(BOILER_LAVA_FRONT_GLOW) }; + rTextures[4][i] = new ITexture[] { TextureFactory.of(MACHINE_STEELBRICKS_SIDE, colorModulation), + TextureFactory.of(BOILER_LAVA_FRONT_ACTIVE), TextureFactory.builder() + .addIcon(BOILER_LAVA_FRONT_ACTIVE_GLOW) + .glow() + .build() }; + rTextures[5][i] = new ITexture[] { TextureFactory.of(MACHINE_STEELBRICKS_SIDE, colorModulation), + TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(FLUID_OUT_SIGN) }; + } + return rTextures; + } + + @Override + public int maxProgresstime() { + return 1000; + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_Lava(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + protected int getPollution() { + return GT_Mod.gregtechproxy.mPollutionHighPressureLavaBoilerPerSecond; + } + + @Override + protected int getProductionPerSecond() { + return PRODUCTION_PER_SECOND; + } + + @Override + protected int getMaxTemperature() { + return 1000; + } + + @Override + protected int getEnergyConsumption() { + this.mCooledLava += CONSUMPTION_PER_HEATUP; + return CONSUMPTION_PER_HEATUP; + } + + @Override + protected int getCooldownInterval() { + return COOLDOWN_INTERVAL; + } + + /** + * Attempts to fill an {@link IFluidTank} from the {@link FluidStack} content of an {@link ItemStack} + * + * @param destinationIFluidTank The destination {@link IFluidTank} to fill + * @param SourceItemStack The source {@link ItemStack} containing the Fluid + * @return The {@link ItemStack} of the Empty version of the source {@link ItemStack} or {@code null} if none + */ + public static ItemStack fillIFluidTankFromItemStack(IFluidTank destinationIFluidTank, ItemStack SourceItemStack) { + if (destinationIFluidTank == null || SourceItemStack == null) return null; + + final FluidStack containedFluidStack = GT_Utility.getFluidForFilledItem(SourceItemStack, true); + if (containedFluidStack == null || containedFluidStack.amount == 0) return null; + + final int fillableAmount = destinationIFluidTank.fill(containedFluidStack, false); + if (fillableAmount <= 0) return null; + + final Item containerItem = SourceItemStack.getItem(); + if (containerItem instanceof IFluidContainerItem equippedIFluidContainerItem) { + destinationIFluidTank.fill(equippedIFluidContainerItem.drain(SourceItemStack, fillableAmount, true), true); + return null; + } else { + final ItemStack emptyContainerItemStack = GT_Utility.getContainerForFilledItem(SourceItemStack, false); + destinationIFluidTank.fill(containedFluidStack, true); + return emptyContainerItemStack; + } + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide() || aPlayer == null) return true; + + final ItemStack equippedItemStack = aPlayer.getCurrentEquippedItem(); + final FluidStack equippedContainerFluidStack = GT_Utility.getFluidForFilledItem(equippedItemStack, true); + final ItemStack returnedItemStack; + final IFluidTank tank; + + if (GT_ModHandler.isWater(equippedContainerFluidStack)) { + tank = this; + } else if (GT_ModHandler.isLava(equippedContainerFluidStack)) { + tank = lavaTank; + } else { + GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + returnedItemStack = fillIFluidTankFromItemStack(tank, equippedItemStack); + if (returnedItemStack != null && !aPlayer.capabilities.isCreativeMode) { + if (equippedItemStack.stackSize > 1) { + if (!aPlayer.inventory.addItemStackToInventory(returnedItemStack)) { + aBaseMetaTileEntity.getWorld() + .spawnEntityInWorld( + new EntityItem( + aBaseMetaTileEntity.getWorld(), + (double) aBaseMetaTileEntity.getXCoord() + 0.5D, + (double) aBaseMetaTileEntity.getYCoord() + 1.5D, + (double) aBaseMetaTileEntity.getZCoord() + 0.5D, + equippedItemStack)); + } else if (aPlayer instanceof EntityPlayerMP) { + ((EntityPlayerMP) aPlayer).sendContainerToPlayer(aPlayer.inventoryContainer); + } + aPlayer.inventory.decrStackSize(aPlayer.inventory.currentItem, 1); + } else { + aPlayer.inventory.setInventorySlotContents(aPlayer.inventory.currentItem, returnedItemStack); + } + } + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + if (lavaTank.getFluid() != null) aNBT.setTag( + "mLava", + lavaTank.getFluid() + .writeToNBT(new NBTTagCompound())); + aNBT.setInteger("mCooledLava", this.mCooledLava); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + lavaTank.setFluid(FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mLava"))); + this.mCooledLava = aNBT.getInteger("mCooledLava"); + } + + /** + * Pushes steam to Fluid inventory at the rear. + * + * @param aBaseMetaTileEntity The tile-entity instance of this Lava Boiler + */ + @Override + protected void pushSteamToInventories(IGregTechTileEntity aBaseMetaTileEntity) { + if (mSteam == null || mSteam.amount == 0) return; + pushSteamToSide( + aBaseMetaTileEntity, + aBaseMetaTileEntity.getFrontFacing() + .getOpposite()); + } + + /** + * Drains Lava from Fluid inventory on top + * + * @param aBaseMetaTileEntity The tile-entity instance of this Lava Boiler + */ + protected void drainLava(IGregTechTileEntity aBaseMetaTileEntity) { + final IFluidHandler upTank = aBaseMetaTileEntity.getITankContainerAtSide(ForgeDirection.UP); + if (upTank == null) return; + // Simulates drain of maximum lava amount up to 1000L that can fit the internal tank + final FluidStack drainableLavaStack = upTank.drain( + ForgeDirection.DOWN, + FluidRegistry.getFluidStack( + "lava", + Math.min( + this.lavaTank.getCapacity() + - (this.lavaTank.getFluid() != null ? this.lavaTank.getFluid().amount : 0), + 1000)), + false); + if (!GT_ModHandler.isLava(drainableLavaStack) || drainableLavaStack.amount <= 0) return; + // Performs actual drain up and fill internal tank + this.lavaTank.fill(upTank.drain(ForgeDirection.DOWN, drainableLavaStack, true), true); + } + + /** + * Processes cooled Lava into Obsidian + * + * @return success | failure when cannot output + */ + private boolean lavaToObsidian() { + if (this.mCooledLava >= 1000) { + if (getBaseMetaTileEntity().addStackToSlot(3, new ItemStack(Blocks.obsidian, 1))) { + this.mCooledLava -= 1000; + } else { + return false; + } + } + return true; + } + + /** + * Draws random flames and smoke particles in front of this Lava Boiler when it is active + * + * @param aBaseMetaTileEntity The entity that will handle the {@link Block#randomDisplayTick} + */ + @SideOnly(Side.CLIENT) + @Override + public void onRandomDisplayTick(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.isActive()) { + + final ForgeDirection frontFacing = aBaseMetaTileEntity.getFrontFacing(); + + if ((frontFacing.flag & (ForgeDirection.UP.flag | ForgeDirection.DOWN.flag)) == 0 + && aBaseMetaTileEntity.getCoverIDAtSide(frontFacing) == 0 + && !aBaseMetaTileEntity.getOpacityAtSide(frontFacing)) { + + final double oX = aBaseMetaTileEntity.getOffsetX(frontFacing, 1) + 8D / 16D; + final double oY = aBaseMetaTileEntity.getOffsetY(frontFacing, 1); + final double oZ = aBaseMetaTileEntity.getOffsetZ(frontFacing, 1) + 8D / 16D; + final double offset = -0.48D; + final double horizontal = XSTR_INSTANCE.nextFloat() * 10D / 16D - 5D / 16D; + + final double x, y, z; + + y = oY + XSTR_INSTANCE.nextFloat() * 6D / 16D; + + switch (frontFacing) { + case WEST -> { + x = oX - offset; + z = oZ + horizontal; + } + case EAST -> { + x = oX + offset; + z = oZ + horizontal; + } + case NORTH -> { + x = oX + horizontal; + z = oZ - offset; + } + default -> { // case SOUTH: + x = oX + horizontal; + z = oZ + offset; + } + } + + ParticleEventBuilder particleEventBuilder = (new ParticleEventBuilder()).setMotion(0D, 0D, 0D) + .setPosition(x, y, z) + .setWorld(getBaseMetaTileEntity().getWorld()); + particleEventBuilder.setIdentifier(ParticleFX.SMOKE) + .run(); + particleEventBuilder.setIdentifier(ParticleFX.FLAME) + .run(); + } + } + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return GT_ModHandler.isWater(aFluid) || GT_ModHandler.isLava(aFluid); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (!aBaseMetaTileEntity.isServerSide()) return; + final FluidStack containedFluidStack = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true); + if (GT_ModHandler.isWater(containedFluidStack)) super.onPreTick(aBaseMetaTileEntity, aTick); + if (GT_ModHandler.isLava(containedFluidStack) + && lavaTank.fill(containedFluidStack, false) == containedFluidStack.amount + && aBaseMetaTileEntity.addStackToSlot( + getOutputSlot(), + GT_Utility.getContainerForFilledItem(mInventory[getInputSlot()], true), + 1)) { + lavaTank.fill(containedFluidStack, true); + aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aTick % 20 == 0) drainLava(aBaseMetaTileEntity); + super.onPostTick(aBaseMetaTileEntity, aTick); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return true; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return true; + } + + @Override + public void doSound(byte aIndex, double aX, double aY, double aZ) { + if (aIndex != GT_MetaTileEntity_Boiler.SOUND_EVENT_LET_OFF_EXCESS_STEAM) return; + + final ForgeDirection rearDirection = getBaseMetaTileEntity().getFrontFacing() + .getOpposite(); + GT_Utility.doSoundAtClient( + SoundResource.RANDOM_FIZZ, + 2, + 1.0F, + // Sound emitted from center of rear face (Steam Output) + aX + 0.5 * rearDirection.offsetX, + aY, + aZ + 0.5 * rearDirection.offsetZ); + + new ParticleEventBuilder().setIdentifier(ParticleFX.CLOUD) + .setWorld(getBaseMetaTileEntity().getWorld()) + // Particles emitted with a 1 block/s velocity toward rear + .setMotion(rearDirection.offsetX / 20D, 0D, rearDirection.offsetZ / 20D) + .<ParticleEventBuilder>times( + 8, + // Particles emitted from center of rear face (Steam Output) + x -> x.setPosition(aX + rearDirection.offsetX / 2D, aY, aZ + rearDirection.offsetZ / 2D) + .run()); + } + + @Override + protected void updateFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (!lavaToObsidian()) return; + if (lavaTank.getFluid() == null || lavaTank.getFluid().amount <= 0) return; + final int amountToDrain = Math.min(lavaTank.getFluid().amount, 1000); + final FluidStack drainedLava = lavaTank.drain(amountToDrain, false); + if (drainedLava == null || drainedLava.amount == 0) return; + lavaTank.drain(amountToDrain, true); + this.mProcessingEnergy += drainedLava.amount * ENERGY_PER_LAVA; + } + + @Override + public SteamVariant getSteamVariant() { + return SteamVariant.STEEL; + } + + @Override + public int fill(FluidStack aFluid, boolean doFill) { + if (GT_ModHandler.isWater(aFluid)) return super.fill(aFluid, doFill); + if (GT_ModHandler.isLava(aFluid)) return lavaTank.fill(aFluid, doFill); + return 0; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection side) { + return new FluidTankInfo[] { super.getTankInfo(side)[0], + new FluidTankInfo(this.lavaTank.getFluid(), this.lavaTank.getCapacity()), + new FluidTankInfo(getDrainableStack(), getSteamCapacity()) }; + } + + @Override + protected IDrawable[] getAshSlotBackground() { + return new IDrawable[] { getGUITextureSet().getItemSlot(), + GT_UITextures.OVERLAY_SLOT_BLOCK_STEAM.get(getSteamVariant()) }; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new SlotWidget(inventoryHandler, 0).setPos(43, 25) + .setBackground(getGUITextureSet().getItemSlot(), getOverlaySlotIn())) + .widget( + new SlotWidget(inventoryHandler, 1).setAccess(true, false) + .setPos(43, 61) + .setBackground(getGUITextureSet().getItemSlot(), getOverlaySlotOut())) + .widget( + new FluidSlotWidget(lavaTank).setBackground(getGUITextureSet().getFluidSlot(), getOverlaySlotIn()) + .setPos(115, 61)) + .widget(createAshSlot()) + .widget( + new ProgressBar().setProgress(() -> mSteam == null ? 0 : (float) mSteam.amount / getSteamCapacity()) + .setTexture(getProgressbarEmpty(), GT_UITextures.PROGRESSBAR_BOILER_STEAM, 10) + .setDirection(ProgressBar.Direction.UP) + .setPos(70, 25) + .setSize(10, 54)) + .widget( + new ProgressBar().setProgress(() -> mFluid == null ? 0 : (float) mFluid.amount / getCapacity()) + .setTexture(getProgressbarEmpty(), GT_UITextures.PROGRESSBAR_BOILER_WATER, 10) + .setDirection(ProgressBar.Direction.UP) + .setPos(83, 25) + .setSize(10, 54)) + .widget( + new ProgressBar().setProgress(() -> (float) mTemperature / maxProgresstime()) + .setTexture(getProgressbarEmpty(), GT_UITextures.PROGRESSBAR_BOILER_HEAT, 10) + .setDirection(ProgressBar.Direction.UP) + .setPos(96, 25) + .setSize(10, 54)) + .widget( + new ProgressBar() + // cap minimum so that one can easily see there's fuel remaining + .setProgress(() -> mProcessingEnergy > 0 ? Math.max((float) mProcessingEnergy / 1000, 1f / 5) : 0) + .setTexture(getProgressbarFuel(), 14) + .setDirection(ProgressBar.Direction.UP) + .setPos(116, 45) + .setSize(14, 14)) + .widget( + new DrawableWidget().setDrawable(getOverlaySlotCanister()) + .setPos(43, 43) + .setSize(18, 18)); + } + + static class LavaTank extends FluidTank { + + public LavaTank(FluidStack stack, int capacity) { + super(stack, capacity); + } + + @Override + public int fill(FluidStack resource, boolean doFill) { + return GT_ModHandler.isLava(resource) ? super.fill(resource, doFill) : 0; + } + } +} diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java new file mode 100644 index 0000000000..f5c59330ed --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java @@ -0,0 +1,381 @@ +package gregtech.common.tileentities.boilers; + +import static gregtech.api.GregTech_API.sMachineFile; +import static gregtech.api.enums.ConfigCategories.machineconfig; +import static mcp.mobius.waila.api.SpecialChars.GOLD; +import static mcp.mobius.waila.api.SpecialChars.RESET; + +import java.util.List; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.SteamVariant; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +public class GT_MetaTileEntity_Boiler_Solar extends GT_MetaTileEntity_Boiler { + + public static final String LPS_FMT = "%s L/s"; + private static final String localizedDescFormat = GT_LanguageManager.addStringLocalization( + "gt.blockmachines.boiler.solar.desc.format", + "Steam Power by the Sun%n" + "Produces %sL of Steam per second%n" + + "Calcifies over time, reducing Steam output to %sL/s%n" + + "Break and replace to descale"); + protected final Config mConfig; + protected final int basicTemperatureMod = 5; // Base Celsius gain or loss + private int mRunTimeTicks = 0; + + public GT_MetaTileEntity_Boiler_Solar(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, new String[0]); + mConfig = createConfig(); + } + + public GT_MetaTileEntity_Boiler_Solar(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + mConfig = createConfig(); + } + + public GT_MetaTileEntity_Boiler_Solar(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + mConfig = createConfig(); + } + + protected GT_MetaTileEntity_Boiler_Solar(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, + Config aConfig) { + super(aName, aTier, aDescription, aTextures); + mConfig = aConfig; + } + + protected Config createConfig() { + return new Config(machineconfig + ".boiler.solar.bronze", 1080000, 40, 120, 45); + } + + public int getMaxOutputPerSecond() { + return mConfig.getMaxOutputPerSecond(); + } + + @Override + public String[] getDescription() { + return String + .format( + localizedDescFormat, + GT_Utility.formatNumbers(getMaxOutputPerSecond()), + GT_Utility.formatNumbers(getMinOutputPerSecond())) + .split("\\R"); + } + + public int getMinOutputPerSecond() { + return mConfig.getMinOutputPerSecond(); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[4][17][]; + for (int color = -1; color < 16; color++) { + int i = color + 1; + short[] colorModulation = Dyes.getModulation(color, Dyes._NULL.mRGBa); + rTextures[0][i] = new ITexture[] { + TextureFactory.of(BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM, colorModulation) }; + rTextures[1][i] = new ITexture[] { TextureFactory.of(BlockIcons.MACHINE_BRONZEBRICKS_TOP, colorModulation), + TextureFactory.of(BlockIcons.BOILER_SOLAR) }; + rTextures[2][i] = new ITexture[] { + TextureFactory.of(BlockIcons.MACHINE_BRONZEBRICKS_SIDE, colorModulation) }; + rTextures[3][i] = new ITexture[] { TextureFactory.of(BlockIcons.MACHINE_BRONZEBRICKS_SIDE, colorModulation), + TextureFactory.of(BlockIcons.OVERLAY_PIPE) }; + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + final int i = colorIndex + 1; + if ((sideDirection.flag & (ForgeDirection.UP.flag | ForgeDirection.DOWN.flag)) == 0) { // Horizontal + if (sideDirection != facingDirection) return mTextures[2][i]; + return mTextures[3][i]; + } + return mTextures[sideDirection.ordinal()][i]; + } + + @Override + public int maxProgresstime() { + return 500; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("mRunTime", mRunTimeTicks); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mRunTimeTicks = aNBT.getInteger("mRunTime"); + } + + @Override + protected void produceSteam(int aAmount) { + super.produceSteam(aAmount); + // Disable calcification when using distilled water + if (mFluid.isFluidEqual(GT_ModHandler.getWater(1))) { + // produceSteam is getting called every 10 ticks + if (mRunTimeTicks >= 0 && mRunTimeTicks < (Integer.MAX_VALUE - 10)) mRunTimeTicks += 10; + else mRunTimeTicks = Integer.MAX_VALUE; // Prevent Integer overflow wrap + } + } + + @Override + protected void pushSteamToInventories(IGregTechTileEntity aBaseMetaTileEntity) { + if (mSteam == null || mSteam.amount == 0) return; + pushSteamToSide(aBaseMetaTileEntity, aBaseMetaTileEntity.getFrontFacing()); + } + + @Override + protected int getPollution() { + return 0; + } + + @Override + public int getProductionPerSecond() { + if (mTemperature < 100) { + return 0; + } + if (mRunTimeTicks > mConfig.getMaxRuntimeTicks()) { + return mConfig.getMinOutputPerSecond(); + } else if (mRunTimeTicks > mConfig.getCalcificationTicks()) { + /* + * When reaching calcification ticks; discount the proportion of run-time spent on calcification from the + * maximum output per second, and return this or the minimum output per second + */ + return mConfig.getMaxOutputPerSecond() + - mConfig.getMaxOutputPerSecond() * (mRunTimeTicks - mConfig.getCalcificationTicks()) + / mConfig.getCalcificationTicks(); + } else { + return mConfig.getMaxOutputPerSecond(); + } + } + + @Override + protected int getMaxTemperature() { + return 500; + } + + @Override + protected int getEnergyConsumption() { + return basicTemperatureMod; + } + + @Override + protected int getCooldownInterval() { + return mConfig.getCoolDownTicks() / basicTemperatureMod; + } + + @Override + protected int getHeatUpAmount() { + return basicTemperatureMod; + } + + @Override + protected void updateFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + World world = aBaseMetaTileEntity.getWorld(); + // Heat-up every 12s (240 ticks), has to be multiple of 20 ticks + if ((aTick % 240L != 0L) || (world.isThundering())) { + return; + } + if (!aBaseMetaTileEntity.getSkyAtSide(ForgeDirection.UP)) { + return; + } + boolean weatherClear = !world.isRaining() || aBaseMetaTileEntity.getBiome().rainfall == 0.0F; + if (!weatherClear && world.skylightSubtracted >= 4) { + return; + } + if (weatherClear) { + if (world.isDaytime()) { + mProcessingEnergy += 8 * basicTemperatureMod; + } else { + mProcessingEnergy += basicTemperatureMod; + } + } else { + mProcessingEnergy += basicTemperatureMod; + } + } + + @Override + public SteamVariant getSteamVariant() { + return SteamVariant.BRONZE; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return String + .format( + "Heat Capacity: " + EnumChatFormatting.GREEN + + "%s %%" + + EnumChatFormatting.RESET + + " Hot time: " + + EnumChatFormatting.RED + + "%s s" + + EnumChatFormatting.RESET + + "%n" + + "Min output: " + + EnumChatFormatting.RED + + LPS_FMT + + EnumChatFormatting.RESET + + " Max output: " + + EnumChatFormatting.RED + + LPS_FMT + + EnumChatFormatting.RESET + + "%n" + + "Current Output: " + + EnumChatFormatting.YELLOW + + LPS_FMT + + EnumChatFormatting.RESET, + GT_Utility.formatNumbers(getHeatCapacityPercent()), + GT_Utility.formatNumbers(getHotTimeSeconds()), + GT_Utility.formatNumbers(getMinOutputPerSecond()), + GT_Utility.formatNumbers(getMaxOutputPerSecond()), + GT_Utility.formatNumbers(getProductionPerSecond())) + .split("\\R"); + } + + public int getHeatCapacityPercent() { + return mTemperature * 100 / maxProgresstime(); + } + + public int getHotTimeSeconds() { + return mRunTimeTicks / 20; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_Solar(mName, mTier, mDescriptionArray, mTextures, mConfig); + } + + @Override + protected IDrawable[] getFuelSlotBackground() { + return new IDrawable[] { GT_UITextures.TRANSPARENT }; + } + + @Override + protected IDrawable[] getAshSlotBackground() { + return new IDrawable[] { GT_UITextures.TRANSPARENT }; + } + + @Override + protected SlotWidget createFuelSlot() { + // todo: remove this slot after some time + return super.createFuelSlot().setAccess(true, false); + } + + @Override + protected SlotWidget createAshSlot() { + // todo: remove this slot after some time + return super.createAshSlot().setAccess(true, false); + } + + @Override + public void getWailaBody(ItemStack itemStack, List<String> currentTip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + final NBTTagCompound tag = accessor.getNBTData(); + currentTip.add( + String.format( + (GOLD + "Solar Boiler Output: " + RESET + "%d/%d L/s"), + tag.getInteger("calcificationOutput"), + tag.getInteger("maxCalcificationOutput"))); + + super.getWailaBody(itemStack, currentTip, accessor, config); + } + + @Override + public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, + int z) { + super.getWailaNBTData(player, tile, tag, world, x, y, z); + tag.setInteger("calcificationOutput", (getProductionPerSecond())); + tag.setInteger("maxCalcificationOutput", (getMaxOutputPerSecond())); + } + + protected static class Config { + + private final int calcificationTicks; + private final int minOutputPerSecond; + private final int maxOutputPerSecond; + private final int coolDownTicks; + private final int maxRuntimeTicks; + + public Config(String aCategory, int aDefaultCalcificationTicks, int aDefaultMinOutputPerSecond, + int aDefaultMaxOutputPerSecond, int aDefaultCoolDownTicks) { + calcificationTicks = get( + aCategory, + "CalcificationTicks", + aDefaultCalcificationTicks, + "Number of run-time ticks before boiler starts calcification.", + "100% calcification and minimal output will be reached at 2 times this."); + minOutputPerSecond = get(aCategory, "MinOutputPerSecond", aDefaultMinOutputPerSecond); + maxOutputPerSecond = get(aCategory, "MaxOutputPerSecond", aDefaultMaxOutputPerSecond); + coolDownTicks = get( + aCategory, + "CoolDownTicks", + aDefaultCoolDownTicks, + "Number of ticks it takes to lose 1°C."); + // After which min output is reached. + maxRuntimeTicks = (getMaxOutputPerSecond() - getMinOutputPerSecond()) * getCalcificationTicks() + / getMaxOutputPerSecond() + getCalcificationTicks(); + } + + protected int get(final String aCategory, final String aKey, final int aDefaultValue, + final String... aComments) { + final StringBuilder tCommentBuilder = new StringBuilder(); + for (String tComment : aComments) tCommentBuilder.append(tComment) + .append('\n'); + tCommentBuilder.append("Default: ") + .append(aDefaultValue); + return sMachineFile.mConfig.get(aCategory, aKey, aDefaultValue, tCommentBuilder.toString()) + .getInt(); + } + + public int getCalcificationTicks() { + return calcificationTicks; + } + + public int getMinOutputPerSecond() { + return minOutputPerSecond; + } + + public int getMaxOutputPerSecond() { + return maxOutputPerSecond; + } + + public int getCoolDownTicks() { + return coolDownTicks; + } + + public int getMaxRuntimeTicks() { + return maxRuntimeTicks; + } + } +} diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar_Steel.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar_Steel.java new file mode 100644 index 0000000000..c20ea4018a --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar_Steel.java @@ -0,0 +1,77 @@ +package gregtech.common.tileentities.boilers; + +import static gregtech.api.enums.ConfigCategories.machineconfig; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.SteamVariant; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.render.TextureFactory; + +public class GT_MetaTileEntity_Boiler_Solar_Steel extends GT_MetaTileEntity_Boiler_Solar { + + public GT_MetaTileEntity_Boiler_Solar_Steel(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_Boiler_Solar_Steel(String aName, int aTier, String aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public GT_MetaTileEntity_Boiler_Solar_Steel(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public GT_MetaTileEntity_Boiler_Solar_Steel(String aName, int aTier, String[] aDescription, + ITexture[][][] aTextures, Config aConfig) { + super(aName, aTier, aDescription, aTextures, aConfig); + } + + @Override + protected Config createConfig() { + return new Config(machineconfig + ".boiler.solar.steel", 1080000, 120, 360, 75); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + + ITexture[][][] rTextures = new ITexture[4][17][]; + for (int color = -1; color < 16; color++) { + int i = color + 1; + short[] colorModulation = Dyes.getModulation(color, Dyes._NULL.mRGBa); + rTextures[0][i] = new ITexture[] { + TextureFactory.of(BlockIcons.MACHINE_STEELBRICKS_BOTTOM, colorModulation) }; + rTextures[1][i] = new ITexture[] { TextureFactory.of(BlockIcons.MACHINE_STEELBRICKS_TOP, colorModulation), + TextureFactory.of(BlockIcons.BOILER_SOLAR) }; + rTextures[2][i] = new ITexture[] { + TextureFactory.of(BlockIcons.MACHINE_STEELBRICKS_SIDE, colorModulation) }; + rTextures[3][i] = new ITexture[] { TextureFactory.of(BlockIcons.MACHINE_STEELBRICKS_SIDE, colorModulation), + TextureFactory.of(BlockIcons.OVERLAY_PIPE) }; + } + return rTextures; + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + public SteamVariant getSteamVariant() { + return SteamVariant.STEEL; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_Solar_Steel( + this.mName, + this.mTier, + this.mDescriptionArray, + this.mTextures, + this.mConfig); + } +} diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java new file mode 100644 index 0000000000..12374c3313 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java @@ -0,0 +1,108 @@ +package gregtech.common.tileentities.boilers; + +import static gregtech.api.enums.Textures.BlockIcons.BOILER_FRONT; +import static gregtech.api.enums.Textures.BlockIcons.BOILER_FRONT_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.BOILER_FRONT_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.BOILER_FRONT_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_STEELBRICKS_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_STEELBRICKS_TOP; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE; + +import gregtech.GT_Mod; +import gregtech.api.enums.SteamVariant; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.render.TextureFactory; + +public class GT_MetaTileEntity_Boiler_Steel extends GT_MetaTileEntity_Boiler_Bronze { + + public GT_MetaTileEntity_Boiler_Steel(int aID, String aName, String aNameRegional) { + super( + aID, + aName, + aNameRegional, + new String[] { "Faster than the Bronze Boiler", "Produces 300L of Steam per second", + "Causes " + GT_Mod.gregtechproxy.mPollutionHighPressureCoalBoilerPerSecond + " Pollution per second" }); + } + + public GT_MetaTileEntity_Boiler_Steel(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public GT_MetaTileEntity_Boiler_Steel(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[5][17][]; + final ITexture[] texBottom = { TextureFactory.of(MACHINE_STEELBRICKS_BOTTOM) }, + texTop = { TextureFactory.of(MACHINE_STEELBRICKS_TOP), TextureFactory.of(OVERLAY_PIPE) }, + texSide = { TextureFactory.of(MACHINE_STEELBRICKS_SIDE), TextureFactory.of(OVERLAY_PIPE) }, + texFront = { TextureFactory.of(MACHINE_STEELBRICKS_SIDE), TextureFactory.of(BOILER_FRONT), + TextureFactory.builder() + .addIcon(BOILER_FRONT_GLOW) + .glow() + .build() }, + texFrontActive = { TextureFactory.of(MACHINE_STEELBRICKS_SIDE), TextureFactory.of(BOILER_FRONT_ACTIVE), + TextureFactory.builder() + .addIcon(BOILER_FRONT_ACTIVE_GLOW) + .glow() + .build() }; + for (int i = 0; i < 17; i++) { + rTextures[0][i] = texBottom; + rTextures[1][i] = texTop; + rTextures[2][i] = texSide; + rTextures[3][i] = texFront; + rTextures[4][i] = texFrontActive; + } + return rTextures; + } + + @Override + public int maxProgresstime() { + return 1000; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Boiler_Steel(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + protected int getPollution() { + return GT_Mod.gregtechproxy.mPollutionHighPressureCoalBoilerPerSecond; + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + protected int getProductionPerSecond() { + return 300; + } + + @Override + protected int getMaxTemperature() { + return 1000; + } + + @Override + protected int getEnergyConsumption() { + return 2; + } + + @Override + protected int getCooldownInterval() { + return 40; + } + + @Override + public SteamVariant getSteamVariant() { + return SteamVariant.STEEL; + } +} |