Search in sources :

Example 6 with TileEntityOxygenSealer

use of micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer in project Galacticraft by micdoodle8.

the class GuiHandler method getClientGuiElement.

@SideOnly(Side.CLIENT)
private Object getClientGuiElement(int ID, EntityPlayer player, World world, BlockPos position) {
    EntityPlayerSP playerClient = PlayerUtil.getPlayerBaseClientFromPlayer(player, false);
    if (ID == GuiIdsCore.GALAXY_MAP) {
        return new GuiCelestialSelection(true, null);
    } else if (ID == GuiIdsCore.ROCKET_INVENTORY && player.ridingEntity instanceof EntityTieredRocket) {
        return new GuiRocketInventory(player.inventory, (EntityTieredRocket) player.ridingEntity, ((EntityTieredRocket) player.ridingEntity).getType());
    } else if (ID == GuiIdsCore.EXTENDED_INVENTORY) {
        return new GuiExtendedInventory(player, ClientProxyCore.dummyInventory);
    } else if (ID == GuiIdsCore.SPACE_RACE_START) {
        return new GuiNewSpaceRace(player);
    } else if (ID == GuiIdsCore.SPACE_RACE_JOIN) {
        return new GuiJoinSpaceRace(playerClient);
    } else if (ID == GuiIdsCore.PRE_LAUNCH_CHECKLIST) {
        return new GuiPreLaunchChecklist(WorldUtil.getAllChecklistKeys(), player.getHeldItem().hasTagCompound() ? (NBTTagCompound) player.getHeldItem().getTagCompound().getTag("checklistData") : null);
    }
    TileEntity tile = world.getTileEntity(position);
    if (tile != null) {
        if (tile instanceof TileEntityCrafting) {
            return new GuiCrafting(player.inventory, (TileEntityCrafting) tile);
        } else if (tile instanceof TileEntityRefinery) {
            return new GuiRefinery(player.inventory, (TileEntityRefinery) world.getTileEntity(position));
        } else if (tile instanceof TileEntityOxygenCollector) {
            return new GuiOxygenCollector(player.inventory, (TileEntityOxygenCollector) tile);
        } else if (tile instanceof TileEntityOxygenDistributor) {
            return new GuiOxygenDistributor(player.inventory, (TileEntityOxygenDistributor) tile);
        } else if (tile instanceof TileEntityFuelLoader) {
            return new GuiFuelLoader(player.inventory, (TileEntityFuelLoader) tile);
        } else if (tile instanceof TileEntityOxygenSealer) {
            return new GuiOxygenSealer(player.inventory, (TileEntityOxygenSealer) tile);
        } else if (tile instanceof TileEntityCargoLoader) {
            return new GuiCargoLoader(player.inventory, (TileEntityCargoLoader) tile);
        } else if (tile instanceof TileEntityCargoUnloader) {
            return new GuiCargoUnloader(player.inventory, (TileEntityCargoUnloader) tile);
        } else if (tile instanceof TileEntityParaChest) {
            return new GuiParaChest(player.inventory, (TileEntityParaChest) tile);
        } else if (tile instanceof TileEntitySolar) {
            return new GuiSolar(player.inventory, (TileEntitySolar) tile);
        } else if (tile instanceof TileEntityAirLockController) {
            return new GuiAirLockController((TileEntityAirLockController) tile);
        } else if (tile instanceof TileEntityEnergyStorageModule) {
            return new GuiEnergyStorageModule(player.inventory, (TileEntityEnergyStorageModule) tile);
        } else if (tile instanceof TileEntityCoalGenerator) {
            return new GuiCoalGenerator(player.inventory, (TileEntityCoalGenerator) tile);
        } else if (tile instanceof TileEntityElectricFurnace) {
            return new GuiElectricFurnace(player.inventory, (TileEntityElectricFurnace) tile);
        } else if (tile instanceof TileEntityIngotCompressor) {
            return new GuiIngotCompressor(player.inventory, (TileEntityIngotCompressor) tile);
        } else if (tile instanceof TileEntityElectricIngotCompressor) {
            return new GuiElectricIngotCompressor(player.inventory, (TileEntityElectricIngotCompressor) tile);
        } else if (tile instanceof TileEntityCircuitFabricator) {
            return new GuiCircuitFabricator(player.inventory, (TileEntityCircuitFabricator) tile);
        } else if (tile instanceof TileEntityOxygenStorageModule) {
            return new GuiOxygenStorageModule(player.inventory, (TileEntityOxygenStorageModule) tile);
        } else if (tile instanceof TileEntityOxygenCompressor) {
            return new GuiOxygenCompressor(player.inventory, (TileEntityOxygenCompressor) tile);
        } else if (tile instanceof TileEntityOxygenDecompressor) {
            return new GuiOxygenDecompressor(player.inventory, (TileEntityOxygenDecompressor) tile);
        } else if (tile instanceof TileEntityDeconstructor) {
            return new GuiDeconstructor(player.inventory, (TileEntityDeconstructor) tile);
        } else if (tile instanceof TileEntityPainter) {
            return new GuiPainter(player.inventory, (TileEntityPainter) tile);
        }
    }
    if (playerClient != null) {
        GCPlayerStatsClient stats = GCPlayerStatsClient.get(playerClient);
        for (ISchematicPage page : stats.getUnlockedSchematics()) {
            if (ID == page.getGuiID()) {
                GuiScreen screen = page.getResultScreen(playerClient, position);
                if (screen instanceof ISchematicResultPage) {
                    ((ISchematicResultPage) screen).setPageIndex(page.getPageID());
                }
                return screen;
            }
        }
    }
    return null;
}
Also used : EntityTieredRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket) GuiJoinSpaceRace(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiJoinSpaceRace) GuiCelestialSelection(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiCelestialSelection) GCPlayerStatsClient(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient) ISchematicResultPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicResultPage) TileEntity(net.minecraft.tileentity.TileEntity) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) GuiScreen(net.minecraft.client.gui.GuiScreen) GuiNewSpaceRace(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiNewSpaceRace) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) GuiPreLaunchChecklist(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiPreLaunchChecklist) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 7 with TileEntityOxygenSealer

