Improved Anvil-Level handling
This commit is contained in:
parent
bb15db429d
commit
2aa13a76ee
9 changed files with 64 additions and 53 deletions
|
@ -4,6 +4,7 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.util.FormattedCharSequence;
|
import net.minecraft.util.FormattedCharSequence;
|
||||||
|
import net.minecraft.world.item.Tiers;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.material.MaterialColor;
|
import net.minecraft.world.level.material.MaterialColor;
|
||||||
|
@ -20,8 +21,9 @@ public class LeveledAnvilBlock extends BaseAnvilBlock {
|
||||||
|
|
||||||
public static int getAnvilCraftingLevel(Block anvil) {
|
public static int getAnvilCraftingLevel(Block anvil) {
|
||||||
if (anvil instanceof LeveledAnvilBlock l) return l.getCraftingLevel();
|
if (anvil instanceof LeveledAnvilBlock l) return l.getCraftingLevel();
|
||||||
if (anvil == Blocks.ANVIL || anvil == Blocks.CHIPPED_ANVIL || anvil == Blocks.DAMAGED_ANVIL) return 0;
|
if (anvil == Blocks.ANVIL || anvil == Blocks.CHIPPED_ANVIL || anvil == Blocks.DAMAGED_ANVIL)
|
||||||
return -1;
|
return Tiers.IRON.getLevel() - 1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canHandle(Block anvil, int level) {
|
public static boolean canHandle(Block anvil, int level) {
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
package org.betterx.bclib.integration.emi;
|
|
||||||
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.level.ItemLike;
|
|
||||||
|
|
||||||
import dev.emi.emi.api.stack.ItemEmiStack;
|
|
||||||
|
|
||||||
public class AnvilEmiStack extends ItemEmiStack {
|
|
||||||
public AnvilEmiStack(ItemLike itemLike) {
|
|
||||||
super(new ItemStack(itemLike));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -57,7 +57,7 @@ public class EMIAlloyingRecipe implements EmiRecipe {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDisplayWidth() {
|
public int getDisplayWidth() {
|
||||||
return 76;
|
return 96;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,6 +77,6 @@ public class EMIAlloyingRecipe implements EmiRecipe {
|
||||||
// Adds an output slot on the right
|
// Adds an output slot on the right
|
||||||
// Note that output slots need to call `recipeContext` to inform EMI about their recipe context
|
// Note that output slots need to call `recipeContext` to inform EMI about their recipe context
|
||||||
// This includes being able to resolve recipe trees, favorite stacks with recipe context, and more
|
// This includes being able to resolve recipe trees, favorite stacks with recipe context, and more
|
||||||
widgets.addSlot(output.get(0), 58, 0).recipeContext(this);
|
widgets.addSlot(output.get(0), 78, 0).recipeContext(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class EMIAnvilRecipe implements EmiRecipe {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDisplayWidth() {
|
public int getDisplayWidth() {
|
||||||
return 76;
|
return 96;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,6 +90,6 @@ public class EMIAnvilRecipe implements EmiRecipe {
|
||||||
// Adds an output slot on the right
|
// Adds an output slot on the right
|
||||||
// Note that output slots need to call `recipeContext` to inform EMI about their recipe context
|
// Note that output slots need to call `recipeContext` to inform EMI about their recipe context
|
||||||
// This includes being able to resolve recipe trees, favorite stacks with recipe context, and more
|
// This includes being able to resolve recipe trees, favorite stacks with recipe context, and more
|
||||||
widgetHolder.addSlot(output.get(0), 58, 0).recipeContext(this);
|
widgetHolder.addSlot(output.get(0), 78, 0).recipeContext(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.betterx.bclib.util.RomanNumeral;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.blaze3d.vertex.Tesselator;
|
import com.mojang.blaze3d.vertex.Tesselator;
|
||||||
|
import com.mojang.math.Matrix4f;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
|
@ -60,22 +61,22 @@ public class EMIAnvilRecipeCategory extends EmiRecipeCategory {
|
||||||
final Font font = Minecraft.getInstance().font;
|
final Font font = Minecraft.getInstance().font;
|
||||||
final String content = RomanNumeral.toRoman(anvilLevel);
|
final String content = RomanNumeral.toRoman(anvilLevel);
|
||||||
|
|
||||||
MultiBufferSource.BufferSource bufferSource = MultiBufferSource
|
final MultiBufferSource.BufferSource bufferSource = MultiBufferSource
|
||||||
.immediate(
|
.immediate(Tesselator.getInstance().getBuilder());
|
||||||
Tesselator.getInstance()
|
final int xx = x + 19 - 2 - font.width(content);
|
||||||
.getBuilder()
|
final int yy = y + 6 + 3;
|
||||||
);
|
final Matrix4f matrix = stack.last().pose();
|
||||||
font.drawInBatch(
|
|
||||||
content,
|
font.drawInBatch(content, xx - 1, yy - 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
|
||||||
x + 19 - 2 - font.width(content), y + 6 + 3,
|
font.drawInBatch(content, xx, yy - 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
|
||||||
0xFFFFFF,
|
font.drawInBatch(content, xx + 1, yy - 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
|
||||||
true,
|
font.drawInBatch(content, xx - 1, yy, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
|
||||||
stack.last().pose(),
|
font.drawInBatch(content, xx + 1, yy, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
|
||||||
bufferSource,
|
font.drawInBatch(content, xx - 1, yy + 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
|
||||||
false,
|
font.drawInBatch(content, xx + 1, yy + 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
|
||||||
0,
|
font.drawInBatch(content, xx, yy + 1, 0xFF000000, false, matrix, bufferSource, false, 0, 0xF000F0);
|
||||||
0xF000F0
|
|
||||||
);
|
font.drawInBatch(content, xx, yy, 0xFFFFFFFF, true, matrix, bufferSource, false, 0, 0xF000F0);
|
||||||
bufferSource.endBatch();
|
bufferSource.endBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,20 +69,24 @@ public class EMIPlugin implements EmiPlugin {
|
||||||
|
|
||||||
for (int anvilLevel = 0; anvilLevel <= maxAnvilLevel; anvilLevel++) {
|
for (int anvilLevel = 0; anvilLevel <= maxAnvilLevel; anvilLevel++) {
|
||||||
int finalAnvilLevel = anvilLevel;
|
int finalAnvilLevel = anvilLevel;
|
||||||
ANVIL_WORKSTATIONS[anvilLevel] = new AnvilEmiStack(LeveledAnvilBlock
|
ANVIL_WORKSTATIONS[anvilLevel] = EmiStack.of(LeveledAnvilBlock
|
||||||
.getAnvils()
|
.getAnvils()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(b -> LeveledAnvilBlock.canHandle(b, finalAnvilLevel))
|
.filter(b -> LeveledAnvilBlock.canHandle(b, finalAnvilLevel))
|
||||||
.sorted(Comparator.comparingInt(LeveledAnvilBlock::getAnvilCraftingLevel))
|
.sorted(Comparator.comparingInt(LeveledAnvilBlock::getAnvilCraftingLevel))
|
||||||
.findFirst().orElse(Blocks.BARRIER)
|
.findFirst().orElse(Blocks.BARRIER)
|
||||||
);
|
);
|
||||||
|
|
||||||
ANVIL_CATEGORIES[anvilLevel] = new EMIAnvilRecipeCategory(
|
ANVIL_CATEGORIES[anvilLevel] = new EMIAnvilRecipeCategory(
|
||||||
BCLib.makeID("anvil_" + anvilLevel),
|
BCLib.makeID("anvil_" + anvilLevel),
|
||||||
ANVIL_WORKSTATIONS[anvilLevel],
|
ANVIL_WORKSTATIONS[anvilLevel],
|
||||||
getSprite(0, 0),
|
getSprite(0, 0),
|
||||||
anvilLevel
|
anvilLevel
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (anvilLevel > 0 && ANVIL_WORKSTATIONS[anvilLevel].isEqual(ANVIL_WORKSTATIONS[anvilLevel - 1])) {
|
||||||
|
ANVIL_WORKSTATIONS[anvilLevel - 1] = ANVIL_WORKSTATIONS[anvilLevel];
|
||||||
|
ANVIL_CATEGORIES[anvilLevel - 1] = ANVIL_CATEGORIES[anvilLevel];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,14 +58,11 @@ public abstract class AnvilMenuMixin extends ItemCombinerMenu implements AnvilSc
|
||||||
if (context != ContainerLevelAccess.NULL) {
|
if (context != ContainerLevelAccess.NULL) {
|
||||||
int level = context.evaluate((world, blockPos) -> {
|
int level = context.evaluate((world, blockPos) -> {
|
||||||
Block anvilBlock = world.getBlockState(blockPos).getBlock();
|
Block anvilBlock = world.getBlockState(blockPos).getBlock();
|
||||||
if (anvilBlock instanceof LeveledAnvilBlock) {
|
return LeveledAnvilBlock.getAnvilCraftingLevel(anvilBlock);
|
||||||
return ((LeveledAnvilBlock) anvilBlock).getCraftingLevel();
|
}, 0);
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}, 1);
|
|
||||||
anvilLevel.set(level);
|
anvilLevel.set(level);
|
||||||
} else {
|
} else {
|
||||||
anvilLevel.set(1);
|
anvilLevel.set(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,19 @@
|
||||||
"title.config.bclib.client.ui.forceBetterXPreset": "BetterX als Standard-Welt-Typ verwenden",
|
"title.config.bclib.client.ui.forceBetterXPreset": "BetterX als Standard-Welt-Typ verwenden",
|
||||||
"description.config.bclib.client.ui.forceBetterXPreset": "Der Welt-Typ bestimmt, wie eine Welt generiert wird. In den meisten Fällen solltet BetterX als Standardeinstellung beibehalten werden (Du kannst den Typ jederzeit im Welt-Erstellen-Bildschirm ändern). Dieser Typ ist für maximale Kompatibilität zwischen DataPacks, unserer Mod und anderen Fabric-Mods optimiert. Außerdem bietet er einige einzigartige Funktionen für BetterNether und BetterEnd. Du solltest diese Option nur deaktivieren, wenn Du einen Grund dazu hast!",
|
"description.config.bclib.client.ui.forceBetterXPreset": "Der Welt-Typ bestimmt, wie eine Welt generiert wird. In den meisten Fällen solltet BetterX als Standardeinstellung beibehalten werden (Du kannst den Typ jederzeit im Welt-Erstellen-Bildschirm ändern). Dieser Typ ist für maximale Kompatibilität zwischen DataPacks, unserer Mod und anderen Fabric-Mods optimiert. Außerdem bietet er einige einzigartige Funktionen für BetterNether und BetterEnd. Du solltest diese Option nur deaktivieren, wenn Du einen Grund dazu hast!",
|
||||||
"warning.config.bclib.client.ui.forceBetterXPreset": "IN DEN MEISTEN FÄLLEN SOLLTE DIESE OPTION AKTIVIERT BLEIBEN.\n",
|
"warning.config.bclib.client.ui.forceBetterXPreset": "IN DEN MEISTEN FÄLLEN SOLLTE DIESE OPTION AKTIVIERT BLEIBEN.\n",
|
||||||
"emi.category.bclib.alloying": "Endsteinschmelzofen",
|
"emi.category.bclib.alloying": "Legierungen",
|
||||||
"tag.c.barrel": "Fässer"
|
"tag.c.barrel": "Fässer",
|
||||||
|
"emi.category.bclib.anvil_0": "Amboss (Stufe 0)",
|
||||||
|
"emi.category.bclib.anvil_1": "Amboss (Stufe I)",
|
||||||
|
"emi.category.bclib.anvil_2": "Amboss (Stufe II)",
|
||||||
|
"emi.category.bclib.anvil_3": "Amboss (Stufe III)",
|
||||||
|
"emi.category.bclib.anvil_4": "Amboss (Stufe IV)",
|
||||||
|
"emi.category.bclib.anvil_5": "Amboss (Stufe V)",
|
||||||
|
"tag.c.wooden_barrels": "Hölzerne Fässer Barrels",
|
||||||
|
"tag.c.workbench": "Werkbänke",
|
||||||
|
"tag.c.furnaces": "Brennöfen",
|
||||||
|
"tag.c.saplings": "Setzlinge",
|
||||||
|
"tag.c.hammers": "Hämmer",
|
||||||
|
"tag.c.leaves": "Blätter",
|
||||||
|
"tag.c.soul_ground": "Seelenböden"
|
||||||
}
|
}
|
|
@ -83,12 +83,19 @@
|
||||||
"title.config.bclib.client.ui.forceBetterXPreset": "Use BetterX as Default World-Type",
|
"title.config.bclib.client.ui.forceBetterXPreset": "Use BetterX as Default World-Type",
|
||||||
"warning.config.bclib.client.ui.forceBetterXPreset": "MOST LIKELY YOU WILL WANT TO KEEP THIS OPTION ENABLED.\n",
|
"warning.config.bclib.client.ui.forceBetterXPreset": "MOST LIKELY YOU WILL WANT TO KEEP THIS OPTION ENABLED.\n",
|
||||||
"description.config.bclib.client.ui.forceBetterXPreset": "The world type determines how a world is generated. In most cases, BetterX should be kept as the default (you can change the type at any time in the world creation screen). This type is optimized for maximum compatibility between DataPacks, our mod, and other Fabric mods. It also provides some unique features for BetterNether and BetterEnd. You should only disable this option if you have a reason to do so!",
|
"description.config.bclib.client.ui.forceBetterXPreset": "The world type determines how a world is generated. In most cases, BetterX should be kept as the default (you can change the type at any time in the world creation screen). This type is optimized for maximum compatibility between DataPacks, our mod, and other Fabric mods. It also provides some unique features for BetterNether and BetterEnd. You should only disable this option if you have a reason to do so!",
|
||||||
"emi.category.bclib.alloying": "End Stone Smelter",
|
"emi.category.bclib.alloying": "Alloying",
|
||||||
"emi.category.bclib.anvil_0": "Anvil",
|
"emi.category.bclib.anvil_0": "Anvil (Level 0)",
|
||||||
"emi.category.bclib.anvil_1": "Anvil I",
|
"emi.category.bclib.anvil_1": "Anvil (Level I)",
|
||||||
"emi.category.bclib.anvil_2": "Anvil II",
|
"emi.category.bclib.anvil_2": "Anvil (Level II)",
|
||||||
"emi.category.bclib.anvil_3": "Anvil III",
|
"emi.category.bclib.anvil_3": "Anvil (Level III)",
|
||||||
"emi.category.bclib.anvil_4": "Anvil IV",
|
"emi.category.bclib.anvil_4": "Anvil (Level IV)",
|
||||||
"emi.category.bclib.anvil_5": "Anvil V",
|
"emi.category.bclib.anvil_5": "Anvil (Level V)",
|
||||||
"tag.c.barrel": "Barrels"
|
"tag.c.barrel": "Barrels",
|
||||||
|
"tag.c.wooden_barrels": "Wooden Barrels",
|
||||||
|
"tag.c.workbench": "Crafting Tables",
|
||||||
|
"tag.c.furnaces": "Furnaces",
|
||||||
|
"tag.c.saplings": "Saplings",
|
||||||
|
"tag.c.hammers": "Hammers",
|
||||||
|
"tag.c.leaves": "Leaves",
|
||||||
|
"tag.c.soul_ground": "Soul Ground"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue