diff options
author | GlodBlock <1356392126@qq.com> | 2022-01-31 23:31:02 +0800 |
---|---|---|
committer | GlodBlock <1356392126@qq.com> | 2022-01-31 23:31:02 +0800 |
commit | 38147469ef6666a0a61693ad04699fe4260618a6 (patch) | |
tree | ab02e833730222995fc04fb5f5e290368f3679f8 /src/main/java/goodgenerator/blocks | |
parent | 112b14f67aacc3cd2a10f2b11dcd3e1d691d8369 (diff) | |
download | GT5-Unofficial-38147469ef6666a0a61693ad04699fe4260618a6.tar.gz GT5-Unofficial-38147469ef6666a0a61693ad04699fe4260618a6.tar.bz2 GT5-Unofficial-38147469ef6666a0a61693ad04699fe4260618a6.zip |
start the work of large fusion
Diffstat (limited to 'src/main/java/goodgenerator/blocks')
-rw-r--r-- | src/main/java/goodgenerator/blocks/tileEntity/LargeFusionComputer.java | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/LargeFusionComputer.java b/src/main/java/goodgenerator/blocks/tileEntity/LargeFusionComputer.java new file mode 100644 index 0000000000..c6eda8c51d --- /dev/null +++ b/src/main/java/goodgenerator/blocks/tileEntity/LargeFusionComputer.java @@ -0,0 +1,77 @@ +package goodgenerator.blocks.tileEntity; + +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_ChunkManager; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.ChunkCoordIntPair; + +public class LargeFusionComputer extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { + + private boolean isLoadedChunk; + + public LargeFusionComputer(String name) { + super(name); + } + + public LargeFusionComputer(int id, String name, String nameRegional) { + super(id,name,nameRegional); + } + + @Override + public void construct(ItemStack itemStack, boolean b) { + + } + + @Override + public String[] getStructureDescription(ItemStack itemStack) { + return new String[0]; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide() && !aBaseMetaTileEntity.isAllowedToWork()) { + // if machine has stopped, stop chunkloading + GT_ChunkManager.releaseTicket((TileEntity)aBaseMetaTileEntity); + this.isLoadedChunk = false; + } + else if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && !this.isLoadedChunk) { + //load a 3x3 area when machine is running + GT_ChunkManager.releaseTicket((TileEntity)aBaseMetaTileEntity); + GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() + 1, getChunkZ() + 1)); + GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() + 1, getChunkZ())); + GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() + 1, getChunkZ() - 1)); + GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() - 1, getChunkZ() + 1)); + GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() - 1, getChunkZ())); + GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX() - 1, getChunkZ() - 1)); + GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX(), getChunkZ() + 1)); + GT_ChunkManager.requestChunkLoad((TileEntity)aBaseMetaTileEntity, new ChunkCoordIntPair(getChunkX(), getChunkZ() - 1)); + this.isLoadedChunk = true; + } + } + + @Override + public void onRemoval() { + if (this.isLoadedChunk) + GT_ChunkManager.releaseTicket((TileEntity)getBaseMetaTileEntity()); + super.onRemoval(); + } + + public int getChunkX() { + return getBaseMetaTileEntity().getXCoord() >> 4; + } + + public int getChunkZ() { + return getBaseMetaTileEntity().getZCoord() >> 4; + } + +} |