aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity/implementations
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity/implementations')
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java5
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java37
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java44
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java22
4 files changed, 77 insertions, 31 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java
index 5835a6c9ab..1a81e4d570 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java
@@ -240,6 +240,7 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier
mChargeableCount++;
}
}
+ count++;
}
@Override
@@ -309,11 +310,11 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier
@Override
public String[] getInfoData() {
- count++;
- if (mMax == 0 || count % 20 == 0) {
+ if (mMax == 0 || (count > 20)) {
long[] tmp = getStoredEnergy();
mStored = tmp[0];
mMax = tmp[1];
+ count = 0;
}
return new String[]{
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java
index d57aff8fc9..26e816a52c 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java
@@ -43,19 +43,30 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan
@Override
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
- int textureIndex=actualTexture|(mTexturePage<<7);//Shift seven since one page is 128 textures!
- int texturePointer=(byte)(actualTexture&0x7F);//just to be sure, from my testing the 8th bit cannot be set clientside
- return aSide != aFacing ?
- textureIndex > 0 ?
- new ITexture[]{Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]} :
- new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]} :
- textureIndex > 0 ?
- aActive ?
- getTexturesActive(Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]) :
- getTexturesInactive(Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]) :
- aActive ?
- getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]) :
- getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]);
+ int textureIndex = actualTexture | (mTexturePage << 7);//Shift seven since one page is 128 textures!
+ int texturePointer = (byte) (actualTexture & 0x7F);//just to be sure, from my testing the 8th bit cannot be set clientside
+ try {
+ if (aSide != aFacing) {
+ if (textureIndex > 0)
+ return new ITexture[]{Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]};
+ else
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]};
+ } else {
+ if (textureIndex > 0) {
+ if (aActive)
+ return getTexturesActive(Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]);
+ else
+ return getTexturesInactive(Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]);
+ } else {
+ if (aActive)
+ return getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]);
+ else
+ return getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]);
+ }
+ }
+ } catch (NullPointerException npe) {
+ return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[0][0]};
+ }
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java
index 9c74811b23..71eea9bf87 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java
@@ -10,9 +10,9 @@ import gregtech.api.util.GT_Utility;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
-import net.minecraftforge.fluids.FluidStack;
-import net.minecraftforge.fluids.IFluidHandler;
+import net.minecraftforge.fluids.*;
public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
private String lockedFluidName = null;
@@ -207,7 +207,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
playerThatLockedfluid = aPlayer;
if (mFluid == null) {
this.setLockedFluidName(null);
- inBrackets = trans("115.3","currently none, will be locked to the next that is put in");
+ inBrackets = trans("115.3","currently none, will be locked to the next that is put in (or use fluid cell to lock)");
} else {
this.setLockedFluidName(this.getDrainableStack().getUnlocalizedName());
inBrackets = this.getDrainableStack().getLocalizedName();
@@ -218,7 +218,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
playerThatLockedfluid = aPlayer;
if (mFluid == null) {
this.setLockedFluidName(null);
- inBrackets = trans("115.3","currently none, will be locked to the next that is put in");
+ inBrackets = trans("115.3","currently none, will be locked to the next that is put in (or use fluid cell to lock)");
} else {
this.setLockedFluidName(this.getDrainableStack().getUnlocalizedName());
inBrackets = this.getDrainableStack().getLocalizedName();
@@ -227,7 +227,41 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch {
break;
}
}
-
+ private boolean tryToLockHatch(EntityPlayer aPlayer, byte aSide) {
+ if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity()))
+ return false;
+ if (!isFluidLocked())
+ return false;
+ ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem();
+ if (tCurrentItem == null)
+ return false;
+ FluidStack tFluid = FluidContainerRegistry.getFluidForFilledItem(tCurrentItem);
+ if (tFluid == null && tCurrentItem.getItem() instanceof IFluidContainerItem)
+ tFluid = ((IFluidContainerItem)tCurrentItem.getItem()).getFluid(tCurrentItem);
+ if (tFluid != null) {
+ if (getLockedFluidName() != null && !getLockedFluidName().equals(tFluid.getUnlocalizedName())) {
+ GT_Utility.sendChatToPlayer(aPlayer, String.format("%s %s", trans("151.3",
+ "Hatch is locked to a different fluid. To change the locking, empty it and made it locked to the next fluid with a screwdriver. Currently locked to")
+ , StatCollector.translateToLocal(getLockedFluidName())));
+ }
+ else {
+ setLockedFluidName(tFluid.getUnlocalizedName());
+ if (mMode == 8)
+ GT_Utility.sendChatToPlayer(aPlayer, String.format("%s (%s)", trans("151.1", "Outputs items and 1 specific Fluid"), tFluid.getLocalizedName()));
+ else
+ GT_Utility.sendChatToPlayer(aPlayer, String.format("%s (%s)", trans("151.2", "Outputs 1 specific Fluid"), tFluid.getLocalizedName()));
+ }
+ return true;
+ }
+ return false;
+ }
+ @Override
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) {
+ if (tryToLockHatch(aPlayer, aSide))
+ return true;
+ return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ);
+ }
+
public String trans(String aKey, String aEnglish){
return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false);
}
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 2da97a1939..da80a9e231 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
@@ -8,8 +8,6 @@ import java.util.ArrayList;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.enums.ConfigCategories;
-import gregtech.api.enums.Materials;
-import gregtech.api.enums.OrePrefixes;
import gregtech.api.gui.GT_Container_MultiMachine;
import gregtech.api.gui.GT_GUIContainer_MultiMachine;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
@@ -19,7 +17,6 @@ import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_ModHandler;
-import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map;
import gregtech.api.util.GT_Utility;
import gregtech.common.GT_Pollution;
@@ -435,7 +432,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
NBTTagCompound tNBT = mInventory[1].getTagCompound();
if (tNBT != null) {
NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents");//tNBT2 dont use out if
- if (!tNBT.getBoolean("mDis")) {
+ /*if (!tNBT.getBoolean("mDis")) {
tNBT2 = new NBTTagCompound();
Materials tMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[1]);
ItemStack tTurbine = GT_OreDictUnificator.get(OrePrefixes.turbineBlade, tMaterial, 1);
@@ -487,7 +484,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
tNBT.setBoolean("mDis", true);
mInventory[1].setTagCompound(tNBT);
- }
+ }*/
}
((GT_MetaGenerated_Tool) mInventory[1].getItem()).doDamage(mInventory[1], (long)getDamageToComponent(mInventory[1]) * (long) Math.min(mEUt / this.damageFactorLow, Math.pow(mEUt, this.damageFactorHigh)));
if (mInventory[1].stackSize == 0) mInventory[1] = null;
@@ -566,7 +563,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
//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)) {
@@ -574,11 +571,14 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
aVoltage = aDynamo.maxEUOutput();
aAmpsToInject = (int) (leftToInject / aVoltage);
aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage));
- long powerGain;
- for (int i = 0; i < Math.min(aDynamo.maxAmperesOut(), aAmpsToInject > 0 ? aAmpsToInject : 1); i++) {
- powerGain = aAmpsToInject > 0 ? aVoltage : aRemainder;
- aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(powerGain, false);
- injected += powerGain;
+ ampsOnCurrentHatch= (int) Math.min(aDynamo.maxAmperesOut(), aAmpsToInject);
+ for (int i = 0; i < ampsOnCurrentHatch; i++) {
+ aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aVoltage, false);
+ }
+ injected+=aVoltage*ampsOnCurrentHatch;
+ if(aRemainder>0 && ampsOnCurrentHatch<aDynamo.maxAmperesOut()){
+ aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aRemainder, false);
+ injected+=aRemainder;
}
}
}