Skip to content

Commit e012030

Browse files
committed
Update TODOs and retarget certain ones for completion by the 1.21 release
Also addresses certain trivial TODOs
1 parent ec48d8a commit e012030

File tree

70 files changed

+208
-276
lines changed

Some content is hidden

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

70 files changed

+208
-276
lines changed

src/api/java/mekanism/api/SerializerHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import net.minecraft.Util;
1818
import org.jetbrains.annotations.NotNull;
1919

20-
//TODO - 1.20.5: Update the wiki docs to fix the syntax
20+
//TODO - 1.21: Update the wiki docs to fix the syntax
2121
@NothingNullByDefault
2222
public class SerializerHelper {
2323

src/api/java/mekanism/api/chemical/BasicChemicalTank.java

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,34 @@ public void setStack(STACK stack) {
5353
}
5454

5555
/**
56-
* Helper method to allow easily setting a rate at which this {@link BasicChemicalTank} can insert/extract chemicals.
56+
* Helper method to allow easily setting a rate at which chemicals can be inserted into this {@link BasicChemicalTank}.
5757
*
5858
* @param automationType The automation type to limit the rate by or null if we don't have access to an automation type.
5959
*
6060
* @return The rate this tank can insert/extract at.
6161
*
6262
* @implNote By default, this returns {@link Long#MAX_VALUE} to not actually limit the tank's rate. By default, this is also ignored for direct setting of the
6363
* stack/stack size
64+
*
65+
* @since 10.6.0, previously was combined with {@link #getExtractRate(AutomationType)} as a method named getRate
66+
*/
67+
protected long getInsertRate(@Nullable AutomationType automationType) {
68+
return Long.MAX_VALUE;
69+
}
70+
71+
/**
72+
* Helper method to allow easily setting a rate at which chemicals can be extracted from this {@link BasicChemicalTank}.
73+
*
74+
* @param automationType The automation type to limit the rate by or null if we don't have access to an automation type.
75+
*
76+
* @return The rate this tank can insert/extract at.
77+
*
78+
* @implNote By default, this returns {@link Long#MAX_VALUE} to not actually limit the tank's rate. By default, this is also ignored for direct setting of the
79+
* stack/stack size
80+
*
81+
* @since 10.6.0, previously was combined with {@link #getInsertRate(AutomationType)} as a method named getRate
6482
*/
65-
protected long getRate(@Nullable AutomationType automationType) {
66-
//TODO: Decide if we want to split this into a rate for inserting and a rate for extracting.
83+
protected long getExtractRate(@Nullable AutomationType automationType) {
6784
return Long.MAX_VALUE;
6885
}
6986

@@ -95,7 +112,7 @@ public STACK insert(@NotNull STACK stack, Action action, AutomationType automati
95112
//"Fail quick" if the given stack is empty, or we can never insert the chemical or currently are unable to insert it
96113
return stack;
97114
}
98-
long needed = Math.min(getRate(automationType), getNeeded());
115+
long needed = Math.min(getInsertRate(automationType), getNeeded());
99116
if (needed <= 0) {
100117
//Fail if we are a full tank or our rate is zero
101118
return stack;
@@ -130,7 +147,7 @@ public STACK extract(long amount, Action action, AutomationType automationType)
130147
}
131148
//Note: While we technically could just return the stack itself if we are removing all that we have, it would require a lot more checks
132149
// We also are limiting it by the rate this tank has
133-
long size = Math.min(Math.min(getRate(automationType), getStored()), amount);
150+
long size = Math.min(Math.min(getExtractRate(automationType), getStored()), amount);
134151
if (size == 0) {
135152
return getEmptyStack();
136153
}
@@ -190,9 +207,11 @@ public long growStack(long amount, Action action) {
190207
return 0;
191208
} else if (amount > 0) {
192209
//Cap adding amount at how much we need, so that we don't risk long overflow
193-
amount = Math.min(Math.min(amount, getNeeded()), getRate(null));
210+
//If we are increasing the stack's size, use the insert rate
211+
amount = Math.min(Math.min(amount, getNeeded()), getInsertRate(null));
194212
} else if (amount < 0) {
195-
amount = Math.max(amount, -getRate(null));
213+
//If we are decreasing the stack's size, use the extract rate
214+
amount = Math.max(amount, -getExtractRate(null));
196215
}
197216
long newSize = setStackSize(current + amount, action);
198217
return newSize - current;

src/api/java/mekanism/api/chemical/merged/BoxedChemical.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class BoxedChemical implements IHasTextComponent {
6565
*/
6666
public static BoxedChemical box(Chemical<?> chemical) {
6767
if (chemical.isEmptyType()) {
68-
//TODO: Do we care that this can lose the type of chemical as it uses a single instance that always has a type of gas?
68+
//TODO - 1.21: Do we care that this can lose the type of chemical as it uses a single instance that always has a type of gas?
6969
return EMPTY;
7070
}
7171
return new BoxedChemical(ChemicalType.getTypeFor(chemical), chemical);

src/api/java/mekanism/api/chemical/merged/BoxedChemicalStack.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class BoxedChemicalStack implements IHasTextComponent {
6666
*/
6767
public static BoxedChemicalStack box(ChemicalStack<?> chemicalStack) {
6868
if (chemicalStack.isEmpty()) {
69-
//TODO: Do we care that this can lose the type of chemical as it uses a single instance that always has a type of gas?
69+
//TODO - 1.21: Do we care that this can lose the type of chemical as it uses a single instance that always has a type of gas?
7070
return EMPTY;
7171
}
7272
return new BoxedChemicalStack(ChemicalType.getTypeFor(chemicalStack), chemicalStack);

src/api/java/mekanism/api/gear/ICustomModule.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ default <MODE extends IRadialMode> boolean setMode(IModule<MODULE> module, Playe
195195

196196
/**
197197
* Called when this module is added to an item.
198+
* <p>
199+
* Due to the way {@link net.minecraft.core.component.DataComponentType data components} work, the instance of the {@link ICustomModule} that this method gets called
200+
* on is as follows:
201+
* <ul>
202+
* <li>The passed in {@link IModuleContainer module container} instance is the new one that contains the added module in its known modules</li>
203+
* <li>The stack has been updated to know about the updated state (including any changes to enchantments if this module is also a {@link EnchantmentAwareModule})</li>
204+
* <li>The {@link ICustomModule} instance is one created after installing the modules</li>
205+
* </ul>
198206
*
199207
* @param module Module instance.
200208
* @param moduleContainer The container this module is part of.
@@ -209,6 +217,24 @@ default void onAdded(IModule<MODULE> module, IModuleContainer moduleContainer, I
209217

210218
/**
211219
* Called when this module is removed from an item.
220+
* <p>
221+
* Due to the way {@link net.minecraft.core.component.DataComponentType data components} work, the instance of the {@link ICustomModule} that this method gets called
222+
* on is as follows:
223+
*
224+
* <ul>
225+
* <li>
226+
* The passed in {@link IModuleContainer module container} instance is the new one that contains the reduced number of modules (or none if last) in its known
227+
* modules
228+
* </li>
229+
* <li>The stack has been updated to know about the updated state (including any changes to enchantments if this module is also a {@link EnchantmentAwareModule})</li>
230+
* <li>
231+
* If this was not the {@code wasLast} module removed, this behaves similarly to {@link #onAdded(IModule, IModuleContainer, ItemStack, boolean)} in that the
232+
* {@link ICustomModule} instance is one created after uninstalling the the modules. <strong>However</strong>, if all the modules of this type have been
233+
* removed and {@code wasLast == true}, then this method is instead called on the previously installed {@link ICustomModule} instance, and it should be assumed
234+
* that the number of installed modules is zero, rather than querying it via {@link IModule#getInstalledCount()}. Do note, even in this case, the stack and
235+
* {@link IModuleContainer module container} still point to the updated state, as specified above.
236+
* </li>
237+
* </ul>
212238
*
213239
* @param module Module instance.
214240
* @param moduleContainer The container this module is part of.

src/api/java/mekanism/api/recipes/MekanismRecipe.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public abstract class MekanismRecipe implements Recipe<IgnoredIInventory> {//TOD
1414

1515
@Override
1616
public boolean matches(@NotNull IgnoredIInventory inv, @NotNull Level world) {
17-
//TODO: Decide if we ever want to make use of this method
17+
//TODO - 1.21: Decide if we ever want to make use of this method, as with the changes in 1.21 to allow for extending RecipeInput
18+
// instead of Container, we potentially could implement this even for things that don't use items
1819
//Default to not being able to match incomplete recipes though
1920
return !isIncomplete();
2021
}

src/datagen/main/java/mekanism/client/integration/emi/BaseEmiAliasProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ protected void addAliases(List<EmiIngredient> stacks, IHasTranslationKey... alia
117117
.map(IHasTranslationKey::getTranslationKey)
118118
.sorted()
119119
.toList();
120-
//TODO - 1.20.5: Is there some global sort, or stack based sort we can apply as well?
120+
//TODO: Is there some global sort, or stack based sort we can apply as well?
121121
if (!data.add(new AliasInfo(stacks, sortedAliases))) {
122122
//TODO: Can we improve the validation we have relating to duplicate values/make things more compact?
123123
// This if statement exists mainly as a simple check against copy-paste errors

src/datagen/main/java/mekanism/client/integration/emi/MekanismEmiAliasProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private void addStorageAliases() {
220220
MekanismAliases.SLURRY_STORAGE
221221
);
222222

223-
//TODO - 1.20.5: Fix energy stuff not displaying properly when searching for "energy storage"? Probably has to do with components
223+
//TODO - 1.21: Fix energy stuff not displaying properly when searching for "energy storage"? Probably has to do with components
224224
addAliases(List.of(
225225
EmiStack.of(MekanismBlocks.BASIC_ENERGY_CUBE),
226226
EmiStack.of(MekanismBlocks.ADVANCED_ENERGY_CUBE),
@@ -233,7 +233,7 @@ private void addStorageAliases() {
233233
addAliases(MekanismItems.ENERGY_TABLET, MekanismAliases.ENERGY_STORAGE, MekanismAliases.ENERGY_STORAGE_BATTERY);
234234

235235
addAliases(List.of(
236-
//TODO - 1.20.5: Why does the creative bin not show up?
236+
//TODO - 1.21: Why does the creative bin not show up?
237237
EmiStack.of(MekanismBlocks.CREATIVE_BIN),
238238
EmiStack.of(MekanismBlocks.CREATIVE_FLUID_TANK),
239239
EmiStack.of(MekanismBlocks.CREATIVE_CHEMICAL_TANK),

src/datagen/main/java/mekanism/client/lang/FormatSplitter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ public boolean isChoice() {
209209
*
210210
* @return A {@link MessageFormatComponent} representing the given contents, or {@code null} if the contents do not represent a valid
211211
* {@link MessageFormatComponent}
212+
*
213+
* @see net.neoforged.fml.i18n.FMLTranslations
212214
*/
213215
@Nullable
214216
private static MessageFormatComponent fromContents(String contents) {
@@ -287,9 +289,9 @@ private static MessageFormatComponent fromContents(String contents) {
287289
return null;
288290
}
289291
}
290-
case "featurebound", "lower", "upper", "vr" -> {
292+
case "featurebound", "lower", "upper", "vr", "i18ntranslate" -> {
291293
if (formatStyle != null) {
292-
//featurebound, lower, upper, and vr do not support any format style
294+
//None of these support any format style
293295
return null;
294296
}
295297
}

src/datagen/main/java/mekanism/common/recipe/RecipeProviderUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static void addSmeltingBlastingRecipes(RecipeOutput consumer, Ingredient
5050

5151
public static void addCrusherBioFuelRecipes(RecipeOutput consumer, String basePath, Predicate<String> shouldHandle, @Nullable ICondition condition) {
5252
//Generate baseline recipes from Composter recipe set
53-
//TODO - 1.20.4: Move these to being "generated" recipes at runtime (maybe behind a config option) that uses the compostable datamap?
53+
//TODO - 1.21: Move these to being "generated" recipes at runtime (maybe behind a config option) that uses the compostable datamap?
5454
for (Object2FloatMap.Entry<ItemLike> chance : ComposterBlock.COMPOSTABLES.object2FloatEntrySet()) {
5555
Item input = chance.getKey().asItem();
5656
ResourceLocation name = RegistryUtils.getName(input);

0 commit comments

Comments
 (0)