-
Notifications
You must be signed in to change notification settings - Fork 109
Scroll tweaks #837
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
Merged
Merged
Scroll tweaks #837
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
39a5004
Make scroll-filling function usable without requiring a LootContext
Robotgiggle 6433832
Scrolls can now load and/or reveal the pattern on inventory tick
Robotgiggle f11d46e
Wandering traders can sell scrolls
Robotgiggle 04f8446
Creative tab for scrolls
Robotgiggle cd4c44f
Assorted lang
Robotgiggle b2675a1
Merge branch 'FallingColors:main' into scroll-tweaks
Robotgiggle 6230aa7
Move op_id pattern-loading into ItemScroll
Robotgiggle 3bf9689
Clamp trader scroll chance between 0 and 1
Robotgiggle f30d22e
Revert name change of main creative tab to unbreak addon compat
Robotgiggle 2134295
Make scroll trade replace special trade instead of one of the 5 junks
Robotgiggle 248ca92
Fixed crash with invalid op_id on unloaded scroll
Robotgiggle c04d6d2
Cleanup
Robotgiggle 4940868
Merge branch 'main' into scroll-tweaks
SamsTheNerd 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
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
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
37 changes: 37 additions & 0 deletions
37
Common/src/main/java/at/petrak/hexcasting/mixin/MixinWanderingTrader.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,37 @@ | ||
| package at.petrak.hexcasting.mixin; | ||
|
|
||
| import net.minecraft.world.entity.npc.WanderingTrader; | ||
| import net.minecraft.world.item.trading.MerchantOffers; | ||
| import net.minecraft.world.item.trading.MerchantOffer; | ||
| import net.minecraft.world.item.ItemStack; | ||
| import net.minecraft.world.item.Items; | ||
| import net.minecraft.util.RandomSource; | ||
| import net.minecraft.server.MinecraftServer; | ||
| import at.petrak.hexcasting.api.mod.HexConfig; | ||
| import at.petrak.hexcasting.api.utils.NBTHelper; | ||
| import at.petrak.hexcasting.common.lib.HexItems; | ||
| import at.petrak.hexcasting.common.loot.AddPerWorldPatternToScrollFunc; | ||
| import at.petrak.hexcasting.common.items.storage.ItemScroll; | ||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.injection.At; | ||
| import org.spongepowered.asm.mixin.injection.Inject; | ||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
|
||
| // Adds ancient scrolls to the wandering trader by replacing the special trade in the last slot | ||
| @Mixin(WanderingTrader.class) | ||
| public class MixinWanderingTrader { | ||
| @Inject(method = "updateTrades", at = @At("RETURN")) | ||
| private void addNewTrades(CallbackInfo ci) { | ||
SamsTheNerd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| var self = (WanderingTrader) (Object) this; | ||
| MerchantOffers offerList = self.getOffers(); | ||
| if (offerList == null) | ||
| return; | ||
| RandomSource rand = self.getRandom(); | ||
| if (rand.nextFloat() < HexConfig.server().traderScrollChance() && self.getServer() != null) { | ||
| ItemStack scroll = new ItemStack(HexItems.SCROLL_LARGE); | ||
| AddPerWorldPatternToScrollFunc.doStatic(scroll, rand, self.getServer().overworld()); | ||
| NBTHelper.putBoolean(scroll, ItemScroll.TAG_NEEDS_PURCHASE, true); | ||
| offerList.set(5, new MerchantOffer(new ItemStack(Items.EMERALD, 12), scroll, 1, 1, 1)); | ||
| } | ||
| } | ||
| } | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.