diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-09-18 02:09:45 +1000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2018-09-18 02:09:45 +1000 |
commit | b42970c14f07c3a34203413b2b82b0303317e75a (patch) | |
tree | e97395f5406e124ebf6efc9a45fcef3d2a5f1a49 /src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/misc | |
parent | a177ece7d75a21ac682a9bb850a4205e7dbcbd34 (diff) | |
download | GT5-Unofficial-b42970c14f07c3a34203413b2b82b0303317e75a.tar.gz GT5-Unofficial-b42970c14f07c3a34203413b2b82b0303317e75a.tar.bz2 GT5-Unofficial-b42970c14f07c3a34203413b2b82b0303317e75a.zip |
% More Solar Tower Work, Reflectors and Towers now link, which encourages heating within the tower.
$ Refactored lots of hard references to soft String based linking. Prevents loose chunks and dimensions staying loaded.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/misc')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java | 67 |
1 files changed, 49 insertions, 18 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java index 78d04bfa43..f7b1764e16 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/misc/TileEntitySolarHeater.java @@ -8,6 +8,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachi import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_SolarTower; @@ -17,10 +18,11 @@ import net.minecraft.nbt.NBTTagCompound; public class TileEntitySolarHeater extends GT_MetaTileEntity_TieredMachineBlock { - private GregtechMetaTileEntity_SolarTower mSolarTower; + public String mSolarTower; + public boolean mHasTower = false; + private Integer mTX, mTY, mTZ; private Byte mRequiredFacing; - private boolean mHasTower = false; public TileEntitySolarHeater(final int aID, final String aName, final String aNameRegional, final int aTier, final String aDescription, final int aSlotCount) { @@ -111,8 +113,8 @@ public class TileEntitySolarHeater extends GT_MetaTileEntity_TieredMachineBlock } @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return null; + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return new TileEntitySolarHeater(this.mName, this.mTier, this.mDescription, this.mTextures, 0); } @Override @@ -259,28 +261,57 @@ public class TileEntitySolarHeater extends GT_MetaTileEntity_TieredMachineBlock public void onExplosion() { } + + public GregtechMetaTileEntity_SolarTower getSolarTower() { + if (this.mHasTower && this.mSolarTower != null && this.mSolarTower.length() > 0) { + BlockPos p = BlockPos.generateBlockPos(mSolarTower); + if (p != null) { + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntity(p.xPos, p.yPos, p.zPos); + if (tTileEntity != null && tTileEntity instanceof GregtechMetaTileEntity_SolarTower) { + return (GregtechMetaTileEntity_SolarTower) tTileEntity; + } + } + } + return null; + } + - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (this.mSolarTower != null) { - if (!mHasTower) { - this.mTX = mSolarTower.getBaseMetaTileEntity().getXCoord(); - this.mTY = (int) mSolarTower.getBaseMetaTileEntity().getYCoord(); - this.mTZ = mSolarTower.getBaseMetaTileEntity().getZCoord(); - //this.mRequiredFacing = null; + public boolean setSolarTower(BlockPos aTowerPos) { + if (!this.mHasTower && setSolarTowerInternal(aTowerPos.getUniqueIdentifier())) { + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntity(aTowerPos.xPos, aTowerPos.yPos, aTowerPos.zPos); + if (tTileEntity != null && tTileEntity instanceof GregtechMetaTileEntity_SolarTower) { + this.mTX = tTileEntity.getXCoord(); + this.mTY = (int) tTileEntity.getYCoord(); + this.mTZ = tTileEntity.getZCoord(); this.mHasTower = true; - } + return true; + } } - else { - if (mTX != null || mTY != null || mTZ != null || mRequiredFacing != null) { + return false; + } + + private boolean clearSolarTower() { + if (mHasTower || mTX != null || mTY != null || mTZ != null || mRequiredFacing != null || this.mSolarTower != null) { this.mTX = null; this.mTY = null; this.mTZ = null; this.mRequiredFacing = null; + this.mSolarTower = null; this.mHasTower = false; - } - } + return true; + } + return false; + } + + private final boolean setSolarTowerInternal(String aTowerPos) { + this.mSolarTower = aTowerPos; + return this.mSolarTower != null && this.mSolarTower.length() > 0; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + } @Override |