use of micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer in project Galacticraft by micdoodle8.

the class GuiHandler method getServerGuiElement.

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
    if (playerBase == null) {
        player.addChatMessage(new ChatComponentText("Galacticraft player instance null server-side. This is a bug."));
        return null;
    }
    GCPlayerStats stats = GCPlayerStats.get(playerBase);
    if (ID == GuiIdsCore.ROCKET_INVENTORY && player.ridingEntity instanceof EntityTieredRocket) {
        return new ContainerRocketInventory(player.inventory, (EntityTieredRocket) player.ridingEntity, ((EntityTieredRocket) player.ridingEntity).getType(), player);
    } else if (ID == GuiIdsCore.EXTENDED_INVENTORY) {
        return new ContainerExtendedInventory(player, stats.getExtendedInventory());
    }
    BlockPos pos = new BlockPos(x, y, z);
    TileEntity tile = world.getTileEntity(pos);
    if (tile != null) {
        if (tile instanceof TileEntityCrafting) {
            return new ContainerCrafting(player.inventory, (TileEntityCrafting) tile);
        } else if (tile instanceof TileEntityRefinery) {
            return new ContainerRefinery(player.inventory, (TileEntityRefinery) tile, player);
        } else if (tile instanceof TileEntityOxygenCollector) {
            return new ContainerOxygenCollector(player.inventory, (TileEntityOxygenCollector) tile);
        } else if (tile instanceof TileEntityOxygenDistributor) {
            return new ContainerOxygenDistributor(player.inventory, (TileEntityOxygenDistributor) tile);
        } else if (tile instanceof TileEntityFuelLoader) {
            return new ContainerFuelLoader(player.inventory, (TileEntityFuelLoader) tile);
        } else if (tile instanceof TileEntityOxygenSealer) {
            return new ContainerOxygenSealer(player.inventory, (TileEntityOxygenSealer) tile);
        } else if (tile instanceof TileEntityCargoLoader) {
            return new ContainerCargoLoader(player.inventory, (TileEntityCargoLoader) tile);
        } else if (tile instanceof TileEntityCargoUnloader) {
            return new ContainerCargoLoader(player.inventory, (TileEntityCargoUnloader) tile);
        } else if (tile instanceof TileEntityParaChest) {
            return new ContainerParaChest(player.inventory, (TileEntityParaChest) tile, player);
        } else if (tile instanceof TileEntitySolar) {
            return new ContainerSolar(player.inventory, (TileEntitySolar) tile);
        } else if (tile instanceof TileEntityEnergyStorageModule) {
            return new ContainerEnergyStorageModule(player.inventory, (TileEntityEnergyStorageModule) tile);
        } else if (tile instanceof TileEntityCoalGenerator) {
            return new ContainerCoalGenerator(player.inventory, (TileEntityCoalGenerator) tile);
        } else if (tile instanceof TileEntityElectricFurnace) {
            return new ContainerElectricFurnace(player.inventory, (TileEntityElectricFurnace) tile);
        } else if (tile instanceof TileEntityIngotCompressor) {
            return new ContainerIngotCompressor(player.inventory, (TileEntityIngotCompressor) tile);
        } else if (tile instanceof TileEntityElectricIngotCompressor) {
            return new ContainerElectricIngotCompressor(player.inventory, (TileEntityElectricIngotCompressor) tile);
        } else if (tile instanceof TileEntityCircuitFabricator) {
            return new ContainerCircuitFabricator(player.inventory, (TileEntityCircuitFabricator) tile);
        } else if (tile instanceof TileEntityOxygenStorageModule) {
            return new ContainerOxygenStorageModule(player.inventory, (TileEntityOxygenStorageModule) tile);
        } else if (tile instanceof TileEntityOxygenCompressor) {
            return new ContainerOxygenCompressor(player.inventory, (TileEntityOxygenCompressor) tile, player);
        } else if (tile instanceof TileEntityOxygenDecompressor) {
            return new ContainerOxygenDecompressor(player.inventory, (TileEntityOxygenDecompressor) tile, player);
        } else if (tile instanceof TileEntityDeconstructor) {
            return new ContainerDeconstructor(player.inventory, (TileEntityDeconstructor) tile);
        } else if (tile instanceof TileEntityPainter) {
            return new ContainerPainter(player.inventory, (TileEntityPainter) tile);
        }
    }
    for (ISchematicPage page : stats.getUnlockedSchematics()) {
        if (ID == page.getGuiID()) {
            return page.getResultContainer(playerBase, new BlockPos(x, y, z));
        }
    }
    return null;
}
Also used : EntityTieredRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) BlockPos(net.minecraft.util.BlockPos) ChatComponentText(net.minecraft.util.ChatComponentText) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TileEntity(net.minecraft.tileentity.TileEntity) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)

