diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/ToolProperty.java b/common/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/ToolProperty.java index e5aec51528..ed44913043 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/ToolProperty.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/properties/ToolProperty.java @@ -150,7 +150,7 @@ public static Builder of(float harvestSpeed, float attackDamage, int durability, SHOVEL, AXE, HOE, - + MINING_HAMMER, SAW, HARD_HAMMER, // SOFT_MALLET, diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/ConfiguratorPanel.java b/common/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/ConfiguratorPanel.java index 663c5639bf..ff87668f92 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/ConfiguratorPanel.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/ConfiguratorPanel.java @@ -188,6 +188,18 @@ protected void onChildSizeUpdate(Widget child) { this.addWidget(view); } + @Override + public void writeInitialData(FriendlyByteBuf buffer) { + super.writeInitialData(buffer); + configurator.writeInitialData(buffer); + } + + @Override + public void readInitialData(FriendlyByteBuf buffer) { + super.readInitialData(buffer); + configurator.readInitialData(buffer); + } + @Override public void detectAndSendChanges() { super.detectAndSendChanges(); diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/IFancyConfigurator.java b/common/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/IFancyConfigurator.java index 45b6083c1d..6bf7d7d89f 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/IFancyConfigurator.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/gui/fancy/IFancyConfigurator.java @@ -34,4 +34,11 @@ default void readUpdateInfo(int id, FriendlyByteBuf buf) { } + default void writeInitialData(FriendlyByteBuf buffer) { + + } + + default void readInitialData(FriendlyByteBuf buffer) { + + } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/gui/widget/CoverContainerConfigurator.java b/common/src/main/java/com/gregtechceu/gtceu/api/gui/widget/CoverContainerConfigurator.java index 8e723c0f8e..26f18f4bc9 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/gui/widget/CoverContainerConfigurator.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/gui/widget/CoverContainerConfigurator.java @@ -87,6 +87,9 @@ public void apply(boolean isTESR, RenderType layer) { RenderSystem.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE); } }); + + var playerRotation = gui.entityPlayer.getRotationVector(); + sceneWidget.setCameraYawAndPitch(playerRotation.x, playerRotation.y - 90); } addWidget(sceneWidget.setBackground(ColorPattern.BLACK.rectTexture())); addWidget(slotWidget = new SlotWidget(transfer, 0, 4, 80 - 4 - 18) @@ -94,10 +97,6 @@ public void apply(boolean isTESR, RenderType layer) { .setBackgroundTexture(new GuiTextureGroup(GuiTextures.SLOT, GuiTextures.FILTER_SLOT_OVERLAY))); slotWidget.setVisible(false); slotWidget.setActive(false); - - - var playerRotation = gui.entityPlayer.getRotationVector(); - sceneWidget.setCameraYawAndPitch(playerRotation.x, playerRotation.y); } private void coverRemoved() { diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/machine/fancyconfigurator/OverclockFancyConfigurator.java b/common/src/main/java/com/gregtechceu/gtceu/api/machine/fancyconfigurator/OverclockFancyConfigurator.java index 1136341b11..508a064966 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/machine/fancyconfigurator/OverclockFancyConfigurator.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/machine/fancyconfigurator/OverclockFancyConfigurator.java @@ -16,7 +16,6 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; -import javax.annotation.Nullable; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,64 +31,38 @@ public class OverclockFancyConfigurator implements IFancyConfigurator { protected IOverclockMachine overclockMachine; // runtime protected int currentTier; - @Nullable - protected WidgetGroup group; - protected Map lightGroups; public OverclockFancyConfigurator(IOverclockMachine overclockMachine) { this.overclockMachine = overclockMachine; - this.lightGroups = new HashMap<>(); + } + + @Override + public String getTitle() { + return "gtceu.gui.overclock.title"; + } + + @Override + public IGuiTexture getIcon() { + return new TextTexture(GTValues.VNF[this.currentTier]).setDropShadow(false); + } + + @Override + public void writeInitialData(FriendlyByteBuf buffer) { + this.currentTier = overclockMachine.getOverclockTier(); + buffer.writeVarInt(currentTier); + } + + @Override + public void readInitialData(FriendlyByteBuf buffer) { + this.currentTier = buffer.readVarInt(); } @Override public void detectAndSendChange(BiConsumer> sender) { var newTier = overclockMachine.getOverclockTier(); - if (newTier != this.currentTier) { + if (newTier != currentTier) { this.currentTier = newTier; - sender.accept(0, buf -> buf.writeVarInt(this.currentTier)); - } - int min = overclockMachine.getMinOverclockTier(); - int max = overclockMachine.getMaxOverclockTier(); - if (lightGroups.size() != max - min + 1) { - updateLightButton(min, max); - sender.accept(1, buf -> { - buf.writeVarInt(min); - buf.writeVarInt(max); - }); - } else { - for (int i = min; i <= max; i++) { - if (!lightGroups.containsKey(i)) { - updateLightButton(min, max); - sender.accept(1, buf -> { - buf.writeVarInt(min); - buf.writeVarInt(max); - }); - return; - } - } - } - } - - private void updateLightButton(int min, int max) { - if (group != null) { - for (WidgetGroup light : lightGroups.values()) { - group.removeWidget(light); - } - lightGroups.clear(); - int x = 5; - for (int tier = min; tier <= max ; tier++) { - int finalTier = tier; - var lightGroup = new WidgetGroup(x, 27, 8, 8); - lightGroup.addWidget(new ButtonWidget(0, 0, 8, 8, null, cd -> { - if (!cd.isRemote) { - overclockMachine.setOverclockTier(finalTier); - } - })); - lightGroup.addWidget(new ImageWidget(0, 0, 8, 8, () -> currentTier >= finalTier ? GuiTextures.LIGHT_ON : GuiTextures.LIGHT_OFF)); - lightGroups.put(tier, lightGroup); - group.addWidget(lightGroup); - x += 10; - } + sender.accept(0, buf -> buf.writeVarInt(newTier)); } } @@ -97,42 +70,109 @@ private void updateLightButton(int min, int max) { public void readUpdateInfo(int id, FriendlyByteBuf buf) { if (id == 0) { this.currentTier = buf.readVarInt(); - } else if (id == 1) { - int min = buf.readVarInt(); - int max = buf.readVarInt(); - updateLightButton(min, max); } } @Override - public String getTitle() { - return "gtceu.gui.overclock.title"; - } + public Widget createConfigurator() { + return new WidgetGroup(0, 0, 120, 40) { + final Map lightGroups = new HashMap<>(); - @Override - public IGuiTexture getIcon() { - return new TextTexture(GTValues.VNF[this.currentTier]).setDropShadow(false); - } + @Override + public void initWidget() { + super.initWidget(); + setBackground(GuiTextures.BACKGROUND_INVERSE); + addWidget(new PredicatedButtonWidget(5, 5, 10, 20, new GuiTextureGroup(GuiTextures.BUTTON, Icons.LEFT.copy().scale(0.7f)), cd -> { + if (!cd.isRemote) { + overclockMachine.setOverclockTier(currentTier - 1); + } + }).setPredicate(() -> currentTier > overclockMachine.getMinOverclockTier())); + addWidget(new ImageWidget(20, 5, 120 - 5 - 10 - 5 - 20, 20, () -> new GuiTextureGroup(GuiTextures.DISPLAY_FRAME, new TextTexture(GTValues.VNF[currentTier])))); + addWidget(new PredicatedButtonWidget(120 -5 - 10, 5, 10, 20, new GuiTextureGroup(GuiTextures.BUTTON, Icons.RIGHT.copy().scale(0.7f)), cd -> { + if (!cd.isRemote) { + overclockMachine.setOverclockTier(currentTier + 1); + } + }).setPredicate(() -> currentTier < overclockMachine.getMaxOverclockTier())); + } - @Override - public Widget createConfigurator() { - group = new WidgetGroup(0, 0, 120, 40); - group.setBackground(GuiTextures.BACKGROUND_INVERSE); - group.addWidget(new PredicatedButtonWidget(5, 5, 10, 20, new GuiTextureGroup(GuiTextures.BUTTON, Icons.LEFT.copy().scale(0.7f)), cd -> { - if (!cd.isRemote) { - overclockMachine.setOverclockTier(currentTier - 1); + @Override + public void writeInitialData(FriendlyByteBuf buffer) { + int min = overclockMachine.getMinOverclockTier(); + int max = overclockMachine.getMaxOverclockTier(); + buffer.writeVarInt(min); + buffer.writeVarInt(max); + buffer.writeVarInt(currentTier); + updateLightButton(min, max); + super.writeInitialData(buffer); } - }).setPredicate(() -> currentTier > overclockMachine.getMinOverclockTier())); - group.addWidget(new ImageWidget(20, 5, 120 - 5 - 10 - 5 - 20, 20, () -> new GuiTextureGroup(GuiTextures.DISPLAY_FRAME, new TextTexture(GTValues.VNF[this.currentTier])))); - group.addWidget(new PredicatedButtonWidget(120 -5 - 10, 5, 10, 20, new GuiTextureGroup(GuiTextures.BUTTON, Icons.RIGHT.copy().scale(0.7f)), cd -> { - if (!cd.isRemote) { - overclockMachine.setOverclockTier(currentTier + 1); + + @Override + public void readInitialData(FriendlyByteBuf buffer) { + int min = buffer.readVarInt(); + int max = buffer.readVarInt(); + currentTier = buffer.readVarInt(); + updateLightButton(min, max); + super.readInitialData(buffer); } - }).setPredicate(() -> currentTier < overclockMachine.getMaxOverclockTier())); - return group; - } + private void updateLightButton(int min, int max) { + for (WidgetGroup light : lightGroups.values()) { + removeWidget(light); + } + lightGroups.clear(); + int x = 5; + for (int tier = min; tier <= max ; tier++) { + int finalTier = tier; + var lightGroup = new WidgetGroup(x, 27, 8, 8); + lightGroup.addWidget(new ButtonWidget(0, 0, 8, 8, null, cd -> { + if (!cd.isRemote) { + overclockMachine.setOverclockTier(finalTier); + } + })); + lightGroup.addWidget(new ImageWidget(0, 0, 8, 8, () -> currentTier >= finalTier ? GuiTextures.LIGHT_ON : GuiTextures.LIGHT_OFF)); + lightGroups.put(tier, lightGroup); + addWidget(lightGroup); + x += 10; + } + } + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + int min = overclockMachine.getMinOverclockTier(); + int max = overclockMachine.getMaxOverclockTier(); + if (lightGroups.size() != max - min + 1) { + updateLightButton(min, max); + writeUpdateInfo(0, buf -> { + buf.writeVarInt(min); + buf.writeVarInt(max); + }); + } else { + for (int i = min; i <= max; i++) { + if (!lightGroups.containsKey(i)) { + updateLightButton(min, max); + writeUpdateInfo(0, buf -> { + buf.writeVarInt(min); + buf.writeVarInt(max); + }); + return; + } + } + } + } + + @Override + public void readUpdateInfo(int id, FriendlyByteBuf buffer) { + if (id == 0) { + int min = buffer.readVarInt(); + int max = buffer.readVarInt(); + updateLightButton(min, max); + } else { + super.readUpdateInfo(id, buffer); + } + } + }; + } @Override public List getTooltips() { diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/RecipeLogic.java b/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/RecipeLogic.java index fca4a78cb1..775181b695 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/RecipeLogic.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/machine/trait/RecipeLogic.java @@ -71,8 +71,7 @@ public enum Status { @Getter protected long totalContinuousRunningTime; protected TickableSubscription subscription; - @Environment(EnvType.CLIENT) - protected AutoReleasedSound workingSound; + protected Object workingSound; public RecipeLogic(IRecipeLogicMachine machine) { super(machine.self()); @@ -474,11 +473,11 @@ public ManagedFieldHolder getFieldHolder() { public void updateSound() { if (isWorking() && machine.shouldWorkingPlaySound()) { var sound = machine.getRecipeType().getSound(); - if (workingSound != null) { - if (workingSound.soundEntry == sound && !workingSound.isStopped()) { + if (workingSound instanceof AutoReleasedSound soundEntry) { + if (soundEntry.soundEntry == sound && !soundEntry.isStopped()) { return; } - workingSound.release(); + soundEntry.release(); workingSound = null; } if (sound != null) { @@ -489,8 +488,8 @@ && isWorking() && getMachine().getLevel().isLoaded(getMachine().getPos()) && MetaMachine.getMachine(getMachine().getLevel(), getMachine().getPos()) == getMachine(), getMachine().getPos(), true, 0, 1, 1); } - } else if (workingSound != null) { - workingSound.release(); + } else if (workingSound instanceof AutoReleasedSound soundEntry) { + soundEntry.release(); workingSound = null; } } diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/recipe/StrictShapedRecipe.java b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/StrictShapedRecipe.java new file mode 100644 index 0000000000..bc326209e2 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/api/recipe/StrictShapedRecipe.java @@ -0,0 +1,107 @@ +package com.gregtechceu.gtceu.api.recipe; + +import com.google.gson.JsonObject; +import com.gregtechceu.gtceu.core.mixins.ShapedRecipeInvoker; +import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.core.NonNullList; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.GsonHelper; +import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.ShapedRecipe; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; + +import javax.annotation.ParametersAreNonnullByDefault; +import java.util.Map; + +/** + * @author KilaBash + * @date 2023/7/24 + * @implNote StrictShapedRecipe + */ +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class StrictShapedRecipe extends ShapedRecipe { + public static final RecipeSerializer SERIALIZER = new Serializer(); + + public StrictShapedRecipe(ResourceLocation id, String group, int width, int height, NonNullList recipeItems, ItemStack result) { + super(id, group, width, height, recipeItems, result); + } + + @Override + public boolean matches(CraftingContainer inv, Level level) { + for (int i = 0; i <= inv.getWidth() - this.getWidth(); ++i) { + for (int j = 0; j <= inv.getHeight() - this.getHeight(); ++j) { + if (this.matches(inv, i, j)) { + return true; + } + } + } + return false; + } + + + /** + * Checks if the region of a crafting inventory is match for the recipe. + */ + private boolean matches(CraftingContainer craftingInventory, int width, int height) { + for (int i = 0; i < craftingInventory.getWidth(); ++i) { + for (int j = 0; j < craftingInventory.getHeight(); ++j) { + int k = i - width; + int l = j - height; + Ingredient ingredient = Ingredient.EMPTY; + if (k >= 0 && l >= 0 && k < this.getWidth() && l < this.getHeight()) { + ingredient = this.getIngredients().get(k + l * this.getWidth()); + } + if (ingredient.test(craftingInventory.getItem(i + j * craftingInventory.getWidth()))) continue; + return false; + } + } + return true; + } + + @Override + public @NotNull RecipeSerializer getSerializer() { + return SERIALIZER; + } + + public static class Serializer implements RecipeSerializer { + @Override + public StrictShapedRecipe fromJson(ResourceLocation recipeId, JsonObject json) { + String string = GsonHelper.getAsString(json, "group", ""); + Map map = ShapedRecipeInvoker.callKeyFromJson(GsonHelper.getAsJsonObject(json, "key")); + String[] strings = ShapedRecipeInvoker.callPatternFromJson(GsonHelper.getAsJsonArray(json, "pattern")); + int i = strings[0].length(); + int j = strings.length; + NonNullList nonNullList = ShapedRecipeInvoker.callDissolvePattern(strings, map, i, j); + ItemStack itemStack = StrictShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(json, "result")); + return new StrictShapedRecipe(recipeId, string, i, j, nonNullList, itemStack); + } + + @Override + public StrictShapedRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) { + int i = buffer.readVarInt(); + int j = buffer.readVarInt(); + String string = buffer.readUtf(); + NonNullList nonNullList = NonNullList.withSize(i * j, Ingredient.EMPTY); + nonNullList.replaceAll(ignored -> Ingredient.fromNetwork(buffer)); + ItemStack itemStack = buffer.readItem(); + return new StrictShapedRecipe(recipeId, string, i, j, nonNullList, itemStack); + } + + @Override + public void toNetwork(FriendlyByteBuf buffer, StrictShapedRecipe recipe) { + buffer.writeVarInt(recipe.getWidth()); + buffer.writeVarInt(recipe.getHeight()); + buffer.writeUtf(recipe.getGroup()); + for (Ingredient ingredient : recipe.getIngredients()) { + ingredient.toNetwork(buffer); + } + buffer.writeItem(recipe.getResultItem()); + } + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/api/syncdata/EnhancedFieldManagedStorage.java b/common/src/main/java/com/gregtechceu/gtceu/api/syncdata/EnhancedFieldManagedStorage.java index 393f650c27..a32fa0564d 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/api/syncdata/EnhancedFieldManagedStorage.java +++ b/common/src/main/java/com/gregtechceu/gtceu/api/syncdata/EnhancedFieldManagedStorage.java @@ -1,6 +1,7 @@ package com.gregtechceu.gtceu.api.syncdata; import com.gregtechceu.gtceu.GTCEu; +import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.syncdata.field.FieldManagedStorage; import com.lowdragmc.lowdraglib.syncdata.managed.IRef; @@ -26,7 +27,9 @@ public void init() { super.init(); if (initialized) return; initialized = true; - initEnhancedFeature(); + if (LDLib.isClient()) { + initEnhancedFeature(); + } } public void initEnhancedFeature() { diff --git a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java index 5d36e26d45..512960491f 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java +++ b/common/src/main/java/com/gregtechceu/gtceu/common/data/GTRecipeTypes.java @@ -7,15 +7,12 @@ import com.gregtechceu.gtceu.api.capability.recipe.EURecipeCapability; import com.gregtechceu.gtceu.api.capability.recipe.IO; import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; -import com.gregtechceu.gtceu.api.recipe.FacadeCoverRecipe; -import com.gregtechceu.gtceu.api.recipe.GTRecipeSerializer; -import com.gregtechceu.gtceu.api.recipe.OverclockingLogic; +import com.gregtechceu.gtceu.api.recipe.*; import com.gregtechceu.gtceu.api.recipe.content.Content; import com.gregtechceu.gtceu.common.recipe.RPMCondition; import com.gregtechceu.gtceu.common.recipe.RockBreakerCondition; import com.gregtechceu.gtceu.api.capability.recipe.FluidRecipeCapability; import com.gregtechceu.gtceu.api.gui.GuiTextures; -import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.registry.GTRegistries; import com.gregtechceu.gtceu.api.sound.ExistingSoundEntry; import com.gregtechceu.gtceu.data.recipe.RecipeHelper; @@ -584,6 +581,7 @@ public static void init() { } GTRegistries.register(Registry.RECIPE_SERIALIZER, GTCEu.id("gt_recipe_serializer"), GTRecipeSerializer.SERIALIZER); GTRegistries.register(Registry.RECIPE_SERIALIZER, GTCEu.id("facade_cover_serializer"), FacadeCoverRecipe.SERIALIZER); + GTRegistries.register(Registry.RECIPE_SERIALIZER, GTCEu.id("strict_shaped_recipe_serializer"), StrictShapedRecipe.SERIALIZER); } public static GTRecipeType get(String name) { diff --git a/common/src/main/java/com/gregtechceu/gtceu/core/mixins/ShapedRecipeInvoker.java b/common/src/main/java/com/gregtechceu/gtceu/core/mixins/ShapedRecipeInvoker.java new file mode 100644 index 0000000000..6e29e3bf34 --- /dev/null +++ b/common/src/main/java/com/gregtechceu/gtceu/core/mixins/ShapedRecipeInvoker.java @@ -0,0 +1,34 @@ +package com.gregtechceu.gtceu.core.mixins; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import net.minecraft.core.NonNullList; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.ShapedRecipe; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +import java.util.Map; + +/** + * @author KilaBash + * @date 2023/7/24 + * @implNote ShapedRecipeAccessor + */ +@Mixin(ShapedRecipe.class) +public interface ShapedRecipeInvoker { + @Invoker + static Map callKeyFromJson(JsonObject keyEntry) { + return null; + } + + @Invoker + static String[] callPatternFromJson(JsonArray patternArray) { + return null; + } + + @Invoker + static NonNullList callDissolvePattern(String[] pattern, Map keys, int patternWidth, int patternHeight) { + return null; + } +} diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/VanillaRecipeHelper.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/VanillaRecipeHelper.java index 7892761efa..39fcc85bdc 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/VanillaRecipeHelper.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/VanillaRecipeHelper.java @@ -76,6 +76,10 @@ public static void addShapedRecipe(Consumer provider, @Nonnull S addShapedRecipe(provider, false, regName, result, recipe); } + public static void addStrictShapedRecipe(Consumer provider, @Nonnull String regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { + addStrictShapedRecipe(provider, false, regName, result, recipe); + } + /** * Adds Shaped Crafting Recipes. *

@@ -101,8 +105,9 @@ public static void addShapedRecipe(Consumer provider, @Nonnull S * @param result the output for the recipe * @param recipe the contents of the recipe */ - public static void addShapedRecipe(Consumer provider, boolean withUnificationData, @Nonnull String regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { + public static void addShapedRecipe(Consumer provider, boolean withUnificationData, boolean isStrict, @Nonnull String regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { var builder = new ShapedRecipeBuilder(GTCEu.id(regName.toLowerCase())).output(result); + builder.isStrict(isStrict); CharSet set = new CharOpenHashSet(); for (int i = 0; i < recipe.length; i++) { var o = recipe[i]; @@ -145,6 +150,14 @@ public static void addShapedRecipe(Consumer provider, boolean wi } } + public static void addShapedRecipe(Consumer provider, boolean withUnificationData, @Nonnull String regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { + addShapedRecipe(provider, withUnificationData, false, regName, result, recipe); + } + + public static void addStrictShapedRecipe(Consumer provider, boolean withUnificationData, @Nonnull String regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { + addShapedRecipe(provider, withUnificationData, true, regName, result, recipe); + } + public static void addShapelessRecipe(Consumer provider, @Nonnull String regName, @Nonnull ItemStack result, @Nonnull Object... recipe) { var builder = new ShapelessRecipeBuilder(GTCEu.id(regName.toLowerCase())).output(result); for (Object content : recipe) { diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/ShapedRecipeBuilder.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/ShapedRecipeBuilder.java index 315c661a3d..87a72e8625 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/ShapedRecipeBuilder.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/builder/ShapedRecipeBuilder.java @@ -2,6 +2,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import com.gregtechceu.gtceu.api.recipe.StrictShapedRecipe; import com.gregtechceu.gtceu.api.recipe.ingredient.NBTIngredient; import com.lowdragmc.lowdraglib.LDLib; import com.lowdragmc.lowdraglib.utils.Builder; @@ -29,6 +30,7 @@ public class ShapedRecipeBuilder extends Builder getType() { - return RecipeSerializer.SHAPED_RECIPE; + return isStrict ? StrictShapedRecipe.SERIALIZER : RecipeSerializer.SHAPED_RECIPE; } @Nullable diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/MaterialRecipeHandler.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/MaterialRecipeHandler.java index eb3fe47fe3..650a9cea5f 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/MaterialRecipeHandler.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/MaterialRecipeHandler.java @@ -212,8 +212,7 @@ public static void processSmallDust(TagPrefix orePrefix, Material material, Dust ItemStack smallDustStack = ChemicalHelper.get(orePrefix, material); ItemStack dustStack = ChemicalHelper.get(dust, material); - // todo this recipe doesnt work right - VanillaRecipeHelper.addShapedRecipe(provider, String.format("small_dust_disassembling_%s", material), + VanillaRecipeHelper.addStrictShapedRecipe(provider, String.format("small_dust_disassembling_%s", material), GTUtil.copyAmount(4, smallDustStack), " X ", " ", " ", 'X', new UnificationEntry(dust, material)); VanillaRecipeHelper.addShapedRecipe(provider, String.format("small_dust_assembling_%s", material), dustStack, "XX", "XX", 'X', new UnificationEntry(orePrefix, material)); @@ -235,8 +234,7 @@ public static void processTinyDust(TagPrefix orePrefix, Material material, DustP ItemStack tinyDustStack = ChemicalHelper.get(orePrefix, material); ItemStack dustStack = ChemicalHelper.get(dust, material); - // todo this recipe doesnt work right - VanillaRecipeHelper.addShapedRecipe(provider, String.format("tiny_dust_disassembling_%s", material), + VanillaRecipeHelper.addStrictShapedRecipe(provider, String.format("tiny_dust_disassembling_%s", material), GTUtil.copyAmount(9, tinyDustStack), "X ", " ", " ", 'X', new UnificationEntry(dust, material)); VanillaRecipeHelper.addShapedRecipe(provider, String.format("tiny_dust_assembling_%s", material), dustStack, "XXX", "XXX", "XXX", 'X', new UnificationEntry(orePrefix, material)); diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/ToolRecipeHandler.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/ToolRecipeHandler.java index 5590dc150e..e3c922db83 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/ToolRecipeHandler.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/generated/ToolRecipeHandler.java @@ -110,10 +110,6 @@ private static void processTool(TagPrefix prefix, Material material, ToolPropert UnificationEntry ingot = new UnificationEntry(material.hasProperty(PropertyKey.GEM) ? TagPrefix.gem : TagPrefix.ingot, material); if (material.hasFlag(GENERATE_PLATE)) { - //addToolRecipe(provider, material, GTToolType.MINING_HAMMER, true, - // "PPf", "PPS", "PPh", - // 'P', plate, - // 'S', rod); //addToolRecipe(provider, material, GTToolType.SPADE, false, // "fPh", "PSP", " S ", @@ -181,6 +177,7 @@ private static void processTool(TagPrefix prefix, Material material, ToolPropert if (material.hasFlag(GENERATE_ROD)) { UnificationEntry rod = new UnificationEntry(TagPrefix.rod, material); + addToolRecipe(provider, material, GTToolType.PLUNGER, false, "xRR", " SR", "S f", 'S', rod, @@ -199,6 +196,11 @@ private static void processTool(TagPrefix prefix, Material material, ToolPropert 'T', new UnificationEntry(TagPrefix.screw, material), 'S', rod); } + + addToolRecipe(provider, material, GTToolType.MINING_HAMMER, true, + "PPf", "PPS", "PPh", + 'P', plate, + 'S', rod); } addToolRecipe(provider, material, GTToolType.SCREWDRIVER, true, diff --git a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/CraftingRecipeLoader.java b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/CraftingRecipeLoader.java index 730bc0a981..542edabe06 100644 --- a/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/CraftingRecipeLoader.java +++ b/common/src/main/java/com/gregtechceu/gtceu/data/recipe/misc/CraftingRecipeLoader.java @@ -93,39 +93,39 @@ public static void init(Consumer provider) { /////////////////////////////////////////////////// VanillaRecipeHelper.addShapedRecipe(provider, "shape_empty", SHAPE_EMPTY.asStack(), "hf", "PP", "PP", 'P', new UnificationEntry(plate, Steel)); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_bottle", SHAPE_EXTRUDER_BOTTLE.asStack(), " x", " S ", " ", 'S', SHAPE_EXTRUDER_RING.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_gear", SHAPE_EXTRUDER_GEAR.asStack(), "x ", " S ", " ", 'S', SHAPE_EXTRUDER_RING.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_block", SHAPE_EXTRUDER_BLOCK.asStack(), "x ", " S ", " ", 'S', SHAPE_EXTRUDER_INGOT.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_pipe_huge", SHAPE_EXTRUDER_PIPE_HUGE.asStack(), " ", " S ", " x", 'S', SHAPE_EXTRUDER_BOLT.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_pipe_large", SHAPE_EXTRUDER_PIPE_LARGE.asStack(), " ", " Sx", " ", 'S', SHAPE_EXTRUDER_BOLT.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_pipe_normal", SHAPE_EXTRUDER_PIPE_NORMAL.asStack(), " x", " S ", " ", 'S', SHAPE_EXTRUDER_BOLT.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_pipe_small", SHAPE_EXTRUDER_PIPE_SMALL.asStack(), " x ", " S ", " ", 'S', SHAPE_EXTRUDER_BOLT.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_pipe_tiny", SHAPE_EXTRUDER_PIPE_TINY.asStack(), "x ", " S ", " ", 'S', SHAPE_EXTRUDER_BOLT.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_wire", SHAPE_EXTRUDER_WIRE.asStack(), " x ", " S ", " ", 'S', SHAPE_EXTRUDER_ROD.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_ingot", SHAPE_EXTRUDER_INGOT.asStack(), "x ", " S ", " ", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_cell", SHAPE_EXTRUDER_CELL.asStack(), " ", " Sx", " ", 'S', SHAPE_EXTRUDER_RING.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_ring", SHAPE_EXTRUDER_RING.asStack(), " ", " S ", " x ", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_bolt", SHAPE_EXTRUDER_BOLT.asStack(), "x ", " S ", " ", 'S', SHAPE_EXTRUDER_ROD.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_rod", SHAPE_EXTRUDER_ROD.asStack(), " ", " Sx", " ", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_rod_long", SHAPE_EXTRUDER_ROD_LONG.asStack(), " x", " S ", " ", 'S', SHAPE_EXTRUDER_ROD.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_plate", SHAPE_EXTRUDER_PLATE.asStack(), "x ", " S ", " ", 'S', SHAPE_EXTRUDER_FOIL.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_gear_small", SHAPE_EXTRUDER_GEAR_SMALL.asStack(), " x ", " S ", " ", 'S', SHAPE_EXTRUDER_RING.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_foil", SHAPE_EXTRUDER_FOIL.asStack(), " ", " S ", " x", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_extruder_rotor", SHAPE_EXTRUDER_ROTOR.asStack(), " ", " S ", "x ", 'S', SHAPE_EMPTY.asStack()); - - VanillaRecipeHelper.addShapedRecipe(provider, "shape_mold_rotor", SHAPE_MOLD_ROTOR.asStack(), " h", " S ", " ", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_mold_gear_small", SHAPE_MOLD_GEAR_SMALL.asStack(), " ", " ", "h S", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_mold_name", SHAPE_MOLD_NAME.asStack(), " S", " ", "h ", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_mold_anvil", SHAPE_MOLD_ANVIL.asStack(), " S", " ", " h ", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_mold_cylinder", SHAPE_MOLD_CYLINDER.asStack(), " S", " ", " h", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_mold_nugget", SHAPE_MOLD_NUGGET.asStack(), "S h", " ", " ", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_mold_block", SHAPE_MOLD_BLOCK.asStack(), " ", "hS ", " ", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_mold_ball", SHAPE_MOLD_BALL.asStack(), " ", " S ", "h ", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_mold_ingot", SHAPE_MOLD_INGOT.asStack(), " ", " S ", " h ", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_mold_bottle", SHAPE_MOLD_BOTTLE.asStack(), " ", " S ", " h", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_mold_credit", SHAPE_MOLD_CREDIT.asStack(), "h ", " S ", " ", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_mold_gear", SHAPE_MOLD_GEAR.asStack(), " ", " Sh", " ", 'S', SHAPE_EMPTY.asStack()); - VanillaRecipeHelper.addShapedRecipe(provider, "shape_mold_plate", SHAPE_MOLD_PLATE.asStack(), " h ", " S ", " ", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_bottle", SHAPE_EXTRUDER_BOTTLE.asStack(), " x", " S ", " ", 'S', SHAPE_EXTRUDER_RING.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_gear", SHAPE_EXTRUDER_GEAR.asStack(), "x ", " S ", " ", 'S', SHAPE_EXTRUDER_RING.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_block", SHAPE_EXTRUDER_BLOCK.asStack(), "x ", " S ", " ", 'S', SHAPE_EXTRUDER_INGOT.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_pipe_huge", SHAPE_EXTRUDER_PIPE_HUGE.asStack(), " ", " S ", " x", 'S', SHAPE_EXTRUDER_BOLT.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_pipe_large", SHAPE_EXTRUDER_PIPE_LARGE.asStack(), " ", " Sx", " ", 'S', SHAPE_EXTRUDER_BOLT.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_pipe_normal", SHAPE_EXTRUDER_PIPE_NORMAL.asStack(), " x", " S ", " ", 'S', SHAPE_EXTRUDER_BOLT.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_pipe_small", SHAPE_EXTRUDER_PIPE_SMALL.asStack(), " x ", " S ", " ", 'S', SHAPE_EXTRUDER_BOLT.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_pipe_tiny", SHAPE_EXTRUDER_PIPE_TINY.asStack(), "x ", " S ", " ", 'S', SHAPE_EXTRUDER_BOLT.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_wire", SHAPE_EXTRUDER_WIRE.asStack(), " x ", " S ", " ", 'S', SHAPE_EXTRUDER_ROD.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_ingot", SHAPE_EXTRUDER_INGOT.asStack(), "x ", " S ", " ", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_cell", SHAPE_EXTRUDER_CELL.asStack(), " ", " Sx", " ", 'S', SHAPE_EXTRUDER_RING.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_ring", SHAPE_EXTRUDER_RING.asStack(), " ", " S ", " x ", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_bolt", SHAPE_EXTRUDER_BOLT.asStack(), "x ", " S ", " ", 'S', SHAPE_EXTRUDER_ROD.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_rod", SHAPE_EXTRUDER_ROD.asStack(), " ", " Sx", " ", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_rod_long", SHAPE_EXTRUDER_ROD_LONG.asStack(), " x", " S ", " ", 'S', SHAPE_EXTRUDER_ROD.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_plate", SHAPE_EXTRUDER_PLATE.asStack(), "x ", " S ", " ", 'S', SHAPE_EXTRUDER_FOIL.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_gear_small", SHAPE_EXTRUDER_GEAR_SMALL.asStack(), " x ", " S ", " ", 'S', SHAPE_EXTRUDER_RING.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_foil", SHAPE_EXTRUDER_FOIL.asStack(), " ", " S ", " x", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_extruder_rotor", SHAPE_EXTRUDER_ROTOR.asStack(), " ", " S ", "x ", 'S', SHAPE_EMPTY.asStack()); + + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_mold_rotor", SHAPE_MOLD_ROTOR.asStack(), " h", " S ", " ", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_mold_gear_small", SHAPE_MOLD_GEAR_SMALL.asStack(), " ", " ", "h S", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_mold_name", SHAPE_MOLD_NAME.asStack(), " S", " ", "h ", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_mold_anvil", SHAPE_MOLD_ANVIL.asStack(), " S", " ", " h ", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_mold_cylinder", SHAPE_MOLD_CYLINDER.asStack(), " S", " ", " h", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_mold_nugget", SHAPE_MOLD_NUGGET.asStack(), "S h", " ", " ", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_mold_block", SHAPE_MOLD_BLOCK.asStack(), " ", "hS ", " ", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_mold_ball", SHAPE_MOLD_BALL.asStack(), " ", " S ", "h ", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_mold_ingot", SHAPE_MOLD_INGOT.asStack(), " ", " S ", " h ", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_mold_bottle", SHAPE_MOLD_BOTTLE.asStack(), " ", " S ", " h", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_mold_credit", SHAPE_MOLD_CREDIT.asStack(), "h ", " S ", " ", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_mold_gear", SHAPE_MOLD_GEAR.asStack(), " ", " Sh", " ", 'S', SHAPE_EMPTY.asStack()); + VanillaRecipeHelper.addStrictShapedRecipe(provider, "shape_mold_plate", SHAPE_MOLD_PLATE.asStack(), " h ", " S ", " ", 'S', SHAPE_EMPTY.asStack()); /////////////////////////////////////////////////// // Credits // diff --git a/common/src/main/resources/gtceu-common.mixins.json b/common/src/main/resources/gtceu-common.mixins.json index 458d514945..fef5b7240a 100644 --- a/common/src/main/resources/gtceu-common.mixins.json +++ b/common/src/main/resources/gtceu-common.mixins.json @@ -24,6 +24,7 @@ "RecipeManagerMixin", "ServerChunkProviderMixin", "ServerPlayerGameModeMixin", + "ShapedRecipeInvoker", "TagLoaderMixin", "TagManagerMixin", "create.RotationPropagatorMixin",