Vat Utilities

- Vat Attachments can now specify conditions in which they aren't operational.
- The Vat now saves all attachments to a map of Operation ID and BlockPos.
- Attachments are checked every tick to ensure they are operational.
- Modified Goggle Info of the Vat to notify if an attachment is not operational.
- Electrodes now always supply their operation ID but require a minumum current to operate.
- Industrial Mixers now require a minimum rpm to operate.
This commit is contained in:
PouffyDev
2025-07-08 20:34:47 +01:00
parent 8bdf360d97
commit 5eadb57708
8 changed files with 65 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
// 1.20.1 2025-07-03T14:20:42.800196 Registrate Provider for tfmg [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
// 1.20.1 2025-07-08T20:26:28.2936491 Registrate Provider for tfmg [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)]
ff5a5721633b83465ab501cbdfdc579a0f20e938 assets/tfmg/blockstates/accumulator.json
e982a263b6af75821042107fdeff7bd809436d08 assets/tfmg/blockstates/air_intake.json
e7f63aadfc892e337d9f87b5e50af8b1c7e4103f assets/tfmg/blockstates/aluminum_bars.json
@@ -436,8 +436,8 @@ a1988ec6a98f23cad8321b46345fbf1c5fd20489 assets/tfmg/blockstates/yellow_rebar_co
c58fa20c091e5ecddfb7164cba45538a8f911431 assets/tfmg/blockstates/yellow_rebar_concrete_wall.json
0271e2b940bb94cdb7e951b81e277ee633d64d62 assets/tfmg/blockstates/zinc_frame.json
1bd66f29acffb67f30bfe94c8535509bd009beab assets/tfmg/blockstates/zinc_truss.json
8489b12e9de05253138b7dbf6a09639d0bd0108b assets/tfmg/lang/en_ud.json
d1d839eaaafa2f59677b435ec41e917d8ea0a6db assets/tfmg/lang/en_us.json
357f4d6abeef0bde539d7075fea14bc2853eb121 assets/tfmg/lang/en_ud.json
4178184df5302698896a54d0d9d9eaef71340069 assets/tfmg/lang/en_us.json
9e6a6b62f5e7528c4e4d4f72f3510edcd8f0c078 assets/tfmg/models/block/aluminum_block.json
1d33a893d6ac05f9adaceb7f84423ebe9b195c01 assets/tfmg/models/block/aluminum_cable_hub.json
da469bf3233944085f07d4ef437827061e408838 assets/tfmg/models/block/aluminum_cap.json

View File

@@ -588,6 +588,7 @@
"create.goggles.vat.heat_status": " :snʇɐʇS ʇɐǝH",
"create.goggles.vat.heated": "pǝʇɐǝH",
"create.goggles.vat.no_heat": "ʇɐǝH oN",
"create.goggles.vat.not_operational": "ןɐuoıʇɐɹǝdO ʇoN",
"create.goggles.vat.superheated": "pǝʇɐǝɥɹǝdnS",
"create.goggles.vat.tfmg.centrifuge": "ǝbnɟıɹʇuǝƆ ",
"create.goggles.vat.tfmg.electrode": "ǝpoɹʇɔǝןƎ ",

View File

@@ -588,6 +588,7 @@
"create.goggles.vat.heat_status": "Heat Status: ",
"create.goggles.vat.heated": "Heated",
"create.goggles.vat.no_heat": "No Heat",
"create.goggles.vat.not_operational": "Not Operational",
"create.goggles.vat.superheated": "Superheated",
"create.goggles.vat.tfmg.centrifuge": " Centrifuge",
"create.goggles.vat.tfmg.electrode": " Electrode",

View File