Example 8 with TileEntityOxygenSealer

use of micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer in project Galacticraft by micdoodle8.

the class ThreadFindSeal method doLayerNearMapEdge.

/**
 * Again, literally the only difference from doLayer() should be these two lines:
 *        Block id = sideVec.getBlockID_noChunkLoad(world);
 *
 * In this code, there is a map edge check on the x, z coordinates (outside map edge at 30,000,000 blocks?)
 * This check is skipped in the "safe" version of the same code, for higher performance
 * because doing this check 50000 times when looking at blocks around a sealer at spawn is obviously dumb
 */
private void doLayerNearMapEdge() {
    // Local variables are fractionally faster than statics
    Block breatheableAirID = GCBlocks.breatheableAir;
    Block airID = Blocks.air;
    Block breatheableAirIDBright = GCBlocks.brightBreatheableAir;
    Block airIDBright = GCBlocks.brightAir;
    Block oxygenSealerID = GCBlocks.oxygenSealer;
    LinkedList<BlockVec3> nextLayer = new LinkedList<>();
    World world = this.world;
    int side, bits;
    while (this.sealed && this.currentLayer.size() > 0) {
        for (BlockVec3 vec : this.currentLayer) {
            // This is for side = 0 to 5 - but using do...while() is fractionally quicker
            side = 0;
            bits = vec.sideDoneBits;
            do {
                // This is also used to skip looking on the solid sides of partially sealable blocks
                if ((bits & (1 << side)) == 0) {
                    if (!checkedContains(vec, side)) {
                        BlockVec3 sideVec = vec.newVecSide(side);
                        if (this.checkCount > 0) {
                            this.checkCount--;
                            Block id = sideVec.getBlockID_noChunkLoad(world);
                            // The most likely case
                            if (id == breatheableAirID) {
                                checkedAdd(sideVec);
                                nextLayer.add(sideVec);
                                this.ambientThermalTracked.add(sideVec);
                            } else if (id == airID) {
                                checkedAdd(sideVec);
                                nextLayer.add(sideVec);
                                this.airToReplace.add(sideVec);
                            } else if (id == breatheableAirIDBright) {
                                checkedAdd(sideVec);
                                nextLayer.add(sideVec);
                                this.ambientThermalTrackedBright.add(sideVec);
                            } else if (id == airIDBright) {
                                checkedAdd(sideVec);
                                nextLayer.add(sideVec);
                                this.airToReplaceBright.add(sideVec);
                            } else if (id == null) {
                                // Broken through to the void or the
                                // stratosphere (above y==255) - set
                                // unsealed and abort
                                this.checkCount = 0;
                                this.sealed = false;
                                return;
                            } else if (id == oxygenSealerID) {
                                TileEntityOxygenSealer sealer = this.sealersAround.get(sideVec);
                                if (sealer != null && !this.sealers.contains(sealer)) {
                                    if (side == 0) {
                                        checkedAdd(sideVec);
                                        this.sealers.add(sealer);
                                        if (sealer.thermalControlEnabled()) {
                                            foundAmbientThermal = true;
                                        }
                                        this.checkCount += sealer.getFindSealChecks();
                                    }
                                // if side != 0, no checkedAdd() - allows this sealer to be checked again from other sides
                                }
                            } else if (this.canBlockPassAirCheck(id, sideVec, side)) {
                                nextLayer.add(sideVec);
                            }
                        // If the chunk was unloaded, BlockVec3.getBlockID returns Blocks.bedrock
                        // which is a solid block, so the loop will treat that as a sealed edge
                        // and not iterate any further in that direction
                        } else // the if (this.isSealed) check here is unnecessary because of the returns
                        {
                            Block id = sideVec.getBlockID_noChunkLoad(this.world);
                            // of which are unsealed obviously
                            if (id == null || id == airID || id == breatheableAirID || id == airIDBright || id == breatheableAirIDBright || this.canBlockPassAirCheck(id, sideVec, side)) {
                                this.sealed = false;
                                if (this.sealers.size() > 0) {
                                    vec.sideDoneBits = side << 6;
                                    traceLeak(vec);
                                }
                                return;
                            }
                        }
                    }
                }
                side++;
            } while (side < 6);
        }
        // Is there a further layer of air/permeable blocks to test?
        this.currentLayer = nextLayer;
        nextLayer = new LinkedList<BlockVec3>();
    }
}
Also used : TileEntityOxygenSealer(micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer) IPartialSealableBlock(micdoodle8.mods.galacticraft.api.block.IPartialSealableBlock) World(net.minecraft.world.World) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 9 with TileEntityOxygenSealer

