Skip to content

Commit

Permalink
Fix fluid amount formatting and anvil recipes (#1995)
Browse files Browse the repository at this point in the history
  • Loading branch information
pupnewfster committed Jul 3, 2020
1 parent 9e0e09b commit fc2e336
Show file tree
Hide file tree
Showing 29 changed files with 131 additions and 83 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.daemon=false

mcversion=1.16.1
forgeversion=32.0.23
forgeversion=32.0.47
forgegroup=net.minecraftforge
mcp_mappings=20200514-1.16
curse_project_id=238222
Expand Down
99 changes: 71 additions & 28 deletions src/main/java/mezz/jei/plugins/vanilla/anvil/AnvilRecipeMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.ItemTier;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
Expand Down Expand Up @@ -102,89 +103,129 @@ private static void getBookEnchantmentRecipes(List<Object> recipes, IVanillaReci
}

private static void getRepairRecipes(List<Object> recipes, IVanillaRecipeFactory vanillaRecipeFactory) {
Map<List<ItemStack>, List<ItemStack>> items = Maps.newHashMap();
Map<Ingredient, List<ItemStack>> items = Maps.newHashMap();

List<ItemStack> repairWoods = ItemTags.PLANKS.func_230236_b_().stream()
.map(ItemStack::new)
.collect(Collectors.toList());
Ingredient repairWoods = ItemTier.WOOD.getRepairMaterial();
items.put(repairWoods, Lists.newArrayList(
new ItemStack(Items.WOODEN_SWORD),
new ItemStack(Items.WOODEN_PICKAXE),
new ItemStack(Items.WOODEN_AXE),
new ItemStack(Items.WOODEN_SHOVEL),
new ItemStack(Items.WOODEN_HOE),
new ItemStack(Items.WOODEN_HOE)
));

Ingredient repairShields = Ingredient.fromTag(ItemTags.PLANKS);
items.put(repairShields, Lists.newArrayList(
new ItemStack(Items.SHIELD)
));

ItemStack repairStone = new ItemStack(Blocks.COBBLESTONE);
items.put(Collections.singletonList(repairStone), Lists.newArrayList(
items.put(ItemTier.STONE.getRepairMaterial(), Lists.newArrayList(
new ItemStack(Items.STONE_SWORD),
new ItemStack(Items.STONE_PICKAXE),
new ItemStack(Items.STONE_AXE),
new ItemStack(Items.STONE_SHOVEL),
new ItemStack(Items.STONE_HOE)
));

ItemStack repairLeather = new ItemStack(Items.LEATHER);
items.put(Collections.singletonList(repairLeather), Lists.newArrayList(
Ingredient repairLeather = ArmorMaterial.LEATHER.getRepairMaterial();
items.put(repairLeather, Lists.newArrayList(
new ItemStack(Items.LEATHER_HELMET),
new ItemStack(Items.LEATHER_CHESTPLATE),
new ItemStack(Items.LEATHER_LEGGINGS),
new ItemStack(Items.LEATHER_BOOTS)
));


ItemStack repairIron = new ItemStack(Items.IRON_INGOT);
items.put(Collections.singletonList(repairIron), Lists.newArrayList(
Ingredient repairIronItems = ItemTier.IRON.getRepairMaterial();
items.put(repairIronItems, Lists.newArrayList(
new ItemStack(Items.IRON_SWORD),
new ItemStack(Items.IRON_PICKAXE),
new ItemStack(Items.IRON_AXE),
new ItemStack(Items.IRON_SHOVEL),
new ItemStack(Items.IRON_HOE),
new ItemStack(Items.IRON_HOE)
));

Ingredient repairIronArmor = ArmorMaterial.IRON.getRepairMaterial();
items.put(repairIronArmor, Lists.newArrayList(
new ItemStack(Items.IRON_HELMET),
new ItemStack(Items.IRON_CHESTPLATE),
new ItemStack(Items.IRON_LEGGINGS),
new ItemStack(Items.IRON_BOOTS),
new ItemStack(Items.IRON_BOOTS)
));

Ingredient repairChain = ArmorMaterial.CHAIN.getRepairMaterial();
items.put(repairChain, Lists.newArrayList(
new ItemStack(Items.CHAINMAIL_HELMET),
new ItemStack(Items.CHAINMAIL_CHESTPLATE),
new ItemStack(Items.CHAINMAIL_LEGGINGS),
new ItemStack(Items.CHAINMAIL_BOOTS)
));

ItemStack repairGold = new ItemStack(Items.GOLD_INGOT);
items.put(Collections.singletonList(repairGold), Lists.newArrayList(
Ingredient repairGoldItems = ItemTier.GOLD.getRepairMaterial();
items.put(repairGoldItems, Lists.newArrayList(
new ItemStack(Items.GOLDEN_SWORD),
new ItemStack(Items.GOLDEN_PICKAXE),
new ItemStack(Items.GOLDEN_AXE),
new ItemStack(Items.GOLDEN_SHOVEL),
new ItemStack(Items.GOLDEN_HOE),
new ItemStack(Items.GOLDEN_HOE)
));

Ingredient repairGoldArmor = ArmorMaterial.GOLD.getRepairMaterial();
items.put(repairGoldArmor, Lists.newArrayList(
new ItemStack(Items.GOLDEN_HELMET),
new ItemStack(Items.GOLDEN_CHESTPLATE),
new ItemStack(Items.GOLDEN_LEGGINGS),
new ItemStack(Items.GOLDEN_BOOTS)
));

ItemStack repairDiamond = new ItemStack(Items.DIAMOND);
items.put(Collections.singletonList(repairDiamond), Lists.newArrayList(
Ingredient repairDiamondItems = ItemTier.DIAMOND.getRepairMaterial();
items.put(repairDiamondItems, Lists.newArrayList(
new ItemStack(Items.DIAMOND_SWORD),
new ItemStack(Items.DIAMOND_PICKAXE),
new ItemStack(Items.DIAMOND_AXE),
new ItemStack(Items.DIAMOND_SHOVEL),
new ItemStack(Items.DIAMOND_HOE),
new ItemStack(Items.DIAMOND_HOE)
));

Ingredient repairDiamondArmor = ArmorMaterial.DIAMOND.getRepairMaterial();
items.put(repairDiamondArmor, Lists.newArrayList(
new ItemStack(Items.DIAMOND_HELMET),
new ItemStack(Items.DIAMOND_CHESTPLATE),
new ItemStack(Items.DIAMOND_LEGGINGS),
new ItemStack(Items.DIAMOND_BOOTS)
));

ItemStack repairElytra = new ItemStack(Items.PHANTOM_MEMBRANE);
items.put(Collections.singletonList(repairElytra), Lists.newArrayList(
Ingredient repairNetheriteItems = ItemTier.NETHERITE.getRepairMaterial();
items.put(repairNetheriteItems, Lists.newArrayList(
new ItemStack(Items.field_234754_kI_),
new ItemStack(Items.field_234756_kK_),
new ItemStack(Items.field_234757_kL_),
new ItemStack(Items.field_234755_kJ_),
new ItemStack(Items.field_234758_kU_)
));

Ingredient repairNetheriteArmor = ArmorMaterial.NETHERITE.getRepairMaterial();
items.put(repairNetheriteArmor, Lists.newArrayList(
new ItemStack(Items.field_234763_ls_),
new ItemStack(Items.field_234764_lt_),
new ItemStack(Items.field_234765_lu_),
new ItemStack(Items.field_234766_lv_)
));

Ingredient repairElytra = Ingredient.fromItems(Items.PHANTOM_MEMBRANE);
items.put(repairElytra, Lists.newArrayList(
new ItemStack(Items.ELYTRA)
));

for (Map.Entry<List<ItemStack>, List<ItemStack>> entry : items.entrySet()) {
Ingredient repairTurtle = ArmorMaterial.TURTLE.getRepairMaterial();
items.put(repairTurtle, Lists.newArrayList(
new ItemStack(Items.TURTLE_HELMET)
));

for (Map.Entry<Ingredient, List<ItemStack>> entry : items.entrySet()) {

List<ItemStack> repairMaterials = entry.getKey();
List<ItemStack> repairMaterials = Lists.newArrayList(
entry.getKey().getMatchingStacks()
);

for (ItemStack ingredient : entry.getValue()) {

Expand All @@ -195,9 +236,11 @@ private static void getRepairRecipes(List<Object> recipes, IVanillaRecipeFactory
ItemStack damaged3 = ingredient.copy();
damaged3.setDamage(damaged3.getMaxDamage() * 2 / 4);

Object repairWithMaterial = vanillaRecipeFactory.createAnvilRecipe(damaged1, repairMaterials, Collections.singletonList(damaged2));
if (!repairMaterials.isEmpty()) {
Object repairWithMaterial = vanillaRecipeFactory.createAnvilRecipe(damaged1, repairMaterials, Collections.singletonList(damaged2));
recipes.add(repairWithMaterial);
}
Object repairWithSame = vanillaRecipeFactory.createAnvilRecipe(damaged2, Collections.singletonList(damaged2), Collections.singletonList(damaged3));
recipes.add(repairWithMaterial);
recipes.add(repairWithSame);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mezz.jei.plugins.vanilla.ingredients.fluid;

import java.util.Collection;
import javax.annotation.Nullable;
import java.util.Collections;

Expand Down Expand Up @@ -110,6 +111,11 @@ public FluidStack normalizeIngredient(FluidStack ingredient) {
return copy;
}

@Override
public Collection<ResourceLocation> getTags(FluidStack ingredient) {
return ingredient.getFluid().getTags();
}

@Override
public String getErrorInfo(@Nullable FluidStack ingredient) {
if (ingredient == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mezz.jei.plugins.vanilla.ingredients.fluid;

import com.mojang.blaze3d.matrix.MatrixStack;
import java.text.NumberFormat;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -26,6 +27,7 @@
import mezz.jei.api.ingredients.IIngredientRenderer;

public class FluidStackRenderer implements IIngredientRenderer<FluidStack> {
private static final NumberFormat nf = NumberFormat.getIntegerInstance();
private static final int TEX_WIDTH = 16;
private static final int TEX_HEIGHT = 16;
private static final int MIN_FLUID_HEIGHT = 1; // ensure tiny amounts of fluid are still visible
Expand Down Expand Up @@ -182,10 +184,10 @@ public List<ITextComponent> getTooltip(FluidStack fluidStack, ITooltipFlag toolt

int amount = fluidStack.getAmount();
if (tooltipMode == TooltipMode.SHOW_AMOUNT_AND_CAPACITY) {
TranslationTextComponent amountString = new TranslationTextComponent("jei.tooltip.liquid.amount.with.capacity", amount, capacityMb);
TranslationTextComponent amountString = new TranslationTextComponent("jei.tooltip.liquid.amount.with.capacity", nf.format(amount), nf.format(capacityMb));
tooltip.add(amountString.func_240699_a_(TextFormatting.GRAY));
} else if (tooltipMode == TooltipMode.SHOW_AMOUNT) {
TranslationTextComponent amountString = new TranslationTextComponent("jei.tooltip.liquid.amount", amount);
TranslationTextComponent amountString = new TranslationTextComponent("jei.tooltip.liquid.amount", nf.format(amount));
tooltip.add(amountString.func_240699_a_(TextFormatting.GRAY));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagCollection;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;

Expand Down Expand Up @@ -161,8 +159,7 @@ public boolean isIngredientOnServer(ItemStack ingredient) {

@Override
public Collection<ResourceLocation> getTags(ItemStack ingredient) {
TagCollection<Item> collection = ItemTags.getCollection();
return collection.getOwningTags(ingredient.getItem());
return ingredient.getItem().getTags();
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/jei/lang/ar_sa.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"jei.tooltip.show.recipes": "اظهر الوصفات",
"jei.tooltip.show.all.recipes": "اظهر كل الوصفات",
"jei.tooltip.delete.item": "انقر للحذف",
"jei.tooltip.liquid.amount.with.capacity": "%,d / %,d mB",
"jei.tooltip.liquid.amount": "%,d mB",
"jei.tooltip.liquid.amount.with.capacity": "%s / %s mB",
"jei.tooltip.liquid.amount": "%s mB",
"jei.tooltip.transfer": "حرك الأشاء",
"jei.tooltip.recipe.tag": "%s :يقبل أي من",
"jei.tooltip.item.colors": "Colors: %s",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/jei/lang/bg_bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"jei.tooltip.show.recipes": "Покажи Рецепти",
"jei.tooltip.show.all.recipes": "Покажи Всички Речепти",
"jei.tooltip.delete.item": "Натисни за да Изтриеш",
"jei.tooltip.liquid.amount.with.capacity": "%,d / %,d mB",
"jei.tooltip.liquid.amount": "%,d mB",
"jei.tooltip.liquid.amount.with.capacity": "%s / %s mB",
"jei.tooltip.liquid.amount": "%s mB",
"jei.tooltip.transfer": "Премести Предмети",
"jei.tooltip.recipe.tag": "Приема всички: %s",
"jei.tooltip.item.colors": "Чветове: %s",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/jei/lang/cs_cz.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"jei.tooltip.show.recipes": "Zobrazit Recepty",
"jei.tooltip.show.all.recipes": "Zobrazit Všechny Recepty",
"jei.tooltip.delete.item": "Klikni pro smazání",
"jei.tooltip.liquid.amount.with.capacity": "%,d / %,d mB",
"jei.tooltip.liquid.amount": "%,d mB",
"jei.tooltip.liquid.amount.with.capacity": "%s / %s mB",
"jei.tooltip.liquid.amount": "%s mB",
"jei.tooltip.transfer": "Přesunout itemy",
"jei.tooltip.recipe.tag": "Jakkýkoliv přístup: %s",
"jei.tooltip.item.colors": "Barvy: %s",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/jei/lang/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"jei.tooltip.show.recipes": "Zeige Rezepte",
"jei.tooltip.show.all.recipes": "Zeige alle Rezepte",
"jei.tooltip.delete.item": "Klicke zum Löschen",
"jei.tooltip.liquid.amount.with.capacity": "%,d / %,d mB",
"jei.tooltip.liquid.amount": "%,d mB",
"jei.tooltip.liquid.amount.with.capacity": "%s / %s mB",
"jei.tooltip.liquid.amount": "%s mB",
"jei.tooltip.transfer": "Bewege Items",
"jei.tooltip.recipe.tag": "Akzeptiert: %s",
"jei.tooltip.item.colors": "Farben: %s",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/jei/lang/el_gr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"jei.tooltip.show.recipes": "Δείξε συνταγές",
"jei.tooltip.show.all.recipes": "Δείξε όλες τις συνταγές",
"jei.tooltip.delete.item": "Πάτα για Διαγραφή",
"jei.tooltip.liquid.amount.with.capacity": "%,d / %,d mB",
"jei.tooltip.liquid.amount": "%,d mB",
"jei.tooltip.liquid.amount.with.capacity": "%s / %s mB",
"jei.tooltip.liquid.amount": "%s mB",
"jei.tooltip.transfer": "Μετακίνησε αντικείμενα",
"jei.tooltip.recipe.tag": "Δέχεται: %s",
"jei.tooltip.item.colors": "Χρώματα: %s",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/jei/lang/en_au.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"jei.tooltip.show.recipes": "Show Recipes",
"jei.tooltip.show.all.recipes": "Show All Recipes",
"jei.tooltip.delete.item": "Click to Delete",
"jei.tooltip.liquid.amount.with.capacity": "%,d / %,d mB",
"jei.tooltip.liquid.amount": "%,d mB",
"jei.tooltip.liquid.amount.with.capacity": "%s / %s mB",
"jei.tooltip.liquid.amount": "%s mB",
"jei.tooltip.transfer": "Move Items",
"jei.tooltip.recipe.tag": "Accepts any: %s",
"jei.tooltip.item.colors": "Colours: %s",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/jei/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"jei.tooltip.show.recipes": "Show Recipes",
"jei.tooltip.show.all.recipes": "Show All Recipes",
"jei.tooltip.delete.item": "Click to Delete",
"jei.tooltip.liquid.amount.with.capacity": "%,d / %,d mB",
"jei.tooltip.liquid.amount": "%,d mB",
"jei.tooltip.liquid.amount.with.capacity": "%s / %s mB",
"jei.tooltip.liquid.amount": "%s mB",
"jei.tooltip.transfer": "Move Items",
"jei.tooltip.recipe.tag": "Accepts any: %s",
"jei.tooltip.item.colors": "Colors: %s",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/jei/lang/es_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"jei.tooltip.show.recipes": "Mostrar recetas",
"jei.tooltip.show.all.recipes": "Mostrar todas las recetas",
"jei.tooltip.delete.item": "Click para borrar",
"jei.tooltip.liquid.amount.with.capacity": "%,d / %,d mB",
"jei.tooltip.liquid.amount": "%,d mB",
"jei.tooltip.liquid.amount.with.capacity": "%s / %s mB",
"jei.tooltip.liquid.amount": "%s mB",
"jei.tooltip.transfer": "Mover objetos",
"jei.tooltip.recipe.tag": "Acepta cualquier: %s",
"jei.tooltip.item.colors": "Colores: %s",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/jei/lang/fi_fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"jei.tooltip.show.recipes": "Näytä reseptit",
"jei.tooltip.show.all.recipes": "Näytä kaikki reseptit",
"jei.tooltip.delete.item": "Paina poistaaksesi",
"jei.tooltip.liquid.amount.with.capacity": "%,d / %,d mB",
"jei.tooltip.liquid.amount": "%,d mB",
"jei.tooltip.liquid.amount.with.capacity": "%s / %s mB",
"jei.tooltip.liquid.amount": "%s mB",
"jei.tooltip.transfer": "Siirrä tavaroita",
"jei.tooltip.recipe.tag": "Hyväksyy minkä tahansa: %s",
"jei.tooltip.item.colors": "Värit: %s",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/jei/lang/fr_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"jei.tooltip.show.recipes": "Afficher les recettes",
"jei.tooltip.show.all.recipes": "Afficher toutes les recettes",
"jei.tooltip.delete.item": "Cliquer pour supprimer",
"jei.tooltip.liquid.amount.with.capacity": "%,d / %,d mB",
"jei.tooltip.liquid.amount": "%,d mB",
"jei.tooltip.liquid.amount.with.capacity": "%s / %s mB",
"jei.tooltip.liquid.amount": "%s mB",
"jei.tooltip.transfer": "Transférer les objets",
"jei.tooltip.recipe.tag": "Accepte n'importe lequel : %s",
"jei.tooltip.item.colors": "Couleurs : %s",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/jei/lang/he_il.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"jei.tooltip.show.recipes": "הצג מתכונים",
"jei.tooltip.show.all.recipes": "הצג את כל המתכונים",
"jei.tooltip.delete.item": "לחץ כדי למחוק",
"jei.tooltip.liquid.amount.with.capacity": "%,d / %,d mB",
"jei.tooltip.liquid.amount": "%,d mB",
"jei.tooltip.liquid.amount.with.capacity": "%s / %s mB",
"jei.tooltip.liquid.amount": "%s mB",
"jei.tooltip.transfer": "הזז חפצים",
"jei.tooltip.recipe.tag": "קבל כל: %s",
"jei.tooltip.item.colors": "צבעים: %s",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/jei/lang/it_it.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"jei.tooltip.show.recipes": "Mostra ricette",
"jei.tooltip.show.all.recipes": "Mostra tutte le ricette",
"jei.tooltip.delete.item": "Clicca per eliminare",
"jei.tooltip.liquid.amount.with.capacity": "%,d / %,d mB",
"jei.tooltip.liquid.amount": "%,d mB",
"jei.tooltip.liquid.amount.with.capacity": "%s / %s mB",
"jei.tooltip.liquid.amount": "%s mB",
"jei.tooltip.transfer": "Sposta item",
"jei.tooltip.recipe.tag": "Accetta: %s",
"jei.tooltip.item.colors": "Colori: %s",
Expand Down
Loading

0 comments on commit fc2e336

Please sign in to comment.