Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.network.chat.Component;
import net.neganote.gtutilities.GregTechModernUtilities;
import net.neganote.gtutilities.common.machine.multiblock.PTERBMachine;
import net.neganote.gtutilities.common.machine.multiblock.WEBMachine;
import net.neganote.gtutilities.common.machine.singleblock.AutoChargerMachine;
import net.neganote.gtutilities.common.materials.UtilMaterials;
import net.neganote.gtutilities.config.UtilConfig;
Expand Down Expand Up @@ -159,12 +160,13 @@ public static MachineDefinition[] registerTieredMachines(String name,
}

public static MultiblockMachineDefinition PTERB_MACHINE = null;
public static MultiblockMachineDefinition WEB_MACHINE = null;

static {
if (UtilConfig.INSTANCE.features.pterbEnabled || GTCEu.isDataGen()) {
PTERB_MACHINE = REGISTRATE
.multiblock("pterb_machine", PTERBMachine::new)
.langValue("Wireless Active Transformer")
.langValue("Wireless Energy Bridge Hub")
.rotationState(RotationState.ALL)
.recipeType(GTRecipeTypes.DUMMY_RECIPES)
.appearanceBlock(CASING_PALLADIUM_SUBSTATION)
Expand Down Expand Up @@ -208,7 +210,48 @@ public static MachineDefinition[] registerTieredMachines(String name,
.allowExtendedFacing(true)
.hasBER(true)
.register();

WEB_MACHINE = REGISTRATE
.multiblock("web_machine", WEBMachine::new)
.langValue("Wireless Energy Bridge Reciever")
.rotationState(RotationState.ALL)
.recipeType(GTRecipeTypes.DUMMY_RECIPES)
.appearanceBlock(HIGH_POWER_CASING)
.tooltips(Component.translatable("tooltip.web_machine.purpose"),
Component.translatable("gtceu.machine.active_transformer.tooltip.1"),
Component.translatable("tooltip.web_machine.frequencies")
.withStyle(ChatFormatting.GRAY))
.conditionalTooltip(
Component
.translatable("tooltip.pterb_machine.uses_coolant",
UtilMaterials.QuantumCoolant !=
null ? UtilMaterials.QuantumCoolant.getLocalizedName()
.withStyle(ChatFormatting.AQUA) : "")
.withStyle(ChatFormatting.DARK_RED),
UtilConfig.coolantEnabled())
.conditionalTooltip(Component.translatable("tooltip.pterb_machine.input_coolant_before_use")
.withStyle(ChatFormatting.DARK_RED), UtilConfig.coolantEnabled())
.pattern((multiblockMachineDefinition -> FactoryBlockPattern.start()
.aisle("abbba", "aabaa", "aaaaa", "aaaaa", "aaaaa", "aacaa", "aacaa", "aadaa")
.aisle("bbbbb", "abdba", "aacaa", "aaaaa", "aaaaa", "aacaa", "aaaaa", "aaaaa")
.aisle("bbbbb", "bdddb", "acdca", "aadaa", "aadaa", "ccdcc", "cadac", "daaad")
.aisle("bbbbb", "abdba", "aacaa", "aaaaa", "aaaaa", "aacaa", "aaaaa", "aaaaa")
.aisle("abeba", "aabaa", "aaaaa", "aaaaa", "aaaaa", "aacaa", "aacaa", "aadaa")
.where("e", controller(blocks(multiblockMachineDefinition.getBlock())))
.where('b',
blocks(HIGH_POWER_CASING.get()).setMinGlobalLimited(12)
.or(WEBMachine.getHatchPredicates()))
.where("d", blocks(SUPERCONDUCTING_COIL.get()))
.where("c", frames(GTMaterials.NaquadahAlloy))
.where("a", air())
.build()))
.workableCasingModel(GTCEu.id("block/casings/hpca/high_power_casing"),
GTCEu.id("block/multiblock/data_bank"))
.allowExtendedFacing(true)
.hasBER(true)
.register();
}

}

public static void init() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,13 @@ public void explode() {
removeWirelessEnergy();

long inputVoltage = 0;
long outputVoltage = 0;

if (!localPowerInput.isEmpty()) {
EnergyContainerList localInputs = EnergyUtils.getEnergyListFromMultiParts(localPowerInput);
inputVoltage = localInputs.getInputVoltage();
}

if (!localPowerOutput.isEmpty()) {
EnergyContainerList localOutputs = EnergyUtils.getEnergyListFromMultiParts(localPowerOutput);
outputVoltage = localOutputs.getOutputVoltage();
}

long tier = Math.max(GTUtil.getFloorTierByVoltage(inputVoltage), GTUtil.getFloorTierByVoltage(outputVoltage));
long tier = GTUtil.getFloorTierByVoltage(inputVoltage);

doExplosion(15f + tier);
}
Expand Down Expand Up @@ -169,22 +163,14 @@ public void convertEnergyTick() {
private int calculateCoolantDrain() {
long inputAmperage = 0;
long inputVoltage = 0;
long outputAmperage = 0;
long outputVoltage = 0;

if (!localPowerInput.isEmpty()) {
EnergyContainerList localInputs = EnergyUtils.getEnergyListFromMultiParts(localPowerInput);
inputAmperage = localInputs.getInputAmperage();
inputVoltage = localInputs.getInputVoltage();
}

if (!localPowerOutput.isEmpty()) {
EnergyContainerList localOutputs = EnergyUtils.getEnergyListFromMultiParts(localPowerOutput);
outputAmperage = localOutputs.getOutputAmperage();
outputVoltage = localOutputs.getOutputVoltage();
}

long scalingFactor = Math.max(inputAmperage * inputVoltage, outputAmperage * outputVoltage);
long scalingFactor = inputAmperage * inputVoltage;

int coolantDrain = UtilConfig.INSTANCE.features.pterbCoolantBaseDrain +
(int) (scalingFactor * UtilConfig.INSTANCE.features.pterbCoolantIOMultiplier);
Expand Down Expand Up @@ -306,7 +292,6 @@ private void removeWirelessEnergy() {
if (getLevel() instanceof ServerLevel serverLevel) {
PTERBSavedData savedData = PTERBSavedData.getOrCreate(serverLevel.getServer().overworld());
savedData.removeEnergyInputs(frequency, localPowerInput);
savedData.removeEnergyOutputs(frequency, localPowerOutput);
savedData.saveDataToCache();
}
}
Expand All @@ -315,18 +300,14 @@ private void addWirelessEnergy() {
if (getLevel() instanceof ServerLevel serverLevel) {
PTERBSavedData savedData = PTERBSavedData.getOrCreate(serverLevel.getServer().overworld());
savedData.addEnergyInputs(frequency, localPowerInput);
savedData.addEnergyOutputs(frequency, localPowerOutput);
savedData.saveDataToCache();
}
}

public static TraceabilityPredicate getHatchPredicates() {
var predicate = abilities(PartAbility.INPUT_ENERGY).setPreviewCount(1)
.or(abilities(PartAbility.OUTPUT_ENERGY).setPreviewCount(2))
.or(abilities(PartAbility.SUBSTATION_INPUT_ENERGY).setPreviewCount(1))
.or(abilities(PartAbility.SUBSTATION_OUTPUT_ENERGY).setPreviewCount(1))
.or(abilities(PartAbility.INPUT_LASER).setPreviewCount(1))
.or(abilities(PartAbility.OUTPUT_LASER).setPreviewCount(1));
.or(abilities(PartAbility.INPUT_LASER).setPreviewCount(1));
if (UtilConfig.coolantEnabled()) {
predicate = predicate.or(abilities(PartAbility.IMPORT_FLUIDS).setExactLimit(1));
}
Expand All @@ -335,7 +316,7 @@ public static TraceabilityPredicate getHatchPredicates() {

@Override
public void addDisplayText(@NotNull List<Component> textList) {
if (isFormed()) {
if (isFormed() && getLevel() instanceof ServerLevel serverLevel) {
if (frequency == 0) {
textList.add(Component.translatable("gtmutils.pterb_machine.invalid_frequency")
.withStyle(ChatFormatting.RED));
Expand All @@ -346,23 +327,14 @@ public void addDisplayText(@NotNull List<Component> textList) {
} else if (isActive()) {
long inputAmperage = 0;
long inputVoltage = 0;
long outputAmperage = 0;
long outputVoltage = 0;

if (!localPowerInput.isEmpty()) {
EnergyContainerList localInputs = EnergyUtils.getEnergyListFromMultiParts(localPowerInput);
inputAmperage = localInputs.getInputAmperage();
inputVoltage = localInputs.getInputVoltage();
}

if (!localPowerOutput.isEmpty()) {
EnergyContainerList localOutputs = EnergyUtils.getEnergyListFromMultiParts(localPowerOutput);
outputAmperage = localOutputs.getOutputAmperage();
outputVoltage = localOutputs.getOutputVoltage();
}

long inputTotal = inputVoltage * inputAmperage;
long outputTotal = outputVoltage * outputAmperage;

textList.add(Component.translatable("gtceu.multiblock.running"));
if (inputTotal > 0) {
Expand All @@ -371,12 +343,6 @@ public void addDisplayText(@NotNull List<Component> textList) {
FormattingUtil.formatNumbers(
Math.abs(inputTotal))));
}
if (outputTotal > 0) {
textList.add(Component
.translatable("gtceu.multiblock.active_transformer.max_output",
FormattingUtil.formatNumbers(
Math.abs(outputTotal))));
}
if (UtilConfig.coolantEnabled()) {
textList.add(Component
.translatable("gtmutils.multiblock.pterb_machine.coolant_usage",
Expand Down
Loading