use of micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer in project Galacticraft by micdoodle8.

the class ThreadFindSeal method unseal.

private void unseal() {
    // Local variables are fractionally faster than statics
    Block breatheableAirID = GCBlocks.breatheableAir;
    Block breatheableAirIDBright = GCBlocks.brightBreatheableAir;
    Block oxygenSealerID = GCBlocks.oxygenSealer;
    Block fireBlock = Blocks.fire;
    Block airBlock = Blocks.air;
    Block airBlockBright = GCBlocks.brightAir;
    List<BlockVec3> toReplaceLocal = this.breatheableToReplace;
    List<BlockVec3> toReplaceLocalBright = this.breatheableToReplaceBright;
    LinkedList<BlockVec3> nextLayer = new LinkedList<>();
    World world = this.world;
    int side, bits;
    while (this.currentLayer.size() > 0) {
        for (BlockVec3 vec : this.currentLayer) {
            side = 0;
            bits = vec.sideDoneBits;
            do {
                if ((bits & (1 << side)) == 0) {
                    if (!checkedContains(vec, side)) {
                        BlockVec3 sideVec = vec.newVecSide(side);
                        Block id = sideVec.getBlockIDsafe_noChunkLoad(world);
                        if (id == breatheableAirID) {
                            toReplaceLocal.add(sideVec);
                            nextLayer.add(sideVec);
                            checkedAdd(sideVec);
                        } else if (id == breatheableAirIDBright) {
                            toReplaceLocalBright.add(sideVec);
                            nextLayer.add(sideVec);
                            checkedAdd(sideVec);
                        } else if (id == fireBlock) {
                            this.fireToReplace.add(sideVec);
                            nextLayer.add(sideVec);
                            checkedAdd(sideVec);
                        } else if (id == oxygenSealerID) {
                            TileEntityOxygenSealer sealer = this.sealersAround.get(sideVec);
                            if (sealer != null && !this.sealers.contains(sealer)) {
                                if (side == 0) {
                                    // Accessing the vent side of the sealer, so add it
                                    this.otherSealers.add(sealer);
                                    checkedAdd(sideVec);
                                }
                            // if side is not 0, do not add to checked so can be rechecked from other sides
                            } else {
                                checkedAdd(sideVec);
                            }
                        } else {
                            if (id != null && id != airBlock && id != airBlockBright) {
                                // This test applies any necessary checkedAdd();
                                if (this.canBlockPassAirCheck(id, sideVec, side)) {
                                    // Look outbound through partially sealable blocks in case there is breatheableAir to clear beyond
                                    nextLayer.add(sideVec);
                                }
                            } else {
                                if (id != null)
                                    checkedAdd(sideVec);
                            }
                        }
                    }
                }
                side++;
            } while (side < 6);
        }
        // Set up the next layer as current layer for the while loop
        this.currentLayer = nextLayer;
        nextLayer = new LinkedList<BlockVec3>();
    }
}
Also used : TileEntityOxygenSealer(micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer) IPartialSealableBlock(micdoodle8.mods.galacticraft.api.block.IPartialSealableBlock) World(net.minecraft.world.World) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 10 with TileEntityOxygenSealer

