aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity')
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java12
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java49
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseTileEntity.java22
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java3
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java46
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java2
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java65
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java156
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java11
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java97
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java11
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java93
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java2
13 files changed, 357 insertions, 212 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java
index b9c8641a86..6025e7eb13 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java
@@ -54,7 +54,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING];
private boolean mInventoryChanged = false, mWorkUpdate = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false;
private boolean mCheckConnections = false;
- private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0;
+ private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0;
private int oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0;
private short mID = 0;
private long mTickTimer = 0;
@@ -308,11 +308,12 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData);
}
- if (mNeedsBlockUpdate) {
- worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0));
- mNeedsBlockUpdate = false;
+ if (mNeedsBlockUpdate) {
+ updateNeighbours(mStrongRedstone, oStrongRedstone);
+ oStrongRedstone = mStrongRedstone;
+ mNeedsBlockUpdate = false;
+ }
}
- }
default:
tCode = -1;
break;
@@ -907,6 +908,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
mStrongRedstone ^= (1 << tSide);
GT_Utility.sendChatToPlayer(aPlayer, trans("091","Redstone Output at Side ") + tSide + trans("092"," set to: ") + ((mStrongRedstone & (1 << tSide)) != 0 ? trans("093","Strong") : trans("094","Weak")));
GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord);
+ issueBlockUpdate();
}
doEnetUpdate();
return true;
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index 63c88cfd0a..cfb34eb34e 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -62,7 +62,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
private byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15};
private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING];
private boolean mHasEnoughEnergy = true, mRunningThroughTick = false, mInputDisabled = false, mOutputDisabled = false, mMuffler = false, mLockUpgrade = false, mActive = false, mRedstone = false, mWorkUpdate = false, mSteamConverter = false, mInventoryChanged = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false, oRedstone = false;
- private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage=0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0;
+ private byte mColor = 0, oColor = 0, oStrongRedstone = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage=0, oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0;
private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0;
private short mID = 0;
public long mTickTimer = 0;
@@ -447,11 +447,16 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
}
if (getRandomNumber(1000) == 0) {
+ int precipitationHeightAtSide2 = worldObj.getPrecipitationHeight(xCoord, zCoord - 1);
+ int precipitationHeightAtSide3 = worldObj.getPrecipitationHeight(xCoord, zCoord + 1);
+ int precipitationHeightAtSide4 = worldObj.getPrecipitationHeight(xCoord - 1, zCoord);
+ int precipitationHeightAtSide5 = worldObj.getPrecipitationHeight(xCoord + 1, zCoord);
+
if ((getCoverIDAtSide((byte) 1) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord)
- || (getCoverIDAtSide((byte) 2) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord - 1) - 1 < yCoord)
- || (getCoverIDAtSide((byte) 3) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord + 1) - 1 < yCoord)
- || (getCoverIDAtSide((byte) 4) == 0 && worldObj.getPrecipitationHeight(xCoord - 1, zCoord) - 1 < yCoord)
- || (getCoverIDAtSide((byte) 5) == 0 && worldObj.getPrecipitationHeight(xCoord + 1, zCoord) - 1 < yCoord)) {
+ || (getCoverIDAtSide((byte) 2) == 0 && precipitationHeightAtSide2 - 1 < yCoord && precipitationHeightAtSide2 > -1)
+ || (getCoverIDAtSide((byte) 3) == 0 && precipitationHeightAtSide3 - 1 < yCoord && precipitationHeightAtSide3 > -1)
+ || (getCoverIDAtSide((byte) 4) == 0 && precipitationHeightAtSide4 - 1 < yCoord && precipitationHeightAtSide4 > -1)
+ || (getCoverIDAtSide((byte) 5) == 0 && precipitationHeightAtSide5 - 1 < yCoord && precipitationHeightAtSide5 > -1)) {
if (GregTech_API.sMachineRainExplosions && worldObj.isRaining() && getBiome().rainfall > 0) {
if (getRandomNumber(10) == 0) {
try{
@@ -496,15 +501,17 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) {
if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) {
dischargeItem(mMetaTileEntity.mInventory[i]);
- if(ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i])>0){
+ if(ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i])>0){
if((getStoredEU() + ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i]))<getEUCapacity()){
increaseStoredEnergyUnits((long)ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i]),false);
mMetaTileEntity.mInventory[i].stackSize--;
+ mInventoryChanged = true;
}
}
- if (mMetaTileEntity.mInventory[i].stackSize <= 0)
+ if (mMetaTileEntity.mInventory[i].stackSize <= 0) {
mMetaTileEntity.mInventory[i] = null;
- mInventoryChanged = true;
+ mInventoryChanged = true;
+ }
}
}
}
@@ -516,9 +523,10 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) {
if (getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) {
chargeItem(mMetaTileEntity.mInventory[i]);
- if (mMetaTileEntity.mInventory[i].stackSize <= 0)
+ if (mMetaTileEntity.mInventory[i].stackSize <= 0) {
mMetaTileEntity.mInventory[i] = null;
- mInventoryChanged = true;
+ mInventoryChanged = true;
+ }
}
}
}
@@ -545,7 +553,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
NW.sendPacketToAllPlayersInRange(worldObj,
new GT_Packet_TileEntity(xCoord, (short) yCoord, zCoord, mID,
mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5],
- oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)),
+ oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0) | (mWorks ? 64 : 0) ),
oTexturePage = (hasValidMetaTileEntity() && mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) ? ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage() : 0,
oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0,
oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)),
@@ -556,7 +564,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
}
if (mTickTimer > 10) {
- byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0));
+ byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)| (mWorks ? 64 : 0));
if (tData != oTextureData) sendBlockEvent((byte) 0, oTextureData = tData);
tData = mMetaTileEntity.getUpdateData();
@@ -583,7 +591,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
}
if (mNeedsBlockUpdate) {
- worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0));
+ updateNeighbours(mStrongRedstone, oStrongRedstone);
+ oStrongRedstone = mStrongRedstone;
mNeedsBlockUpdate = false;
}
}
@@ -681,6 +690,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mActive = ((aValue & 8) != 0);
mRedstone = ((aValue & 16) != 0);
//mLockUpgrade = ((aValue&32) != 0);
+ mWorks = ((aValue & 64) != 0);
break;
case 1:
if (hasValidMetaTileEntity()) {
@@ -1395,6 +1405,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mStrongRedstone ^= (1 << tSide);
GT_Utility.sendChatToPlayer(aPlayer, trans("091","Redstone Output at Side ") + tSide + trans("092"," set to: ") + ((mStrongRedstone & (1 << tSide)) != 0 ? trans("093","Strong") : trans("094","Weak")));
GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord);
+ issueBlockUpdate();
}
doEnetUpdate();
return true;
@@ -1724,15 +1735,19 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
@Override
public long getAverageElectricInput() {
long rEU = 0;
- for (long tEU : mAverageEUInput) rEU += tEU;
- return rEU / mAverageEUInput.length;
+ for (int i = 0; i < mAverageEUInput.length; ++i)
+ if (i != mAverageEUInputIndex)
+ rEU += mAverageEUInput[i];
+ return rEU / (mAverageEUInput.length - 1);
}
@Override
public long getAverageElectricOutput() {
long rEU = 0;
- for (long tEU : mAverageEUOutput) rEU += tEU;
- return rEU / mAverageEUOutput.length;
+ for (int i = 0; i < mAverageEUOutput.length; ++i)
+ if (i != mAverageEUOutputIndex)
+ rEU += mAverageEUOutput[i];
+ return rEU / (mAverageEUOutput.length - 1);
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java
index f5ba784162..dcaa98f120 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java
@@ -427,6 +427,28 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje
clearNullMarkersFromTileEntityBuffer();
}
+ public void updateNeighbours(int mStrongRedstone, int oStrongRedstone) {
+ Block thisBlock = getBlockOffset(0, 0, 0);
+ for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
+ int x1 = xCoord + dir.offsetX, y1 = yCoord + dir.offsetY, z1 = zCoord + dir.offsetZ;
+
+ if (worldObj.blockExists(x1, y1, z1)) {
+ worldObj.notifyBlockOfNeighborChange(x1, y1, z1, thisBlock);
+
+ //update if it was / is strong powered.
+ if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0 ) && getBlock(x1, y1, z1).isNormalCube()) {
+ int skipUpdateSide = dir.getOpposite().ordinal(); //Don't update this block. Still updates diagonal blocks twice if conditions meet.
+
+ for (ForgeDirection dir2 : ForgeDirection.VALID_DIRECTIONS) {
+ int x2 = x1 + dir2.offsetX, y2 = y1 + dir2.offsetY, z2 = z1 + dir2.offsetZ;
+ if (dir2.ordinal() != skipUpdateSide && worldObj.blockExists(x2, y2, z2))
+ worldObj.notifyBlockOfNeighborChange(x2, y2, z2, thisBlock);
+ }
+ }
+ }
+ }
+ }
+
@Override
public final void sendBlockEvent(byte aID, byte aValue) {
NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_Block_Event(xCoord, (short) yCoord, zCoord, aID, aValue), xCoord, zCoord);
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java
index 3373b142c4..02d6752bdd 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java
@@ -24,7 +24,6 @@ import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
import gregtech.common.GT_Client;
import gregtech.common.covers.GT_Cover_SolarPanel;
-import gregtech.loaders.postload.PartP2PGTPower;
import ic2.api.energy.EnergyNet;
import ic2.api.energy.tile.IEnergyEmitter;
import ic2.api.energy.tile.IEnergySink;
@@ -423,8 +422,6 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile
// AE2-p2p Compat
if (GT_Mod.gregtechproxy.mAE2Integration) {
- if (tTileEntity instanceof IEnergySource && tTileEntity instanceof IPartHost && ((IPartHost)tTileEntity).getPart(tDir) instanceof PartP2PGTPower && ((IEnergySource) tTileEntity).emitsEnergyTo((TileEntity) baseMetaTile, tDir))
- return true;
if (tTileEntity instanceof appeng.tile.powersink.IC2 && ((appeng.tile.powersink.IC2)tTileEntity).acceptsEnergyFrom((TileEntity)baseMetaTile, tDir))
return true;
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java
index 0767bd0081..2afc996df2 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java
@@ -1,8 +1,12 @@
package gregtech.api.metatileentity.implementations;
+import cpw.mods.fml.common.Optional;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
-import gregtech.api.enums.*;
+import gregtech.api.enums.Dyes;
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.ICoverable;
@@ -104,7 +108,13 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
{1, 0, 2, 3},
{1, 0, 2, 3}
};
- if (aSide >= 0 && aSide < 6) for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i;
+ if (aSide >= 0 && aSide < 6) {
+ for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i;
+ //Full block size renderer flips side 5 and 2 textures, flip restrictor textures to compensate
+ if (aSide == 5 || aSide == 2 || aSide == 0)
+ if (tMask > 3 && tMask < 12)
+ tMask = (byte) (tMask ^ 12);
+ }
return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), getRestrictorTexture(tMask)};
}
@@ -383,36 +393,46 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity {
@Override
public boolean canConnect(byte aSide, TileEntity tTileEntity) {
- if (tTileEntity == null) return false;
+ if (tTileEntity == null)
+ return false;
final byte tSide = (byte)ForgeDirection.getOrientation(aSide).getOpposite().ordinal();
final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity();
- if (baseMetaTile == null) return false;
+ if (baseMetaTile == null)
+ return false;
final GT_CoverBehavior coverBehavior = baseMetaTile.getCoverBehaviorAtSide(aSide);
final IGregTechTileEntity gTileEntity = (tTileEntity instanceof IGregTechTileEntity) ? (IGregTechTileEntity) tTileEntity : null;
- if (coverBehavior instanceof GT_Cover_Drain) return true;
-
- // Tinker Construct Faucets return a null tank info, so check the class
- if (GregTech_API.mTConstruct && tTileEntity instanceof tconstruct.smeltery.logic.FaucetLogic) return true;
+ if (coverBehavior instanceof GT_Cover_Drain || (GregTech_API.mTConstruct && isTConstructFaucet(tTileEntity)))
+ return true;
final IFluidHandler fTileEntity = (tTileEntity instanceof IFluidHandler) ? (IFluidHandler) tTileEntity : null;
if (fTileEntity != null) {
FluidTankInfo[] tInfo = fTileEntity.getTankInfo(ForgeDirection.getOrientation(tSide));
if (tInfo != null) {
- if (tInfo.length > 0) return true;
-
- // Translocators return a TankInfo, but it's of 0 length - so check the class if we see this pattern
- if (GregTech_API.mTranslocator && tTileEntity instanceof codechicken.translocator.TileLiquidTranslocator) return true;
- if (gTileEntity != null && gTileEntity.getCoverBehaviorAtSide(tSide) instanceof GT_Cover_FluidRegulator) return true;
+ return tInfo.length > 0
+ || (GregTech_API.mTranslocator && isTranslocator(tTileEntity))
+ || gTileEntity != null && gTileEntity.getCoverBehaviorAtSide(tSide) instanceof GT_Cover_FluidRegulator;
}
}
return false;
}
+ @Optional.Method(modid = "TConstruct")
+ private boolean isTConstructFaucet(TileEntity tTileEntity){
+ // Tinker Construct Faucets return a null tank info, so check the class
+ return tTileEntity instanceof tconstruct.smeltery.logic.FaucetLogic;
+ }
+
+ @Optional.Method(modid = "Translocator")
+ private boolean isTranslocator(TileEntity tTileEntity){
+ // Translocators return a TankInfo, but it's of 0 length - so check the class if we see this pattern
+ return tTileEntity instanceof codechicken.translocator.TileLiquidTranslocator;
+ }
+
@Override
public boolean getGT6StyleConnection() {
// Yes if GT6 pipes are enabled
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
index 650e9a031e..c73e95e95b 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java
@@ -270,7 +270,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE
TileEntity tInventory = getBaseMetaTileEntity().getTileEntityAtSide(aSide);
if (tInventory != null && !(tInventory instanceof BaseMetaPipeEntity)) {
if ((!(tInventory instanceof TileEntityHopper) && !(tInventory instanceof TileEntityDispenser)) || getBaseMetaTileEntity().getMetaIDAtSide(aSide) != GT_Utility.getOppositeSide(aSide)) {
- return GT_Utility.moveOneItemStack(aSender, tInventory, (byte) 6, GT_Utility.getOppositeSide(aSide), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1) > 0;
+ return GT_Utility.moveMultipleItemStacks(aSender, tInventory, (byte) 6, GT_Utility.getOppositeSide(aSide), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,1) > 0;
}
}
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
index 1c5b90f7db..2c632c596b 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
@@ -7,6 +7,7 @@ import gregtech.api.enums.Textures;
import gregtech.api.gui.GT_Container_BasicMachine;
import gregtech.api.gui.GT_GUIContainer_BasicMachine;
import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMachineCallback;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.GT_RenderedTexture;
@@ -15,6 +16,7 @@ import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
+import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_Cleanroom;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -30,6 +32,7 @@ import java.util.Arrays;
import static gregtech.api.enums.GT_Values.V;
import static gregtech.api.enums.GT_Values.debugCleanroom;
+import static gregtech.api.util.GT_Utility.moveMultipleItemStacks;
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
@@ -37,7 +40,8 @@ import static gregtech.api.enums.GT_Values.debugCleanroom;
* This is the main construct for my Basic Machines such as the Automatic Extractor
* Extend this class to make a simple Machine
*/
-public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank {
+public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank implements IMachineCallback<GT_MetaTileEntity_Cleanroom> {
+
/**
* return values for checkRecipe()
*/
@@ -51,8 +55,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false;
public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0;
public FluidStack mOutputFluid;
- public String mGUIName = "", mNEIName = "";
- public GT_MetaTileEntity_MultiBlockBase mCleanroom;
+ public String mGUIName, mNEIName;
+
+
+ @Deprecated
+ public GT_MetaTileEntity_Cleanroom mCleanroom;
/**
* Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered
*/
@@ -126,6 +133,21 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
}
@Override
+ public GT_MetaTileEntity_Cleanroom getCallbackBase() {
+ return this.mCleanroom;
+ }
+
+ @Override
+ public void setCallbackBase(GT_MetaTileEntity_Cleanroom callback) {
+ this.mCleanroom = callback;
+ }
+
+ @Override
+ public Class<GT_MetaTileEntity_Cleanroom> getType() {
+ return GT_MetaTileEntity_Cleanroom.class;
+ }
+
+ @Override
public ITexture[][][] getTextureSet(ITexture[] aTextures) {
ITexture[][][] rTextures = new ITexture[14][17][];
aTextures = Arrays.copyOf(aTextures, 14);
@@ -449,7 +471,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy());
else if (mOutputFluid.isFluidEqual(getDrainableStack()))
getDrainableStack().amount += mOutputFluid.amount;
- for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null;
+ Arrays.fill(mOutputItems, null);
mOutputFluid = null;
mEUt = 0;
mProgresstime = 0;
@@ -489,10 +511,17 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) {
TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing());
- for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) {
- tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
- if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true);
- }
+ long tStoredEnergy = aBaseMetaTileEntity.getUniversalEnergyStored();
+ int tMaxStacks = (int)(tStoredEnergy/64l);
+ if (tMaxStacks > mOutputItems.length)
+ tMaxStacks = mOutputItems.length;
+
+ int tCost = moveMultipleItemStacks(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,tMaxStacks);
+ aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCost, true);
+// for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) {
+// tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
+// if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true);
+// }
}
if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0;
@@ -518,7 +547,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
startProcess();
} else {
mMaxProgresstime = 0;
- for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null;
+ Arrays.fill(mOutputItems, null);
mOutputFluid = null;
}
}
@@ -584,7 +613,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
//Long EUt calculation
long xEUt=aEUt;
//Isnt too low EUt check?
- long tempEUt = xEUt<V[1] ? V[1] : xEUt;
+ long tempEUt = Math.max(xEUt, V[1]);
mMaxProgresstime = aDuration;
@@ -652,7 +681,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
protected boolean isOutputEmpty() {
boolean rIsEmpty = true;
- for (ItemStack tOutputSlotContent : getAllOutputs()) if (tOutputSlotContent != null) rIsEmpty = false;
+ for (ItemStack tOutputSlotContent : getAllOutputs())
+ if (tOutputSlotContent != null) {
+ rIsEmpty = false;
+ break;
+ }
return rIsEmpty;
}
@@ -816,7 +849,9 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
/**
*
* @param skipOC disables OverclockedNess calculation and check - if you do you must implement your own method...
- * @return
+ * @return DID_NOT_FIND_RECIPE = 0,
+ * FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1,
+ * FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2;
*/
public int checkRecipe(boolean skipOC){
GT_Recipe_Map tMap = getRecipeList();
@@ -832,7 +867,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
mOutputBlocked++;
return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
}
- if (tRecipe.mSpecialValue == -200 && (mCleanroom == null || mCleanroom.mEfficiency == 0))
+ if (tRecipe.mSpecialValue == -200 && (getCallbackBase() == null || getCallbackBase().mEfficiency == 0))
return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs()))
return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;
@@ -841,12 +876,12 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B
mOutputItems[i] = tRecipe.getOutput(i);
if (tRecipe.mSpecialValue == -200 || tRecipe.mSpecialValue == -300)
for (int i = 0; i < mOutputItems.length; i++)
- if (mOutputItems[i] != null && getBaseMetaTileEntity().getRandomNumber(10000) > mCleanroom.mEfficiency)
+ if (mOutputItems[i] != null && getBaseMetaTileEntity().getRandomNumber(10000) > getCallbackBase().mEfficiency)
{
if (debugCleanroom) {
GT_Log.out.println(
"BasicMachine: Voiding output due to efficiency failure. mEfficiency = " +
- mCleanroom.mEfficiency
+ getCallbackBase().mEfficiency
);
}
mOutputItems[i] = null;
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java
index 73ab28822a..8758ea1a02 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java
@@ -8,11 +8,19 @@ import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.util.ForgeDirection;
import static gregtech.api.enums.GT_Values.V;
public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredMachineBlock {
- public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bStockingMode = true;
+ private static final int OUTPUT_INDEX = 0;
+ private static final int ARROW_RIGHT_INDEX = 1;
+ private static final int ARROW_DOWN_INDEX = 2;
+ private static final int ARROW_LEFT_INDEX = 3;
+ private static final int ARROW_UP_INDEX = 4;
+ private static final int FRONT_INDEX = 5;
+
+ public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bStockingMode = false;
public int mSuccess = 0, mTargetStackSize = 0;
public GT_MetaTileEntity_Buffer(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) {
@@ -33,74 +41,85 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
@Override
public ITexture[][][] getTextureSet(ITexture[] aTextures) {
- ITexture[][][] rTextures = new ITexture[6][17][];
- ITexture tIcon = getOverlayIcon(), tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT), tUp = new GT_RenderedTexture(Textures.BlockIcons.ARROW_UP), tDown = new GT_RenderedTexture(Textures.BlockIcons.ARROW_DOWN), tLeft = new GT_RenderedTexture(Textures.BlockIcons.ARROW_LEFT), tRight = new GT_RenderedTexture(Textures.BlockIcons.ARROW_RIGHT);
- for (byte i = -1; i < 16; i++) {
- rTextures[0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tOut};
- rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tRight, tIcon};
- rTextures[2][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tDown, tIcon};
- rTextures[3][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tLeft, tIcon};
- rTextures[4][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tUp, tIcon};
- rTextures[5][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tIcon};
+ ITexture[][][] rTextures = new ITexture[ForgeDirection.VALID_DIRECTIONS.length][17][];
+ ITexture tIcon = getOverlayIcon();
+ ITexture tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT);
+ ITexture tUp = new GT_RenderedTexture(Textures.BlockIcons.ARROW_UP);
+ ITexture tDown = new GT_RenderedTexture(Textures.BlockIcons.ARROW_DOWN);
+ ITexture tLeft = new GT_RenderedTexture(Textures.BlockIcons.ARROW_LEFT);
+ ITexture tRight = new GT_RenderedTexture(Textures.BlockIcons.ARROW_RIGHT);
+ for (int i = 0; i < rTextures[0].length; i++) {
+ rTextures[OUTPUT_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tOut};
+ rTextures[ARROW_RIGHT_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tRight, tIcon};
+ rTextures[ARROW_DOWN_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tDown, tIcon};
+ rTextures[ARROW_LEFT_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tLeft, tIcon};
+ rTextures[ARROW_UP_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tUp, tIcon};
+ rTextures[FRONT_INDEX][i] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i], tIcon};
}
return rTextures;
}
@Override
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
- if (aSide == aFacing) return mTextures[5][aColorIndex + 1];
- if (GT_Utility.getOppositeSide(aSide) == aFacing) return mTextures[0][aColorIndex + 1];
- switch (aFacing) {
- case 0:
- return mTextures[4][aColorIndex + 1];
- case 1:
- return mTextures[2][aColorIndex + 1];
- case 2:
- switch (aSide) {
- case 0:
- return mTextures[2][aColorIndex + 1];
- case 1:
- return mTextures[2][aColorIndex + 1];
- case 4:
- return mTextures[1][aColorIndex + 1];
- case 5:
- return mTextures[3][aColorIndex + 1];
+ int colorIndex = aColorIndex + 1;
+ ForgeDirection side = ForgeDirection.VALID_DIRECTIONS[aSide];
+ ForgeDirection facing = ForgeDirection.VALID_DIRECTIONS[aFacing];
+ if (side == facing) return mTextures[FRONT_INDEX][colorIndex];
+ if (ForgeDirection.OPPOSITES[aSide] == aFacing) return mTextures[OUTPUT_INDEX][colorIndex];
+ switch (facing) {
+ case DOWN:
+ return mTextures[ARROW_UP_INDEX][colorIndex]; // ARROW_UP
+ case UP:
+ return mTextures[ARROW_DOWN_INDEX][colorIndex]; // ARROW_DOWN
+ case NORTH:
+ switch (side) {
+ case DOWN:
+ case UP:
+ return mTextures[ARROW_DOWN_INDEX][colorIndex]; // ARROW_DOWN
+ case WEST:
+ return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT
+ case EAST:
+ return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT
+ default:
}
- case 3:
- switch (aSide) {
- case 0:
- return mTextures[4][aColorIndex + 1];
- case 1:
- return mTextures[4][aColorIndex + 1];
- case 4:
- return mTextures[3][aColorIndex + 1];
- case 5:
- return mTextures[1][aColorIndex + 1];
+ break;
+ case SOUTH:
+ switch (side) {
+ case DOWN:
+ case UP:
+ return mTextures[ARROW_UP_INDEX][colorIndex]; // ARROW_UP
+ case WEST:
+ return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT
+ case EAST:
+ return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT
+ default:
}
- case 4:
- switch (aSide) {
- case 0:
- return mTextures[3][aColorIndex + 1];
- case 1:
- return mTextures[1][aColorIndex + 1];
- case 2:
- return mTextures[3][aColorIndex + 1];
- case 3:
- return mTextures[1][aColorIndex + 1];
+ break;
+ case WEST:
+ switch (side) {
+ case DOWN:
+ case UP:
+ case SOUTH:
+ return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT
+ case NORTH:
+ return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT
+ default:
}
- case 5:
- switch (aSide) {
- case 0:
- return mTextures[1][aColorIndex + 1];
- case 1:
- return mTextures[3][aColorIndex + 1];
- case 2:
- return mTextures[1][aColorIndex + 1];
- case 3:
- return mTextures[3][aColorIndex + 1];
+ break;
+ case EAST:
+ switch (side) {
+ case DOWN:
+ case UP:
+ case SOUTH:
+ return mTextures[ARROW_LEFT_INDEX][colorIndex]; // ARROW_LEFT
+ case NORTH:
+ return mTextures[ARROW_RIGHT_INDEX][colorIndex]; // ARROW_RIGHT
+ default:
}
+ break;
+ default:
}
- return mTextures[5][aColorIndex + 1];
+ return mTextures[FRONT_INDEX][colorIndex];
}
@Override
@@ -257,18 +276,15 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM
}
protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) {
- if( bStockingMode ) {
- int tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, (byte) 64, (byte) 1);
- if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) {
- mSuccess = 50;
- aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true);
- }
- } else {
- int tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, (byte) 64, (byte) 1, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize);
- if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) {
- mSuccess = 50;
- aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true);
- }
+ int tCost;
+ if( bStockingMode )
+ tCost = GT_Utility.moveMultipleItemStacks(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, (byte) 64, (byte) 1,1);
+ else
+ tCost = GT_Utility.moveMultipleItemStacks(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, (byte) 64, (byte) 1, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize,1);
+
+ if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) {
+ mSuccess = 50;
+ aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true);
}
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java
index 8c36c2af65..f2f76dca4f 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java
@@ -13,10 +13,12 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.StatCollector;
public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch {
public GT_Recipe_Map mRecipeMap = null;
public boolean disableSort;
+ public boolean disableFilter = false;
public GT_MetaTileEntity_Hatch_InputBus(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{
@@ -136,12 +138,14 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch {
public void saveNBTData(NBTTagCompound aNBT) {
super.saveNBTData(aNBT);
aNBT.setBoolean("disableSort", disableSort);
+ aNBT.setBoolean("disableFilter", disableFilter);
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
super.loadNBTData(aNBT);
disableSort = aNBT.getBoolean("disableSort");
+ disableFilter = aNBT.getBoolean("disableFilter");
}
@Override
@@ -151,6 +155,9 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch {
if (aPlayer.isSneaking()) {
disableSort = !disableSort;
GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Sort mode: " + (disableSort ? "Disabled" : "Enabled")));
+ } else {
+ disableFilter = !disableFilter;
+ GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableFilter."+disableFilter));
}
}
@@ -160,11 +167,11 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch {
@Override
public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- return false;
+ return aSide == getBaseMetaTileEntity().getFrontFacing();
}
@Override
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
- return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || mRecipeMap.containsInput(aStack));
+ return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || disableFilter || mRecipeMap.containsInput(aStack));
}
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java
index 9cadeaddc2..b3998b62e7 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java
@@ -12,6 +12,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
+import java.util.Arrays;
+
import static gregtech.api.objects.XSTR.XSTR_INSTANCE;
public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch {
@@ -53,10 +55,23 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch {
return true;
}
+ private int[] mFacings;
+
+ /*private void init()*/ {
+ setInValidFacings(ForgeDirection.DOWN);
+ }
+
+ public void setInValidFacings(ForgeDirection... aFacings) {
+ mFacings = Arrays.stream(aFacings).mapToInt(Enum::ordinal).toArray();
+ }
+
@Override
public boolean isFacingValid(byte aFacing) {
- return aFacing != 0;
- }
+ for (int x : mFacings)
+ if (x == aFacing)
+ return false;
+ return true;
+ }
@Override
public boolean isAccessAllowed(EntityPlayer aPlayer) {
@@ -80,9 +95,9 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch {
}
return false;
}
-
- public int calculatePollutionReduction(int aPollution){
- return (int) (aPollution *(Math.pow(0.85F, mTier - 1)));
+
+ public int calculatePollutionReduction(int aPollution) {
+ return (int) (aPollution * (Math.pow(0.85F, mTier - 1)));
}
@Override
@@ -98,51 +113,51 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch {
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
super.onPostTick(aBaseMetaTileEntity, aTick);
- if(aBaseMetaTileEntity.isClientSide() && this.getBaseMetaTileEntity().isActive())
- pollutionParticles(this.getBaseMetaTileEntity().getWorld(),"largesmoke");
- }
-
- public void pollutionParticles(World aWorld,String name){
- boolean chk1,chk2,chk3;
- float ran1=XSTR_INSTANCE.nextFloat(),ran2=0,ran3=0;
- chk1=ran1*100<calculatePollutionReduction(100);
- if(GT_Pollution.getPollution(getBaseMetaTileEntity())>= GT_Mod.gregtechproxy.mPollutionSmogLimit){
- ran2=XSTR_INSTANCE.nextFloat();
- ran3=XSTR_INSTANCE.nextFloat();
- chk2=ran2*100<calculatePollutionReduction(100);
- chk3=ran3*100<calculatePollutionReduction(100);
- if(!(chk1||chk2||chk3))return;
- }else{
- if(!chk1)return;
- chk2=chk3=false;
+ if (aBaseMetaTileEntity.isClientSide() && this.getBaseMetaTileEntity().isActive())
+ pollutionParticles(this.getBaseMetaTileEntity().getWorld(), "largesmoke");
+ }
+
+ public void pollutionParticles(World aWorld, String name) {
+ boolean chk1, chk2, chk3;
+ float ran1 = XSTR_INSTANCE.nextFloat(), ran2 = 0, ran3 = 0;
+ chk1 = ran1 * 100 < calculatePollutionReduction(100);
+ if (GT_Pollution.getPollution(getBaseMetaTileEntity()) >= GT_Mod.gregtechproxy.mPollutionSmogLimit) {
+ ran2 = XSTR_INSTANCE.nextFloat();
+ ran3 = XSTR_INSTANCE.nextFloat();
+ chk2 = ran2 * 100 < calculatePollutionReduction(100);
+ chk3 = ran3 * 100 < calculatePollutionReduction(100);
+ if (!(chk1 || chk2 || chk3)) return;
+ } else {
+ if (!chk1) return;
+ chk2 = chk3 = false;
}
- IGregTechTileEntity aMuffler=this.getBaseMetaTileEntity();
- ForgeDirection aDir=ForgeDirection.getOrientation(aMuffler.getFrontFacing());
- float xPos=aDir.offsetX*0.76F+aMuffler.getXCoord()+0.25F;
- float yPos=aDir.offsetY*0.76F+aMuffler.getYCoord()+0.25F;
- float zPos=aDir.offsetZ*0.76F+aMuffler.getZCoord()+0.25F;
+ IGregTechTileEntity aMuffler = this.getBaseMetaTileEntity();
+ ForgeDirection aDir = ForgeDirection.getOrientation(aMuffler.getFrontFacing());
+ float xPos = aDir.offsetX * 0.76F + aMuffler.getXCoord() + 0.25F;
+ float yPos = aDir.offsetY * 0.76F + aMuffler.getYCoord() + 0.25F;
+ float zPos = aDir.offsetZ * 0.76F + aMuffler.getZCoord() + 0.25F;
- float ySpd=aDir.offsetY*0.1F+0.2F+0.1F*XSTR_INSTANCE.nextFloat();
+ float ySpd = aDir.offsetY * 0.1F + 0.2F + 0.1F * XSTR_INSTANCE.nextFloat();
float xSpd;
float zSpd;
- if(aDir.offsetY==-1){
- float temp=XSTR_INSTANCE.nextFloat()*2*(float)Math.PI;
- xSpd=(float)Math.sin(temp)*0.1F;
- zSpd=(float)Math.cos(temp)*0.1F;
- }else{
- xSpd=aDir.offsetX*(0.1F+0.2F*XSTR_INSTANCE.nextFloat());
- zSpd=aDir.offsetZ*(0.1F+0.2F*XSTR_INSTANCE.nextFloat());
+ if (aDir.offsetY == -1) {
+ float temp = XSTR_INSTANCE.nextFloat() * 2 * (float) Math.PI;
+ xSpd = (float) Math.sin(temp) * 0.1F;
+ zSpd = (float) Math.cos(temp) * 0.1F;
+ } else {
+ xSpd = aDir.offsetX * (0.1F + 0.2F * XSTR_INSTANCE.nextFloat());
+ zSpd = aDir.offsetZ * (0.1F + 0.2F * XSTR_INSTANCE.nextFloat());
}
- if(chk1)
- aWorld.spawnParticle(name, xPos + ran1*0.5F, yPos + XSTR_INSTANCE.nextFloat()*0.5F, zPos + XSTR_INSTANCE.nextFloat()*0.5F, xSpd, ySpd, zSpd);
+ if (chk1)
+ aWorld.spawnParticle(name, xPos + ran1 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F, xSpd, ySpd, zSpd);
- if(chk2)
- aWorld.spawnParticle(name, xPos + ran2*0.5F, yPos + XSTR_INSTANCE.nextFloat()*0.5F, zPos + XSTR_INSTANCE.nextFloat()*0.5F, xSpd, ySpd, zSpd);
+ if (chk2)
+ aWorld.spawnParticle(name, xPos + ran2 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F, xSpd, ySpd, zSpd);
- if(chk3)
- aWorld.spawnParticle(name, xPos + ran3*0.5F, yPos + XSTR_INSTANCE.nextFloat()*0.5F, zPos + XSTR_INSTANCE.nextFloat()*0.5F, xSpd, ySpd, zSpd);
+ if (chk3)
+ aWorld.spawnParticle(name, xPos + ran3 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F, xSpd, ySpd, zSpd);
}
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java
index 6c56ac6a74..1dafbcce5a 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java
@@ -12,6 +12,8 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
+import static gregtech.api.util.GT_Utility.*;
+
public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch {
public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier, getSlots(aTier), new String[]{"Item Output for Multiblocks",
@@ -112,10 +114,11 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch {
if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && (aTick&0x7)==0) {
IInventory tTileEntity =aBaseMetaTileEntity.getIInventoryAtSide(aBaseMetaTileEntity.getFrontFacing());
if(tTileEntity!=null){
- for (ItemStack aMInventory : mInventory)
- GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity,
- aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(),
- null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1);
+ moveMultipleItemStacks(aBaseMetaTileEntity,tTileEntity,aBaseMetaTileEntity.getFrontFacing(),aBaseMetaTileEntity.getBackFacing(),null,false,(byte)64,(byte)1,(byte)64,(byte)1,mInventory.length);
+
+// GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity,
+// aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(),
+// null, false, (byte) 64, (byte) 1, (byte)( 64 * aBaseMetaTileEntity.getSizeInventory()), (byte) 1);
}
}
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
index 3efbe0d57b..202e542c88 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
@@ -1,10 +1,5 @@
package gregtech.api.metatileentity.implementations;
-import static gregtech.api.enums.GT_Values.V;
-import static gregtech.api.enums.GT_Values.VN;
-
-import java.util.ArrayList;
-
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.enums.ConfigCategories;
@@ -29,6 +24,11 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fluids.FluidStack;
+import java.util.ArrayList;
+
+import static gregtech.api.enums.GT_Values.V;
+import static gregtech.api.enums.GT_Values.VN;
+
public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
public static boolean disableMaintenance;
@@ -538,13 +538,6 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
aFirstVoltageFound = aVoltage;
}
else {
- /**
- * Calcualtes overclocked ness using long integers
- * @param aEUt - recipe EUt
- * @param aDuration - recipe Duration
- * @param mAmperage - should be 1 ?
- */
- //Long time calculation
if (aFirstVoltageFound != aVoltage) {
aFoundMixedDynamos = true;
}
@@ -559,13 +552,10 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
}
long leftToInject;
- //Long EUt calculation
long aVoltage;
- //Isnt too low EUt check?
int aAmpsToInject;
int aRemainder;
int ampsOnCurrentHatch;
- //xEUt *= 4;//this is effect of everclocking
for (GT_MetaTileEntity_Hatch_Dynamo aDynamo : mDynamoHatches) {
if (isValidMetaTileEntity(aDynamo)) {
leftToInject = aEU - injected;
@@ -594,51 +584,74 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
}
/**
- * Calcualtes overclocked ness using long integers
- * @param aEUt - recipe EUt
- * @param aDuration - recipe Duration
- * @param mAmperage - should be 1 ?
+ * Calcualtes the overclockedness using long integers
+ * @param aEUt - recipe EUt
+ * @param aDuration - recipe Duration
+ * @param mAmperage - should be 1 ?
+ * @param maxInputVoltage - Multiblock Max input voltage
+ * @param perfectOC - If the Multiblock OCs perfectly, i.e. the large Chemical Reactor
*/
- protected void calculateOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) {
- byte mTier=(byte)Math.max(0,GT_Utility.getTier(maxInputVoltage));
- if(mTier==0){
+ protected void calculateOverclockedNessMultiInternal(int aEUt, int aDuration, int mAmperage, long maxInputVoltage, boolean perfectOC) {
+ byte mTier = (byte) Math.max(0, GT_Utility.getTier(maxInputVoltage));
+ if(mTier == 0){
//Long time calculation
long xMaxProgresstime = ((long)aDuration)<<1;
- if(xMaxProgresstime>Integer.MAX_VALUE-1){
+ if(xMaxProgresstime > Integer.MAX_VALUE - 1){
//make impossible if too long
- mEUt=Integer.MAX_VALUE-1;
- mMaxProgresstime=Integer.MAX_VALUE-1;
+ mEUt = Integer.MAX_VALUE - 1;
+ mMaxProgresstime = Integer.MAX_VALUE - 1;
}else{
- mEUt=aEUt>>2;
- mMaxProgresstime=(int)xMaxProgresstime;
+ mEUt = aEUt >> 2;
+ mMaxProgresstime= (int) xMaxProgresstime;
}
}else{
//Long EUt calculation
- long xEUt=aEUt;
+ long xEUt = aEUt;
//Isnt too low EUt check?
- long tempEUt = xEUt<V[1] ? V[1] : xEUt;
+ long tempEUt = Math.max(xEUt, V[1]);
mMaxProgresstime = aDuration;
- while (tempEUt <= V[mTier -1] * mAmperage) {
- tempEUt<<=2;//this actually controls overclocking
+ final int ocTimeShift = perfectOC ? 2 : 1;
+
+ while (tempEUt <= V[mTier - 1] * mAmperage) {
+ tempEUt <<= 2;//this actually controls overclocking
//xEUt *= 4;//this is effect of everclocking
- mMaxProgresstime>>=1;//this is effect of overclocking
- xEUt = mMaxProgresstime==0 ? xEUt>>1 : xEUt<<2;//U know, if the time is less than 1 tick make the machine use less power
+ int oldTime = mMaxProgresstime;
+ mMaxProgresstime >>= ocTimeShift;//this is effect of overclocking
+ if (mMaxProgresstime <1)
+ {
+ if(oldTime == 1)
+ break;
+ xEUt *= oldTime * (perfectOC ? 1:2);
+ break;
+ }
+ else
+ {
+ xEUt <<= 2;
+ }
}
- if(xEUt>Integer.MAX_VALUE-1){
- mEUt = Integer.MAX_VALUE-1;
- mMaxProgresstime = Integer.MAX_VALUE-1;
- }else{
- mEUt = (int)xEUt;
- if(mEUt==0)
+ if(xEUt > Integer.MAX_VALUE - 1) {
+ mEUt = Integer.MAX_VALUE - 1;
+ mMaxProgresstime = Integer.MAX_VALUE - 1;
+ } else {
+ mEUt = (int) xEUt;
+ if(mEUt == 0)
mEUt = 1;
- if(mMaxProgresstime==0)
+ if(mMaxProgresstime == 0)
mMaxProgresstime = 1;//set time to 1 tick
}
}
}
+ protected void calculateOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) {
+ calculateOverclockedNessMultiInternal(aEUt,aDuration,mAmperage,maxInputVoltage,false);
+ }
+
+ protected void calculatePerfectOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) {
+ calculateOverclockedNessMultiInternal(aEUt,aDuration,mAmperage,maxInputVoltage,true);
+ }
+
public boolean drainEnergyInput(long aEU) {
if (aEU <= 0) return true;
for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches)
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java
index f33b8aa3d9..711670db08 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java
@@ -60,7 +60,7 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi
@Override
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
- return mTextures[Math.min(2, aSide) + (aSide == aFacing ? 3 : 0) + (aActive ? 0 : 6)][aColorIndex + 1];
+ return mTextures[Math.min(2, aSide) + (aSide == aFacing ? 3 : 0) + (aBaseMetaTileEntity.isAllowedToWork() ? 0 : 6)][aColorIndex + 1];
}
@Override