-
Notifications
You must be signed in to change notification settings - Fork 324
Add recipes for netherite tools #4368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JuiceyBeans
wants to merge
7
commits into
GregTechCEu:1.20.1
Choose a base branch
from
JuiceyBeans:netherite-tools
base: 1.20.1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+111
−1
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9f095f2
Smithing recipe helpers
JuiceyBeans c76fd07
Netherite tools
JuiceyBeans d05a576
Move tool existing check to VanillaRecipeHelper#addToolUpgradingRecipe
JuiceyBeans 758d205
Mixin to transform GT tools' NBT properly
JuiceyBeans 16f5419
Import SmithingTransformRecipeBuilder in VanillaRecipeHelper
JuiceyBeans a923847
Use @Share for thread safety
JuiceyBeans a9884c9
Null safety + some other smol changes
JuiceyBeans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/main/java/com/gregtechceu/gtceu/core/mixins/SmithingTransformRecipeMixin.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package com.gregtechceu.gtceu.core.mixins; | ||
|
|
||
| import com.gregtechceu.gtceu.api.item.IGTTool; | ||
| import com.gregtechceu.gtceu.api.item.tool.ToolHelper; | ||
|
|
||
| import net.minecraft.core.RegistryAccess; | ||
| import net.minecraft.nbt.CompoundTag; | ||
| import net.minecraft.nbt.Tag; | ||
| import net.minecraft.world.Container; | ||
| import net.minecraft.world.item.ItemStack; | ||
| import net.minecraft.world.item.crafting.SmithingTransformRecipe; | ||
|
|
||
| import com.llamalad7.mixinextras.sugar.Share; | ||
| import com.llamalad7.mixinextras.sugar.ref.LocalRef; | ||
| import org.spongepowered.asm.mixin.Final; | ||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.Shadow; | ||
| import org.spongepowered.asm.mixin.injection.At; | ||
| import org.spongepowered.asm.mixin.injection.Inject; | ||
| import org.spongepowered.asm.mixin.injection.Redirect; | ||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
|
||
| @Mixin(SmithingTransformRecipe.class) | ||
| public class SmithingTransformRecipeMixin { | ||
|
|
||
| @Shadow | ||
| @Final | ||
| ItemStack result; | ||
|
|
||
| @Inject(method = "assemble", | ||
| at = @At(value = "INVOKE", | ||
| target = "Lnet/minecraft/world/item/ItemStack;setTag(Lnet/minecraft/nbt/CompoundTag;)V")) | ||
| private void gtceu$gtToolSmithingTransform1(Container container, RegistryAccess registryAccess, | ||
| CallbackInfoReturnable<ItemStack> cir, | ||
| @Share("newTag") LocalRef<CompoundTag> sharedTag) { | ||
| ItemStack output = this.result.copy(); | ||
|
|
||
| if (!(output.getItem() instanceof IGTTool igtTool)) return; | ||
|
|
||
| CompoundTag originalTag = container.getItem(1).getTag(); | ||
| CompoundTag newTag = originalTag != null ? originalTag.copy() : null; | ||
| if (newTag == null) return; | ||
|
|
||
| // Remove old tool stats | ||
| newTag.remove("GT.Tool"); | ||
|
|
||
| // Copy stats from the upgraded tool | ||
| ItemStack newStack = ToolHelper.get(igtTool.getToolType(), igtTool.getMaterial()); | ||
| Tag newStats = newStack.getTag() != null ? newStack.getTag().get("GT.Tool") : null; | ||
| if (newStats != null) { | ||
| newTag.put("GT.Tool", newStats); | ||
| sharedTag.set(newTag); | ||
| } | ||
| } | ||
|
|
||
| @Redirect(method = "assemble", | ||
| at = @At(value = "INVOKE", | ||
| target = "Lnet/minecraft/world/item/ItemStack;setTag(Lnet/minecraft/nbt/CompoundTag;)V")) | ||
| private void gtceu$gtToolSmithingTransform2(ItemStack itemStack, CompoundTag tag, | ||
| @Share("newTag") LocalRef<CompoundTag> sharedTag) { | ||
| itemStack.setTag(sharedTag.get()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.