use of micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer in project Galacticraft by micdoodle8.

the class ThreadFindSeal method check.

public void check() {
    long time1 = System.nanoTime();
    this.sealed = true;
    TileEntity tile = this.head.getTileEntityOnSide(world, EnumFacing.DOWN);
    this.foundAmbientThermal = tile instanceof TileEntityOxygenSealer && ((TileEntityOxygenSealer) tile).thermalControlEnabled();
    this.checkedAdd(this.head);
    this.currentLayer = new LinkedList<BlockVec3>();
    this.airToReplace = new LinkedList<BlockVec3>();
    this.airToReplaceBright = new LinkedList<BlockVec3>();
    this.ambientThermalTracked = new LinkedList<BlockVec3>();
    this.ambientThermalTrackedBright = new LinkedList<BlockVec3>();
    if (this.checkCount > 0) {
        this.currentLayer.add(this.head);
        if (this.head.x < -29990000 || this.head.z < -29990000 || this.head.x >= 29990000 || this.head.z >= 29990000) {
            Block b = this.head.getBlockID_noChunkLoad(this.world);
            if (Blocks.air == b) {
                this.airToReplace.add(this.head.clone());
            } else if (b == GCBlocks.brightAir) {
                this.airToReplaceBright.add(this.head.clone());
            }
            this.doLayerNearMapEdge();
        } else {
            Block headblock = this.head.getBlockIDsafe_noChunkLoad(this.world);
            if (Blocks.air == headblock) {
                this.airToReplace.add(this.head.clone());
            } else if (headblock == GCBlocks.brightAir) {
                this.airToReplaceBright.add(this.head.clone());
            }
            this.doLayer();
        }
    } else {
        this.sealed = false;
    }
    long time2 = System.nanoTime();
    // Can only be properly sealed if there is at least one sealer here (on edge check)
    if (this.sealers.isEmpty()) {
        this.sealed = false;
    }
    if (this.sealed) {
        this.makeSealGood(this.foundAmbientThermal);
        this.leakTrace = null;
    } else {
        int checkedSave = checkedSize;
        checkedClear();
        this.breatheableToReplace = new LinkedList<BlockVec3>();
        this.breatheableToReplaceBright = new LinkedList<BlockVec3>();
        this.fireToReplace = new LinkedList<BlockVec3>();
        this.otherSealers = new LinkedList<TileEntityOxygenSealer>();
        // unseal() will mark breatheableAir blocks for change as it
        // finds them, also searches for unchecked sealers
        this.currentLayer.clear();
        this.currentLayer.add(this.head);
        this.torchesToUpdate.clear();
        if (this.head.x < -29990000 || this.head.z < -29990000 || this.head.x >= 29990000 || this.head.z >= 29990000) {
            this.unsealNearMapEdge();
        } else {
            this.unseal();
        }
        if (!this.otherSealers.isEmpty()) {
            // OtherSealers will have members if the space to be made
            // unbreathable actually still has an unchecked sealer in it
            List<TileEntityOxygenSealer> sealersSave = this.sealers;
            List<BlockVec3> torchesSave = this.torchesToUpdate;
            List<TileEntityOxygenSealer> sealersDone = new ArrayList<>();
            sealersDone.addAll(this.sealers);
            for (TileEntityOxygenSealer otherSealer : this.otherSealers) {
                // sealed
                if (!sealersDone.contains(otherSealer) && otherSealer.getFindSealChecks() > 0) {
                    BlockVec3 newhead = new BlockVec3(otherSealer).translate(0, 1, 0);
                    this.sealed = true;
                    this.checkCount = otherSealer.getFindSealChecks();
                    this.sealers = new LinkedList<TileEntityOxygenSealer>();
                    this.sealers.add(otherSealer);
                    if (otherSealer.thermalControlEnabled()) {
                        foundAmbientThermal = true;
                    }
                    checkedClear();
                    this.checkedAdd(newhead);
                    this.currentLayer.clear();
                    this.airToReplace.clear();
                    this.airToReplaceBright.clear();
                    this.torchesToUpdate = new LinkedList<BlockVec3>();
                    this.currentLayer.add(newhead.clone());
                    if (newhead.x < -29990000 || newhead.z < -29990000 || newhead.x >= 29990000 || newhead.z >= 29990000) {
                        this.doLayerNearMapEdge();
                    } else {
                        this.doLayer();
                    }
                    // should take over as head
                    if (this.sealed) {
                        if (ConfigManagerCore.enableDebug) {
                            GCLog.info("Oxygen Sealer replacing head at x" + this.head.x + " y" + (this.head.y - 1) + " z" + this.head.z);
                        }
                        if (!sealersSave.isEmpty()) {
                            TileEntityOxygenSealer oldHead = sealersSave.get(0);
                            if (!this.sealers.contains(oldHead)) {
                                this.sealers.add(oldHead);
                                if (oldHead.thermalControlEnabled()) {
                                    foundAmbientThermal = true;
                                }
                            }
                        }
                        this.head = newhead.clone();
                        otherSealer.threadSeal = this;
                        otherSealer.stopSealThreadCooldown = 75 + TileEntityOxygenSealer.countEntities;
                        checkedSave += checkedSize;
                        break;
                    } else {
                        sealersDone.addAll(this.sealers);
                    }
                    checkedSave += checkedSize;
                }
            }
            // result in a seal
            if (!this.sealed) {
                this.sealers = sealersSave;
                this.torchesToUpdate = torchesSave;
            } else {
                // If the second search sealed the area, there may also be air or torches to update
                this.makeSealGood(foundAmbientThermal);
            }
        }
        checkedSize = checkedSave;
        if (!this.sealed) {
            if (this.head.getBlockID(this.world) == GCBlocks.breatheableAir) {
                this.breatheableToReplace.add(this.head);
            }
            if (this.head.getBlockID(this.world) == GCBlocks.brightBreatheableAir) {
                this.breatheableToReplaceBright.add(this.head);
            }
            this.makeSealBad();
        } else {
            this.leakTrace = null;
        }
    }
    // Set any sealers found which are not the head sealer, not to run their
    // own seal checks for a while
    // (The player can control which is the head sealer in a space by
    // enabling just that one and disabling all the others)
    TileEntityOxygenSealer headSealer = this.sealersAround.get(this.head.clone().translate(0, -1, 0));
    // If it is sealed, cooldown can be extended as frequent checks are not needed
    if (headSealer != null) {
        headSealer.stopSealThreadCooldown = 75 + TileEntityOxygenSealer.countEntities;
    }
    for (TileEntityOxygenSealer sealer : this.sealers) {
        // inactive ones)
        if (sealer != headSealer && headSealer != null) {
            sealer.threadSeal = this;
            sealer.stopSealThreadCooldown = headSealer.stopSealThreadCooldown + 51;
        }
    }
    this.sealedFinal.set(this.sealed);
    this.looping.set(false);
    if (ConfigManagerCore.enableDebug) {
        long time3 = System.nanoTime();
        float total = (time3 - time1) / 1000000.0F;
        float looping = (time2 - time1) / 1000000.0F;
        float replacing = (time3 - time2) / 1000000.0F;
        GCLog.info("Oxygen Sealer Check Completed at x" + this.head.x + " y" + this.head.y + " z" + this.head.z);
        GCLog.info("   Sealed: " + this.sealed + "  ~  " + this.sealers.size() + " sealers  ~  " + (checkedSize - 1) + " blocks");
        GCLog.info("   Total Time taken: " + String.format("%.2f", total) + "ms  ~  " + String.format("%.2f", looping) + " + " + String.format("%.2f", replacing) + "");
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityOxygenSealer(micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer) IPartialSealableBlock(micdoodle8.mods.galacticraft.api.block.IPartialSealableBlock) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Aggregations

BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)8 TileEntityOxygenSealer (micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer)6 IPartialSealableBlock (micdoodle8.mods.galacticraft.api.block.IPartialSealableBlock)5 TileEntity (net.minecraft.tileentity.TileEntity)5 World (net.minecraft.world.World)4 ISchematicPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)3 GuiCelestialSelection (micdoodle8.mods.galacticraft.core.client.gui.screen.GuiCelestialSelection)3 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)3 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)3 BlockPos (net.minecraft.util.BlockPos)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 EntityTieredRocket (micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket)2 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)2 GalacticraftPacketHandler (micdoodle8.mods.galacticraft.core.network.GalacticraftPacketHandler)2 Block (net.minecraft.block.Block)2 Minecraft (net.minecraft.client.Minecraft)2 WorldClient (net.minecraft.client.multiplayer.WorldClient)2 Entity (net.minecraft.entity.Entity)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 GameProfile (com.mojang.authlib.GameProfile)1