@@ -8,6 +8,8 @@ public interface IVatMachine {
*/
String getOperationId();
boolean canOperate(VatBlockEntity vat);
/**
* operations that cant mix with this machine
*/

View File

@@ -7,11 +7,15 @@ import com.drmangotea.tfmg.registry.TFMGPackets;
import com.simibubi.create.api.boiler.BoilerHeater;
import com.simibubi.create.api.connectivity.ConnectivityHandler;
import com.simibubi.create.api.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.kinetics.mixer.MechanicalMixerBlockEntity;
import com.simibubi.create.content.processing.basin.BasinBlockEntity;
import com.simibubi.create.content.processing.recipe.HeatCondition;
import com.simibubi.create.content.processing.recipe.ProcessingOutput;
import com.simibubi.create.foundation.blockEntity.IMultiBlockEntityContainer;
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
import com.simibubi.create.foundation.blockEntity.behaviour.ValueBoxTransform;
import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour;
import com.simibubi.create.foundation.blockEntity.behaviour.fluid.SmartFluidTankBehaviour;
import com.simibubi.create.foundation.fluid.CombinedTankWrapper;
import com.simibubi.create.foundation.fluid.FluidIngredient;
@@ -23,6 +27,7 @@ import com.simibubi.create.infrastructure.config.AllConfigs;
import io.netty.util.internal.MathUtil;
import net.createmod.catnip.animation.LerpedFloat;
import net.createmod.catnip.lang.LangBuilder;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.theme.Color;
import net.createmod.ponder.api.level.PonderLevel;
import net.minecraft.ChatFormatting;
@@ -40,6 +45,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
@@ -86,7 +92,9 @@ public class VatBlockEntity extends SmartBlockEntity implements IHaveGoggleInfor
//
public LerpedFloat[] fluidLevel = new LerpedFloat[8];
/// /
public List<String> machines = new ArrayList<>();
public Map<String, BlockPos> machineMap = new HashMap<>();
public Map<BlockPos, Boolean> operationalMachinesMap = new HashMap<>();
public boolean areMachinesValid = true;
boolean evaluateNextTick = true;
float efficiency = 1;
int timer = 0;
@@ -217,7 +225,11 @@ public class VatBlockEntity extends SmartBlockEntity implements IHaveGoggleInfor
continue;
boolean doesntMatch = false;
if (!Objects.equals(testedRecipe.machines, machines)) {
if (!Objects.equals(testedRecipe.machines, machineMap.keySet().stream().toList())) {
continue;
}
if (!getControllerBE().areMachinesValid) {
continue;
}
@@ -382,6 +394,18 @@ public class VatBlockEntity extends SmartBlockEntity implements IHaveGoggleInfor
handleRecipe();
if (isController()) {
for (BlockPos machinePos : machineMap.values()) {
BlockEntity blockEntity = level.getBlockEntity(machinePos);
if (blockEntity instanceof IVatMachine vatMachine) {
boolean operational = vatMachine.canOperate(this);
operationalMachinesMap.put(machinePos, operational);
}
}
}
areMachinesValid = operationalMachinesMap.entrySet().stream().allMatch((op) -> op.getValue() == true);
if (syncCooldown > 0) {
syncCooldown--;
if (syncCooldown == 0 && queuedSync)
@@ -613,8 +637,8 @@ public class VatBlockEntity extends SmartBlockEntity implements IHaveGoggleInfor
return;
}
List<String> oldMachines = machines;
machines = new ArrayList<>();
Map<String, BlockPos> oldMachineMap = machineMap;
machineMap = new HashMap<>();
heatLevel = 0;
heatCondition = HeatCondition.NONE;
@@ -641,7 +665,7 @@ public class VatBlockEntity extends SmartBlockEntity implements IHaveGoggleInfor
continue;
be.vatUpdated(this);
machines.add(be.getOperationId());
machineMap.put(be.getOperationId(), pos);
efficiency *= (be.getWorkPercentage() / 100);
}
@@ -650,13 +674,12 @@ public class VatBlockEntity extends SmartBlockEntity implements IHaveGoggleInfor
}
}
efficiency = speed;
if (oldMachines != machines)
if (oldMachineMap != machineMap)
recipe = null;
notifyUpdate();
}
public boolean isAtValidLocation(IVatMachine.PositionRequirement requirement, BlockPos pos) {
return switch (requirement) {
case ANY -> true;
@@ -859,9 +882,13 @@ public class VatBlockEntity extends SmartBlockEntity implements IHaveGoggleInfor
return null;
}
public void addMachineTooltip(String operationId, List<Component> tooltip) {
CreateLang.translate("goggles.vat."+operationId.replace(":","."))
.forGoggles(tooltip);
public void addMachineTooltip(String operationId, boolean isOperational, List<Component> tooltip) {
LangBuilder operation = CreateLang.translate("goggles.vat."+operationId.replace(":","."));
if (!isOperational) {
operation.add(CreateLang.text(" - ")).add(CreateLang.translate("goggles.vat.not_operational")
.style(ChatFormatting.RED));
}
operation.forGoggles(tooltip);
}
@Override
@@ -879,8 +906,11 @@ public class VatBlockEntity extends SmartBlockEntity implements IHaveGoggleInfor
CreateLang.translate("goggles.vat.attachments")
.style(ChatFormatting.GRAY)
.forGoggles(tooltip);
for (String operation : machines)
addMachineTooltip(operation, tooltip);
for (Map.Entry<String, BlockPos> machines : machineMap.entrySet()) {
boolean operational = operationalMachinesMap.getOrDefault(machines.getValue(), true);
addMachineTooltip(machines.getKey(), operational, tooltip);
}
CreateLang.translate("goggles.vat.heat_status")

View File

@@ -126,7 +126,7 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I
@Override
public String getOperationId() {
return isOperational() ? electrode.getOperationId() : "";
return electrode.getOperationId();
//return switch (electrodeType) {
//
@@ -136,6 +136,11 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I
//};
}
@Override
public boolean canOperate(VatBlockEntity vat) {
return isOperational();
}
@Override
public int getWorkPercentage() {
return (getPowerUsage() / 5000) * 100;

View File

@@ -7,10 +7,14 @@ import com.drmangotea.tfmg.content.machinery.vat.base.VatBlockEntity;
import com.drmangotea.tfmg.registry.TFMGItems;
import com.drmangotea.tfmg.registry.TFMGPartialModels;
import com.simibubi.create.AllPartialModels;
import com.simibubi.create.Create;
import com.simibubi.create.content.kinetics.base.IRotate;
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
import com.simibubi.create.content.kinetics.base.OrientedRotatingVisual;
import com.simibubi.create.content.kinetics.gantry.GantryShaftBlock;
import com.simibubi.create.content.kinetics.gantry.GantryShaftBlockEntity;
import com.simibubi.create.content.kinetics.mixer.MechanicalMixerBlock;
import com.simibubi.create.infrastructure.config.AllConfigs;
import dev.engine_room.flywheel.api.visual.BlockEntityVisual;
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
import dev.engine_room.flywheel.lib.model.Models;
@@ -109,6 +113,11 @@ public class IndustrialMixerBlockEntity extends KineticBlockEntity implements IV
};
}
@Override
public boolean canOperate(VatBlockEntity vat) {
return getSpeed() >= IRotate.SpeedLevel.MEDIUM.getSpeedValue() || getSpeed() <= -IRotate.SpeedLevel.MEDIUM.getSpeedValue();
}
public boolean setMixerMode(ItemStack modeItem, boolean simulate) {
for (MixerMode mode : MixerMode.values()) {
if (mode.item.is(modeItem.getItem())) {

View File

@@ -92,6 +92,7 @@
"create.goggles.vat.no_heat": "No Heat",
"create.goggles.vat.heated": "Heated",
"create.goggles.vat.superheated": "Superheated",
"create.goggles.vat.not_operational": "Not Operational",
"create.goggles.vat.tfmg.graphite_electrode": " Graphite Electrode",
"create.goggles.vat.tfmg.electrode": " Electrode",
"create.goggles.vat.tfmg.mixing": " Mixer",