aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java529
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java3
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java375
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java224
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java5
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java1
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java372
8 files changed, 1153 insertions, 358 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java
index 10a1f96be7..33c6bacbd4 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaAtmosphericReconditioner.java
@@ -71,13 +71,11 @@ public class GregtechMetaAtmosphericReconditioner extends GT_MetaTileEntity_Basi
super(aName, aTier, 2, aDescription, aTextures, 2, 0, aGUIName, aNEIName);
}*/
- @SuppressWarnings("deprecation")
@Override
public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new GregtechMetaAtmosphericReconditioner(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName);
}
- @SuppressWarnings("deprecation")
@Override
public String[] getDescription() {
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java
index 10023722c0..2a2b6d5090 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java
@@ -1,122 +1,165 @@
package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic;
import static gregtech.api.enums.GT_Values.V;
+import static gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils.mPollution;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.HashSet;
import java.util.Set;
-import java.util.UUID;
-import com.google.common.collect.MapMaker;
-import com.google.common.collect.UnmodifiableIterator;
-
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.world.ChunkCoordIntPair;
-import net.minecraftforge.common.ForgeChunkManager;
-import net.minecraftforge.common.ForgeChunkManager.Ticket;
-import net.minecraftforge.common.ForgeChunkManager.Type;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock;
+import gregtech.api.items.GT_MetaGenerated_Tool;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine;
import gregtech.api.objects.GT_RenderedTexture;
-import gtPlusPlus.GTplusplus;
-import gtPlusPlus.api.interfaces.IGregtechPacketEntity;
-import gtPlusPlus.core.handler.chunkloading.ChunkManager;
-import gtPlusPlus.core.util.minecraft.network.PacketBuilder;
-
-public class GregtechMetaTileEntityChunkLoader extends GT_MetaTileEntity_TieredMachineBlock implements IGregtechPacketEntity {
-
- @SuppressWarnings("unused")
- private final static int yMin = 0;
- private final static int yMax = 254;
- private final int xMin, xMax;
- private final int zMin, zMax;
-
- public GregtechMetaTileEntityChunkLoader(final int aID, final String aName, final String aNameRegional, final int aTier) {
- super(aID, aName, aNameRegional, aTier, 0, "Loads chunks: " + (16 + (48 * aTier)) + " powered");
- xMin = this.xCoord-47;
- xMax = this.xCoord+47;
- zMin = this.zCoord-47;
- zMax = this.zCoord+47;
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.api.interfaces.IChunkLoader;
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.chunkloading.GTPP_ChunkManager;
+import gtPlusPlus.core.chunkloading.StaticChunkFunctions;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.math.MathUtils;
+import gtPlusPlus.core.util.minecraft.PlayerUtils;
+import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils;
+import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity;
+import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.ChunkCoordIntPair;
+import net.minecraft.world.World;
+import net.minecraft.world.chunk.Chunk;
+
+public class GregtechMetaTileEntityChunkLoader extends GT_MetaTileEntity_BasicMachine implements IChunkLoader {
+
+ public GregtechMetaTileEntityChunkLoader(int aID, String aName, String aNameRegional, int aTier) {
+ super(aID, aName, aNameRegional, aTier, 2, "Loads " + getMaxChunksToLoadForTier(aTier) + " chunks when powered", 0, 0, "Recycler.png", "",
+ new ITexture[]{
+ new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB_ACTIVE),
+ new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_MASSFAB),
+ new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab_Active),
+ new GT_RenderedTexture(TexturesGtBlock.Overlay_MatterFab),
+ new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent_Fast),
+ new GT_RenderedTexture(TexturesGtBlock.Overlay_Machine_Vent),
+ new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB_ACTIVE),
+ new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_MASSFAB)
+ });
}
- public GregtechMetaTileEntityChunkLoader(final String aName, final int aTier, final int aInvSlotCount, final String aDescription, final ITexture[][][] aTextures) {
- super(aName, aTier, aInvSlotCount, aDescription, aTextures);
- xMin = this.xCoord-47;
- xMax = this.xCoord+47;
- zMin = this.zCoord-47;
- zMax = this.zCoord+47;
+ public GregtechMetaTileEntityChunkLoader(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) {
+ super(aName, aTier, 2, aDescription, aTextures, 0, 0, aGUIName, aNEIName);
}
- @Override
- public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
- return new GregtechMetaTileEntityChunkLoader(this.mName, this.mTier, this.mInventory.length, this.mDescription, this.mTextures);
+ public static int getMaxChunksToLoadForTier(int aTier) {
+ return (aTier * aTier);
}
@Override
- public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
- return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1], (aSide != 1) ? null : aActive ? new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) : new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER)};
+ public String[] getDescription() {
+ return new String[] {
+ this.mDescription,
+ };
}
@Override
- public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) {
-
+ public ITexture[][][] getTextureSet(final ITexture[] aTextures) {
+ final ITexture[][][] rTextures = new ITexture[10][17][];
+ for (byte i = -1; i < 16; i++) {
+ rTextures[0][i + 1] = this.getFront(i);
+ rTextures[1][i + 1] = this.getBack(i);
+ rTextures[2][i + 1] = this.getBottom(i);
+ rTextures[3][i + 1] = this.getTop(i);
+ rTextures[4][i + 1] = this.getSides(i);
+ rTextures[5][i + 1] = this.getFrontActive(i);
+ rTextures[6][i + 1] = this.getBackActive(i);
+ rTextures[7][i + 1] = this.getBottomActive(i);
+ rTextures[8][i + 1] = this.getTopActive(i);
+ rTextures[9][i + 1] = this.getSidesActive(i);
+ }
+ return rTextures;
}
@Override
- public void onRemoval() {
-
+ public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) {
+ return this.mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1];
}
- @Override
- public boolean isSimpleMachine() {
- return false;
+
+ public ITexture[] getFront(final byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)};
}
- @Override
- public boolean isFacingValid(final byte aFacing) {
- return aFacing > 1;
+
+ public ITexture[] getBack(final byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)};
}
- @Override
- public boolean isEnetInput() {
- return true;
+
+ public ITexture[] getBottom(final byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)};
}
- @Override
- public boolean isInputFacing(final byte aSide) {
- return true;
+
+ public ITexture[] getTop(final byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)};
}
- @Override
- public boolean isTeleporterCompatible() {
- return false;
+
+ public ITexture[] getSides(final byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redox_3)};
}
- @Override
- public long getMinimumStoredEU() {
- return 512;
+
+ public ITexture[] getFrontActive(final byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)};
+ }
+
+
+ public ITexture[] getBackActive(final byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel)};
+ }
+
+
+ public ITexture[] getBottomActive(final byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)};
+ }
+
+
+ public ITexture[] getTopActive(final byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium)};
+ }
+
+
+ public ITexture[] getSidesActive(final byte aColor) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[this.mTier][aColor + 1], new GT_RenderedTexture(TexturesGtBlock.Casing_Redox_3)};
}
@Override
- public long maxEUStore() {
- return 512 + (V[this.mTier] * 50);
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ PlayerUtils.messagePlayer(aPlayer, "Running every "+" minutes.");
+ super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
}
@Override
- public long maxEUInput() {
- return V[this.mTier];
+ public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) {
+ return new GregtechMetaTileEntityChunkLoader(this.mName, this.mTier, this.mDescription, this.mTextures, this.mGUIName, this.mNEIName);
}
@Override
- public long maxAmperesIn() {
- return 2;
+ public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) {
+ if (aBaseMetaTileEntity.isClientSide()){
+ return true;
+ }
+ this.showPollution(aPlayer.getEntityWorld(), aPlayer);
+ return true;
+ }
+
+ private void showPollution(final World worldIn, final EntityPlayer playerIn){
+ //PlayerUtils.messagePlayer(playerIn, "Running every "+mFrequency+" minutes. Owner: "+this.getBaseMetaTileEntity().getOwnerName());
+ //PlayerUtils.messagePlayer(playerIn, "Last run: "+Utils.getSecondsFromMillis(aDiff)+" seconds ago.");
}
@Override
@@ -129,230 +172,230 @@ public class GregtechMetaTileEntityChunkLoader extends GT_MetaTileEntity_TieredM
return false;
}
+
@Override
- public ITexture[][][] getTextureSet(final ITexture[] aTextures) {
- return new ITexture[0][0][0];
+ public String[] getInfoData() {
+ return new String[] {
+ this.getLocalName()
+ };
}
@Override
- public void saveNBTData(final NBTTagCompound aNBT) {
-
+ public boolean isGivingInformation() {
+ return true;
}
@Override
- public void loadNBTData(final NBTTagCompound aNBT) {
-
+ public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) {
+ return false;
}
-
-
-
-
- /**
- * Chunkloading Code from Railcraft
- */
-
- private static final Map<UUID, Ticket> tickets = new MapMaker().makeMap();
- private static final byte MAX_CHUNKS = 25;
- private static final byte ANCHOR_RADIUS = 1;
- private int prevX;
- private int prevY;
- private int prevZ;
- private Set<ChunkCoordIntPair> chunks;
- private boolean hasTicket;
- private boolean refreshTicket;
- private boolean powered;
- private UUID uuid;
- private int xCoord, yCoord, zCoord;
-
- public UUID getUUID() {
- if (this.uuid == null) {
- this.uuid = UUID.randomUUID();
- }
- return this.uuid;
+ @Override
+ public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) {
+ return false;
}
- private boolean sendClientUpdate = false;
-
- public void sendUpdateToClient(IGregTechTileEntity aBaseMetaTileEntity) {
- if (aBaseMetaTileEntity.hasWorkJustBeenEnabled()) {
- this.sendClientUpdate = true;
- } else {
- PacketBuilder.instance().sendTileEntityPacket(aBaseMetaTileEntity);
- }
+ @Override
+ public int getSizeInventory() {
+ return 0;
+ }
+ @Override
+ public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) {
+ return true;
}
-
@Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) {
- super.onPostTick(aBaseMetaTileEntity, aTimer);
- if (!aBaseMetaTileEntity.isServerSide()) {
- return;
- }
- else {
- if (this.xCoord != this.prevX || this.yCoord != this.prevY || this.zCoord != this.prevZ) {
- this.releaseTicket(aBaseMetaTileEntity);
- this.prevX = this.xCoord;
- this.prevY = this.yCoord;
- this.prevZ = this.zCoord;
- }
-
- this.powered = meetsTicketRequirements();
- if (this.hasActiveTicket() && (this.getTicket().world != aBaseMetaTileEntity.getWorld() || this.refreshTicket || !this.powered)) {
- this.releaseTicket(aBaseMetaTileEntity);
- }
- if (!this.hasActiveTicket()) {
- this.requestTicket(aBaseMetaTileEntity);
+ public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+
+ // Have we set the Chunk this Tile resides in yet?
+ if (mCurrentChunk == null) {
+ int xTile = getBaseMetaTileEntity().getXCoord();
+ int zTile = getBaseMetaTileEntity().getZCoord();
+ createInitialWorkingChunk(aBaseMetaTileEntity, xTile, zTile);
+ }
+
+ // Try unload all chunks if fail to meet global chunkloading conditions.
+ if (StaticChunkFunctions.onPostTick(aBaseMetaTileEntity, aTick)) {
+ // Can this tile actively chunkload?
+ if (getChunkLoadingActive()) {
+ // Consume some power
+ this.setEUVar(this.getEUVar() - (maxEUInput() * maxAmperesIn()));
+
+ // Do we need to re-request tickets?
+ if (getDoesWorkChunkNeedReload()) {
+ // Request ticket for current chunk.
+ GTPP_ChunkManager.requestChunkLoad((TileEntity)getBaseMetaTileEntity(), mCurrentChunk);
+ // Request a ticket for each chunk we have mapped out in a spiral pattern.
+ if (!mLoadedChunks.isEmpty()) {
+ for (ChunkCoordIntPair Y : mLoadedChunks) {
+ GTPP_ChunkManager.requestChunkLoad((TileEntity)getBaseMetaTileEntity(), Y);
+ }
+ }
+ setDoesWorkChunkNeedReload(false);
+ }
+
}
- }
- if (this.sendClientUpdate) {
- this.sendClientUpdate = false;
- PacketBuilder.instance().sendTileEntityPacket(aBaseMetaTileEntity);
- }
+ }
}
- public void validate() {
- this.refreshTicket = true;
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ StaticChunkFunctions.saveNBTDataForTileEntity(this.getBaseMetaTileEntity(), aNBT);
}
- protected void releaseTicket(IGregTechTileEntity aBaseMetaTileEntity) {
- this.refreshTicket = false;
- this.setTicket(aBaseMetaTileEntity, (Ticket) null);
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ StaticChunkFunctions.loadNBTDataForTileEntity(this.getBaseMetaTileEntity(), aNBT);
}
- protected void requestTicket(IGregTechTileEntity aBaseMetaTileEntity) {
- if (this.meetsTicketRequirements()) {
- Ticket chunkTicket = this.getTicketFromForge(aBaseMetaTileEntity);
- if (chunkTicket != null) {
- this.setTicketData(aBaseMetaTileEntity, chunkTicket);
- this.forceChunkLoading(aBaseMetaTileEntity, chunkTicket);
- }
- }
+ @Override
+ public long maxAmperesIn() {
+ return 2;
}
- protected boolean meetsTicketRequirements() {
- return this.getEUVar() > (V[this.mTier]*2);
- }
-
- public Ticket getTicketFromForge(IGregTechTileEntity aBaseMetaTileEntity) {
- return ForgeChunkManager.requestTicket(GTplusplus.instance, aBaseMetaTileEntity.getWorld(), Type.NORMAL);
+ @Override
+ public long getMinimumStoredEU() {
+ return V[mTier] * 2;
}
- protected void setTicketData(IGregTechTileEntity aBaseMetaTileEntity, Ticket chunkTicket) {
- chunkTicket.getModData().setInteger("xCoord", this.xCoord);
- chunkTicket.getModData().setInteger("yCoord", this.yCoord);
- chunkTicket.getModData().setInteger("zCoord", this.zCoord);
- chunkTicket.getModData().setString("type", "StandardChunkLoader");
+ @Override
+ public long maxEUStore() {
+ return V[mTier] * 256;
}
- public boolean hasActiveTicket() {
- return this.getTicket() != null;
+ @Override
+ public long maxEUInput() {
+ return V[mTier];
}
- public Ticket getTicket() {
- return (Ticket) tickets.get(this.getUUID());
+
+ /*
+ * Chunkloading Vars
+ */
+
+ private long mTicksRemainingForChunkloading = -1;
+ private ChunkCoordIntPair mCurrentChunk;
+ private Set<ChunkCoordIntPair> mLoadedChunks = new HashSet<ChunkCoordIntPair>();
+ private boolean mRefreshChunkTickets = false;
+
+ @Override
+ public long getTicksRemaining() {
+ return -1;
}
- public void setTicket(IGregTechTileEntity aBaseMetaTileEntity, Ticket t) {
- boolean changed = false;
- Ticket ticket = this.getTicket();
- if (ticket != t) {
- if (ticket != null) {
- if (ticket.world == aBaseMetaTileEntity.getWorld()) {
- UnmodifiableIterator<ChunkCoordIntPair> var4 = ticket.getChunkList().iterator();
-
- while (var4.hasNext()) {
- ChunkCoordIntPair chunk = (ChunkCoordIntPair) var4.next();
- if (ForgeChunkManager.getPersistentChunksFor(aBaseMetaTileEntity.getWorld()).keys().contains(chunk)) {
- ForgeChunkManager.unforceChunk(ticket, chunk);
- }
- }
-
- ForgeChunkManager.releaseTicket(ticket);
- }
-
- tickets.remove(this.getUUID());
- }
-
- changed = true;
- }
-
- this.hasTicket = t != null;
- if (this.hasTicket) {
- tickets.put(this.getUUID(), t);
- }
-
- if (changed) {
- this.sendUpdateToClient(aBaseMetaTileEntity);
- }
-
+ @Override
+ public void setTicksRemaining(long aTicks) {
+ mTicksRemainingForChunkloading = aTicks;
}
-
- public void forceChunkLoading(IGregTechTileEntity aBaseMetaTileEntity, Ticket ticket) {
- this.setTicket(aBaseMetaTileEntity, ticket);
- this.setupChunks();
- if (this.chunks != null) {
- Iterator<ChunkCoordIntPair> var2 = this.chunks.iterator();
- while (var2.hasNext()) {
- ChunkCoordIntPair chunk = (ChunkCoordIntPair) var2.next();
- ForgeChunkManager.forceChunk(ticket, chunk);
- }
- }
+
+ @Override
+ public ChunkCoordIntPair getResidingChunk() {
+ return mCurrentChunk;
}
-
- public void setupChunks() {
- if (!this.hasTicket) {
- this.chunks = null;
- }
- else {
- this.chunks = ChunkManager.getInstance().getChunksAround(this.xCoord >> 4, this.zCoord >> 4, 1);
- }
+
+ @Override
+ public void setResidingChunk(ChunkCoordIntPair aCurrentChunk) {
+ mCurrentChunk = aCurrentChunk;
}
@Override
- public void onExplosion() {
- this.releaseTicket(this.getBaseMetaTileEntity());
- super.onExplosion();
+ public boolean getChunkLoadingActive() {
+ return this.getEUVar() >= maxEUInput() * maxAmperesIn();
}
@Override
- public void onValueUpdate(byte aValue) {
- super.onValueUpdate(aValue);
+ public void setChunkLoadingActive(boolean aActive) {
+
}
@Override
- public void onMachineBlockUpdate() {
- super.onMachineBlockUpdate();
+ public boolean getDoesWorkChunkNeedReload() {
+ return mRefreshChunkTickets;
}
@Override
- public void markDirty() {
- this.refreshTicket = true;
- super.markDirty();
+ public void setDoesWorkChunkNeedReload(boolean aActive) {
+ mRefreshChunkTickets = aActive;
}
@Override
- public boolean connectsToItemPipe(byte aSide) {
- return false;
+ public boolean addChunkToLoadedList(ChunkCoordIntPair aActiveChunk) {
+ return mLoadedChunks.add(aActiveChunk);
}
@Override
- public void doExplosion(long aExplosionPower) {
- this.releaseTicket(this.getBaseMetaTileEntity());
- super.doExplosion(aExplosionPower);
+ public boolean removeChunkFromLoadedList(ChunkCoordIntPair aActiveChunk) {
+ return mLoadedChunks.remove(aActiveChunk);
}
- public void writePacketData(DataOutputStream data) throws IOException {
- data.writeBoolean(this.hasTicket);
+ @Override
+ public Set<ChunkCoordIntPair> getManagedChunks() {
+ return mLoadedChunks;
}
- public void readPacketData(DataInputStream data) throws IOException {
- boolean tick = data.readBoolean();
- if (this.hasTicket != tick) {
- this.hasTicket = tick;
- this.markDirty();
+ @Override
+ public void onRemoval() {
+ StaticChunkFunctions.onRemoval(getBaseMetaTileEntity());
+ super.onRemoval();
+ }
+
+ public static Set<ChunkCoordIntPair> spiralChunks(final IGregTechTileEntity aBaseMetaTileEntity, int X, int Z) {
+ World w = aBaseMetaTileEntity.getWorld();
+ HashSet<ChunkCoordIntPair> aSet = new HashSet<ChunkCoordIntPair>();
+ if (w == null) {
+ return aSet;
}
- this.setupChunks();
+ Chunk thisChunk = w.getChunkFromBlockCoords(aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getZCoord());
+ ChunkCoordIntPair aChunkCo = new ChunkCoordIntPair(thisChunk.xPosition, thisChunk.zPosition);
+ int x,z,dx,dz;
+ x = z = dx =0;
+ dz = -1;
+ int t = Math.max(X,Z);
+ int maxI = t*t;
+ for(int i =0; i < maxI; i++){
+ if ((-X/2 <= x) && (x <= X/2) && (-Z/2 <= z) && (z <= Z/2)){
+ Chunk C = w.getChunkFromChunkCoords(aChunkCo.chunkXPos + x, aChunkCo.chunkZPos + z);
+ if (C != null) {
+ aSet.add(new ChunkCoordIntPair(C.xPosition, C.zPosition));
+ }
+ }
+ if( (x == z) || ((x < 0) && (x == -z)) || ((x > 0) && (x == 1-z))){
+ t = dx;
+ dx = -dz;
+ dz = t;
+ }
+ x += dx;
+ z += dz;
+ }
+ return aSet;
}
-}
+
+ @Override
+ public int getChunkloaderTier() {
+ return mTier;
+ }
+
+ public void createInitialWorkingChunk(IGregTechTileEntity aBaseMetaTileEntity, int aTileX, int aTileZ) {
+ final int centerX = aTileX >> 4;
+ final int centerZ = aTileZ >> 4;
+ addChunkToLoadedList(new ChunkCoordIntPair(centerX, centerZ));
+ GTPP_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity.getMetaTileEntity(), getResidingChunk());
+ // If this surrounding chunk map for this tile is empty, we spiral out and map chunks to keep loaded.
+ if (getManagedChunks().isEmpty()) {
+ int aChunks = GregtechMetaTileEntityChunkLoader.getMaxChunksToLoadForTier(getChunkloaderTier());
+ mLoadedChunks.addAll(spiralChunks(aBaseMetaTileEntity, getChunkloaderTier(), getChunkloaderTier()));
+ }
+ if (!mLoadedChunks.isEmpty()) {
+ for (ChunkCoordIntPair Y : mLoadedChunks) {
+ GTPP_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity.getMetaTileEntity(), Y);
+ }
+ }
+ setDoesWorkChunkNeedReload(false);
+ }
+
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java
index 4cead1c2a8..78896dd650 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java
@@ -212,6 +212,7 @@ public class GregtechMetaTileEntity_IndustrialDehydrator extends GregtechMeta_Mu
long tVoltage = getMaxInputVoltage();
byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
+ long tEnergy = getMaxInputEnergy();
Logger.WARNING("Running checkRecipeGeneric(0)");
GT_Recipe tRecipe = this.getRecipeMap().findRecipe(getBaseMetaTileEntity(), mLastRecipe, false,
@@ -239,7 +240,7 @@ public class GregtechMetaTileEntity_IndustrialDehydrator extends GregtechMeta_Mu
int parallelRecipes = 0;
// Count recipes to do in parallel, consuming input items and fluids and
// considering input voltage limits
- for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) {
+ for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) {
if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) {
Logger.WARNING("Broke at " + parallelRecipes + ".");
break;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java
new file mode 100644
index 0000000000..e5387d8c6f
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_DistillationTower.java
@@ -0,0 +1,375 @@
+package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.advanced;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Textures;
+import gregtech.api.gui.GT_GUIContainer_MultiMachine;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
+import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.minecraft.PlayerUtils;
+import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.FluidStack;
+import org.apache.commons.lang3.ArrayUtils;
+
+import java.util.ArrayList;
+
+public class GregtechMetaTileEntity_Adv_DistillationTower extends GregtechMeta_MultiBlockBase {
+
+ private static final int CASING_INDEX = 49;
+
+ private short mControllerY = 0;
+
+ private byte mMode = 0;
+
+ public GregtechMetaTileEntity_Adv_DistillationTower(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ public GregtechMetaTileEntity_Adv_DistillationTower(String aName) {
+ super(aName);
+ }
+
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GregtechMetaTileEntity_Adv_DistillationTower(this.mName);
+ }
+
+ public String[] getTooltip() {
+ String s = "Max parallel dictated by tower tier and mode";
+ String s1 = "DTower Mode: T1=4, T2=12";
+ String s2 = "Distilery Mode: Tower Tier * (4*InputTier)";
+ return new String[]{
+ "Controller Block for the Advanced Distillation Tower",
+ "T1 constructed identical to standard DT",
+ "T2 is currently disabled.",
+ "T2 is not variable height",
+ "Size(WxHxD): 3x26x3",
+ "Controller (Front bottom)",
+ "1x Input Hatch (Any bottom layer casing)",
+ "24x Output Hatch (One per layer except bottom/top layer)",
+ "1x Output Bus (Any bottom layer casing)",
+ "1x Maintenance Hatch (Any casing)",
+ "1x Energy Hatch (Any casing)",
+ "Integral Framework I's for the rest",
+ s,
+ s1,
+ s2};
+ }
+
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ if (aSide == aFacing) {
+ return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_INDEX], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER)};
+ }
+ return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_INDEX]};
+ }
+
+ public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
+ return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "DistillationTower.png");
+ }
+
+ public GT_Recipe.GT_Recipe_Map getRecipeMap() {
+ return mMode == 0 ? GT_Recipe.GT_Recipe_Map.sDistillationRecipes : GT_Recipe.GT_Recipe_Map.sDistilleryRecipes;
+ }
+
+ public boolean isCorrectMachinePart(ItemStack aStack) {
+ return true;
+ }
+
+ public boolean isFacingValid(byte aFacing) {
+ return aFacing > 1;
+ }
+
+ public int getMaxEfficiency(ItemStack aStack) {
+ return 10000;
+ }
+
+ public int getPollutionPerTick(ItemStack aStack) {
+ return this.mMode == 1 ? 12 : 24;
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ aNBT.setByte("mMode", mMode);
+ super.saveNBTData(aNBT);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ mMode = aNBT.getByte("mMode");
+ super.loadNBTData(aNBT);
+ }
+
+ @Override
+ public String getSound() {
+ return GregTech_API.sSoundList.get(Integer.valueOf(203));
+ }
+
+ @Override
+ public void startProcess() {
+ this.sendLoopStart((byte) 1);
+ }
+
+ @Override
+ public void onModeChangeByScrewdriver(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ mMode++;
+ if (mMode > 1){
+ mMode = 0;
+ PlayerUtils.messagePlayer(aPlayer, "Now running in Distillation Tower Mode.");
+ }
+ else {
+ PlayerUtils.messagePlayer(aPlayer, "Now running in Distillery Mode.");
+ }
+ }
+
+ public int getDamageToComponent(ItemStack aStack) {
+ return 0;
+ }
+
+ public boolean explodesOnComponentBreak(ItemStack aStack) {
+ return false;
+ }
+
+ @Override
+ public boolean addOutput(FluidStack aLiquid) {
+ if (aLiquid == null) return false;
+ FluidStack tLiquid = aLiquid.copy();
+ for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
+ if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid) ? tHatch.outputsSteam() : tHatch.outputsLiquids()) {
+ if (tHatch.getBaseMetaTileEntity().getYCoord() == this.mControllerY + 1) {
+ int tAmount = tHatch.fill(tLiquid, false);
+ if (tAmount >= tLiquid.amount) {
+ return tHatch.fill(tLiquid, true) >= tLiquid.amount;
+ } else if (tAmount > 0) {
+ tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true);
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected void addFluidOutputs(FluidStack[] mOutputFluids2) {
+ for (int i = 0; i < mOutputFluids2.length; i++) {
+ if (mOutputHatches.size() > i && mOutputHatches.get(i) != null && mOutputFluids2[i] != null && isValidMetaTileEntity(mOutputHatches.get(i))) {
+ if (mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord() == this.mControllerY + 1 + i) {
+ mOutputHatches.get(i).fill(mOutputFluids2[i], true);
+ }
+ }
+ }
+
+ }
+
+ @Override
+ public boolean hasSlotInGUI() {
+ return true;
+ }
+
+ @Override
+ public boolean requiresVanillaGtGUI() {
+ return true;
+ }
+
+ @Override
+ public String getCustomGUIResourceName() {
+ return "DistillationTower";
+ }
+
+ @Override
+ public String getMachineType() {
+ return "Distillery, Distillation Tower";
+ }
+
+ @Override
+ public boolean checkRecipe(final ItemStack aStack) {
+ for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) {
+ ArrayList<ItemStack> tBusItems = new ArrayList<ItemStack>();
+ tBus.mRecipeMap = getRecipeMap();
+ if (isValidMetaTileEntity(tBus)) {
+ for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) {
+ if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null)
+ tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i));
+ }
+ }
+ ItemStack[] inputs = new ItemStack[tBusItems.size()];
+ int slot = 0;
+ for (ItemStack g : tBusItems) {
+ inputs[slot++] = g;
+ }
+ if (inputs.length > 0) {
+ int para = (4* GT_Utility.getTier(this.getMaxInputVoltage()));
+ log("Recipe. ["+inputs.length+"]["+para+"]");
+ if (checkRecipeGeneric(inputs, new FluidStack[]{}, para, 100, 250, 10000)) {
+ log("Recipe 2.");
+ return true;
+ }
+ }
+
+ }
+ return false;
+ }
+
+ @Override
+ public int getMaxParallelRecipes() {
+ if (this.mMode == 0) {
+ return getTierOfTower() == 1 ? 4 : getTierOfTower() == 2 ? 12 : 0;
+ }
+ else if (this.mMode == 1) {
+ return getTierOfTower() * (4 * GT_Utility.getTier(this.getMaxInputVoltage()));
+ }
+ return 0;
+ }
+
+ @Override
+ public int getEuDiscountForParallelism() {
+ return 15;
+ }
+
+ @Override
+ public boolean checkMultiblock(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ int aTier = getTierOfTower();
+ if (aTier > 0) {
+ if (aTier == 1) {
+ return checkTierOneTower(aBaseMetaTileEntity, aStack);
+ }
+ else if (aTier == 2) {
+ return checkTierTwoTower(aBaseMetaTileEntity, aStack);
+ }
+ }
+ return false;
+ }
+
+ private int getTierOfTower() {
+ return 1;
+ }
+
+ private boolean checkTierOneTower(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ mControllerY = aBaseMetaTileEntity.getYCoord();
+ int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;
+ int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ;
+ int y = 0; //height
+ int casingAmount = 0;
+ boolean reachedTop = false;
+
+ for (int x = xDir - 1; x <= xDir + 1; x++) { //x=width
+ for (int z = zDir - 1; z <= zDir + 1; z++) { //z=depth
+ if (x != 0 || z != 0) {
+ IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x, y, z);
+ Block block = aBaseMetaTileEntity.getBlockOffset(x, y, z);
+ if (!addInputToMachineList(tileEntity, CASING_INDEX)
+ && !addOutputToMachineList(tileEntity, CASING_INDEX)
+ && !addMaintenanceToMachineList(tileEntity, CASING_INDEX)
+ && !addEnergyInputToMachineList(tileEntity, CASING_INDEX)) {
+ if (block == GregTech_API.sBlockCasings4 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 1) {
+ casingAmount++;
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ y++;
+
+ while (y < 12 && !reachedTop) {
+ for (int x = xDir - 1; x <= xDir + 1; x++) { //x=width
+ for (int z = zDir - 1; z <= zDir + 1; z++) { //z=depth
+ IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x, y, z);
+ Block block = aBaseMetaTileEntity.getBlockOffset(x, y, z);
+ if (aBaseMetaTileEntity.getAirOffset(x, y, z)) {
+ if (x != xDir || z != zDir) {
+ return false;
+ }
+ } else {
+ if (x == xDir && z == zDir) {
+ reachedTop = true;
+ }
+ if (!addOutputToMachineList(tileEntity, CASING_INDEX)
+ && !addMaintenanceToMachineList(tileEntity, CASING_INDEX)
+ && !addEnergyInputToMachineList(tileEntity, CASING_INDEX)) {
+ if (block == GregTech_API.sBlockCasings4 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 1) {
+ casingAmount++;
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ y++;
+ }
+ return casingAmount >= 7 * y - 5 && y >= 3 && y <= 12 && reachedTop;
+ }
+
+ private boolean checkTierTwoTower(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ mControllerY = aBaseMetaTileEntity.getYCoord();
+ int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX;
+ int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ;
+ int y = 0; //height
+ int casingAmount = 0;
+ boolean reachedTop = false;
+
+ for (int x = xDir - 1; x <= xDir + 1; x++) { //x=width
+ for (int z = zDir - 1; z <= zDir + 1; z++) { //z=depth
+ if (x != 0 || z != 0) {
+ IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x, y, z);
+ Block block = aBaseMetaTileEntity.getBlockOffset(x, y, z);
+ if (!addInputToMachineList(tileEntity, CASING_INDEX)
+ && !addOutputToMachineList(tileEntity, CASING_INDEX)
+ && !addMaintenanceToMachineList(tileEntity, CASING_INDEX)
+ && !addEnergyInputToMachineList(tileEntity, CASING_INDEX)) {
+ if (block == GregTech_API.sBlockCasings4 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 1) {
+ casingAmount++;
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ y++;
+
+ while (y < 12 && !reachedTop) {
+ for (int x = xDir - 1; x <= xDir + 1; x++) { //x=width
+ for (int z = zDir - 1; z <= zDir + 1; z++) { //z=depth
+ IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x, y, z);
+ Block block = aBaseMetaTileEntity.getBlockOffset(x, y, z);
+ if (aBaseMetaTileEntity.getAirOffset(x, y, z)) {
+ if (x != xDir || z != zDir) {
+ return false;
+ }
+ } else {
+ if (x == xDir && z == zDir) {
+ reachedTop = true;
+ }
+ if (!addOutputToMachineList(tileEntity, CASING_INDEX)
+ && !addMaintenanceToMachineList(tileEntity, CASING_INDEX)
+ && !addEnergyInputToMachineList(tileEntity, CASING_INDEX)) {
+ if (block == GregTech_API.sBlockCasings4 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 1) {
+ casingAmount++;
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ y++;
+ }
+ return casingAmount >= 7 * y - 5 && y >= 3 && y <= 12 && reachedTop;
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java
index bc36cb32a1..8e3e40b3ab 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java
@@ -40,6 +40,7 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
protected int fuelValue;
protected int fuelRemaining;
protected int freeFuelTicks = 0;
+ protected int euProduction = 0;
protected boolean boostEu;
public static String mLubricantName = "Carbon Dioxide";
@@ -86,12 +87,13 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
mCoolantName = FluidUtils.getFluidStack("liquidhydrogen", 1).getLocalizedName();
}
return new String[] {
- "Controller Block for the Large Combustion Engine",
- "Supply Rocket Fuels and 1000L of "+mLubricantName+" per hour to run",
- "Supply 40L of "+mCoolantName+" per second to boost output (optional)",
- "Consumes upto 5000L of Air per second",
- "Default: Produces "+GT_Values.V[5]+"EU/t at 100% efficiency",
- "Boosted: Produces "+(GT_Values.V[5]*3)+"EU/t at 150% efficiency",
+ "Controller Block for the Large Rocket Engine",
+ "Supply Rocket Fuels and 1000L(3000L boosted) of "+mLubricantName+" per hour to run",
+ "Supply 4L of "+mCoolantName+" per second per 2100 eu/t to boost output (optional)",
+ "Consumes upto 37500L of Air per second",
+ "Produces between 4K and 32K eu/t depending on how much fuel is fed",
+ "When producing more then 16K eu/t fuel wil be consume less efficiently (3x - 1.5x eff)",
+ "Boosting will produce 3x the amount of power but will consume 3x fuel",
"Size(WxHxD): 3x3x10, Controller (front centered)",
"3x3x10 of Stable "+mCasingName+" (hollow, Min 64!)",
"8x "+mGearboxName+" inside the Hollow Casing",
@@ -122,15 +124,20 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
}
public int getAir() {
+ log("geting air in ");
if (this.mAirIntakes.isEmpty() || this.mAirIntakes.size() <= 0) {
+ log("return air 0");
return 0;
}
else {
int totalAir = 0;
FluidStack airstack = FluidUtils.getFluidStack("air", 1);
for (GT_MetaTileEntity_Hatch_AirIntake u : this.mAirIntakes) {
- if (u != null) {
+ if (u != null && u.mFluid != null) {
+ log(" to fluid stack");
+ // had this trow errors cousing the machine to stop probebly fixed
FluidStack f = u.mFluid;
+ log("fluid stack made");
if (f.isFluidEqual(airstack)) {
totalAir += f.amount;
}
@@ -142,66 +149,100 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
@Override
public boolean checkRecipe(final ItemStack aStack) {
+ if (this.mEfficiency < 0)
+ log(" geting air");
final ArrayList<FluidStack> tFluids = this.getStoredFluids();
FluidStack air = FluidUtils.getFluidStack("air", 1);
+ log(" geting air 2");
int aircount = getAir() ;
- if (aircount < (boostEu ? 500 : 200)) {
- //Logger.INFO("Not Enough Air to Run "+aircount);
+ if (aircount < euProduction/32) {
+ log(" not enough air");
+ //log("Not Enough Air to Run "+aircount);
return false;
}
- else {
- boolean hasIntakeAir = this.depleteInput(FluidUtils.getFluidStack(air, boostEu ? 500 : 200));
+ else {
+ log(" no boost");
+ boolean hasIntakeAir = this.depleteInput(FluidUtils.getFluidStack(air, euProduction/32));
if (!hasIntakeAir) {
- //Logger.INFO("Could not consume Air to run "+aircount);
+ //log("Could not consume Air to run "+aircount);
+ freeFuelTicks = 0;
return false;
}
}
- //Logger.INFO("Running "+aircount);
-
+ // reste fuel ticks incase it does not reset when it stops
+ if (freeFuelTicks != 0 && this.mProgresstime == 0 && this.mEfficiency == 0)
+ freeFuelTicks = 0;
+
+ //log("Running "+aircount);
+ log("looking at hatch");
final Collection<GT_Recipe> tRecipeList = Recipe_GT.Gregtech_Recipe_Map.sRocketFuels.mRecipeList;
+
+
if (tFluids.size() > 0 && tRecipeList != null) {
+ log("has fluid");
+
+ if (tFluids.contains(MISC_MATERIALS.CARBON_DIOXIDE.getFluid(this.boostEu ? 3 : 1)) || tFluids.contains(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 3 : 1)))) {
+ log("Found CO2");
+ if (this.mRuntime % 72 == 0 || this.mRuntime == 0) {
+ if (!consumeCO2()) {
+ freeFuelTicks = 0;
+ return false;
+ }
+ }
+ } else
+ {
+ log("no CO found");
+ freeFuelTicks = 0;
+ return false;
+ }
+
+ if (freeFuelTicks == 0)
+ this.boostEu = consumeLOH();
+ log("Did we consume LOH? "+boostEu);
+
for (final FluidStack hatchFluid1 : tFluids) {
if (hatchFluid1.isFluidEqual(air)) {
continue;
- }
- for (final GT_Recipe aFuel : tRecipeList) {
- final FluidStack tLiquid;
- tLiquid = aFuel.mFluidInputs[0];
- if (hatchFluid1.isFluidEqual(tLiquid)) {
-
- final int n = (int) (this.boostEu ? ((GT_Values.V[5]*2) / aFuel.mSpecialValue) : (GT_Values.V[5] / aFuel.mSpecialValue));
-
- if (!consumeFuel(aFuel)) {
- continue;
- }
-
- //Logger.INFO("Consumed some input fuel");
- this.boostEu = consumeLOH();
- //Logger.INFO("Did we consume LOH? "+boostEu);
-
- if (tFluids.contains(MISC_MATERIALS.CARBON_DIOXIDE.getFluid(this.boostEu ? 2 : 1)) || tFluids.contains(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 2 : 1)))) {
- //Logger.INFO("Found CO2");
- if (this.mRuntime % 72 == 0 || this.mRuntime == 0) {
- if (!consumeCO2()) {
- return false;
- }
- }
+ }
+
+ if (freeFuelTicks == 0) {
+ log("tick = 0 consuming fuel");
+ for (final GT_Recipe aFuel : tRecipeList) {
+ final FluidStack tLiquid;
+ tLiquid = aFuel.mFluidInputs[0];
+ if (hatchFluid1.isFluidEqual(tLiquid)) {
+ log("consume fuel amount" + hatchFluid1.amount);
+ if (!consumeFuel(aFuel,hatchFluid1.amount)) {
+ continue;
+ }
this.fuelValue = aFuel.mSpecialValue;
this.fuelRemaining = hatchFluid1.amount;
- this.mEUt = (int) ((this.mEfficiency < 2000) ? 0 : GT_Values.V[5]);
+ this.mEUt = (int) ((this.mEfficiency < 2000) ? 0 : GT_Values.V[5]<<1);
this.mProgresstime = 1;
this.mMaxProgresstime = 1;
- this.mEfficiencyIncrease = 5;
+ this.mEfficiencyIncrease = euProduction/4000;
return true;
+ //log("");
}
- return false;
}
+
+ } else
+ {
+ this.mEfficiencyIncrease = euProduction/4000;
+ freeFuelTicks--;
+ this.mEUt = (int) ((this.mEfficiency < 1000) ? 0 : GT_Values.V[5]<<1);
+ this.mProgresstime = 1;
+ this.mMaxProgresstime = 1;
+ return true;
}
+
}
}
this.mEUt = 0;
this.mEfficiency = 0;
+ log("no fuel found");
+ freeFuelTicks = 0;
return false;
}
@@ -210,34 +251,50 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
* @param aFuel
* @return
*/
- public boolean consumeFuel(GT_Recipe aFuel) {
- if (freeFuelTicks > 0) {
- freeFuelTicks--;
- return true;
- }
- else {
- Logger.INFO("Consuming fuel.");
+ public boolean consumeFuel(GT_Recipe aFuel,int amount) {
+ amount *= this.boostEu ? 0.3 : 0.9;
+ log("Consuming fuel.");
freeFuelTicks = 0;
- int value = aFuel.mSpecialValue * 3000;
- Logger.INFO("Value: "+value);
- value /= GT_Values.V[4];
- value /= 10;
- Logger.INFO("Value: "+value);
- FluidStack tLiquid = FluidUtils.getFluidStack(aFuel.mFluidInputs[0], value);
+ int value = aFuel.mSpecialValue * 3;
+ log("amount: "+amount);
+ log("Value: "+value);
+ int energy = value * amount;
+ //engine needs at leas 2A EV of fuel to waork
+ if (energy < 40000){
+ log("not enough fuel to work");
+ return false;
+ }
+ //limits engine to LuV fuel consumption
+ if (energy > 427500){
+ amount = (int) ((double) 427500/value);
+ energy = 427500;
+ }
+ log("amount2: "+amount);
+ FluidStack tLiquid = FluidUtils.getFluidStack(aFuel.mFluidInputs[0], (this.boostEu ? amount * 3 : amount));
if (!this.depleteInput(tLiquid)) {
+ log("could not deplete fluid");
return false;
}
else {
- this.fuelConsumption = value;
- this.freeFuelTicks = value*2;
- Logger.INFO("Consumed "+value+"L. Waiting "+freeFuelTicks+" ticks to consume more.");
+ this.fuelConsumption = this.boostEu ? amount * 3 : amount;
+ this.freeFuelTicks = 20;
+ setEUProduction(energy);
+ log("Consumed "+amount+"L. Waiting "+freeFuelTicks+" ticks to consume more.");
return true;
}
- }
+ }
+
+ public void setEUProduction(int energy){
+ energy /= 20;
+ // 3x eff unles it gose above 16K eu/t
+ double energyEfficiency = energy > 5500 ? ((double) Math.sqrt(5500)/Math.sqrt(energy) * energy) : energy;
+ euProduction = (int) ((double) energyEfficiency * 1.84);
+ if (this.boostEu)
+ euProduction *= 3;
}
public boolean consumeCO2() {
- if (this.depleteInput(MISC_MATERIALS.CARBON_DIOXIDE.getFluid(this.boostEu ? 2 : 1)) || this.depleteInput(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 2 : 1)))) {
+ if (this.depleteInput(MISC_MATERIALS.CARBON_DIOXIDE.getFluid(this.boostEu ? 3 : 1)) || this.depleteInput(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 3 : 1)))) {
return true;
}
else {
@@ -246,7 +303,8 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
}
public boolean consumeLOH() {
- return this.depleteInput(FluidUtils.getFluidStack(RocketFuels.Liquid_Hydrogen, 2));
+ int LOHamount = (3 * euProduction)/1000;
+ return this.depleteInput(FluidUtils.getFluidStack(RocketFuels.Liquid_Hydrogen, LOHamount)); //(40 * ((long) euProduction / 10000))
}
@Override
@@ -258,15 +316,15 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
final int MAX_LENGTH = 8;
for (int length=0;length<MAX_LENGTH;length++) {
if(getBaseMetaTileEntity().getBlockAtSideAndDistance(tSide, length+1) != getGearboxBlock()) {
- Logger.INFO("Bad Gearbox Block");
+ log("Bad Gearbox Block");
return false;
}
if(getBaseMetaTileEntity().getMetaIDAtSideAndDistance(tSide, length+1) != getGearboxMeta()) {
- Logger.INFO("Bad Gearbox Meta");
+ log("Bad Gearbox Meta");
return false;
}
}
- Logger.INFO("Found "+MAX_LENGTH+" "+mGearboxName+"s.");
+ log("Found "+MAX_LENGTH+" "+mGearboxName+"s.");
for (byte i = -1; i < 2; i = (byte) (i + 1)) {
for (byte j = -1; j < 2; j = (byte) (j + 1)) {
if ((i != 0) || (j != 0)) {
@@ -284,12 +342,12 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
//final Block frontAir = getBaseMetaTileEntity().getBlock(fX, aY, fZ);
//final String frontAirName = frontAir.getUnlocalizedName();
//if(!(getBaseMetaTileEntity().getAir(fX, aY, fZ) || frontAirName.equalsIgnoreCase("tile.air") || frontAirName.equalsIgnoreCase("tile.railcraft.residual.heat"))) {
- //Logger.INFO("Bad Air Check");
+ //log("Bad Air Check");
//return false; //Fail if vent blocks are obstructed
//}
if (((i == 0) || (j == 0)) && ((aLength > 0) && (aLength <= MAX_LENGTH))) {
- Logger.INFO("Checking for Hatches. "+aLength);
+ log("Checking for Hatches. "+aLength);
//Top Row
if (j == 1) {
if (addDynamoToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(aX, aY, aZ), getCasingTextureIndex())) {
@@ -302,7 +360,7 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
// Do nothing
}
else {
- Logger.INFO("Top Row - "+aLength+" | Did not find casing or Dynamo");
+ log("Top Row - "+aLength+" | Did not find casing or Dynamo");
return false;
}
}
@@ -312,7 +370,7 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
final IMetaTileEntity bCheck = aCheck.getMetaTileEntity();
// Only allow Dynamos on Top
if (bCheck instanceof GT_MetaTileEntity_Hatch_Dynamo) {
- Logger.INFO("Found dynamo in disallowed location | "+aX+", "+aY+", "+aZ+" | "+i+", "+j+", "+aLength);
+ log("Found dynamo in disallowed location | "+aX+", "+aY+", "+aZ+" | "+i+", "+j+", "+aLength);
return false;
}
}
@@ -328,30 +386,30 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
else if (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCasingMeta()) {
// Do nothing
}
- else {Logger.INFO("Bad block.");
+ else {log("Bad block.");
return false;
}
}
- Logger.INFO("Passed check. "+aLength);
+ log("Passed check. "+aLength);
} else if (aLength == 0) {
- Logger.INFO("Searching for Gearbox");
+ log("Searching for Gearbox");
if (addMaintenanceToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(aX, aY, aZ), getCasingTextureIndex())) {
// Do Nothing
}
else if(!(getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCasingMeta())) {
- Logger.INFO("Bad Missing Casing || Bad Meta");
+ log("Bad Missing Casing || Bad Meta");
return false;
}
else {
- Logger.INFO("Found "+mCasingName+".");
+ log("Found "+mCasingName+".");
}
} else if (getBaseMetaTileEntity().getBlock(aX, aY, aZ) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(aX, aY, aZ) == getCasingMeta()) {
- Logger.INFO("Found Casing.");
+ log("Found Casing.");
// Do nothing
} else {
- Logger.INFO("Bad XXX");
+ log("Bad XXX");
return false;
}
}
@@ -369,24 +427,24 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
}
if (this.mDynamoHatches.size() <= 0 || this.mDynamoHatches.isEmpty()) {
- Logger.INFO("Wrong count for Dynamos");
+ log("Wrong count for Dynamos");
return false;
}
if (this.mMufflerHatches.size() != 1 || this.mMufflerHatches.isEmpty()) {
- Logger.INFO("Wrong count for Mufflers");
+ log("Wrong count for Mufflers");
return false;
}
if (this.mAirIntakes.size() < 8 || this.mAirIntakes.isEmpty()) {
- Logger.INFO("Wrong count for Air Intakes | "+this.mAirIntakes.size());
+ log("Wrong count for Air Intakes | "+this.mAirIntakes.size());
return false;
}
if (this.mMaintenanceHatches.size() < 1 || this.mMaintenanceHatches.isEmpty()) {
- Logger.INFO("Wrong count for Maint. Hatches");
+ log("Wrong count for Maint. Hatches");
return false;
}
- Logger.INFO("Formed Rocket Engine.");
+ log("Formed Rocket Engine.");
return true;
}
@@ -426,6 +484,7 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
@Override
public void saveNBTData(final NBTTagCompound aNBT) {
aNBT.setInteger("freeFuelTicks", freeFuelTicks);
+ aNBT.setInteger("euProduction", euProduction);
super.saveNBTData(aNBT);
}
@@ -433,6 +492,7 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
public void loadNBTData(final NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
freeFuelTicks = aNBT.getInteger("freeFuelTicks");
+ euProduction = aNBT.getInteger("euProduction");
}
@Override
@@ -442,12 +502,12 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
@Override
public int getMaxEfficiency(final ItemStack aStack) {
- return this.boostEu ? 30000 : 10000;
+ return euProduction;
}
@Override
public int getPollutionPerTick(final ItemStack aStack) {
- return this.boostEu ? 150 : 75;
+ return 75 * ( euProduction / 10000);
}
@Override
@@ -463,8 +523,8 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi
"Current Pollution: " + getPollutionPerTick(null),
"Time until next fuel consumption: "+freeFuelTicks,
"Current Output: " + this.mEUt * this.mEfficiency / 10000 + " EU/t",
- "Fuel Consumption: " + this.fuelConsumption + "L/t",
- "Fuel Value: " + this.fuelValue + " EU/L",
+ "Fuel Consumption: " + (this.fuelConsumption) + "L/s",
+ "Fuel Value: " + this.fuelValue*3 + " EU/L",
"Fuel Remaining: " + this.fuelRemaining + " Litres",
"Current Efficiency: " + this.mEfficiency / 100 + "%",
(this.getIdealStatus() == this.getRepairStatus()) ? "No Maintainance issues" : "Needs Maintainance" };
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java
index e531103a37..e78e5ef16c 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_MassFabricator.java
@@ -322,7 +322,8 @@ public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlo
if (this.mMode == MODE_SCRAP) {
long tVoltage = getMaxInputVoltage();
- byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
+ byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
+ long tEnergy = getMaxInputEnergy();
GT_Recipe c = new Recipe_GT(false, new ItemStack[] { GT_Utility.copyAmount(1, aItemInputs[0]) },
GT_ModHandler.getRecyclerOutput(GT_Utility.copyAmount(64, aItemInputs[0]), 0) == null ? null
: new ItemStack[] { ItemList.IC2_Scrap.get(1) },
@@ -335,7 +336,7 @@ public class GregtechMetaTileEntity_MassFabricator extends GregtechMeta_MultiBlo
int parallelRecipes = 0;
// Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits
- for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tVoltage - tRecipeEUt); parallelRecipes++) {
+ for (; parallelRecipes < aMaxParallelRecipes && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) {
if (!c.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) {
log("Broke at "+parallelRecipes+".");
break;
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java
index fda79876f6..a05ecca551 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/algae/GregtechMTE_AlgaePondBase.java
@@ -61,6 +61,7 @@ public class GregtechMTE_AlgaePondBase extends GregtechMeta_MultiBlockBase {
return new String[] {
"Grows Algae!",
"Controller Block for the Algae Farm",
+ "Provide compost to boost production by one tier",
"Size: 9x3x9 [WxHxL] (open)",
"X X",
"X X",
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java
index 654d036bf8..87f8d81bb2 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java
@@ -1,41 +1,63 @@
package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.chemplant;
import static gregtech.api.enums.GT_Values.E;
+import static gtPlusPlus.core.util.data.ArrayUtils.removeNulls;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
+
+import org.apache.commons.lang3.ArrayUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.GregTech_API;
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Materials;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock;
+import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.Recipe_GT;
+import gtPlusPlus.api.helpers.GregtechPlusPlus_API.Multiblock_API;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.minecraft.multi.SpecialMultiBehaviour;
+import gtPlusPlus.core.item.chemistry.AgriculturalChem;
+import gtPlusPlus.core.item.chemistry.GenericChem;
+import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase;
import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.math.MathUtils;
import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase;
import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy;
import gtPlusPlus.xmod.gregtech.common.StaticFields59;
import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock;
import net.minecraft.block.Block;
+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.FluidStack;
public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase {
-
+
private int mSolidCasingTier = 0;
private int mMachineCasingTier = 0;
private int mPipeCasingTier = 0;
private int mCoilTier = 0;
+
/**
* Internal Recipe Map which holds the actual recipes, backed by the real map, shown by NEI.
*/
@@ -78,13 +100,30 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase {
@Override
public String[] getTooltip() {
return new String[] {
- "Heavy Industry, now right at your doorstep!",
"Controller Block for the Chemical Plant",
- "27 Coils",
- "18 Pipe Casings",
- "57 Tiered Machine Casings",
+ "Heavy Industry, now right at your doorstep!",
+ "Solid Casings dictate Chemical Plant tier",
+ "Machine Casings dictate Hatch tier",
+ "Higher tier coils speed up the machine",
+ "CuNi 50% , FeAlCr 100% , Ni4Cr 150% , ...",
+ "Higher tier pipe casings boost parallel and reduce catalyst consumption",
+ "+2 parallel per tier, 20% extra chance of not damaging catalyst per tier",
+ "27x Coils",
+ "18x Pipe Casings",
+ "57x Tiered Machine Casings",
"80+ Solid Casings",
- "Hatch tier is limited to Machine Casing tier",
+ "Construction Guide:",
+ "Controller is placed on a middle casing in the bottom layer",
+ "Hatches can only be placed on the bottom layer edges",
+ "7x7x7 Hollow frame of solid casings",
+ "5x1x5 layer of solid casings (fills in top layer)",
+ "5x1x5 layer of machine casings (fills in bottom layer)",
+ "In the central 3x5x3:",
+ "3x1x3 layer of Coils, surrounded by ring of Machine Casings",
+ "3x1x3 layer of Pipe Casings",
+ "3x1x3 layer of Coils",
+ "3x1x3 layer of Pipe Casings",
+ "3x1x3 layer of Coils, surrounded by ring of Machine Casings",
};
}
@@ -121,7 +160,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase {
aOriginalTexture = Textures.BlockIcons.CASING_BLOCKS[11];
}
-
if (aSide == aFacing) {
return new ITexture[]{aOriginalTexture, new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)};
}
@@ -158,7 +196,7 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase {
@Override
public int getEuDiscountForParallelism() {
- return 0;
+ return 100;
}
private int getSolidCasingTier() {
@@ -699,24 +737,6 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase {
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@Override
public int getMaxEfficiency(final ItemStack aStack) {
return 10000;
@@ -741,6 +761,15 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase {
public String getCustomGUIResourceName() {
return null;
}
+
+ // Same speed bonus as pyro oven
+ public int getSpeedBonus() {
+ return 50 * (this.mCoilTier - 2);
+ }
+
+ public int getMaxCatalystDurability() {
+ return 50;
+ }
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
@@ -758,10 +787,297 @@ public class GregtechMTE_ChemicalPlant extends GregtechMeta_MultiBlockBase {
}
@Override
- public boolean checkRecipe(final ItemStack aStack) {
- return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0);
+ public boolean checkRecipe(final ItemStack aStack) {
+ return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), getSpeedBonus());
+ }
+
+
+ @Override
+ public boolean checkRecipeGeneric(
+ ItemStack[] aItemInputs, FluidStack[] aFluidInputs,
+ int aMaxParallelRecipes, int aEUPercent,
+ int aSpeedBonusPercent, int aOutputChanceRoll, GT_Recipe aRecipe) {
+
+ // Based on the Processing Array. A bit overkill, but very flexible.
+
+ // Reset outputs and progress stats
+ this.mEUt = 0;
+ this.mMaxProgresstime = 0;
+ this.mOutputItems = new ItemStack[]{};
+ this.mOutputFluids = new FluidStack[]{};
+
+ long tVoltage = getMaxInputVoltage();
+ byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage));
+ long tEnergy = getMaxInputEnergy();
+ log("Running checkRecipeGeneric(0)");
+
+ GT_Recipe tRecipe = findRecipe(
+ getBaseMetaTileEntity(), mLastRecipe, false,
+ gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs);
+
+
+ log("Running checkRecipeGeneric(1)");
+ // Remember last recipe - an optimization for findRecipe()
+ this.mLastRecipe = tRecipe;
+
+
+ if (tRecipe == null) {
+ log("BAD RETURN - 1");
+ return false;
+ }
+
+ if (tRecipe.mSpecialValue > this.mSolidCasingTier) {
+ log("solid tier is too low");
+ return false;
+ }
+
+
+ if (!this.canBufferOutputs(tRecipe, aMaxParallelRecipes)) {
+ log("BAD RETURN - 2");
+ return false;
+ }
+
+ // checks if it has enough catalyst durabilety
+ ArrayList<ItemStack>tCatalysts = null;
+ int tMaxParrallelCatalyst = aMaxParallelRecipes;
+ ItemStack tCatalystRecipe = findCatalyst(tRecipe.mInputs);
+ if (tCatalystRecipe != null) {
+ log("needs catalyst");
+ tCatalysts = new ArrayList<ItemStack>();
+ tMaxParrallelCatalyst = getCatalysts(aItemInputs, tCatalystRecipe, aMaxParallelRecipes,tCatalysts);
+ }
+
+ if (tMaxParrallelCatalyst == 0) {
+ log("found not enough catalists catalyst");
+ return false;
+ }
+
+ // EU discount
+ float tRecipeEUt = (tRecipe.mEUt * aEUPercent) / 100.0f;
+ float tTotalEUt = 0.0f;
+ log("aEUPercent "+aEUPercent);
+ log("mEUt "+tRecipe.mEUt);
+
+ int parallelRecipes = 0;
+
+ log("parallelRecipes: "+parallelRecipes);
+ log("aMaxParallelRecipes: "+tMaxParrallelCatalyst);
+ log("tTotalEUt: "+tTotalEUt);
+ log("tVoltage: "+tVoltage);
+ log("tEnergy: "+tEnergy);
+ log("tRecipeEUt: "+tRecipeEUt);
+ // Count recipes to do in parallel, consuming input items and fluids and considering input voltage limits
+ for (; parallelRecipes < tMaxParrallelCatalyst && tTotalEUt < (tEnergy - tRecipeEUt); parallelRecipes++) {
+ if (!tRecipe.isRecipeInputEqual(true, aFluidInputs, aItemInputs)) {
+ log("Broke at "+parallelRecipes+".");
+ break;
+ }
+ log("Bumped EU from "+tTotalEUt+" to "+(tTotalEUt+tRecipeEUt)+".");
+ tTotalEUt += tRecipeEUt;
+ }
+
+ if (parallelRecipes == 0) {
+ log("BAD RETURN - 3");
+ return false;
+ }
+
+ if (tCatalysts != null) {
+ log("damaging catalyst");
+ for (int j = 0;j<parallelRecipes;j++) {
+ log("j = "+j);
+ for (int i = 0;i<tCatalysts.size();i++) {
+ log("i = "+i);
+ if (tCatalysts.get(i) != null && tCatalysts.get(i).stackSize != 0) {
+ damageCatalyst(tCatalysts.get(i));
+ break;
+ }
+ }
+ }
+ }
+
+ // -- Try not to fail after this point - inputs have already been consumed! --
+
+
+ // Convert speed bonus to duration multiplier
+ // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration.
+ aSpeedBonusPercent = Math.max(-99, aSpeedBonusPercent);
+ float tTimeFactor = 100.0f / (100.0f + aSpeedBonusPercent);
+ this.mMaxProgresstime = (int)(tRecipe.mDuration * tTimeFactor);
+
+ this.mEUt = (int)Math.ceil(tTotalEUt);
+
+ this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
+ this.mEfficiencyIncrease = 10000;
+
+ // Overclock
+ if (this.mEUt <= 16) {
+ this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1));
+ this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1));
+ } else {
+ while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) {
+ this.mEUt *= 4;
+ this.mMaxProgresstime /= 2;
+ }
+ }
+
+ if (this.mEUt > 0) {
+ this.mEUt = (-this.mEUt);
+ }
+
+
+ this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime);
+
+ // Collect fluid outputs
+ FluidStack[] tOutputFluids = new FluidStack[tRecipe.mFluidOutputs.length];
+ for (int h = 0; h < tRecipe.mFluidOutputs.length; h++) {
+ if (tRecipe.getFluidOutput(h) != null) {
+ tOutputFluids[h] = tRecipe.getFluidOutput(h).copy();
+ tOutputFluids[h].amount *= parallelRecipes;
+ }
+ }
+
+ // Collect output item types
+ ItemStack[] tOutputItems = new ItemStack[tRecipe.mOutputs.length];
+ for (int h = 0; h < tRecipe.mOutputs.length; h++) {
+ if (tRecipe.getOutput(h) != null) {
+ tOutputItems[h] = tRecipe.getOutput(h).copy();
+ tOutputItems[h].stackSize = 0;
+ }
+ }
+
+ // Set output item stack sizes (taking output chance into account)
+ for (int f = 0; f < tOutputItems.length; f++) {
+ if (tRecipe.mOutputs[f] != null && tOutputItems[f] != null) {
+ for (int g = 0; g < parallelRecipes; g++) {
+ if (getBaseMetaTileEntity().getRandomNumber(aOutputChanceRoll) < tRecipe.getOutputChance(f))
+ tOutputItems[f].stackSize += tRecipe.mOutputs[f].stackSize;
+ }
+ }
+ }
+
+ tOutputItems = removeNulls(tOutputItems);
+
+ // Sanitize item stack size, splitting any stacks greater than max stack size
+ List<ItemStack> splitStacks = new ArrayList<ItemStack>();
+ for (ItemStack tItem : tOutputItems) {
+ while (tItem.getMaxStackSize() < tItem.stackSize) {
+ ItemStack tmp = tItem.copy();
+ tmp.stackSize = tmp.getMaxStackSize();
+ tItem.stackSize = tItem.stackSize - tItem.getMaxStackSize();
+ splitStacks.add(tmp);
+ }
+ }
+
+ if (splitStacks.size() > 0) {
+ ItemStack[] tmp = new ItemStack[splitStacks.size()];
+ tmp = splitStacks.toArray(tmp);
+ tOutputItems = ArrayUtils.addAll(tOutputItems, tmp);
+ }
+
+ // Strip empty stacks
+ List<ItemStack> tSList = new ArrayList<ItemStack>();
+ for (ItemStack tS : tOutputItems) {
+ if (tS.stackSize > 0) tSList.add(tS);
+ }
+ tOutputItems = tSList.toArray(new ItemStack[tSList.size()]);
+
+ // Commit outputs
+ this.mOutputItems = tOutputItems;
+ this.mOutputFluids = tOutputFluids;
+ updateSlots();
+
+ // Play sounds (GT++ addition - GT multiblocks play no sounds)
+ startProcess();
+
+ log("GOOD RETURN - 1");
+ return true;
+ }
+
+ private int getCatalysts(ItemStack[] aItemInputs,ItemStack aRecipeCatalyst,int aMaxParrallel,ArrayList<ItemStack> aOutPut) {
+ int allowedParrallel = 0;
+ for (final ItemStack aInput : aItemInputs) {
+ if (aRecipeCatalyst.isItemEqual(aInput)) {
+ if (aInput.stackSize == 1) {
+ int damage = getDamage(aInput) + aMaxParrallel;
+ if (damage > getMaxCatalystDurability() ) {
+ aOutPut.add(aInput);
+ allowedParrallel += aMaxParrallel + (getMaxCatalystDurability() - damage);
+ if (allowedParrallel >aMaxParrallel ) {
+ return aMaxParrallel;
+ }
+ continue;
+ }
+ }
+ aOutPut.add(aInput);
+ return aMaxParrallel;
+ }
+ }
+ return allowedParrallel;
}
+ private ItemStack findCatalyst(ItemStack[] aItemInputs) {
+ if (aItemInputs != null) {
+ for (final ItemStack aInput : aItemInputs) {
+ if (aInput != null) {
+ if (aInput.isItemEqual(GenericChem.mRedCatalyst))
+ return aInput;
+ else if (aInput.isItemEqual(GenericChem.mYellowCatalyst))
+ return aInput;
+ else if (aInput.isItemEqual(GenericChem.mBlueCatalyst))
+ return aInput;
+ else if (aInput.isItemEqual(GenericChem.mOrangeCatalyst))
+ return aInput;
+ else if (aInput.isItemEqual(GenericChem.mPurpleCatalyst))
+ return aInput;
+ else if (aInput.isItemEqual(AgriculturalChem.mGreenCatalyst))
+ return aInput;
+ else if (aInput.isItemEqual(GenericChem.mBrownCatalyst))
+ return aInput;
+ }
+ }
+ }
+ return null;
+ }
+
+
+ private void damageCatalyst(ItemStack aStack) {
+ if (MathUtils.randFloat(0, 10000000)/10000000f < (1.2f - (0.2 * this.mPipeCasingTier))) {
+ int damage = getDamage(aStack) + 1;
+ log("damage catalyst "+damage);
+ if (damage >= getMaxCatalystDurability()) {
+ log("consume catalyst");
+ ItemStack emptyCatalyst = ItemUtils.getSimpleStack(AgriculturalChem.mCatalystCarrier,1);
+ addOutput(emptyCatalyst);
+ setDamage(aStack,0);
+ aStack.stackSize -= 1;
+ }
+ else {
+ setDamage(aStack,damage);
+ }
+ }
+ else {
+ log("not consuming catalyst");
+ }
+ }
+
+ private int getDamage(ItemStack aStack) {
+ if (aStack.getTagCompound() == null || aStack.getTagCompound().hasNoTags()) {
+ final NBTTagCompound tagMain = new NBTTagCompound();
+ final NBTTagCompound tagNBT = new NBTTagCompound();
+ tagNBT.setInteger("Damage", 0);
+ tagMain.setTag("catalyst", tagNBT);
+ aStack.setTagCompound(tagMain);
+ }
+ NBTTagCompound aNBT = aStack.getTagCompound();
+ return aNBT.getCompoundTag("catalyst").getInteger("Damage");
+ }
+
+ private void setDamage(ItemStack aStack,int aAmount) {
+ NBTTagCompound aNBT = aStack.getTagCompound();
+ aNBT = aNBT.getCompoundTag("catalyst");
+ aNBT.setInteger("Damage", aAmount);
+ }
+
@SideOnly(Side.CLIENT)