Skip to content

Commit de11000

Browse files
committed
- Remove RequirementRandomItem and RequirementTypeRandomItemArray.
- Add RequirementIngredientArray JEI output tips. - RecipeCraftingContextPool now will clear POOL directly when reloaded.
1 parent cf33317 commit de11000

9 files changed

Lines changed: 29 additions & 109 deletions

File tree

src/main/java/github/kasuminova/mmce/common/concurrent/RecipeCraftingContextPool.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ public static void returnCtx(@Nonnull RecipeCraftingContext ctx) {
4444
}
4545

4646
public static void onReload() {
47-
for (final Queue<RecipeCraftingContext> queue : POOL.values()) {
48-
queue.clear();
49-
}
47+
POOL.clear();
5048

5149
reloadCounter++;
5250
}

src/main/java/hellfirepvp/modularmachinery/common/crafting/helper/ComponentOutputRestrictor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
* Created by HellFirePvP
1919
* Date: 12.07.2017 / 21:19
2020
*/
21+
@Deprecated
2122
public abstract class ComponentOutputRestrictor {
2223

24+
@Deprecated
2325
public static class RestrictionTank extends ComponentOutputRestrictor {
2426

2527
public final HybridFluid inserted;
@@ -32,6 +34,7 @@ public RestrictionTank(HybridFluid inserted, ProcessingComponent<?> exactCompone
3234

3335
}
3436

37+
@Deprecated
3538
public static class RestrictionInventory extends ComponentOutputRestrictor {
3639

3740
public final ItemStack inserted;

src/main/java/hellfirepvp/modularmachinery/common/crafting/requirement/RequirementRandomItem.java

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/main/java/hellfirepvp/modularmachinery/common/crafting/requirement/jei/JEIComponentIngredientArray.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import hellfirepvp.modularmachinery.common.crafting.requirement.RequirementIngredientArray;
66
import hellfirepvp.modularmachinery.common.integration.ingredient.IngredientItemStack;
77
import hellfirepvp.modularmachinery.common.integration.recipe.RecipeLayoutPart;
8+
import hellfirepvp.modularmachinery.common.machine.IOType;
89
import hellfirepvp.modularmachinery.common.util.ItemUtils;
910
import hellfirepvp.modularmachinery.common.util.MiscUtils;
1011
import net.minecraft.client.resources.I18n;
@@ -69,34 +70,40 @@ public RecipeLayoutPart<IngredientItemStack> getLayoutPart(Point offset) {
6970
@Override
7071
public void onJEIHoverTooltip(int slotIndex, boolean input, IngredientItemStack ingredient, List<String> tooltip) {
7172
tooltip.add("");
72-
tooltip.add(I18n.format("tooltip.machinery.ingredient_array_input"));
73+
IOType actionType = requirement.getActionType();
74+
75+
switch (actionType) {
76+
case INPUT -> tooltip.add(I18n.format("tooltip.machinery.ingredient_array_input"));
77+
case OUTPUT -> tooltip.add(I18n.format("tooltip.machinery.ingredient_array_output"));
78+
}
79+
80+
float totalChance = 1F;
81+
if (actionType == IOType.OUTPUT) {
82+
totalChance = 0;
83+
for (final ChancedIngredientStack reqIngredient : requirement.getIngredients()) {
84+
totalChance += reqIngredient.chance;
85+
}
86+
}
87+
7388
StringBuilder tooltipBuilder = new StringBuilder();
7489
for (ChancedIngredientStack stack : requirement.getIngredients()) {
7590
switch (stack.ingredientType) {
76-
case ITEMSTACK -> {
77-
ItemStack itemStack = stack.itemStack;
78-
tooltipBuilder.append(itemStack.getDisplayName());
79-
}
80-
case ORE_DICT -> {
81-
tooltipBuilder.append(stack.oreDictName);
82-
}
91+
case ITEMSTACK -> tooltipBuilder.append(stack.itemStack.getDisplayName());
92+
case ORE_DICT -> tooltipBuilder.append(stack.oreDictName);
8393
}
8494

8595
if (stack.minCount != stack.maxCount) {
8696
tooltipBuilder.append(" * ").append(String.format("%d ~ %d", stack.minCount, stack.maxCount));
8797
} else {
88-
switch (stack.ingredientType) {
89-
case ITEMSTACK -> tooltipBuilder.append(" * ").append(stack.itemStack.getCount());
90-
case ORE_DICT -> tooltipBuilder.append(" * ").append(stack.count);
91-
}
98+
tooltipBuilder.append(" * ").append(stack.count);
9299
}
93100

94-
float chance = stack.chance * requirement.chance;
101+
float chance = actionType == IOType.OUTPUT ? stack.chance * requirement.chance : stack.chance / totalChance;
95102
if (chance < 1F && chance >= 0F) {
96103
tooltipBuilder.append(" (");
97104

98105
String keyNever = input ? "tooltip.machinery.chance.in.never" : "tooltip.machinery.chance.out.never";
99-
String keyChance = input ? "tooltip.machinery.chance.in" : "tooltip.machinery.chance.out";
106+
String keyChance = input ? "tooltip.machinery.chance.in" : "tooltip.machinery.ingredient_array_output.weight";
100107

101108
if (chance == 0F) {
102109
tooltipBuilder.append(I18n.format(keyNever));

src/main/java/hellfirepvp/modularmachinery/common/crafting/requirement/type/RequirementTypeRandomItemArray.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/main/java/hellfirepvp/modularmachinery/common/lib/RequirementTypesMM.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class RequirementTypesMM {
2323

2424
public static final ResourceLocation KEY_REQUIREMENT_ITEM = new ResourceLocation(ModularMachinery.MODID, "item");
2525
public static final ResourceLocation KEY_REQUIREMENT_INGREDIENT_ARRAY = new ResourceLocation(ModularMachinery.MODID, "ingredient_array_input");
26-
public static final ResourceLocation KEY_REQUIREMENT_RANDOM_ITEM_ARRAY = new ResourceLocation(ModularMachinery.MODID, "random_item_array");
2726
public static final ResourceLocation KEY_REQUIREMENT_FLUID = new ResourceLocation(ModularMachinery.MODID, "fluid");
2827
public static final ResourceLocation KEY_REQUIREMENT_FLUID_PERTICK = new ResourceLocation(ModularMachinery.MODID, "fluid_pertick");
2928
public static final ResourceLocation KEY_REQUIREMENT_GAS = new ResourceLocation(ModularMachinery.MODID, "gas");
@@ -34,7 +33,6 @@ public class RequirementTypesMM {
3433
public static final ResourceLocation KEY_INTERFACE_NUMBER_INPUT = new ResourceLocation(ModularMachinery.MODID, "interface_number_input");
3534
public static RequirementTypeItem REQUIREMENT_ITEM;
3635
public static RequirementTypeIngredientArray REQUIREMENT_INGREDIENT_ARRAY;
37-
public static RequirementTypeRandomItemArray REQUIREMENT_RANDOM_ITEM_ARRAY;
3836
public static RequirementTypeFluid REQUIREMENT_FLUID;
3937
public static RequirementTypeFluidPerTick REQUIREMENT_FLUID_PERTICK;
4038
public static RequirementTypeEnergy REQUIREMENT_ENERGY;

src/main/java/hellfirepvp/modularmachinery/common/registry/RegistryRequirementTypes.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ private RegistryRequirementTypes() {
2929
public static void initialize() {
3030
REQUIREMENT_ITEM = register(new RequirementTypeItem(), KEY_REQUIREMENT_ITEM);
3131
REQUIREMENT_INGREDIENT_ARRAY = register(new RequirementTypeIngredientArray(), KEY_REQUIREMENT_INGREDIENT_ARRAY);
32-
REQUIREMENT_RANDOM_ITEM_ARRAY = register(new RequirementTypeRandomItemArray(), KEY_REQUIREMENT_RANDOM_ITEM_ARRAY);
3332
REQUIREMENT_FLUID = register(new RequirementTypeFluid(), KEY_REQUIREMENT_FLUID);
3433
REQUIREMENT_FLUID_PERTICK = register(new RequirementTypeFluidPerTick(), KEY_REQUIREMENT_FLUID_PERTICK);
3534
REQUIREMENT_ENERGY = register(new RequirementTypeEnergy(), KEY_REQUIREMENT_ENERGY);

src/main/resources/assets/modularmachinery/lang/en_US.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ tooltip.item.controller.owner.not_self=§cYou are not the owner of the controlle
148148
tooltip.machinery.empty=Empty
149149

150150
tooltip.machinery.ingredient_array_input=Accepts the following inputs (only one of them is consumed):
151+
tooltip.machinery.ingredient_array_output=Output the following items: %s
152+
tooltip.machinery.ingredient_array_output.weight=Weights: %s
151153
tooltip.machinery.catalyst=§aAs catalyst input. (optional input)
152154
tooltip.machinery.catalyst.effect=Catalytic effect:
153155

src/main/resources/assets/modularmachinery/lang/zh_CN.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ tooltip.item.controller.owner.not_self=§c你不是控制器的所有者。
147147
tooltip.machinery.empty=空
148148

149149
tooltip.machinery.ingredient_array_input=接受以下输入(仅消耗其中一种):
150+
tooltip.machinery.ingredient_array_output=输出以下物品:
151+
tooltip.machinery.ingredient_array_output.weight=权重:%s
150152
tooltip.machinery.catalyst=§a作为催化剂输入(可选输入)。
151153
tooltip.machinery.catalyst.effect=催化剂效果:
152154

0 commit comments

Comments
 (0)