-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add (optionally) Pandora's Box - Add Support for Shop Pedestal Loot
- Loading branch information
Showing
4 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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
64 changes: 64 additions & 0 deletions
64
src/main/java/dev/attackeight/the_vault_jei/mixin/ShopPedestalConfigMixin.java
This file contains 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,64 @@ | ||
package dev.attackeight.the_vault_jei.mixin; | ||
|
||
import dev.attackeight.the_vault_jei.TheVaultJEI; | ||
import iskallia.vault.config.ShopPedestalConfig; | ||
import iskallia.vault.config.entry.IntRangeEntry; | ||
import iskallia.vault.config.entry.LevelEntryList; | ||
import iskallia.vault.core.util.WeightedList; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.apache.commons.lang3.tuple.ImmutablePair; | ||
import org.apache.commons.lang3.tuple.ImmutableTriple; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.apache.commons.lang3.tuple.Triple; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Mixin(value = ShopPedestalConfig.class, remap = false) | ||
public class ShopPedestalConfigMixin { | ||
|
||
@Shadow public LevelEntryList<LevelEntryList.ILevelEntry> LEVELS; | ||
|
||
@Shadow @Final public static ShopPedestalConfig.ShopOffer EMPTY; | ||
|
||
@Unique | ||
public List<Pair<List<Triple<ItemStack, IntRangeEntry, Double>>, Integer>> getTrades() { | ||
List<Pair<List<Triple<ItemStack, IntRangeEntry, Double>>, Integer>> toReturn = new ArrayList<>(); | ||
this.LEVELS.forEach(k -> { | ||
int level = k.getLevel(); | ||
List<WeightedList> entries = new ArrayList<>(); // These are all WeightedList<ShopEntry> | ||
this.LEVELS.getForLevel(level).map((tier) -> { | ||
try { | ||
return tier.getClass().getDeclaredField("TRADE_POOL").get(tier); | ||
} catch (Exception e) { | ||
TheVaultJEI.LOGGER.error(e.toString()); | ||
return EMPTY; | ||
} | ||
}).ifPresent(x -> entries.add((WeightedList) x)); | ||
entries.forEach(entry -> { | ||
List<Triple<ItemStack, IntRangeEntry, Double>> offers = new ArrayList<>(); | ||
entry.forEach((offer, weight) -> { | ||
try { | ||
TheVaultJEI.LOGGER.info("Should be Entry: {}", offer.getClass()); | ||
offers.add(new ImmutableTriple<>( | ||
(ItemStack) offer.getClass().getDeclaredField("OFFER").get(offer), | ||
new IntRangeEntry( | ||
(int) offer.getClass().getDeclaredField("MIN_COST").get(offer), | ||
(int) offer.getClass().getDeclaredField("MAX_COST").get(offer) | ||
), | ||
(Double) weight | ||
)); | ||
} catch (Exception e) { | ||
TheVaultJEI.LOGGER.error(e.toString()); | ||
} | ||
}); | ||
toReturn.add(new ImmutablePair<>(offers, level)); | ||
}); | ||
}); | ||
return toReturn; | ||
} | ||
} |
This file contains 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