oh, in the distance i could see a pale light

This commit is contained in:
Boblet 2025-03-18 16:53:41 +01:00
parent 360daaa524
commit 7b80e9fb64
10 changed files with 31 additions and 15 deletions

View File

@ -40,7 +40,7 @@ public class PowerNetMK2 extends NodeNet<IEnergyReceiverMK2, IEnergyProviderMK2,
Iterator<Entry<IEnergyProviderMK2, Long>> provIt = providerEntries.entrySet().iterator();
while(provIt.hasNext()) {
Entry<IEnergyProviderMK2, Long> entry = provIt.next();
if(timestamp - entry.getValue() > timeout) { provIt.remove(); continue; }
if(timestamp - entry.getValue() > timeout || isBadLink(entry.getKey())) { provIt.remove(); continue; }
long src = Math.min(entry.getKey().getPower(), entry.getKey().getProviderSpeed());
if(src > 0) {
providers.add(new Pair(entry.getKey(), src));
@ -58,7 +58,7 @@ public class PowerNetMK2 extends NodeNet<IEnergyReceiverMK2, IEnergyProviderMK2,
while(recIt.hasNext()) {
Entry<IEnergyReceiverMK2, Long> entry = recIt.next();
if(timestamp - entry.getValue() > timeout) { recIt.remove(); continue; }
if(timestamp - entry.getValue() > timeout || isBadLink(entry.getKey())) { recIt.remove(); continue; }
long rec = Math.min(entry.getKey().getMaxPower() - entry.getKey().getPower(), entry.getKey().getReceiverSpeed());
if(rec > 0) {
int p = entry.getKey().getPriority().ordinal();

View File

@ -53,7 +53,7 @@ public class FluidNetMK2 extends NodeNet<IFluidReceiverMK2, IFluidProviderMK2, F
while(iterator.hasNext()) {
Entry<IFluidProviderMK2, Long> entry = iterator.next();
if(currentTime - entry.getValue() > timeout) { iterator.remove(); continue; }
if(currentTime - entry.getValue() > timeout || isBadLink(entry.getKey())) { iterator.remove(); continue; }
IFluidProviderMK2 provider = entry.getKey();
int[] pressureRange = provider.getProvidingPressureRange(type);
for(int p = pressureRange[0]; p <= pressureRange[1]; p++) {
@ -69,7 +69,7 @@ public class FluidNetMK2 extends NodeNet<IFluidReceiverMK2, IFluidProviderMK2, F
while(iterator.hasNext()) {
Entry<IFluidReceiverMK2, Long> entry = iterator.next();
if(currentTime - entry.getValue() > timeout) { iterator.remove(); continue; }
if(currentTime - entry.getValue() > timeout || isBadLink(entry.getKey())) { iterator.remove(); continue; }
IFluidReceiverMK2 receiver = entry.getKey();
int[] pressureRange = receiver.getReceivingPressureRange(type);
for(int p = pressureRange[0]; p <= pressureRange[1]; p++) {

View File

@ -2,7 +2,9 @@ package api.hbm.fluidmk2;
import com.hbm.inventory.fluid.tank.FluidTank;
public interface IFluidUserMK2 extends IFluidConnectorMK2 {
import api.hbm.tile.ILoadedTile;
public interface IFluidUserMK2 extends IFluidConnectorMK2, ILoadedTile {
public static final int HIGHEST_VALID_PRESSURE = 5;
public static final int[] DEFAULT_PRESSURE_RANGE = new int[] {0, 0};

View File

@ -1,5 +1,6 @@
package api.hbm.tile;
/** For anything that should be removed off networks when considered unloaded, only affects providers and receivers, not links. Must not necessarily be a tile. */
public interface ILoadedTile {
public boolean isLoaded();

View File

@ -324,5 +324,18 @@ public class BlockPWR extends BlockContainer implements IBlockCT {
return false;
}
public boolean isLoaded = true;
@Override
public boolean isLoaded() {
return isLoaded;
}
@Override
public void onChunkUnload() {
super.onChunkUnload();
this.isLoaded = false;
}
}
}

View File

@ -6406,16 +6406,6 @@ public class ModItems {
GameRegistry.registerItem(mp_chip_4, mp_chip_4.getUnlocalizedName());
GameRegistry.registerItem(mp_chip_5, mp_chip_5.getUnlocalizedName());
/*GameRegistry.registerItem(missile_skin_camo, missile_skin_camo.getUnlocalizedName());
GameRegistry.registerItem(missile_skin_desert, missile_skin_desert.getUnlocalizedName());
GameRegistry.registerItem(missile_skin_flames, missile_skin_flames.getUnlocalizedName());
GameRegistry.registerItem(missile_skin_manly_pink, missile_skin_manly_pink.getUnlocalizedName());
GameRegistry.registerItem(missile_skin_orange_insulation, missile_skin_orange_insulation.getUnlocalizedName());
GameRegistry.registerItem(missile_skin_sleek, missile_skin_sleek.getUnlocalizedName());
GameRegistry.registerItem(missile_skin_soviet_glory, missile_skin_soviet_glory.getUnlocalizedName());
GameRegistry.registerItem(missile_skin_soviet_stank, missile_skin_soviet_stank.getUnlocalizedName());
GameRegistry.registerItem(missile_skin_metal, missile_skin_metal.getUnlocalizedName());*/
//Satellites
GameRegistry.registerItem(sat_mapper, sat_mapper.getUnlocalizedName());
GameRegistry.registerItem(sat_scanner, sat_scanner.getUnlocalizedName());

View File

@ -97,6 +97,7 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei
public GunConfig getConfig(ItemStack stack, int index) {
GunConfig cfg = configs_DNA[index];
if(stack == null) return cfg;
return WeaponUpgradeManager.eval(cfg, stack, O_GUNCONFIG + index, this);
}

View File

@ -7,6 +7,9 @@ import java.util.List;
import java.util.Random;
import java.util.Set;
import api.hbm.tile.ILoadedTile;
import net.minecraft.tileentity.TileEntity;
public abstract class NodeNet<R, P, L extends GenNode> {
/** Global random for figuring things out like random leftover distribution */
@ -79,4 +82,10 @@ public abstract class NodeNet<R, P, L extends GenNode> {
this.receiverEntries.clear();
this.providerEntries.clear();
}
public static boolean isBadLink(Object o) {
if(o instanceof ILoadedTile && !((ILoadedTile) o).isLoaded()) return true;
if(o instanceof TileEntity && ((TileEntity) o).isInvalid()) return true;
return false;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB