Skip to content

Commit 6d10740

Browse files
committed
Finish going through and replacing various numbers with taking constants into account to make it easier to track down what things need to be adjusted to fully support vanilla's tick command
1 parent 6fb10f3 commit 6d10740

File tree

51 files changed

+135
-91
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+135
-91
lines changed

src/datagen/main/java/mekanism/client/texture/MekanismSpriteSourceProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected void gather() {
3333
Mekanism.rl("entity/armor/mekatool")
3434
);
3535

36-
//TODO - 1.20: Add javadocs stating that chemical resources now need to be added via sources???
36+
//TODO - 1.21: Add javadocs stating that chemical resources now need to be added via sources???
3737
// is this even accurate? See if fluids need it as well. Chemicals potentially should use their own directory as well
3838
// just to simplify things? Or maybe we add manually and then also add a specific directory to make it easier for others
3939
addChemicalSprites(atlas);

src/generators/java/mekanism/generators/common/config/GeneratorsConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,17 @@ public class GeneratorsConfig extends BaseMekanismConfig {
131131
turbineBladesPerCoil = CachedIntValue.wrap(this, builder.comment("The number of blades on each turbine coil per blade applied.")
132132
.defineInRange("turbineBladesPerCoil", 4, 1, 12));
133133
turbineVentGasFlow = CachedDoubleValue.wrap(this, builder.comment("The rate at which steam is vented into the turbine.")
134-
.defineInRange("turbineVentGasFlow", 32_000D, 0.1, 1_024_000));
134+
.defineInRange("turbineVentGasFlow", 32D * FluidType.BUCKET_VOLUME, 0.1, 1_024 * FluidType.BUCKET_VOLUME));
135135
turbineDisperserGasFlow = CachedDoubleValue.wrap(this, builder.comment("The rate at which steam is dispersed into the turbine.")
136-
.defineInRange("turbineDisperserGasFlow", 1_280D, 0.1, 1_024_000));
136+
.defineInRange("turbineDisperserGasFlow", 1_280D, 0.1, 1_024 * FluidType.BUCKET_VOLUME));
137137
turbineEnergyCapacityPerVolume = CachedFloatingLongValue.define(this, builder, "Amount of energy (J) that each block of the turbine contributes to the total energy capacity. Max = volume * energyCapacityPerVolume",
138138
"energyCapacityPerVolume", FloatingLong.createConst(16_000_000L), CachedFloatingLongValue.greaterZeroLessThan(FloatingLong.createConst(1_000_000_000_000L)));
139139
//Note: We use maxVolume as it still is a large number, and we have no reason to go higher even if some things we technically could
140140
int maxTurbine = 17 * 17 * 18;
141141
turbineGasPerTank = CachedLongValue.wrap(this, builder.comment("Amount of gas (mB) that each block of the turbine's steam cavity contributes to the volume. Max = volume * gasPerTank")
142142
.defineInRange("gasPerTank", 64L * FluidType.BUCKET_VOLUME, 1, Long.MAX_VALUE / maxTurbine));
143143
condenserRate = CachedIntValue.wrap(this, builder.comment("The rate at which steam is condensed in the turbine.")
144-
.defineInRange("condenserRate", 64_000, 1, 2_000_000));
144+
.defineInRange("condenserRate", 64 * FluidType.BUCKET_VOLUME, 1, 2_000 * FluidType.BUCKET_VOLUME));
145145
builder.pop();
146146

147147
builder.comment("Wind Generator Settings").push(WIND_CATEGORY);

src/generators/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import mekanism.api.RelativeSide;
55
import mekanism.api.math.FloatingLong;
66
import mekanism.common.tile.interfaces.IBoundingBlock;
7+
import mekanism.common.util.MekanismUtils;
78
import mekanism.generators.common.config.MekanismGeneratorsConfig;
89
import mekanism.generators.common.registries.GeneratorsBlocks;
10+
import net.minecraft.SharedConstants;
911
import net.minecraft.core.BlockPos;
1012
import net.minecraft.util.Mth;
1113
import net.minecraft.world.level.Level;
@@ -101,7 +103,7 @@ private static class AdvancedSolarCheck extends SolarCheck {
101103
public AdvancedSolarCheck(Level world, BlockPos pos) {
102104
super(world, pos);
103105
//Recheck between every 10-30 ticks, to not end up checking each position each tick
104-
recheckFrequency = Mth.nextInt(world.random, 10, 30);
106+
recheckFrequency = Mth.nextInt(world.random, MekanismUtils.TICKS_PER_HALF_SECOND, MekanismUtils.TICKS_PER_HALF_SECOND + SharedConstants.TICKS_PER_SECOND);
105107
}
106108

107109
@Override

src/generators/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected IFluidTankHolder getInitialFluidTanks(IContentsListener listener) {
9393
protected IInventorySlotHolder getInitialInventory(IContentsListener listener) {
9494
InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection);
9595
//Divide the burn time by 20 as that is the ratio of how much a bucket of lava would burn for
96-
// Eventually we may want to grab the 20 dynamically in case some mod is changing the burn time of a lava bucket
96+
//TODO: Eventually we may want to grab the 20 dynamically in case some mod is changing the burn time of a lava bucket
9797
builder.addSlot(fuelSlot = FluidFuelInventorySlot.forFuel(lavaTank, stack -> stack.getBurnTime(null) / 20, size -> new FluidStack(Fluids.LAVA, size),
9898
listener, 17, 35), RelativeSide.FRONT, RelativeSide.LEFT, RelativeSide.BACK, RelativeSide.TOP, RelativeSide.BOTTOM);
9999
builder.addSlot(energySlot = EnergyInventorySlot.drain(getEnergyContainer(), listener, 143, 35), RelativeSide.RIGHT);

src/main/java/mekanism/client/recipe_viewer/jei/BaseRecipeCategory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,14 @@ public IDrawable getIcon() {
210210

211211
protected IProgressInfoHandler getSimpleProgressTimer() {
212212
if (timer == null) {
213-
timer = guiHelper.createTickTimer(SharedConstants.TICKS_PER_SECOND, 20, false);
213+
timer = guiHelper.createTickTimer(SharedConstants.TICKS_PER_SECOND, SharedConstants.TICKS_PER_SECOND, false);
214214
}
215-
return () -> timer.getValue() / 20D;
215+
return () -> timer.getValue() / (double) SharedConstants.TICKS_PER_SECOND;
216216
}
217217

218218
protected IBarInfoHandler getBarProgressTimer() {
219219
if (timer == null) {
220-
timer = guiHelper.createTickTimer(SharedConstants.TICKS_PER_SECOND, 20, false);
220+
timer = guiHelper.createTickTimer(SharedConstants.TICKS_PER_SECOND, SharedConstants.TICKS_PER_SECOND, false);
221221
}
222222
return new IBarInfoHandler() {
223223
@Override
@@ -227,7 +227,7 @@ public Component getTooltip() {
227227

228228
@Override
229229
public double getLevel() {
230-
return timer.getValue() / 20D;
230+
return timer.getValue() / (double) SharedConstants.TICKS_PER_SECOND;
231231
}
232232
};
233233
}

src/main/java/mekanism/client/render/ModelRenderer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
import mekanism.common.util.MekanismUtils;
1313
import net.minecraft.core.Direction;
1414
import net.neoforged.neoforge.fluids.FluidStack;
15+
import net.neoforged.neoforge.fluids.FluidType;
1516
import org.jetbrains.annotations.Nullable;
1617

1718
public final class ModelRenderer {
1819

1920
private ModelRenderer() {
2021
}
2122

22-
private static final int BLOCK_STAGES = 1_000;
23+
private static final int BLOCK_STAGES = FluidType.BUCKET_VOLUME;
2324

2425
private static final Map<RenderData, Int2ObjectMap<Model3D>> cachedCenterData = new Object2ObjectOpenHashMap<>();
2526
private static final Map<ValveRenderData, Float2ObjectMap<Model3D>> cachedValveFluids = new Object2ObjectOpenHashMap<>();

src/main/java/mekanism/client/render/lib/effect/BoltRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class BoltRenderer {
2424

2525
/** Amount of times per tick we refresh. 3 implies 60 Hz. */
2626
private static final float REFRESH_TIME = 3F;
27-
/** We will keep track of an owner's render data for 100 ticks after there are no bolts remaining. */
27+
/** We will keep track of an owner's render data for 5 seconds after there are no bolts remaining. */
2828
private static final double MAX_OWNER_TRACK_TIME = 5 * SharedConstants.TICKS_PER_SECOND;
2929

3030
private Timestamp refreshTimestamp = new Timestamp();

src/main/java/mekanism/client/sound/SoundHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ private static class TileTickableSound extends AbstractTickableSoundInstance {
291291

292292
private final float originalVolume;
293293

294-
// Choose an interval between 60-80 ticks (3-4 seconds) to check for muffling changes. We do this
294+
// Choose an interval between 20-40 ticks (1-2 seconds) to check for muffling changes. We do this
295295
// to ensure that not every tile sound tries to run on the same tick and thus create
296296
// uneven spikes of CPU usage
297297
private final int checkInterval = SharedConstants.TICKS_PER_SECOND + ThreadLocalRandom.current().nextInt(SharedConstants.TICKS_PER_SECOND);

src/main/java/mekanism/common/block/attribute/AttributeEnergy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import mekanism.api.math.FloatingLong;
44
import mekanism.api.math.FloatingLongSupplier;
5+
import net.minecraft.SharedConstants;
56
import org.jetbrains.annotations.NotNull;
67
import org.jetbrains.annotations.Nullable;
78

@@ -11,7 +12,7 @@ public class AttributeEnergy implements Attribute {
1112

1213
private FloatingLongSupplier energyUsage = () -> FloatingLong.ZERO;
1314
// 2 operations (20 secs) worth of ticks * usage
14-
private FloatingLongSupplier energyStorage = () -> energyUsage.get().multiply(400);
15+
private FloatingLongSupplier energyStorage = () -> energyUsage.get().multiply(20 * SharedConstants.TICKS_PER_SECOND);
1516

1617
public AttributeEnergy(@Nullable FloatingLongSupplier energyUsage, @Nullable FloatingLongSupplier energyStorage) {
1718
if (energyUsage != null) {

src/main/java/mekanism/common/capabilities/energy/ResistiveHeaterEnergyContainer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import mekanism.common.block.attribute.AttributeEnergy;
1010
import mekanism.common.tile.machine.TileEntityResistiveHeater;
1111
import mekanism.common.util.NBTUtils;
12+
import net.minecraft.SharedConstants;
1213
import net.minecraft.core.HolderLookup;
1314
import net.minecraft.nbt.CompoundTag;
1415
import org.jetbrains.annotations.NotNull;
@@ -17,7 +18,7 @@
1718
@NothingNullByDefault
1819
public class ResistiveHeaterEnergyContainer extends MachineEnergyContainer<TileEntityResistiveHeater> {
1920

20-
public static final long USAGE_MULTIPLIER = 400;
21+
public static final long USAGE_MULTIPLIER = 20 * SharedConstants.TICKS_PER_SECOND;
2122

2223
public static ResistiveHeaterEnergyContainer input(TileEntityResistiveHeater tile, @Nullable IContentsListener listener) {
2324
AttributeEnergy electricBlock = validateBlock(tile);

0 commit comments

Comments
 (0)