diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity')
12 files changed, 956 insertions, 727 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java index e637365c1e..6967c8eb33 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java @@ -1,7 +1,9 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; +import java.util.Random; import gregtech.GT_Mod; import gregtech.api.GregTech_API; @@ -9,18 +11,39 @@ import gregtech.api.enums.GT_Values; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; -import gregtech.common.GT_Pollution; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; import ic2.api.Direction; +import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class BaseCustomTileEntity extends BaseMetaTileEntity { protected NBTTagCompound mRecipeStuff2; + private static final Field ENTITY_ITEM_HEALTH_FIELD_2; + + static { + Field f = null; + try { + f = EntityItem.class.getDeclaredField("field_70291_e"); + f.setAccessible(true); + } catch (Exception var4) { + try { + f = EntityItem.class.getDeclaredField("health"); + f.setAccessible(true); + } catch (Exception var3) { + var4.printStackTrace(); + var3.printStackTrace(); + } + } + + ENTITY_ITEM_HEALTH_FIELD_2 = f; + } public BaseCustomTileEntity() { super(); @@ -73,7 +96,14 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity { this.mReleaseEnergy = false; this.mMetaTileEntity.onExplosion(); int i; - if (GT_Mod.gregtechproxy.mExplosionItemDrop) { + + boolean aExplosionDropItem = false; + Object aProxyField = StaticFields59.getFieldFromGregtechProxy(false, "mExplosionItemDrop"); + if (boolean.class.isInstance(aProxyField) || Boolean.class.isInstance(aProxyField)) { + aExplosionDropItem = (boolean) aProxyField; + } + + if (aExplosionDropItem) { for (i = 0; i < this.getSizeInventory(); ++i) { ItemStack tItem = this.getStackInSlot(i); if (tItem != null && tItem.stackSize > 0 && this.isValidSlot(i)) { @@ -94,19 +124,70 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity { } } + + + public void dropItems(ItemStack tItem) { + if (tItem != null) { + Random tRandom = new Random(); + EntityItem tItemEntity = new EntityItem(this.worldObj, + (double) ((float) this.xCoord + tRandom.nextFloat() * 0.8F + 0.1F), + (double) ((float) this.yCoord + tRandom.nextFloat() * 0.8F + 0.1F), + (double) ((float) this.zCoord + tRandom.nextFloat() * 0.8F + 0.1F), + new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); + if (tItem.hasTagCompound()) { + tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy()); + } + + tItemEntity.motionX = tRandom.nextGaussian() * 0.0500000007450581D; + tItemEntity.motionY = tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D; + tItemEntity.motionZ = tRandom.nextGaussian() * 0.0500000007450581D; + tItemEntity.hurtResistantTime = 999999; + tItemEntity.lifespan = 60000; + + try { + if (ENTITY_ITEM_HEALTH_FIELD_2 != null) { + ENTITY_ITEM_HEALTH_FIELD_2.setInt(tItemEntity, 99999999); + } + } catch (Exception var5) { + ; + } + + this.worldObj.spawnEntityInWorld(tItemEntity); + tItem.stackSize = 0; + } + } public ArrayList<ItemStack> getDrops() { - ItemStack rStack = new ItemStack(Meta_GT_Proxy.sBlockMachines, 1, this.getMetaTileID()); - NBTTagCompound aSuperNBT = super.getDrops().get(0).getTagCompound(); - NBTTagCompound tNBT = aSuperNBT; - if (this.hasValidMetaTileEntity()) { - this.mMetaTileEntity.setItemNBT(tNBT); + ArrayList<ItemStack> aDrops = new ArrayList<ItemStack>(); + ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, this.getMetaTileID()); + // Currently not using my custom block. + // ItemStack rStack = new ItemStack(Meta_GT_Proxy.sBlockMachines, 1, + // this.getMetaTileID()); + boolean fail = true; + + ArrayList<ItemStack> aSuperDrops = super.getDrops(); + if (aSuperDrops != null && !aSuperDrops.isEmpty()) { + ItemStack aSuperStack = super.getDrops().get(0); + if (aSuperStack != null && aSuperStack.hasTagCompound()) { + NBTTagCompound aSuperNBT = aSuperStack.getTagCompound(); + if (aSuperNBT != null && !aSuperNBT.hasNoTags()) { + NBTTagCompound tNBT = (NBTTagCompound) aSuperNBT.copy(); + if (tNBT != null && !tNBT.hasNoTags()) { + if (this.hasValidMetaTileEntity()) { + this.mMetaTileEntity.setItemNBT(tNBT); + rStack.setTagCompound(tNBT); + fail = false; + aDrops.add(rStack); + } + } + } + + } } - if (!tNBT.hasNoTags()) { - rStack.setTagCompound(tNBT); + if (fail) { + aDrops.add(rStack); } - - return new ArrayList<ItemStack>(Arrays.asList(new ItemStack[] { rStack })); + return aDrops; } public boolean isTeleporterCompatible(Direction aSide) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java index 1ce7fc49d3..e1b329c07f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicLosslessGenerator.java @@ -247,9 +247,9 @@ public abstract class GTPP_MTE_BasicLosslessGenerator extends GTPP_MTE_BasicTank public int getFuelValue(FluidStack aLiquid) { if (aLiquid != null && this.getRecipes() != null) { Collection<GT_Recipe> tRecipeList = this.getRecipes().mRecipeList; - Logger.WARNING("Fuels: "+tRecipeList.size()); if (tRecipeList != null) { - Iterator var4 = tRecipeList.iterator(); + Logger.WARNING("Fuels: "+tRecipeList.size()); + Iterator<GT_Recipe> var4 = tRecipeList.iterator(); while (var4.hasNext()) { GT_Recipe tFuel = (GT_Recipe) var4.next(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java index 19ba932a02..2eb1d36791 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/GTPP_MTE_BasicMachine.java @@ -11,11 +11,11 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.objects.XSTR; 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 gtPlusPlus.api.objects.random.XSTR; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Heat.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Heat.java deleted file mode 100644 index 68ec0ba0c9..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Heat.java +++ /dev/null @@ -1,532 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; - -import java.util.ArrayList; -import java.util.Arrays; - -import gregtech.GT_Mod; -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures.BlockIcons; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IEnergyConnected; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.metatileentity.MetaPipeEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import gregtech.common.GT_Client; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.interfaces.IHeatEntity; -import gtPlusPlus.xmod.gregtech.api.interfaces.IMetaTileEntityHeatPipe; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; -import ic2.api.energy.tile.IEnergySink; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -public class GT_MetaPipeEntity_Heat extends MetaPipeEntity implements IMetaTileEntityHeatPipe, IHeatEntity { - - public final Materials mMaterial; - public final long mHeatLossPerMeter, mAmperage, mMaxTemp; - public final boolean mInsulated, mCanShock; - public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, mTransferredVoltageLast20 = 0; - public short mOverheat; - - private boolean mCheckConnections; - public byte mDisableInput; - - public GT_MetaPipeEntity_Heat(int aID, String aName, String aNameRegional, Materials aMaterial, long aMaxTemp) { - super(aID, aName, aNameRegional, 0); - mMaterial = aMaterial; - mAmperage = 1; - mMaxTemp = aMaxTemp; - mInsulated = false; - mCanShock = true; - mHeatLossPerMeter = aMaxTemp/1000; - } - - public GT_MetaPipeEntity_Heat(String aName, Materials aMaterial, long aMaxTemp) { - super(aName, 0); - mMaterial = aMaterial; - mAmperage = 1; - mMaxTemp = aMaxTemp; - mInsulated = false; - mCanShock = true; - mHeatLossPerMeter = aMaxTemp/1000; - } - - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaPipeEntity_Heat(mName, mMaterial, mMaxTemp); - } - - @Override - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) { - if (mCanShock && (((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase) - GT_Utility.applyHeatDamage((EntityLivingBase) aEntity, mTransferredVoltageLast20); - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - if (!mCanShock) return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - return AxisAlignedBB.getBoundingBox(aX + 0.125D, aY + 0.125D, aZ + 0.125D, aX + 0.875D, aY + 0.875D, aZ + 0.875D); - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(byte aFacing) { - return false; - } - - @Override - public boolean isValidSlot(int aIndex) { - return true; - } - - @Override - public final boolean renderInside(byte aSide) { - return false; - } - - @Override - public int getProgresstime() { - return (int) mTransferredAmperage * 64; - } - - @Override - public int maxProgresstime() { - return (int) mAmperage * 64; - } - - @Override - public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity())) - return 0; - return transferHeat(aSide, aVoltage, aAmperage, new ArrayList<TileEntity>(Arrays.asList((TileEntity) getBaseMetaTileEntity()))); - } - - @Override - public long transferHeat(byte aSide, long aVoltage, long aAmperage, ArrayList<TileEntity> aAlreadyPassedTileEntityList) { - if (!this.isConnectedAtSide(aSide) && aSide != 6) { - return 0L; - } else { - long rUsedAmperes = 0L; - aVoltage -= this.mHeatLossPerMeter; - if (aVoltage > 0L) { - for (byte i = 0; i < 6 && aAmperage > rUsedAmperes; ++i) { - if (i != aSide && this.isConnectedAtSide(i) - && this.getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i, - this.getBaseMetaTileEntity().getCoverIDAtSide(i), - this.getBaseMetaTileEntity().getCoverDataAtSide(i), this.getBaseMetaTileEntity())) { - TileEntity tTileEntity = this.getBaseMetaTileEntity().getTileEntityAtSide(i); - if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) { - aAlreadyPassedTileEntityList.add(tTileEntity); - if (tTileEntity instanceof IEnergyConnected) { - if (this.getBaseMetaTileEntity().getColorization() >= 0) { - byte tColor = ((IEnergyConnected) tTileEntity).getColorization(); - if (tColor >= 0 && tColor != this.getBaseMetaTileEntity().getColorization()) { - continue; - } - } - - if (tTileEntity instanceof IGregTechTileEntity - && ((IGregTechTileEntity) tTileEntity) - .getMetaTileEntity() instanceof IMetaTileEntityHeatPipe - && ((IGregTechTileEntity) tTileEntity) - .getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i)) - .letsEnergyIn(GT_Utility.getOppositeSide(i), - ((IGregTechTileEntity) tTileEntity) - .getCoverIDAtSide(GT_Utility.getOppositeSide(i)), - ((IGregTechTileEntity) tTileEntity) - .getCoverDataAtSide(GT_Utility.getOppositeSide(i)), - (IGregTechTileEntity) tTileEntity)) { - if (((IGregTechTileEntity) tTileEntity).getTimer() > 50L) { - rUsedAmperes += ((IMetaTileEntityHeatPipe) ((IGregTechTileEntity) tTileEntity) - .getMetaTileEntity()).transferHeat(GT_Utility.getOppositeSide(i), - aVoltage, aAmperage - rUsedAmperes, - aAlreadyPassedTileEntityList); - } - } else { - rUsedAmperes += ((IEnergyConnected) tTileEntity).injectEnergyUnits( - GT_Utility.getOppositeSide(i), aVoltage, aAmperage - rUsedAmperes); - } - } else { - ForgeDirection tDirection; - - if (tTileEntity instanceof IEnergySink) { - tDirection = ForgeDirection.getOrientation(i).getOpposite(); - if (((IEnergySink) tTileEntity) - .acceptsEnergyFrom((TileEntity) this.getBaseMetaTileEntity(), tDirection) - && ((IEnergySink) tTileEntity).getDemandedEnergy() > 0.0D - && ((IEnergySink) tTileEntity).injectEnergy(tDirection, (double) aVoltage, - (double) aVoltage) < (double) aVoltage) { - ++rUsedAmperes; - } - } - } - } - } - } - } - - this.mTransferredAmperage += rUsedAmperes; - this.mTransferredVoltageLast20 = Math.max(this.mTransferredVoltageLast20, aVoltage); - this.mTransferredAmperageLast20 = Math.max(this.mTransferredAmperageLast20, this.mTransferredAmperage); - if (aVoltage <= this.mMaxTemp && this.mTransferredAmperage <= this.mAmperage) { - return rUsedAmperes; - } else { - if (this.mOverheat > GT_Mod.gregtechproxy.mWireHeatingTicks * 100) { - //this.getBaseMetaTileEntity().setToFire(); - } else { - this.mOverheat = (short) (this.mOverheat + 100); - } - - return aAmperage; - } - } - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - this.mTransferredAmperage = 0L; - if (this.mOverheat > 0) { - --this.mOverheat; - } - - if (aTick % 20L == 0L) { - this.mTransferredVoltageLast20 = 0L; - this.mTransferredAmperageLast20 = 0L; - - for (byte tSide = 0; tSide < 6; ++tSide) { - IGregTechTileEntity tBaseMetaTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide(tSide); - byte uSide = GT_Utility.getOppositeSide(tSide); - if ((this.mCheckConnections || this.isConnectedAtSide(tSide) - || aBaseMetaTileEntity.getCoverBehaviorAtSide(tSide).alwaysLookConnected(tSide, - aBaseMetaTileEntity.getCoverIDAtSide(tSide), - aBaseMetaTileEntity.getCoverDataAtSide(tSide), aBaseMetaTileEntity) - || tBaseMetaTileEntity != null && tBaseMetaTileEntity.getCoverBehaviorAtSide(uSide) - .alwaysLookConnected(uSide, tBaseMetaTileEntity.getCoverIDAtSide(uSide), - tBaseMetaTileEntity.getCoverDataAtSide(uSide), tBaseMetaTileEntity)) - && this.connect(tSide) == 0) { - this.disconnect(tSide); - } - } - - if (isGT6Pipes()) { - this.mCheckConnections = false; - } - } - } else if (aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected == 4) { - aBaseMetaTileEntity.issueTextureUpdate(); - } - - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public String[] getDescription() { - return new String[]{ - "Max Voltage: " + EnumChatFormatting.GOLD + mMaxTemp + "C" + EnumChatFormatting.GRAY, - "Loss: " + EnumChatFormatting.RED + mHeatLossPerMeter + EnumChatFormatting.GRAY + " HU per meter", - CORE.GT_Tooltip - }; - } - - @Override - public float getThickNess() { - return 1; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("HeatBuffer", this.HeatBuffer); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - this.HeatBuffer = aNBT.getInteger("HeatBuffer"); - } - - - - - - - - - - - - - - protected int transmitHeat; - protected int maxHeatEmitpeerTick; - protected int HeatBuffer; - - - - - public byte getTileEntityBaseType() { - return 4; - } - - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, - byte aColorIndex, boolean aConnected, boolean aRedstone) { - float tThickNess = this.getThickNess(); - if (this.mDisableInput == 0) { - return new ITexture[]{(ITexture) (aConnected - ? getBaseTexture(tThickNess, 1, this.mMaterial, aColorIndex) - : new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], - Dyes.getModulation(aColorIndex, this.mMaterial.mRGBa)))}; - } else { - byte tMask = 0; - byte[][] sRestrictionArray = new byte[][]{{2, 3, 5, 4}, {2, 3, 4, 5}, {1, 0, 4, 5}, {1, 0, 4, 5}, - {1, 0, 2, 3}, {1, 0, 2, 3}}; - if (aSide >= 0 && aSide < 6) { - for (byte i = 0; i < 4; ++i) { - if (this.isInputDisabledAtSide(sRestrictionArray[aSide][i])) { - tMask = (byte) (tMask | 1 << i); - } - } - } - - return new ITexture[]{ - (ITexture) (aConnected - ? getBaseTexture(tThickNess, 1, this.mMaterial, aColorIndex) - : new GT_RenderedTexture(this.mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], - Dyes.getModulation(aColorIndex, this.mMaterial.mRGBa))), - getRestrictorTexture(tMask)}; - } - } - - protected static final ITexture getBaseTexture(float aThickNess, int aPipeAmount, Materials aMaterial, - byte aColorIndex) { - if (aPipeAmount >= 9) { - return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeNonuple.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - } else if (aPipeAmount >= 4) { - return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeQuadruple.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - } else if (aThickNess < 0.124F) { - return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - } else if (aThickNess < 0.374F) { - return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - } else if (aThickNess < 0.499F) { - return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - } else if (aThickNess < 0.749F) { - return new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - } else { - return aThickNess < 0.874F - ? new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)) - : new GT_RenderedTexture(aMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], - Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - } - } - - protected static final ITexture getRestrictorTexture(byte aMask) { - switch (aMask) { - case 1 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_UP); - case 2 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_DOWN); - case 3 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_UD); - case 4 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_LEFT); - case 5 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_UL); - case 6 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_DL); - case 7 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_NR); - case 8 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_RIGHT); - case 9 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_UR); - case 10 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_DR); - case 11 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_NL); - case 12 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_LR); - case 13 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_ND); - case 14 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR_NU); - case 15 : - return new GT_RenderedTexture(BlockIcons.PIPE_RESTRICTOR); - default : - return null; - } - } - - - public final boolean isGT6Pipes() { - return StaticFields59.mGT6StylePipes; - } - - public void updateHeatEntity() { - int amount = this.getMaxHeatEmittedPerTick() - this.HeatBuffer; - if (amount > 0) { - this.addtoHeatBuffer(this.fillHeatBuffer(amount)); - } - } - - public boolean facingMatchesDirection(ForgeDirection direction) { - return true; - } - - public int maxrequestHeatTick(ForgeDirection directionFrom) { - return this.getMaxHeatEmittedPerTick(); - } - - public int requestHeat(ForgeDirection directionFrom, int requestheat) { - if (this.facingMatchesDirection(directionFrom)) { - int heatbuffertemp = this.getHeatBuffer(); - if (this.getHeatBuffer() >= requestheat) { - this.setHeatBuffer(this.getHeatBuffer() - requestheat); - this.transmitHeat = requestheat; - return requestheat; - } else { - this.transmitHeat = heatbuffertemp; - this.setHeatBuffer(0); - return heatbuffertemp; - } - } else { - return 0; - } - } - - - public int getHeatBuffer() { - return this.HeatBuffer; - } - - public void setHeatBuffer(int HeatBuffer) { - this.HeatBuffer = HeatBuffer; - } - - public void addtoHeatBuffer(int heat) { - this.setHeatBuffer(this.getHeatBuffer() + heat); - } - - - public int fillHeatBuffer(int maxAmount) { - return maxAmount >= this.getMaxHeatEmittedPerTick() ? this.getMaxHeatEmittedPerTick() : maxAmount; - } - - public int getMaxHeatEmittedPerTick() { - return (int) (this.mMaxTemp/1000); - } - - - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, - float aZ) { - if (isGT6Pipes()) { - byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); - byte tMask = (byte) (1 << tSide); - if (aPlayer.isSneaking()) { - if (this.isInputDisabledAtSide(tSide)) { - this.mDisableInput = (byte) (this.mDisableInput & ~tMask); - GT_Utility.sendChatToPlayer(aPlayer, this.trans("212", "Input enabled")); - if (!this.isConnectedAtSide(tSide)) { - this.connect(tSide); - } - } else { - this.mDisableInput |= tMask; - GT_Utility.sendChatToPlayer(aPlayer, this.trans("213", "Input disabled")); - } - } else if (!this.isConnectedAtSide(tSide)) { - if (this.connect(tSide) > 0) { - GT_Utility.sendChatToPlayer(aPlayer, this.trans("214", "Connected")); - } - } else { - this.disconnect(tSide); - GT_Utility.sendChatToPlayer(aPlayer, this.trans("215", "Disconnected")); - } - - return true; - } else { - return false; - } - } - - public boolean isInputDisabledAtSide(int aSide) { - return (this.mDisableInput & 1 << aSide) != 0; - } - - - - - @Override - public int maxHeatInPerTick(ForgeDirection var1) { - return (int) (this.mMaxTemp/500); - } - - @Override - public int addHeat(ForgeDirection var1, int var2) { - - - - /*ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing()); - TileEntity te = this.getBaseMetaTileEntity().getWorld().getTileEntity(this.xCoord + dir.offsetX, this.yCoord + dir.offsetY, - this.zCoord + dir.offsetZ); - if (te instanceof IHeatSource) { - int heatbandwith = ((IHeatSource) te).maxrequestHeatTick(dir.getOpposite()); - double freeEUstorage = (double) this.maxEUStorage - this.EUstorage; - if (freeEUstorage >= this.productionpeerheat * (double) heatbandwith) { - this.receivedheat = ((IHeatSource) te).requestHeat(dir.getOpposite(), heatbandwith); - if (this.receivedheat != 0) { - this.production = (double) this.receivedheat * this.productionpeerheat; - this.EUstorage += this.production; - return true; - } - } - } - - this.production = 0.0D; - this.receivedheat = 0;*/ - - - return 0; - } - - @Override - public int getTransmitHeat() { - return this.transmitHeat; - } - - - - - -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java index 9b730c84a3..5fef0f1088 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DynamoBuffer.java @@ -34,14 +34,17 @@ public class GT_MetaTileEntity_Hatch_DynamoBuffer extends GT_MetaTileEntity_Hatc return new ITexture[]{aBaseTexture, TexturesGtBlock.OVERLAYS_ENERGY_OUT_MULTI_BUFFER[this.mTier]}; } + @Override public long getMinimumStoredEU() { return 0L; } + @Override public long maxEUStore() { return 512L + GT_Values.V[this.mTier + 1] * 2048L; } + @Override public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { return (MetaTileEntity) new GT_MetaTileEntity_Hatch_DynamoBuffer(this.mName, this.mTier, this.mDescription, this.mTextures); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java new file mode 100644 index 0000000000..752321506d --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_TurbineProvider.java @@ -0,0 +1,212 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.CONTAINER_1by1_Turbine; +import gtPlusPlus.xmod.gregtech.api.gui.hatches.GUI_1by1_Turbine; +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.world.World; +import net.minecraft.world.chunk.Chunk; + +public class GT_MetaTileEntity_Hatch_TurbineProvider extends GT_MetaTileEntity_Hatch_InputBus { + + public GT_MetaTileEntity_Hatch_TurbineProvider(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public GT_MetaTileEntity_Hatch_TurbineProvider(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public GT_MetaTileEntity_Hatch_TurbineProvider(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription[0], aTextures); + } + + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_TurbineProvider(this.mName, this.mTier, this.mDescription, this.mTextures); + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new CONTAINER_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GUI_1by1_Turbine(aPlayerInventory, aBaseMetaTileEntity, "Turbine Housing"); + } + + @Override + public String[] getDescription() { + return new String[]{ + "An automation port for Large Turbines", "Will attempt once per 1200 ticks to fill the turbine slot of it's parent turbine", "You may adjust this with a screwdriver", "Hold shift to adjust in finer amounts", "Hold control to adjust direction", "Left Click with Screwdriver to reset", "This module assumes the entire turbine is in the same Chunk"}; + } + + + private GT_MetaTileEntity_LargeTurbine mParent = null; + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + super.onPostTick(aBaseMetaTileEntity, aTimer); + if (aTimer % mRefreshTime == 0 && this.getBaseMetaTileEntity().isServerSide()) { + tryRefillTurbine(); + } + } + + private final void tryFindParentTurbine() { + Logger.INFO("This turbine housing has no parent, searching world."); + IGregTechTileEntity T = this.getBaseMetaTileEntity(); + World W = T.getWorld(); + Chunk C = W.getChunkFromBlockCoords(T.getXCoord(), T.getZCoord()); + for (Object o : C.chunkTileEntityMap.values()) { + if (o instanceof IGregTechTileEntity) { + IGregTechTileEntity G = (IGregTechTileEntity) o; + final IMetaTileEntity aMetaTileEntity = |
