Search in sources :

Example 1 with MultiblockManager

use of mekanism.common.lib.multiblock.MultiblockManager in project Mekanism by mekanism.

the class FissionReactorMultiblockData method meltdownHappened.

public void meltdownHappened(World world) {
    if (isFormed()) {
        IRadiationManager radiationManager = MekanismAPI.getRadiationManager();
        // Calculate radiation level and clear any tanks that had radioactive substances and are contributing to the
        // amount of radiation released
        double radiation = getTankRadioactivityAndDump(fuelTank) + getWasteTankRadioactivity(true) + getTankRadioactivityAndDump(gasCoolantTank) + getTankRadioactivityAndDump(heatedCoolantTank);
        radiation *= MekanismGeneratorsConfig.generators.fissionMeltdownRadiationMultiplier.get();
        // When the meltdown actually happens, release radiation into the atmosphere
        radiationManager.radiate(new Coord4D(getBounds().getCenter(), world), radiation);
        // Dump the heated coolant as "loss" that didn't survive the meltdown
        heatedCoolantTank.setEmpty();
        // Disable the reactor so that if the person rebuilds it, it isn't on by default (QoL)
        active = false;
        // Update reactor damage to the specified level for post meltdown
        reactorDamage = MekanismGeneratorsConfig.generators.fissionPostMeltdownDamage.get();
        // Reset burnRemaining to zero as it is reasonable to have the burnRemaining get wasted when the reactor explodes
        burnRemaining = 0;
        // Reset the partial waste as we just irradiated it and there is not much sense having it exist in limbo
        partialWaste = 0;
        // Reset the heat to the default of the heat capacitor
        heatCapacitor.setHeat(heatCapacitor.getHeatCapacity() * biomeAmbientTemp);
        // Force sync the update to the cache that corresponds to this multiblock
        MultiblockManager<FissionReactorMultiblockData>.CacheWrapper cacheWrapper = MekanismGenerators.fissionReactorManager.inventories.get(inventoryID);
        if (cacheWrapper != null) {
            MultiblockCache<FissionReactorMultiblockData> cache = cacheWrapper.getCache();
            if (cache != null) {
                cache.sync(this);
            }
        }
    }
}
Also used : MultiblockManager(mekanism.common.lib.multiblock.MultiblockManager) IRadiationManager(mekanism.api.radiation.IRadiationManager) Coord4D(mekanism.api.Coord4D)

Example 2 with MultiblockManager

use of mekanism.common.lib.multiblock.MultiblockManager in project Mekanism by mekanism.

the class TileEntityStructuralMultiblock method onActivate.

@Override
public ActionResultType onActivate(PlayerEntity player, Hand hand, ItemStack stack) {
    for (Map.Entry<MultiblockManager<?>, Structure> entry : structures.entrySet()) {
        Structure structure = entry.getValue();
        IMultiblock<?> master = structure.getController();
        if (master != null) {
            MultiblockData data = getMultiblockData(structure);
            if (data.isFormed() && structuralGuiAccessAllowed(entry.getKey().getNameLower())) {
                // make sure this block is on the structure first
                if (data.getBounds().getRelativeLocation(getBlockPos()).isWall()) {
                    return master.onActivate(player, hand, stack);
                }
            }
        }
    }
    return ActionResultType.PASS;
}
Also used : MultiblockManager(mekanism.common.lib.multiblock.MultiblockManager) Structure(mekanism.common.lib.multiblock.Structure) MultiblockData(mekanism.common.lib.multiblock.MultiblockData) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with MultiblockManager

use of mekanism.common.lib.multiblock.MultiblockManager in project Mekanism by mekanism.

the class TileEntityStructuralMultiblock method onUpdateServer.

@Override
protected void onUpdateServer() {
    super.onUpdateServer();
    if (ticker % 10 == 0) {
        String activeMultiblock = null;
        if (!structures.isEmpty()) {
            Iterator<Map.Entry<MultiblockManager<?>, Structure>> iterator = structures.entrySet().iterator();
            while (iterator.hasNext()) {
                Map.Entry<MultiblockManager<?>, Structure> entry = iterator.next();
                Structure structure = entry.getValue();
                if (structure.isValid()) {
                    if (activeMultiblock == null && structure.getController() != null && getMultiblockData(structure).isFormed()) {
                        activeMultiblock = entry.getKey().getNameLower();
                    }
                } else {
                    iterator.remove();
                }
            }
        }
        if (ticker >= 3 && structures.isEmpty()) {
            invalidStructure.tick(this, true);
            // If we managed to find any structures check which one is active
            for (Map.Entry<MultiblockManager<?>, Structure> entry : structures.entrySet()) {
                Structure structure = entry.getValue();
                if (structure.getController() != null && getMultiblockData(structure).isFormed()) {
                    activeMultiblock = entry.getKey().getNameLower();
                    break;
                }
            }
        }
        // this could potentially fail if this structural multiblock tracks multiple structures, but 99.99% of the time this will be accurate
        if (!Objects.equals(activeMultiblock, clientActiveMultiblock)) {
            clientActiveMultiblock = activeMultiblock;
            sendUpdatePacket();
        }
    }
}
Also used : MultiblockManager(mekanism.common.lib.multiblock.MultiblockManager) Structure(mekanism.common.lib.multiblock.Structure) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

MultiblockManager (mekanism.common.lib.multiblock.MultiblockManager)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Structure (mekanism.common.lib.multiblock.Structure)2 Coord4D (mekanism.api.Coord4D)1 IRadiationManager (mekanism.api.radiation.IRadiationManager)1 MultiblockData (mekanism.common.lib.multiblock.MultiblockData)1