Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add speed and power cap upgrades to the Soul Engine #483

Merged
merged 4 commits into from
Oct 8, 2023
Merged
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 @@ -56,8 +56,10 @@ protected void renderLabels(GuiGraphics guiGraphics, int pMouseX, int pMouseY) {
}
EngineSoul.SoulData data = EngineSoul.ENGINE.map.get(rl.get());
if (data != null) {
guiGraphics.drawString(font, data.tickpermb() + " t/mb", imageWidth / 2f + 12 , 40, 4210752, false);
guiGraphics.drawString(font, data.powerpermb() + " µI/mb", imageWidth / 2f + 12 , 50, 4210752, false);
double burnRate = menu.getBlockEntity().getBurnRate();
float genRate = menu.getBlockEntity().getGenerationRate();
guiGraphics.drawString(font, data.tickpermb()/ burnRate + " t/mb", imageWidth / 2f + 12 , 40, 4210752, false);
guiGraphics.drawString(font, (int) (data.powerpermb() * genRate) + " µI/mb", imageWidth / 2f + 12 , 50, 4210752, false);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.enderio.api.capability.StoredEntityData;
import com.enderio.api.capacitor.CapacitorModifier;
import com.enderio.api.capacitor.FixedScalable;
import com.enderio.api.capacitor.LinearScalable;
import com.enderio.api.capacitor.QuadraticScalable;
import com.enderio.api.io.energy.EnergyIOMode;
import com.enderio.core.common.network.slot.FluidStackNetworkDataSlot;
Expand Down Expand Up @@ -46,6 +47,10 @@
public class SoulEngineBlockEntity extends PoweredMachineBlockEntity {

private static final QuadraticScalable CAPACITY = new QuadraticScalable(CapacitorModifier.ENERGY_CAPACITY, MachinesConfig.COMMON.ENERGY.SOUL_ENGINE_CAPACITY);
public static final LinearScalable BURN_SPEED = new LinearScalable(CapacitorModifier.FIXED, MachinesConfig.COMMON.ENERGY.SOUL_ENGINE_BURN_SPEED);
//TODO capacitor increase efficiency
public static final LinearScalable GENERATION_SPEED = new LinearScalable(CapacitorModifier.FIXED, () -> 1);

private static final String BURNED_TICKS = "BurnedTicks";
private StoredEntityData entityData = StoredEntityData.empty();
public static final int FLUID_CAPACITY = 2 * FluidType.BUCKET_VOLUME;
Expand Down Expand Up @@ -97,17 +102,27 @@ protected boolean isActive() {
}

public void producePower() {
if (burnedTicks == soulData.tickpermb()) {
if (!getFluidTankNN().isEmpty() && getEnergyStorage().addEnergy(soulData.powerpermb(), true) == soulData.powerpermb()) {
if (burnedTicks >= soulData.tickpermb()) {
int energy = (int) (soulData.powerpermb() * getGenerationRate());
if (!getFluidTankNN().isEmpty() && getEnergyStorage().addEnergy(energy, true) == energy) {
getFluidTankNN().drain(1, IFluidHandler.FluidAction.EXECUTE);
getEnergyStorage().addEnergy(soulData.powerpermb());
burnedTicks = 0;
getEnergyStorage().addEnergy(energy);
burnedTicks -= soulData.tickpermb();
}
} else {
burnedTicks ++;
burnedTicks += getBurnRate();
}
}

public int getBurnRate() {
return BURN_SPEED.scaleI(this::getCapacitorData).get();
}

public float getGenerationRate() {
//TODO return GENERATION_SPEED.scaleF(this::getCapacitorData).get();
return MachinesConfig.COMMON.ENERGY.SOUL_ENGINE_BURN_SPEED.get();
}

@Override
protected @Nullable FluidTank createFluidTank() {
return new MachineFluidTank(FLUID_CAPACITY, isFluidValid(), this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,10 @@ private void cacheCapacitorData() {
capacitorCacheDirty = false;

// Don't do this on client side, client waits for the sync packet.
if (level.isClientSide()) {
return;
}
// TODO Do we want to sync with a packet cause right now we don't
// if (level.isClientSide()) {
// return;
// }

MachineInventoryLayout layout = getInventoryLayout();
if (requiresCapacitor() && layout != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class EnergyConfig {
public final ForgeConfigSpec.ConfigValue<Integer> WIRED_CHARGER_CAPACITY;
public final ForgeConfigSpec.ConfigValue<Integer> WIRED_CHARGER_USAGE;
public final ForgeConfigSpec.ConfigValue<Integer> SOUL_ENGINE_CAPACITY;
public final ForgeConfigSpec.ConfigValue<Integer> SOUL_ENGINE_BURN_SPEED;
public final ForgeConfigSpec.ConfigValue<Double> SOUL_ENGINE_GENERATION;
public final ForgeConfigSpec.ConfigValue<Integer> DRAIN_CAPACITY;
public final ForgeConfigSpec.ConfigValue<Integer> DRAIN_USAGE;

Expand Down Expand Up @@ -93,8 +95,7 @@ public EnergyConfig(ForgeConfigSpec.Builder builder) {
builder.push("paintingMachine");
PAINTING_MACHINE_CAPACITY = builder.comment("The base energy capacity in uI.").defineInRange("capacity", 64_000, 1, Integer.MAX_VALUE);
PAINTING_MACHINE_USAGE = builder.comment("The base energy consumption in uI/t.").defineInRange("usage", 30, 1, Integer.MAX_VALUE);
PAINTING_MACHINE_ENERGY_COST = builder.comment("The energy required for each painting operation")
.defineInRange("energyCost", 2_400, 1, Integer.MAX_VALUE);
PAINTING_MACHINE_ENERGY_COST = builder.comment("The energy required for each painting operation").defineInRange("energyCost", 2_400, 1, Integer.MAX_VALUE);
builder.pop();

builder.push("photovoltaicCellRates");
Expand All @@ -116,14 +117,16 @@ public EnergyConfig(ForgeConfigSpec.Builder builder) {
WIRED_CHARGER_USAGE = builder.comment("The base energy consumption in uI/t.").defineInRange("usage", 64, 1, Integer.MAX_VALUE);
builder.pop();

builder.push("mob_generator");
builder.push("soul_engine");
SOUL_ENGINE_CAPACITY = builder.defineInRange("capacity",100000, 1, Integer.MAX_VALUE);
SOUL_ENGINE_BURN_SPEED = builder.comment("The base burn-rate the soul engine.").defineInRange("burnSpeed", 1, 1, Integer.MAX_VALUE);
SOUL_ENGINE_GENERATION = builder.comment("Percentage increase in uI produced.").defineInRange("generation", 1.0, 0.001, Double.MAX_VALUE);

builder.pop();

builder.push("drain");
DRAIN_CAPACITY = builder.comment("The base energy capacity in uI.").defineInRange("capacity", 64_000, 1, Integer.MAX_VALUE);
DRAIN_USAGE = builder.comment("The base energy consumption in uI/t.").defineInRange("usage", 10, 1, Integer.MAX_VALUE);

builder.pop();

builder.pop();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"parent": "enderio:block/stirling_generator",
"parent": "enderio:block/soul_engine",
"textures": {
"north": "enderio:block/soul_engine_front_active"
}
Expand Down
Loading