Skip to content

Commit

Permalink
Remove MuTE leftover & minor refactor around ProcessingLogic (#3802)
Browse files Browse the repository at this point in the history
  • Loading branch information
miozune authored Jan 13, 2025
1 parent e4fb6c1 commit 0b346cf
Show file tree
Hide file tree
Showing 58 changed files with 390 additions and 3,957 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public CheckRecipeResult process() {
mFloor = (lastRecipe.mSpecialValue % 10000) * 1000000;
mCeil = (lastRecipe.mSpecialValue / 10000) * 1000000;
if (eV > mCeil || eV < mFloor) {
setOutputItems(ItemRefer.Radioactive_Waste.get(4));
overwriteOutputItems(ItemRefer.Radioactive_Waste.get(4));
}
// NA does not consume power, its hatches do. Set it to 0 to be sure
calculatedEut = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/GTMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import gregtech.api.interfaces.internal.IGTMod;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.implementations.MTEHatchNonConsumableBase;
import gregtech.api.objects.GTItemStack;
import gregtech.api.objects.ItemData;
import gregtech.api.objects.XSTR;
import gregtech.api.registries.LHECoolantRegistry;
Expand All @@ -80,7 +81,6 @@
import gregtech.api.util.GTRecipeRegistrator;
import gregtech.api.util.GTSpawnEventHandler;
import gregtech.api.util.GTUtility;
import gregtech.api.util.item.ItemHolder;
import gregtech.common.GTDummyWorld;
import gregtech.common.GTNetwork;
import gregtech.common.GTProxy;
Expand Down Expand Up @@ -800,7 +800,7 @@ public void onIDChangingEvent(FMLModIdMappingEvent aEvent) {
for (Map<?, ?> gt_itemStackMap : GregTechAPI.sItemStackMappings) {
GTUtility.reMap(gt_itemStackMap);
}
for (SetMultimap<? extends ItemHolder, ?> gt_itemStackMap : GregTechAPI.itemStackMultiMaps) {
for (SetMultimap<GTItemStack, ?> gt_itemStackMap : GregTechAPI.itemStackMultiMaps) {
GTUtility.reMap(gt_itemStackMap);
}
} catch (Throwable e) {
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/gregtech/api/GregTechAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
import gregtech.api.util.GTModHandler;
import gregtech.api.util.GTOreDictUnificator;
import gregtech.api.util.GTUtility;
import gregtech.api.util.item.ItemHolder;
import gregtech.api.world.GTWorldgen;
import gregtech.common.GTDummyWorld;
import gregtech.common.items.ItemIntegratedCircuit;
Expand Down Expand Up @@ -93,7 +92,7 @@ public class GregTechAPI {
* {@link GTItemStack}
*/
public static final Collection<Map<?, ?>> sItemStackMappings = new ArrayList<>();
public static final Collection<SetMultimap<? extends ItemHolder, ?>> itemStackMultiMaps = new ArrayList<>();
public static final Collection<SetMultimap<GTItemStack, ?>> itemStackMultiMaps = new ArrayList<>();

/**
* The MetaTileEntity-ID-List-Length
Expand Down Expand Up @@ -150,17 +149,16 @@ public class GregTechAPI {
/**
* The List of Tools, which can be used. Accepts regular damageable Items and Electric Items
*/
public static final GTHashSet<GTItemStack> sToolList = new GTHashSet<>(), sCrowbarList = new GTHashSet<>(),
sScrewdriverList = new GTHashSet<>(), sWrenchList = new GTHashSet<>(), sSoftHammerList = new GTHashSet<>(),
sHardHammerList = new GTHashSet<>(), sWireCutterList = new GTHashSet<>(),
sSolderingToolList = new GTHashSet<>(), sSolderingMetalList = new GTHashSet<>(),
sJackhammerList = new GTHashSet<>();
public static final GTHashSet sToolList = new GTHashSet(), sCrowbarList = new GTHashSet(),
sScrewdriverList = new GTHashSet(), sWrenchList = new GTHashSet(), sSoftHammerList = new GTHashSet(),
sHardHammerList = new GTHashSet(), sWireCutterList = new GTHashSet(), sSolderingToolList = new GTHashSet(),
sSolderingMetalList = new GTHashSet(), sJackhammerList = new GTHashSet();
/**
* The List of Hazmat Armors
*/
public static final GTHashSet<GTItemStack> sGasHazmatList = new GTHashSet<>(), sBioHazmatList = new GTHashSet<>(),
sFrostHazmatList = new GTHashSet<>(), sHeatHazmatList = new GTHashSet<>(), sRadioHazmatList = new GTHashSet<>(),
sElectroHazmatList = new GTHashSet<>();
public static final GTHashSet sGasHazmatList = new GTHashSet(), sBioHazmatList = new GTHashSet(),
sFrostHazmatList = new GTHashSet(), sHeatHazmatList = new GTHashSet(), sRadioHazmatList = new GTHashSet(),
sElectroHazmatList = new GTHashSet();

private static final Multimap<Integer, ItemStack> sRealConfigurationList = Multimaps
.newListMultimap(new TreeMap<>(), ArrayList::new);
Expand Down
79 changes: 1 addition & 78 deletions src/main/java/gregtech/api/enums/GTValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,79 +230,7 @@ public class GTValues {
*/
public static final class NBT {

public static final String COLOR = "gt.color", // Integer
COVERS = "gt.covers", // String
CUSTOM_NAME = "name", // String
DISPLAY = "gt.display", // String
TIER = "gt.tier", // Number
FACING = "gt.facing", // Byte
LOCK_UPGRADE = "gt.locked", // Boolean
MATERIAL = "gt.material", // String containing the Material Name.
MODE = "gt.mode", // Number
ALLOWED_MODES = "gt.amode", // Number
MTE_ID = "gt.mte.id", // Containing the MTE ID
MTE_REG = "gt.mte.reg", // Containing the MTE Registry ID
OWNER = "gt.owner", // String
OWNER_UUID = "gt.ownerUuid", // UUID (String)

// Machines
ACTIVE = "gt.active", // Boolean
FLUID_OUT = "gt.fluidout", // Output Fluid
ITEM_OUT = "gt.itemout", // Output Item
PARALLEL = "gt.parallel", // Number
TANK_CAPACITY = "gt.tankcap", // Number
TANK_IN = "gt.tank.in.", // FluidStack
TANK_OUT = "gt.tank.out.", // FluidStack
TEXTURE_FOLDER = "gt.texture.folder", // String
INV_INPUT_SIZE = "gt.invsize.in", // Number
INV_OUTPUT_SIZE = "gt.invsize.out", // Number
INV_INPUT_LIST = "gt.invlist.in", // NBT List
INV_OUTPUT_LIST = "gt.invlist.out", // NBT List
VOLTAGE = "gt.voltage", // Number
AMPERAGE = "gt.amperage", // Number
STORED_ENERGY = "gt.stored.energy", // Number
MAXIMUM_ENERGY = "gt.maximum.energy", // Number
EUT_CONSUMPTION = "gt.eut.consumption", // Number
BURN_TIME_LEFT = "gt.burn.time.left", // Number
TOTAL_BURN_TIME = "gt.total.burn.time", // Number
ALLOWED_WORK = "gt.allowed.work", // Boolean
TASKS = "gt.tasks", // Compound

// MultiBlock
STRUCTURE_OK = "gt.structure.ok", ROTATION = "gt.eRotation", FLIP = "gt.eFlip", TARGET = "gt.target", // Boolean
TARGET_X = "gt.target.x", // Number
TARGET_Y = "gt.target.y", // Number
TARGET_Z = "gt.target.z", // Number
LOCKED_FLUID = "gt.locked.fluid", // String
LOCKED_INVENTORY = "gt.locked.inv", // String
LOCKED_INVENTORY_INDEX = "gt.locked.inv.index", // Number
UPGRADE_INVENTORY_SIZE = "gt.invsize.upg", // String
UPGRADE_INVENTORY_UUID = "gt.invuuid.upg", // String
UPGRADE_INVENTORY_NAME = "gt.invname.upg", // String
UPGRADE_INVENTORIES_INPUT = "gt.invlist.upg.in", // NBT List
UPGRADE_INVENTORIES_OUTPUT = "gt.invlist.upg.out", // NBT List
UPGRADE_TANK_CAPACITY = "gt.tank.cap.upg", // Long
UPGRADE_TANK_COUNT = "gt.tank.ct.upg", // Int
UPGRADE_TANK_CAPACITY_MULTIPLIER = "gt.tank.cap.mult.upg", // Long
UPGRADE_TANK_UUID = "gt.tankuuid.upg", // String
UPGRADE_TANK_NAME = "gt.tankname.upg", // String
UPGRADE_TANKS_INPUT = "gt.tanklist.upg.in", // NBT List
UPGRADE_TANKS_OUTPUT = "gt.tanklist.upg.out", // NBT List
UPGRADE_TANKS_PREFIX = "gt.tank.upg", // NBT Tag
UPGRADE_AMPERAGE = "gt.amp.upg", // Long
SEPARATE_INPUTS = "gt.separate.inputs", // Boolean
VOIDING_MODE = "gt.voiding.mode", // String
BATCH_MODE = "gt.batch.mode", // Boolean
RECIPE_LOCK = "gt.recipe.lock", // Boolean

// Logic
POWER_LOGIC = "gt.pow.logic", // NBT Tag
POWER_LOGIC_STORED_ENERGY = "gt.pow.energy", // Number
POWER_LOGIC_ENERGY_CAPACITY = "gt.pow.energy.cap", // Number
POWER_LOGIC_VOLTAGE = "gt.pow.volt", // Number
POWER_LOGIC_AMPERAGE = "gt.pow.amp", // Number
POWER_LOGIC_TYPE = "gt.pow.type", // Number
empty_ = "";
public static final String COVERS = "gt.covers"; // String
}

/** The Color White as RGB Short Array. */
Expand Down Expand Up @@ -435,11 +363,6 @@ public static final class NBT {
* Debug parameter for {@link GTChunkAssociatedData}
*/
public static boolean debugWorldData = false;
/**
* Parameter if multi tile entities (MuTEs) should be enabled in the pack. Turned off by default until
* implementation is done.
*/
public static boolean enableMultiTileEntities = false;
/**
* Number of ticks between sending sound packets to clients for electric machines. Default is 1.5 seconds. Trying to
* mitigate lag and FPS drops.
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/gregtech/api/enums/InventoryType.java

This file was deleted.

56 changes: 0 additions & 56 deletions src/main/java/gregtech/api/gui/GUIHost.java

This file was deleted.

38 changes: 0 additions & 38 deletions src/main/java/gregtech/api/gui/GUIProvider.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

import java.util.Objects;

import javax.annotation.Nonnull;

import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;

import cofh.api.energy.IEnergyReceiver;
import gregtech.api.GregTechAPI;
import gregtech.api.logic.PowerLogic;
import gregtech.api.logic.interfaces.PowerLogicHost;
import gregtech.api.util.GTUtility;
import ic2.api.energy.tile.IEnergySink;

Expand Down Expand Up @@ -77,15 +73,7 @@ public static long emitEnergyToNetwork(long voltage, long amperage, IEnergyConne

final ForgeDirection oppositeSide = Objects.requireNonNull(side.getOpposite());
final TileEntity tTileEntity = emitterTile.getTileEntityAtSide(side);
if (tTileEntity instanceof PowerLogicHost host) {

final PowerLogic logic = host.getPowerLogic(oppositeSide);
if (logic == null || logic.isEnergyReceiver()) {
continue;
}

usedAmperes += logic.injectEnergy(voltage, amperage - usedAmperes);
} else if (tTileEntity instanceof IEnergyConnected energyConnected) {
if (tTileEntity instanceof IEnergyConnected energyConnected) {
if (emitter.getColorization() >= 0) {
final byte tColor = energyConnected.getColorization();
if (tColor >= 0 && tColor != emitter.getColorization()) continue;
Expand All @@ -107,72 +95,5 @@ public static long emitEnergyToNetwork(long voltage, long amperage, IEnergyConne
}
return usedAmperes;
}

/**
* Same as {@link #emitEnergyToNetwork(long, long, IEnergyConnected)}, but instead we remove the energy directly from the logic itself.
* @param emitter The host, which is trying to emit energy in the network
* @param outputSide side from where energy is being outputted to. If its {@link ForgeDirection#UNKNOWN} then it doesn't emit energy to the network
*/
public static void emitEnergyToNetwork(@Nonnull final PowerLogicHost emitter, @Nonnull final ForgeDirection outputSide) {
if (outputSide == ForgeDirection.UNKNOWN) return;
final PowerLogic emitterLogic = emitter.getPowerLogic();
long usedAmperes = 0;
long voltage = emitterLogic.getVoltage();
long amperage = emitterLogic.getMaxAmperage();
if (!(emitter instanceof final IHasWorldObjectAndCoords emitterTile)) {
return;
}
// We need to make sure we can actually output energy on this side. This is more of a safety check.
if (emitter.getPowerLogic(outputSide) == null) {
return;
}

final ForgeDirection oppositeSide = Objects.requireNonNull(outputSide.getOpposite());
final TileEntity tileEntity = emitterTile.getTileEntityAtSide(outputSide);
if (tileEntity instanceof PowerLogicHost host) {

final PowerLogic logic = host.getPowerLogic(oppositeSide);
if (logic == null || logic.isEnergyReceiver()) {
return;
}

usedAmperes += logic.injectEnergy(voltage, amperage);
emitterLogic.removeEnergyUnsafe(usedAmperes * voltage);
return;
}

if (tileEntity instanceof IEnergyConnected energyConnected) {
if (emitter instanceof IColoredTileEntity coloredEmitter && coloredEmitter.getColorization() >= 0) {
final byte tColor = energyConnected.getColorization();
if (tColor >= 0 && tColor != coloredEmitter.getColorization()) {
return;
}
}
usedAmperes += energyConnected.injectEnergyUnits(oppositeSide, voltage, amperage - usedAmperes);
emitterLogic.removeEnergyUnsafe(usedAmperes * voltage);
return;
}

if (tileEntity instanceof IEnergySink sink) {
if (sink.acceptsEnergyFrom((TileEntity) emitter, oppositeSide)) {
while (amperage > usedAmperes && sink.getDemandedEnergy() > 0
&& sink.injectEnergy(oppositeSide, voltage, voltage) < voltage) {
usedAmperes++;
}
emitterLogic.removeEnergyUnsafe(usedAmperes * voltage);
return;
}
}

if (GregTechAPI.mOutputRF && tileEntity instanceof IEnergyReceiver receiver) {
final int rfOut = GTUtility.safeInt(voltage * GregTechAPI.mEUtoRF / 100);
if (receiver.receiveEnergy(oppositeSide, rfOut, true) == rfOut) {
receiver.receiveEnergy(oppositeSide, rfOut, false);
usedAmperes++;
emitterLogic.removeEnergyUnsafe(usedAmperes * voltage);
return;
}
}
}
}
}
Loading

0 comments on commit 0b346cf

Please sign in to comment.