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 ff5a5721633b83465ab501cbdfdc579a0f20e938 assets/tfmg/blockstates/accumulator.json
e982a263b6af75821042107fdeff7bd809436d08 assets/tfmg/blockstates/air_intake.json e982a263b6af75821042107fdeff7bd809436d08 assets/tfmg/blockstates/air_intake.json
e7f63aadfc892e337d9f87b5e50af8b1c7e4103f assets/tfmg/blockstates/aluminum_bars.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 c58fa20c091e5ecddfb7164cba45538a8f911431 assets/tfmg/blockstates/yellow_rebar_concrete_wall.json
0271e2b940bb94cdb7e951b81e277ee633d64d62 assets/tfmg/blockstates/zinc_frame.json 0271e2b940bb94cdb7e951b81e277ee633d64d62 assets/tfmg/blockstates/zinc_frame.json
1bd66f29acffb67f30bfe94c8535509bd009beab assets/tfmg/blockstates/zinc_truss.json 1bd66f29acffb67f30bfe94c8535509bd009beab assets/tfmg/blockstates/zinc_truss.json
8489b12e9de05253138b7dbf6a09639d0bd0108b assets/tfmg/lang/en_ud.json 357f4d6abeef0bde539d7075fea14bc2853eb121 assets/tfmg/lang/en_ud.json
d1d839eaaafa2f59677b435ec41e917d8ea0a6db assets/tfmg/lang/en_us.json 4178184df5302698896a54d0d9d9eaef71340069 assets/tfmg/lang/en_us.json
9e6a6b62f5e7528c4e4d4f72f3510edcd8f0c078 assets/tfmg/models/block/aluminum_block.json 9e6a6b62f5e7528c4e4d4f72f3510edcd8f0c078 assets/tfmg/models/block/aluminum_block.json
1d33a893d6ac05f9adaceb7f84423ebe9b195c01 assets/tfmg/models/block/aluminum_cable_hub.json 1d33a893d6ac05f9adaceb7f84423ebe9b195c01 assets/tfmg/models/block/aluminum_cable_hub.json
da469bf3233944085f07d4ef437827061e408838 assets/tfmg/models/block/aluminum_cap.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.heat_status": " :snʇɐʇS ʇɐǝH",
"create.goggles.vat.heated": "pǝʇɐǝH", "create.goggles.vat.heated": "pǝʇɐǝH",
"create.goggles.vat.no_heat": "ʇɐǝH oN", "create.goggles.vat.no_heat": "ʇɐǝH oN",
"create.goggles.vat.not_operational": "ןɐuoıʇɐɹǝdO ʇoN",
"create.goggles.vat.superheated": "pǝʇɐǝɥɹǝdnS", "create.goggles.vat.superheated": "pǝʇɐǝɥɹǝdnS",
"create.goggles.vat.tfmg.centrifuge": "ǝbnɟıɹʇuǝƆ ", "create.goggles.vat.tfmg.centrifuge": "ǝbnɟıɹʇuǝƆ ",
"create.goggles.vat.tfmg.electrode": "ǝpoɹʇɔǝןƎ ", "create.goggles.vat.tfmg.electrode": "ǝpoɹʇɔǝןƎ ",

View File

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

View File

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

View File

@@ -126,7 +126,7 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I
@Override @Override
public String getOperationId() { public String getOperationId() {
return isOperational() ? electrode.getOperationId() : ""; return electrode.getOperationId();
//return switch (electrodeType) { //return switch (electrodeType) {
// //
@@ -136,6 +136,11 @@ public class ElectrodeHolderBlockEntity extends ElectricBlockEntity implements I
//}; //};
} }
@Override
public boolean canOperate(VatBlockEntity vat) {
return isOperational();
}
@Override @Override
public int getWorkPercentage() { public int getWorkPercentage() {
return (getPowerUsage() / 5000) * 100; 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.TFMGItems;
import com.drmangotea.tfmg.registry.TFMGPartialModels; import com.drmangotea.tfmg.registry.TFMGPartialModels;
import com.simibubi.create.AllPartialModels; 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.KineticBlockEntity;
import com.simibubi.create.content.kinetics.base.OrientedRotatingVisual; import com.simibubi.create.content.kinetics.base.OrientedRotatingVisual;
import com.simibubi.create.content.kinetics.gantry.GantryShaftBlock; import com.simibubi.create.content.kinetics.gantry.GantryShaftBlock;
import com.simibubi.create.content.kinetics.gantry.GantryShaftBlockEntity; 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.visual.BlockEntityVisual;
import dev.engine_room.flywheel.api.visualization.VisualizationContext; import dev.engine_room.flywheel.api.visualization.VisualizationContext;
import dev.engine_room.flywheel.lib.model.Models; 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) { public boolean setMixerMode(ItemStack modeItem, boolean simulate) {
for (MixerMode mode : MixerMode.values()) { for (MixerMode mode : MixerMode.values()) {
if (mode.item.is(modeItem.getItem())) { if (mode.item.is(modeItem.getItem())) {

View File

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