Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions src/main/java/gregtech/integration/RecipeCompatUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import gregtech.api.pipenet.block.material.BlockMaterialPipe;
import gregtech.api.recipes.Recipe;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.unification.material.Material;
import gregtech.api.util.GTUtility;
import gregtech.common.blocks.BlockCompressed;
import gregtech.common.blocks.BlockFrame;
Expand All @@ -23,6 +24,8 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;

/**
* Contains utilities for recipe compatibility with scripting mods
*/
Expand Down Expand Up @@ -51,7 +54,11 @@ public static String getFirstOutputString(@NotNull Recipe recipe) {
public static String getMetaItemId(ItemStack item) {
if (item.getItem() instanceof MetaItem) {
MetaItem<?>.MetaValueItem metaValueItem = ((MetaItem<?>) item.getItem()).getItem(item);
if (metaValueItem != null) return metaValueItem.unlocalizedName;
if (metaValueItem != null) {
String nameSpace = Objects.requireNonNull(metaValueItem.getMetaItem().getRegistryName()).getNamespace();
String name = metaValueItem.unlocalizedName;
return nameSpace.equals(GTValues.MODID) ? name : (nameSpace + ":" + name);
}
}
if (item.getItem() instanceof ItemBlock) {
Block block = ((ItemBlock) item.getItem()).getBlock();
Expand All @@ -62,14 +69,17 @@ public static String getMetaItemId(ItemStack item) {
mte.metaTileEntityId.getPath() : mte.metaTileEntityId.toString());
}
}
if (block instanceof BlockCompressed) {
return "block" + ((BlockCompressed) block).getGtMaterial(item).toCamelCaseString();
if (block instanceof BlockCompressed blockCompressed) {
Material material = blockCompressed.getGtMaterial(item);
return getRLPrefix(material) + "block" + material.toCamelCaseString();
}
if (block instanceof BlockFrame) {
return "frame" + ((BlockFrame) block).getGtMaterial(item).toCamelCaseString();
if (block instanceof BlockFrame blockFrame) {
Material material = blockFrame.getGtMaterial(item);
return getRLPrefix(material) + "frame" + material.toCamelCaseString();
}
if (block instanceof BlockMaterialPipe blockMaterialPipe) {
return blockMaterialPipe.getPrefix().name + blockMaterialPipe.getItemMaterial(item).toCamelCaseString();
if (block instanceof BlockMaterialPipe<?, ?, ?>blockMaterialPipe) {
Material material = blockMaterialPipe.getItemMaterial(item);
return getRLPrefix(material) + blockMaterialPipe.getPrefix().name + material.toCamelCaseString();
}
}
return null;
Expand Down Expand Up @@ -97,6 +107,10 @@ public static TweakerType getPriorityTweaker() {
return TweakerType.NONE;
}

public static String getRLPrefix(Material material) {
return material.getModid().equals(GTValues.MODID) ? "" : material.getModid() + ":";
}

public static boolean isTweakerLoaded() {
return getPriorityTweaker() != TweakerType.NONE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public static String getRecipeRemoveLine(RecipeMap<?> recipeMap, Recipe recipe)
for (GTRecipeInput fluidIngredient : recipe.getFluidInputs()) {
builder.append(GroovyScriptCodeConverter.asGroovyCode(fluidIngredient.getInputFluidStack(), false));

if (fluidIngredient.getAmount() > 1) {
builder.append(" * ")
.append(fluidIngredient.getAmount());
}

builder.append(", ");
}
builder.delete(builder.length() - 2, builder.length())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ public static void onHandCommand(GsHandEvent event) {
}

// tool info
if (stackInHand.getItem() instanceof IGTTool) {
IGTTool tool = (IGTTool) stackInHand.getItem();
if (stackInHand.getItem() instanceof IGTTool tool) {
event.messages.add(
new TextComponentTranslation("gregtech.command.hand.tool_stats", tool.getToolClasses(stackInHand)));
}

// material info
MaterialStack material = OreDictUnifier.getMaterial(stackInHand);
if (material != null) {
String copyText = "material('" + material.material + "')";
MaterialStack ms = OreDictUnifier.getMaterial(stackInHand);
if (ms != null) {
String materialString = RecipeCompatUtil.getRLPrefix(ms.material) + ms.material;
String copyText = "material('" + materialString + "')";
event.messages.add(TextCopyable.translation(copyText, "gregtech.command.hand.material").build()
.appendSibling(new TextComponentString(" " + material.material)
.appendSibling(new TextComponentString(" " + materialString)
.setStyle(new Style().setColor(TextFormatting.GREEN))));
}
// ore prefix info
Expand Down
Loading