From 23de1f09edb99c58aee37182fd07cef642025060 Mon Sep 17 00:00:00 2001 From: Blood-Asp Date: Sun, 4 Jun 2017 00:26:31 +0200 Subject: [PATCH] Cleanroom controller outputs efficency as redstone signal #948 --- .../interfaces/metatileentity/IMetaTileEntity.java | 2 ++ .../api/metatileentity/BaseMetaTileEntity.java | 4 ++-- .../gregtech/api/metatileentity/MetaTileEntity.java | 5 +++++ .../implementations/GT_MetaTileEntity_Buffer.java | 6 ++++++ .../machines/multi/GT_MetaTileEntity_Cleanroom.java | 11 ++++++++++- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java index 64c5072c..2454392c 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java @@ -379,6 +379,8 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand public void onColorChangeClient(byte aColor); public int getLightOpacity(); + + public boolean allowGeneralRedstoneOutput(); public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List outputAABB, Entity collider); diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index b537ce71..2d3e00ae 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -65,7 +65,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE private long mTickTimer = 0, oOutput = 0, mAcceptedAmperes = Long.MAX_VALUE; private String mOwnerName = ""; private NBTTagCompound mRecipeStuff = new NBTTagCompound(); - + private static final Field ENTITY_ITEM_HEALTH_FIELD; static { @@ -1414,7 +1414,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE @Override public byte getOutputRedstoneSignal(byte aSide) { - return getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) ? mSidedRedstone[aSide] : 0; + return getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) ? mSidedRedstone[aSide] : mMetaTileEntity.allowGeneralRedstoneOutput() ? mSidedRedstone[aSide] : 0; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index 662dc59d..0561e871 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -863,4 +863,9 @@ public abstract class MetaTileEntity implements IMetaTileEntity { public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { // } + + @Override + public boolean allowGeneralRedstoneOutput(){ + return false; + } } \ No newline at end of file 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 abbf5b7e..fba40a13 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 @@ -224,6 +224,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isUniversalEnergyStored(getMinimumStoredEU()) && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || mSuccess > 0)) { mSuccess--; moveItems(aBaseMetaTileEntity, aTimer); + System.out.println("inv "+bInvert+" full "+bRedstoneIfFull); aBaseMetaTileEntity.setGenericRedstoneOutput(bInvert); if (bRedstoneIfFull) { aBaseMetaTileEntity.setGenericRedstoneOutput(!bInvert); @@ -256,4 +257,9 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return aSide != aBaseMetaTileEntity.getBackFacing(); } + + @Override + public boolean allowGeneralRedstoneOutput(){ + return true; + } } \ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java index 015670cb..6d3bf945 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_Cleanroom.java @@ -148,9 +148,18 @@ public class GT_MetaTileEntity_Cleanroom extends GT_MetaTileEntity_MultiBlockBas if (doorState) { mEfficiency = Math.max(0, mEfficiency - 200); } - + for(byte i = 0 ; i<6 ; i++){ + byte t = (byte) Math.max(1, (byte)(15/(10000f / mEfficiency))); + aBaseMetaTileEntity.setInternalOutputRedstoneSignal(i, t); + } + return true; } + + @Override + public boolean allowGeneralRedstoneOutput(){ + return true; + } public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == 0 || aSide == 1) {