diff --git a/changelog.md b/changelog.md index 811f89b9..1db743f2 100644 --- a/changelog.md +++ b/changelog.md @@ -1 +1,21 @@ -- changed required Majrusz Library version from 6.1.7+ to 7.0.0+ \ No newline at end of file +- added new item type `Card`, which applies one time effect on accessories +- added Gambling Card +- added Reverse Card +- added Removal Card +- added new advancement for 69% efficiency bonus +- added 25% chance for Swimmer Guide to spawn in buried treasures (suggested by @Ladocterus) +- added Haste and Strength effects to Dream Catcher +- removed Jadeite +- reworked Wandering Trader trades for accessories and boosters +- updated Chinese translation (thanks to @Fiocher) +- increased Tamed Potato Bettle drop chances from 0.2%/0.5% to 0.25%/0.5% +- increased Lucky Ruck drop chance from 0.05% to 0.075% +- decreased Secret Ingredient drop chance from 3.34% to 2% +- optimized accessory checks +- fixed compatibility crash with MineColonies (reported by @Ryus Lightworks) +- fixed bug with Onyx not granting advancement +- fixed bug with current loot bonus displaying invalid value +- fixed bug with Secret Ingredient not working properly with Splash Potions and Lingering Potions +- fixed bug with Certificate of Taming bonuses not being applied on children of boosted animals +- fixed bug with Metal Lure extra items only being fishes +- fixed compatibility issue with accessories having range bonus after using crafting table \ No newline at end of file diff --git a/common/src/main/java/com/majruszsaccessories/MajruszsAccessories.java b/common/src/main/java/com/majruszsaccessories/MajruszsAccessories.java index 37a74f6d..68e1a00d 100644 --- a/common/src/main/java/com/majruszsaccessories/MajruszsAccessories.java +++ b/common/src/main/java/com/majruszsaccessories/MajruszsAccessories.java @@ -12,17 +12,18 @@ import com.majruszlibrary.registry.RegistryGroup; import com.majruszlibrary.registry.RegistryObject; import com.majruszsaccessories.accessories.components.MoreChestLoot; +import com.majruszsaccessories.cards.GamblingCard; +import com.majruszsaccessories.cards.RemovalCard; +import com.majruszsaccessories.cards.ReverseCard; import com.majruszsaccessories.config.Config; import com.majruszsaccessories.integration.ISlotPlatform; -import com.majruszsaccessories.items.AccessoryItem; -import com.majruszsaccessories.items.BoosterItem; -import com.majruszsaccessories.items.BoosterOverlay; -import com.majruszsaccessories.items.CreativeModeTabs; +import com.majruszsaccessories.items.*; import com.majruszsaccessories.particles.BonusParticle; import com.majruszsaccessories.particles.BonusParticleType; import com.majruszsaccessories.recipes.AccessoryRecipe; -import com.majruszsaccessories.recipes.BoostAccessoriesRecipe; +import com.majruszsaccessories.recipes.BoostAccessoryRecipe; import com.majruszsaccessories.recipes.CombineAccessoriesRecipe; +import com.majruszsaccessories.recipes.UseCardRecipe; import net.minecraft.core.particles.ParticleType; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; @@ -45,6 +46,9 @@ public class MajruszsAccessories { public static final RegistryGroup< RecipeSerializer< ? > > RECIPES = HELPER.create( BuiltInRegistries.RECIPE_SERIALIZER ); public static final RegistryGroup< ParticleType< ? > > PARTICLES = HELPER.create( BuiltInRegistries.PARTICLE_TYPE ); + // Network + public static final NetworkObject< MoreChestLoot.BonusInfo > MORE_CHEST_LOOT = HELPER.create( "more_chest_loot", MoreChestLoot.BonusInfo.class ); + // Items (Accessories) public static final RegistryObject< AccessoryItem > ADVENTURER_KIT = ITEMS.create( "adventurer_kit", AccessoryItem.tier1() ); public static final RegistryObject< AccessoryItem > ADVENTURER_RUNE = ITEMS.create( "adventurer_rune", AccessoryItem.tier2() ); @@ -73,10 +77,14 @@ public class MajruszsAccessories { public static final RegistryObject< BoosterItem > GOLDEN_DICE = ITEMS.create( "golden_dice", BoosterItem.rare() ); public static final RegistryObject< BoosterItem > GOLDEN_HORSESHOE = ITEMS.create( "golden_horseshoe", BoosterItem.rare() ); public static final RegistryObject< BoosterItem > HORSESHOE = ITEMS.create( "horseshoe", BoosterItem.basic() ); - public static final RegistryObject< BoosterItem > JADEITE = ITEMS.create( "jadeite", BoosterItem.basic() ); public static final RegistryObject< BoosterItem > ONYX = ITEMS.create( "onyx", BoosterItem.basic() ); public static final RegistryObject< BoosterItem > OWL_FEATHER = ITEMS.create( "owl_feather", BoosterItem.basic() ); + // Items (Cards) + public static final RegistryObject< CardItem > GAMBLING_CARD = ITEMS.create( "gambling_card", GamblingCard::new ); + public static final RegistryObject< CardItem > REMOVAL_CARD = ITEMS.create( "removal_card", RemovalCard::new ); + public static final RegistryObject< CardItem > REVERSE_CARD = ITEMS.create( "reverse_card", ReverseCard::new ); + // Items (Fake) public static final RegistryObject< BoosterOverlay > BOOSTER_OVERLAY_SINGLE = ITEMS.create( "booster_overlay_single", BoosterOverlay::new ); public static final RegistryObject< BoosterOverlay > BOOSTER_OVERLAY_DOUBLE = ITEMS.create( "booster_overlay_double", BoosterOverlay::new ); @@ -84,8 +92,9 @@ public class MajruszsAccessories { // Recipes public static final RegistryObject< RecipeSerializer< ? > > ACCESSORY_RECIPE = RECIPES.create( "crafting_accessory", AccessoryRecipe.create() ); + public static final RegistryObject< RecipeSerializer< ? > > BOOST_ACCESSORY_RECIPE = RECIPES.create( "crafting_boost_accessory", BoostAccessoryRecipe.create() ); public static final RegistryObject< RecipeSerializer< ? > > COMBINE_ACCESSORIES_RECIPE = RECIPES.create( "crafting_combine_accessories", CombineAccessoriesRecipe.create() ); - public static final RegistryObject< RecipeSerializer< ? > > BOOST_ACCESSORIES_RECIPE = RECIPES.create( "crafting_boost_accessories", BoostAccessoriesRecipe.create() ); + public static final RegistryObject< RecipeSerializer< ? > > USE_CARD_RECIPE = RECIPES.create( "crafting_use_card", UseCardRecipe.create() ); // Particles public static final RegistryObject< BonusParticleType > BONUS_PARTICLE = PARTICLES.create( "bonus_normal", BonusParticleType::new ); @@ -93,9 +102,6 @@ public class MajruszsAccessories { // Creative Mode Tabs public static final RegistryObject< CreativeModeTab > CREATIVE_MODE_TAB = CREATIVE_MODE_TABS.create( "primary", CreativeModeTabs.primary() ); - // Network - public static final NetworkObject< MoreChestLoot.BonusInfo > MORE_CHEST_LOOT = HELPER.create( "more_chest_loot", MoreChestLoot.BonusInfo.class ); - // Integration public static final ISlotPlatform SLOT_INTEGRATION = Services.load( ISlotPlatform.class ); diff --git a/common/src/main/java/com/majruszsaccessories/accessories/AdventurerKit.java b/common/src/main/java/com/majruszsaccessories/accessories/AdventurerKit.java index 9242c2a6..5fd3ef09 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/AdventurerKit.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/AdventurerKit.java @@ -5,11 +5,11 @@ import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.MoreChestLoot; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.common.components.TradeOffer; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; @AutoInstance @@ -19,7 +19,7 @@ public AdventurerKit() { this.add( MoreChestLoot.create( 1.2f ) ) .add( AnyChestDropChance.create() ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } static class AnyChestDropChance extends BonusComponent< AccessoryItem > { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/AdventurerRune.java b/common/src/main/java/com/majruszsaccessories/accessories/AdventurerRune.java index 05c7fe89..0ea2ae3f 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/AdventurerRune.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/AdventurerRune.java @@ -5,7 +5,6 @@ import com.majruszsaccessories.accessories.components.BrushingExtraItem; import com.majruszsaccessories.accessories.components.MoreChestLoot; import com.majruszsaccessories.accessories.components.SwimmingSpeedBonus; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; @AutoInstance @@ -15,7 +14,6 @@ public AdventurerRune() { this.add( MoreChestLoot.create( 1.5f ) ) .add( BrushingExtraItem.create( 0.2f ) ) - .add( SwimmingSpeedBonus.create( 0.25f ) ) - .add( TradeOffer.create( 17 ) ); + .add( SwimmingSpeedBonus.create( 0.25f ) ); } } diff --git a/common/src/main/java/com/majruszsaccessories/accessories/AncientScarab.java b/common/src/main/java/com/majruszsaccessories/accessories/AncientScarab.java index 2c6b78d2..a17d06b8 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/AncientScarab.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/AncientScarab.java @@ -7,11 +7,11 @@ import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.BrushingExtraItem; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.common.components.TradeOffer; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; @@ -26,7 +26,7 @@ public AncientScarab() { this.add( BrushingExtraItem.create( 0.16f ) ) .add( SuspiciousBlocksDropChance.create() ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } static class SuspiciousBlocksDropChance extends BonusComponent< AccessoryItem > { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/AnglerRune.java b/common/src/main/java/com/majruszsaccessories/accessories/AnglerRune.java index a8fdb91d..02c95ca7 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/AnglerRune.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/AnglerRune.java @@ -5,7 +5,6 @@ import com.majruszsaccessories.accessories.components.FishingExtraItems; import com.majruszsaccessories.accessories.components.FishingLuckBonus; import com.majruszsaccessories.accessories.components.FishingLureBonus; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; @AutoInstance @@ -15,7 +14,6 @@ public AnglerRune() { this.add( FishingLuckBonus.create( 3 ) ) .add( FishingLureBonus.create( 0.25f ) ) - .add( FishingExtraItems.create( 0.25f, 3 ) ) - .add( TradeOffer.create( 17 ) ); + .add( FishingExtraItems.create( 0.25f, 3 ) ); } } diff --git a/common/src/main/java/com/majruszsaccessories/accessories/AnglerTrophy.java b/common/src/main/java/com/majruszsaccessories/accessories/AnglerTrophy.java index 06ec9aaf..76876ac9 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/AnglerTrophy.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/AnglerTrophy.java @@ -8,11 +8,11 @@ import com.majruszlibrary.registry.Registries; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.FishingLuckBonus; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.common.components.TradeOffer; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import net.minecraft.resources.ResourceLocation; @@ -26,7 +26,7 @@ public AnglerTrophy() { this.add( FishingLuckBonus.create( 3 ) ) .add( FishingDropChance.create( 0.01f ) ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } public static class FishingDropChance extends BonusComponent< AccessoryItem > { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/CertificateOfTaming.java b/common/src/main/java/com/majruszsaccessories/accessories/CertificateOfTaming.java index ff47065c..7b7904fb 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/CertificateOfTaming.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/CertificateOfTaming.java @@ -6,11 +6,11 @@ import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.TamingStrongerAnimals; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.common.components.TradeOffer; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; @AutoInstance @@ -20,7 +20,7 @@ public CertificateOfTaming() { this.add( TamingStrongerAnimals.create( 0.2f ) ) .add( TamingDropChance.create() ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } static class TamingDropChance extends BonusComponent< AccessoryItem > { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/DiscountVoucher.java b/common/src/main/java/com/majruszsaccessories/accessories/DiscountVoucher.java index 56fa194c..aef97c91 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/DiscountVoucher.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/DiscountVoucher.java @@ -6,12 +6,12 @@ import com.majruszlibrary.math.AnyPos; import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.accessories.components.TradingDiscount; import com.majruszsaccessories.common.AccessoryHandler; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.common.components.TradeOffer; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; @AutoInstance @@ -21,7 +21,7 @@ public DiscountVoucher() { this.add( TradingDiscount.create( 0.12f ) ) .add( TradingDropChance.create() ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } static class TradingDropChance extends BonusComponent< AccessoryItem > { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/DreamCatcher.java b/common/src/main/java/com/majruszsaccessories/accessories/DreamCatcher.java index 19928cfc..42b02a45 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/DreamCatcher.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/DreamCatcher.java @@ -7,11 +7,11 @@ import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.SleepingBonuses; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.common.components.TradeOffer; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; @AutoInstance @@ -21,7 +21,7 @@ public DreamCatcher() { this.add( SleepingBonuses.create( 1, 300 ) ) .add( SleepingDropChance.create() ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } static class SleepingDropChance extends BonusComponent< AccessoryItem > { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/HouseholdRune.java b/common/src/main/java/com/majruszsaccessories/accessories/HouseholdRune.java index 220aeac8..192dd39d 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/HouseholdRune.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/HouseholdRune.java @@ -4,7 +4,6 @@ import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.SleepingBonuses; import com.majruszsaccessories.accessories.components.StrongerPotions; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.accessories.components.TradingDiscount; import com.majruszsaccessories.common.AccessoryHandler; @@ -15,7 +14,6 @@ public HouseholdRune() { this.add( TradingDiscount.create( 0.15f ) ) .add( SleepingBonuses.create( 1, 360 ) ) - .add( StrongerPotions.create( 0.5f, 1 ) ) - .add( TradeOffer.create( 17 ) ); + .add( StrongerPotions.create( 0.5f, 1 ) ); } } diff --git a/common/src/main/java/com/majruszsaccessories/accessories/IdolOfFertility.java b/common/src/main/java/com/majruszsaccessories/accessories/IdolOfFertility.java index 173e4937..d100b62a 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/IdolOfFertility.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/IdolOfFertility.java @@ -7,11 +7,11 @@ import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.BreedingTwins; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.common.components.TradeOffer; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; @AutoInstance @@ -21,7 +21,7 @@ public IdolOfFertility() { this.add( BreedingTwins.create( 0.25f ) ) .add( BreedingDropChance.create() ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } static class BreedingDropChance extends BonusComponent< AccessoryItem > { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/LuckyRock.java b/common/src/main/java/com/majruszsaccessories/accessories/LuckyRock.java index 79d205c7..815c8d70 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/LuckyRock.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/LuckyRock.java @@ -5,11 +5,11 @@ import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.MiningExtraItem; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.common.components.TradeOffer; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; @AutoInstance @@ -19,11 +19,11 @@ public LuckyRock() { this.add( MiningExtraItem.create( 0.03f ) ) .add( MiningDropChance.create() ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } static class MiningDropChance extends BonusComponent< AccessoryItem > { - float chance = 0.0005f; + float chance = 0.00075f; public static ISupplier< AccessoryItem > create() { return MiningDropChance::new; diff --git a/common/src/main/java/com/majruszsaccessories/accessories/MetalLure.java b/common/src/main/java/com/majruszsaccessories/accessories/MetalLure.java index f81ccf18..680bd1ae 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/MetalLure.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/MetalLure.java @@ -3,8 +3,8 @@ import com.majruszlibrary.annotation.AutoInstance; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.FishingExtraItems; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; +import com.majruszsaccessories.common.components.TradeOffer; @AutoInstance public class MetalLure extends AccessoryHandler { @@ -13,6 +13,6 @@ public MetalLure() { this.add( FishingExtraItems.create( 0.2f, 2 ) ) .add( AnglerTrophy.FishDropChance.create( 0.01f ) ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } } diff --git a/common/src/main/java/com/majruszsaccessories/accessories/MinerGuide.java b/common/src/main/java/com/majruszsaccessories/accessories/MinerGuide.java index 735b356c..d71b870d 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/MinerGuide.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/MinerGuide.java @@ -6,11 +6,11 @@ import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.MiningSpeedBonus; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.common.components.TradeOffer; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; @AutoInstance @@ -20,7 +20,7 @@ public MinerGuide() { this.add( MiningSpeedBonus.create( 0.1f ) ) .add( UndergroundChestDropChance.create() ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } static class UndergroundChestDropChance extends BonusComponent< AccessoryItem > { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/MinerRune.java b/common/src/main/java/com/majruszsaccessories/accessories/MinerRune.java index b98a34fa..80de724b 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/MinerRune.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/MinerRune.java @@ -5,7 +5,6 @@ import com.majruszsaccessories.accessories.components.MiningDurabilityBonus; import com.majruszsaccessories.accessories.components.MiningExtraItem; import com.majruszsaccessories.accessories.components.MiningSpeedBonus; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; @AutoInstance @@ -15,7 +14,6 @@ public MinerRune() { this.add( MiningExtraItem.create( 0.04f ) ) .add( MiningSpeedBonus.create( 0.12f ) ) - .add( MiningDurabilityBonus.create( 0.12f ) ) - .add( TradeOffer.create( 17 ) ); + .add( MiningDurabilityBonus.create( 0.12f ) ); } } diff --git a/common/src/main/java/com/majruszsaccessories/accessories/NatureRune.java b/common/src/main/java/com/majruszsaccessories/accessories/NatureRune.java index ba92af5b..dd95214a 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/NatureRune.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/NatureRune.java @@ -5,7 +5,6 @@ import com.majruszsaccessories.accessories.components.BreedingTwins; import com.majruszsaccessories.accessories.components.HarvestingDoubleCrops; import com.majruszsaccessories.accessories.components.TamingStrongerAnimals; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; @AutoInstance @@ -15,7 +14,6 @@ public NatureRune() { this.add( TamingStrongerAnimals.create( 0.25f ) ) .add( BreedingTwins.create( 0.3f ) ) - .add( HarvestingDoubleCrops.create( 0.3f ) ) - .add( TradeOffer.create( 17 ) ); + .add( HarvestingDoubleCrops.create( 0.3f ) ); } } diff --git a/common/src/main/java/com/majruszsaccessories/accessories/SecretIngredient.java b/common/src/main/java/com/majruszsaccessories/accessories/SecretIngredient.java index abe2c2e7..4e1c0f43 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/SecretIngredient.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/SecretIngredient.java @@ -8,11 +8,11 @@ import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.StrongerPotions; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.common.components.TradeOffer; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; @AutoInstance @@ -22,11 +22,11 @@ public SecretIngredient() { this.add( StrongerPotions.create( 0.6f, 1 ) ) .add( BrewingDropChance.create() ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } static class BrewingDropChance extends BonusComponent< AccessoryItem > { - float chance = 0.0334f; + float chance = 0.02f; public static ISupplier< AccessoryItem > create() { return BrewingDropChance::new; diff --git a/common/src/main/java/com/majruszsaccessories/accessories/SwimmerGuide.java b/common/src/main/java/com/majruszsaccessories/accessories/SwimmerGuide.java index 04306124..f8ec19ab 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/SwimmerGuide.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/SwimmerGuide.java @@ -8,13 +8,14 @@ import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.SwimmingSpeedBonus; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.common.components.TradeOffer; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.level.storage.loot.BuiltInLootTables; @AutoInstance public class SwimmerGuide extends AccessoryHandler { @@ -23,7 +24,8 @@ public SwimmerGuide() { this.add( SwimmingSpeedBonus.create( 0.2f ) ) .add( UnderwaterChestDropChance.create() ) - .add( TradeOffer.create( 7 ) ); + .add( BuriedTreasureDropChance.create() ) + .add( TradeOffer.create() ); } static class UnderwaterChestDropChance extends BonusComponent< AccessoryItem > { @@ -47,4 +49,25 @@ protected UnderwaterChestDropChance( BonusHandler< AccessoryItem > handler ) { .define( "underwater_chest_spawn_chance", Reader.number(), s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); } } + + static class BuriedTreasureDropChance extends BonusComponent< AccessoryItem > { + float chance = 0.25f; + + public static ISupplier< AccessoryItem > create() { + return BuriedTreasureDropChance::new; + } + + protected BuriedTreasureDropChance( BonusHandler< AccessoryItem > handler ) { + super( handler ); + + OnLootGenerated.listen( this::addToGeneratedLoot ) + .addCondition( Condition.hasLevel() ) + .addCondition( data->data.origin != null ) + .addCondition( data->data.lootId.equals( BuiltInLootTables.BURIED_TREASURE ) ) + .addCondition( CustomConditions.dropChance( s->this.chance, data->data.entity ) ); + + handler.getConfig() + .define( "buried_treasure_spawn_chance", Reader.number(), s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); + } + } } diff --git a/common/src/main/java/com/majruszsaccessories/accessories/TamedPotatoBeetle.java b/common/src/main/java/com/majruszsaccessories/accessories/TamedPotatoBeetle.java index 2d5b0ccb..ca3e4853 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/TamedPotatoBeetle.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/TamedPotatoBeetle.java @@ -6,11 +6,11 @@ import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.HarvestingDoubleCrops; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.OnAccessoryDropChanceGet; +import com.majruszsaccessories.common.components.TradeOffer; +import com.majruszsaccessories.events.OnAccessoryDropChanceGet; import com.majruszsaccessories.items.AccessoryItem; import net.minecraft.world.level.block.Blocks; @@ -21,12 +21,12 @@ public TamedPotatoBeetle() { this.add( HarvestingDoubleCrops.create( 0.25f ) ) .add( HarvestingDropChance.create() ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } static class HarvestingDropChance extends BonusComponent< AccessoryItem > { - float chance = 0.002f; - float potatoMultiplier = 2.5f; + float chance = 0.0025f; + float potatoMultiplier = 2.0f; public static ISupplier< AccessoryItem > create() { return HarvestingDropChance::new; diff --git a/common/src/main/java/com/majruszsaccessories/accessories/ToolScraps.java b/common/src/main/java/com/majruszsaccessories/accessories/ToolScraps.java index 186aa428..3ec04ee4 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/ToolScraps.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/ToolScraps.java @@ -8,11 +8,11 @@ import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.MiningDurabilityBonus; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.common.components.TradeOffer; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; @AutoInstance @@ -22,7 +22,7 @@ public ToolScraps() { this.add( MiningDurabilityBonus.create( 0.1f ) ) .add( MiningDropChance.create() ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } static class MiningDropChance extends BonusComponent< AccessoryItem > { @@ -38,6 +38,7 @@ protected MiningDropChance( BonusHandler< AccessoryItem > handler ) { OnItemDamaged.listen( this::spawnScraps ) .priority( Priority.LOWEST ) .addCondition( OnItemDamaged::isAboutToBroke ) + .addCondition( data->data.player != null ) .addCondition( CustomConditions.dropChance( data->this.multiplier * data.itemStack.getMaxDamage(), data->data.player ) ); handler.getConfig() diff --git a/common/src/main/java/com/majruszsaccessories/accessories/UnbreakableFishingLine.java b/common/src/main/java/com/majruszsaccessories/accessories/UnbreakableFishingLine.java index 8a657a02..795b7339 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/UnbreakableFishingLine.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/UnbreakableFishingLine.java @@ -3,8 +3,8 @@ import com.majruszlibrary.annotation.AutoInstance; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.FishingLureBonus; -import com.majruszsaccessories.accessories.components.TradeOffer; import com.majruszsaccessories.common.AccessoryHandler; +import com.majruszsaccessories.common.components.TradeOffer; @AutoInstance public class UnbreakableFishingLine extends AccessoryHandler { @@ -14,6 +14,6 @@ public UnbreakableFishingLine() { this.add( FishingLureBonus.create( 0.2f ) ) .add( AnglerTrophy.FishingDropChance.create( 0.005f ) ) .add( AnglerTrophy.FishDropChance.create( 0.005f ) ) - .add( TradeOffer.create( 7 ) ); + .add( TradeOffer.create() ); } } diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/BreedingTwins.java b/common/src/main/java/com/majruszsaccessories/accessories/components/BreedingTwins.java index 040b291d..4048dae4 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/BreedingTwins.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/BreedingTwins.java @@ -2,16 +2,19 @@ import com.majruszlibrary.events.OnBabySpawned; import com.majruszlibrary.events.base.Condition; +import com.majruszlibrary.events.base.Events; import com.majruszlibrary.math.Range; +import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; import net.minecraft.world.entity.AgeableMob; public class BreedingTwins extends BonusComponent< AccessoryItem > { + static AgeableMob LAST_CHILD = null; RangedFloat chance = new RangedFloat().id( "chance" ).maxRange( Range.CHANCE ); public static ISupplier< AccessoryItem > create( float chance ) { @@ -26,6 +29,7 @@ protected BreedingTwins( BonusHandler< AccessoryItem > handler, float chance ) { OnBabySpawned.listen( this::spawnTwins ) .addCondition( Condition.isLogicalServer() ) .addCondition( data->data.player != null ) + .addCondition( data->data.child != LAST_CHILD ) .addCondition( CustomConditions.chance( this::getItem, data->data.player, holder->holder.apply( this.chance ) ) ); this.addTooltip( "majruszsaccessories.bonuses.spawn_twins", TooltipHelper.asPercent( this.chance ) ); @@ -35,19 +39,20 @@ protected BreedingTwins( BonusHandler< AccessoryItem > handler, float chance ) { } private void spawnTwins( OnBabySpawned data ) { - AgeableMob child = data.parentA.getBreedOffspring( data.getServerLevel(), data.parentB ); - if( child == null ) { + LAST_CHILD = data.parentA.getBreedOffspring( data.getServerLevel(), data.parentB ); + if( LAST_CHILD == null ) { return; } - child.setBaby( true ); - child.absMoveTo( data.parentA.getX(), data.parentA.getY(), data.parentA.getZ(), 0.0f, 0.0f ); - data.getLevel().addFreshEntity( child ); - this.spawnEffects( data, child ); + LAST_CHILD.setBaby( true ); + LAST_CHILD.absMoveTo( data.parentA.getX(), data.parentA.getY(), data.parentA.getZ(), 0.0f, 0.0f ); + data.getLevel().addFreshEntity( LAST_CHILD ); + Events.dispatch( new OnBabySpawned( data.parentA, data.parentB, LAST_CHILD, data.player ) ); + this.spawnEffects( data, LAST_CHILD ); } private void spawnEffects( OnBabySpawned data, AgeableMob child ) { - CustomConditions.getLastHolder() + AccessoryHolder.get( data.player ) .getParticleEmitter() .count( 4 ) .sizeBased( child ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/BrushingExtraItem.java b/common/src/main/java/com/majruszsaccessories/accessories/components/BrushingExtraItem.java index 35aca211..294102bf 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/BrushingExtraItem.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/BrushingExtraItem.java @@ -5,10 +5,11 @@ import com.majruszlibrary.level.LevelHelper; import com.majruszlibrary.math.AnyPos; import com.majruszlibrary.math.Range; +import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; import net.minecraft.world.entity.EntityType; @@ -53,7 +54,7 @@ private void addExtraLoot( OnItemBrushed data ) { } private void spawnEffects( OnItemBrushed data ) { - CustomConditions.getLastHolder() + AccessoryHolder.get( data.player ) .getParticleEmitter() .count( 8 ) .position( AnyPos.from( data.blockEntity.getBlockPos() ).center().add( data.direction ).vec3() ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/FishingExtraItems.java b/common/src/main/java/com/majruszsaccessories/accessories/components/FishingExtraItems.java index 67321cdc..55740acf 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/FishingExtraItems.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/FishingExtraItems.java @@ -6,11 +6,12 @@ import com.majruszlibrary.level.LevelHelper; import com.majruszlibrary.math.AnyPos; import com.majruszlibrary.math.Range; +import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.config.RangedInteger; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; import net.minecraft.core.BlockPos; @@ -43,9 +44,9 @@ protected FishingExtraItems( BonusHandler< AccessoryItem > handler, float chance } private void addExtraFishes( OnFishingExtraItemsGet data ) { - int count = CustomConditions.getLastHolder().apply( this.count ) - 1; + int count = AccessoryHolder.get( data.player ).apply( this.count ) - 1; for( int idx = 0; idx < count; ++idx ) { - data.extraItems.addAll( LootHelper.getLootTable( BuiltInLootTables.FISHING_FISH ).getRandomItems( LootHelper.toGiftParams( data.player ) ) ); + data.extraItems.addAll( LootHelper.getLootTable( BuiltInLootTables.FISHING ).getRandomItems( LootHelper.toGiftParams( data.player ) ) ); } this.spawnEffects( data ); } @@ -53,7 +54,7 @@ private void addExtraFishes( OnFishingExtraItemsGet data ) { private void spawnEffects( OnFishingExtraItemsGet data ) { BlockPos position = LevelHelper.getPositionOverFluid( data.getLevel(), data.hook.blockPosition() ); - CustomConditions.getLastHolder() + AccessoryHolder.get( data.player ) .getParticleEmitter() .count( 4 ) .offset( ParticleEmitter.offset( 0.125f ) ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/FishingLuckBonus.java b/common/src/main/java/com/majruszsaccessories/accessories/components/FishingLuckBonus.java index 05a0a56e..7faebe99 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/FishingLuckBonus.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/FishingLuckBonus.java @@ -12,7 +12,7 @@ import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedInteger; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; import net.minecraft.core.BlockPos; @@ -57,14 +57,14 @@ private int getLuck( Player player ) { return 0; } - AccessoryHolder holder = AccessoryHolder.find( player, this.getItem() ); - return holder.isValid() ? holder.apply( this.luck ) : 0; + AccessoryHolder holder = AccessoryHolder.get( player ); + return holder.is( this.getItem() ) ? holder.apply( this.luck ) : 0; } private void spawnEffects( OnItemFished data ) { BlockPos position = LevelHelper.getPositionOverFluid( data.getLevel(), data.hook.blockPosition() ); - CustomConditions.getLastHolder() + AccessoryHolder.get( data.player ) .getParticleEmitter() .count( 4 ) .offset( ParticleEmitter.offset( 0.125f ) ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/FishingLureBonus.java b/common/src/main/java/com/majruszsaccessories/accessories/components/FishingLureBonus.java index a962233b..9a1ae7cf 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/FishingLureBonus.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/FishingLureBonus.java @@ -5,10 +5,11 @@ import com.majruszlibrary.level.LevelHelper; import com.majruszlibrary.math.AnyPos; import com.majruszlibrary.math.Range; +import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; import net.minecraft.core.BlockPos; @@ -35,14 +36,14 @@ protected FishingLureBonus( BonusHandler< AccessoryItem > handler, float bonus ) } private void decreaseFishingTime( OnFishingTimeGet data ) { - data.time = Math.round( data.time * ( 1.0f - CustomConditions.getLastHolder().apply( this.multiplier ) ) ); + data.time = Math.round( data.time * ( 1.0f - AccessoryHolder.get( data.player ).apply( this.multiplier ) ) ); this.spawnEffects( data ); } private void spawnEffects( OnFishingTimeGet data ) { BlockPos position = LevelHelper.getPositionOverFluid( data.getLevel(), data.hook.blockPosition() ); - CustomConditions.getLastHolder() + AccessoryHolder.get( data.player ) .getParticleEmitter() .count( 4 ) .offset( ParticleEmitter.offset( 0.125f ) ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/HarvestingDoubleCrops.java b/common/src/main/java/com/majruszsaccessories/accessories/components/HarvestingDoubleCrops.java index a3d1a1e9..b3e1adce 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/HarvestingDoubleCrops.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/HarvestingDoubleCrops.java @@ -5,10 +5,11 @@ import com.majruszlibrary.events.base.Event; import com.majruszlibrary.level.BlockHelper; import com.majruszlibrary.math.Range; +import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; import net.minecraft.world.entity.LivingEntity; @@ -43,7 +44,7 @@ private void doubleLoot( OnLootGenerated data ) { } private void spawnEffects( OnLootGenerated data ) { - CustomConditions.getLastHolder() + AccessoryHolder.get( ( LivingEntity )data.entity ) .getParticleEmitter() .count( 5 ) .position( data.origin ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/MiningDurabilityBonus.java b/common/src/main/java/com/majruszsaccessories/accessories/components/MiningDurabilityBonus.java index 7da64174..3017d44a 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/MiningDurabilityBonus.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/MiningDurabilityBonus.java @@ -2,10 +2,11 @@ import com.majruszlibrary.events.OnItemDamaged; import com.majruszlibrary.math.Range; +import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; @@ -22,6 +23,7 @@ protected MiningDurabilityBonus( BonusHandler< AccessoryItem > handler, float bo this.chance.set( bonus, Range.CHANCE ); OnItemDamaged.listen( this::decreaseDurabilityCost ) + .addCondition( data->data.player != null ) .addCondition( CustomConditions.chance( this::getItem, data->data.player, holder->holder.apply( this.chance ) ) ); this.addTooltip( "majruszsaccessories.bonuses.free_durability_cost", TooltipHelper.asPercent( this.chance ) ); @@ -36,7 +38,7 @@ private void decreaseDurabilityCost( OnItemDamaged data ) { } private void spawnEffects( OnItemDamaged data ) { - CustomConditions.getLastHolder() + AccessoryHolder.get( data.player ) .getParticleEmitter() .count( 3 ) .sizeBased( data.player ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/MiningExtraItem.java b/common/src/main/java/com/majruszsaccessories/accessories/components/MiningExtraItem.java index 242fe7ac..ac8f0b87 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/MiningExtraItem.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/MiningExtraItem.java @@ -9,10 +9,11 @@ import com.majruszlibrary.item.LootHelper; import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; +import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; import net.minecraft.resources.ResourceLocation; @@ -61,7 +62,7 @@ private void addExtraLoot( OnLootGenerated data ) { } private void spawnEffects( OnLootGenerated data ) { - CustomConditions.getLastHolder() + AccessoryHolder.get( ( LivingEntity )data.entity ) .getParticleEmitter() .count( 3 ) .offset( ParticleEmitter.offset( 0.2f ) ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/MiningSpeedBonus.java b/common/src/main/java/com/majruszsaccessories/accessories/components/MiningSpeedBonus.java index 0a71da1e..ed29d816 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/MiningSpeedBonus.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/MiningSpeedBonus.java @@ -5,10 +5,11 @@ import com.majruszlibrary.math.Random; import com.majruszlibrary.math.Range; import com.majruszlibrary.time.TimeHelper; +import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; import net.minecraft.server.level.ServerLevel; @@ -38,20 +39,20 @@ protected MiningSpeedBonus( BonusHandler< AccessoryItem > handler, float bonus ) } private void increaseMineSpeed( OnBreakSpeedGet data ) { - data.speed += data.original * CustomConditions.getLastHolder().apply( this.speedMultiplier ); + data.speed += data.original * AccessoryHolder.get( data.player ).apply( this.speedMultiplier ); if( data.getLevel() instanceof ServerLevel && TimeHelper.haveTicksPassed( 10 ) ) { this.spawnEffects( data ); } } private void decreaseSwingDuration( OnItemSwingDurationGet data ) { - float bonus = CustomConditions.getLastHolder().apply( this.speedMultiplier ); + float bonus = AccessoryHolder.get( data.entity ).apply( this.speedMultiplier ); data.duration -= Random.round( data.original * bonus / ( 1.0f + bonus ) ); } private void spawnEffects( OnBreakSpeedGet data ) { - CustomConditions.getLastHolder() + AccessoryHolder.get( data.player ) .getParticleEmitter() .count( 1 ) .sizeBased( data.player ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/MoreChestLoot.java b/common/src/main/java/com/majruszsaccessories/accessories/components/MoreChestLoot.java index deedef92..a37b9d7f 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/MoreChestLoot.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/MoreChestLoot.java @@ -16,10 +16,11 @@ import com.majruszlibrary.platform.Side; import com.majruszlibrary.text.TextHelper; import com.majruszsaccessories.MajruszsAccessories; +import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.ITooltipProvider; import com.majruszsaccessories.tooltip.TooltipHelper; @@ -54,7 +55,7 @@ protected MoreChestLoot( BonusHandler< AccessoryItem > handler, float sizeMultip private void addExtraLoot( OnLootGenerated data ) { ServerPlayer player = OnChestOpened.findPlayer( data ).orElseThrow(); - float sizeMultiplier = 1.0f + CustomConditions.getLastHolder().apply( this.sizeMultiplier ) * MoreChestLoot.getDistanceBonus( player ); + float sizeMultiplier = 1.0f + AccessoryHolder.get( player ).apply( this.sizeMultiplier ) * MoreChestLoot.getDistanceBonus( player ); boolean hasIncreasedLoot = false; for( ItemStack itemStack : data.generatedLoot ) { int count = Math.min( Random.round( sizeMultiplier * itemStack.getCount() ), itemStack.getMaxStackSize() ); @@ -63,12 +64,12 @@ private void addExtraLoot( OnLootGenerated data ) { } if( hasIncreasedLoot ) { - this.spawnEffects( data ); + this.spawnEffects( data, player ); } } - private void spawnEffects( OnLootGenerated data ) { - CustomConditions.getLastHolder() + private void spawnEffects( OnLootGenerated data, ServerPlayer player ) { + AccessoryHolder.get( player ) .getParticleEmitter() .count( 24 ) .offset( ParticleEmitter.offset( 0.4f ) ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/SleepingBonuses.java b/common/src/main/java/com/majruszsaccessories/accessories/components/SleepingBonuses.java index e35576d3..67c3cbe5 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/SleepingBonuses.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/SleepingBonuses.java @@ -11,7 +11,7 @@ import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedInteger; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; import net.minecraft.world.effect.MobEffect; @@ -30,7 +30,9 @@ public class SleepingBonuses extends BonusComponent< AccessoryItem > { new EffectDef( MobEffects.ABSORPTION, 1 ), new EffectDef( MobEffects.DAMAGE_RESISTANCE, 0 ), new EffectDef( MobEffects.FIRE_RESISTANCE, 0 ), - new EffectDef( MobEffects.MOVEMENT_SPEED, 0 ) + new EffectDef( MobEffects.MOVEMENT_SPEED, 0 ), + new EffectDef( MobEffects.DIG_SPEED, 0 ), + new EffectDef( MobEffects.DAMAGE_BOOST, 0 ) ); public static ISupplier< AccessoryItem > create( int count, int duration ) { @@ -59,7 +61,7 @@ protected SleepingBonuses( BonusHandler< AccessoryItem > handler, int count, int } private void applyBonuses( OnPlayerWakedUp data ) { - AccessoryHolder holder = CustomConditions.getLastHolder(); + AccessoryHolder holder = AccessoryHolder.get( data.player ); int count = holder.apply( this.count ); int duration = TimeHelper.toTicks( holder.apply( this.duration ) ); this.getRandomMobEffects( data.player, count ) @@ -78,7 +80,7 @@ private List< EffectDef > getRandomMobEffects( Player player, int count ) { } private void spawnEffects( OnPlayerWakedUp data ) { - CustomConditions.getLastHolder() + AccessoryHolder.get( data.player ) .getParticleEmitter() .count( 5 ) .position( data.player.position() ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/StrongerPotions.java b/common/src/main/java/com/majruszsaccessories/accessories/components/StrongerPotions.java index 04394eef..242983dd 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/StrongerPotions.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/StrongerPotions.java @@ -11,10 +11,11 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.config.RangedInteger; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.alchemy.PotionUtils; @@ -50,7 +51,8 @@ protected StrongerPotions( BonusHandler< AccessoryItem > handler, float duration } private void boostPotions( OnItemBrewed data ) { - AccessoryHolder holder = CustomConditions.getLastHolder(); + Player player = LevelHelper.getNearestPlayer( data.level, data.blockPos, 10.0f ); + AccessoryHolder holder = AccessoryHolder.get( player ); data.mapPotions( potions->{ float durationMultiplier = 1.0f - holder.apply( this.durationPenalty, -1.0f ); int extraAmplifier = holder.apply( this.amplifier ); @@ -62,7 +64,7 @@ private void boostPotions( OnItemBrewed data ) { return itemStack; } - ItemStack potion = new ItemStack( Items.POTION ); + ItemStack potion = new ItemStack( itemStack.getItem() ); Serializables.write( new Data(), potion.getOrCreateTag() ); return PotionUtils.setCustomEffects( potion, PotionUtils.getMobEffects( itemStack ) @@ -73,11 +75,11 @@ private void boostPotions( OnItemBrewed data ) { } ) .toList(); } ); - this.spawnEffects( data ); + this.spawnEffects( data, player ); } - private void spawnEffects( OnItemBrewed data ) { - CustomConditions.getLastHolder() + private void spawnEffects( OnItemBrewed data, Player player ) { + AccessoryHolder.get( player ) .getParticleEmitter() .count( 6 ) .position( AnyPos.from( data.blockPos ).center().vec3() ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/SwimmingSpeedBonus.java b/common/src/main/java/com/majruszsaccessories/accessories/components/SwimmingSpeedBonus.java index 27b14821..26865efe 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/SwimmingSpeedBonus.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/SwimmingSpeedBonus.java @@ -3,10 +3,11 @@ import com.majruszlibrary.events.OnEntitySwimSpeedMultiplierGet; import com.majruszlibrary.math.Range; import com.majruszlibrary.time.TimeHelper; +import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; import net.minecraft.server.level.ServerLevel; @@ -33,14 +34,14 @@ protected SwimmingSpeedBonus( BonusHandler< AccessoryItem > handler, float bonus } private void increaseSwimSpeed( OnEntitySwimSpeedMultiplierGet data ) { - data.multiplier *= 1.0f + CustomConditions.getLastHolder().apply( this.multiplier ); + data.multiplier *= 1.0f + AccessoryHolder.get( data.entity ).apply( this.multiplier ); if( data.entity.isInWater() && data.getLevel() instanceof ServerLevel && TimeHelper.haveTicksPassed( 5 ) ) { this.spawnEffects( data ); } } private void spawnEffects( OnEntitySwimSpeedMultiplierGet data ) { - CustomConditions.getLastHolder() + AccessoryHolder.get( data.entity ) .getParticleEmitter() .count( 1 ) .sizeBased( data.entity ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/TamingStrongerAnimals.java b/common/src/main/java/com/majruszsaccessories/accessories/components/TamingStrongerAnimals.java index 2e7689c3..1d999d8a 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/TamingStrongerAnimals.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/TamingStrongerAnimals.java @@ -2,14 +2,17 @@ import com.majruszlibrary.entity.AttributeHandler; import com.majruszlibrary.events.OnAnimalTamed; +import com.majruszlibrary.events.OnBabySpawned; import com.majruszlibrary.events.base.Condition; import com.majruszlibrary.math.Range; +import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.horse.Horse; @@ -38,6 +41,10 @@ protected TamingStrongerAnimals( BonusHandler< AccessoryItem > handler, float bo .addCondition( Condition.isLogicalServer() ) .addCondition( CustomConditions.hasAccessory( this::getItem, data->data.tamer ) ); + OnBabySpawned.listen( this::applyBonuses ) + .addCondition( Condition.isLogicalServer() ) + .addCondition( data->this.hasModifier( data.parentA ) || this.hasModifier( data.parentB ) ); + this.addTooltip( "majruszsaccessories.bonuses.animal_attributes", TooltipHelper.asPercent( this.bonus ) ); handler.getConfig() @@ -45,24 +52,39 @@ protected TamingStrongerAnimals( BonusHandler< AccessoryItem > handler, float bo } private void applyBonuses( OnAnimalTamed data ) { - float bonus = CustomConditions.getLastHolder().apply( this.bonus ); - this.health.setValue( bonus ).apply( data.animal ); - if( this.damage.hasAttribute( data.animal ) ) { - this.damage.setValue( bonus ).apply( data.animal ); + this.applyBonuses( AccessoryHolder.get( data.tamer ).apply( this.bonus ), data.animal ); + this.spawnEffects( data ); + } + + private void applyBonuses( OnBabySpawned data ) { + this.applyBonuses( ( float )Math.max( this.getModifierValue( data.parentA ), this.getModifierValue( data.parentB ) ), data.child ); + } + + private void applyBonuses( float bonus, LivingEntity entity ) { + this.health.setValue( bonus ).apply( entity ); + if( this.damage.hasAttribute( entity ) ) { + this.damage.setValue( bonus ).apply( entity ); } - if( data.animal instanceof Horse horse ) { + if( entity instanceof Horse horse ) { this.jumpHeight.setValue( bonus ).apply( horse ); this.speed.setValue( bonus ).apply( horse ); } - data.animal.setHealth( data.animal.getMaxHealth() ); - this.spawnEffects( data ); + entity.setHealth( entity.getMaxHealth() ); } private void spawnEffects( OnAnimalTamed data ) { - CustomConditions.getLastHolder() + AccessoryHolder.get( data.tamer ) .getParticleEmitter() .count( 4 ) .sizeBased( data.animal ) .emit( data.getServerLevel() ); } + + private double getModifierValue( LivingEntity entity ) { + return entity.getAttributes().getModifierValue( Attributes.MAX_HEALTH, this.health.getUUID() ); + } + + private boolean hasModifier( LivingEntity entity ) { + return entity.getAttributes().hasModifier( Attributes.MAX_HEALTH, this.health.getUUID() ); + } } diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/TradeOffer.java b/common/src/main/java/com/majruszsaccessories/accessories/components/TradeOffer.java deleted file mode 100644 index 3b357330..00000000 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/TradeOffer.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.majruszsaccessories.accessories.components; - -import com.majruszlibrary.annotation.AutoInstance; -import com.majruszlibrary.data.Reader; -import com.majruszlibrary.events.OnWanderingTradesUpdated; -import com.majruszlibrary.math.Random; -import com.majruszlibrary.math.Range; -import com.majruszsaccessories.common.BonusComponent; -import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.items.AccessoryItem; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.item.trading.MerchantOffer; - -import java.util.ArrayList; -import java.util.List; -import java.util.function.Predicate; - -public class TradeOffer extends BonusComponent< AccessoryItem > { - private static final List< TradeOffer > OFFERS = new ArrayList<>(); - int price; - - public static ISupplier< AccessoryItem > create( int price ) { - return handler->new TradeOffer( handler, price ); - } - - protected TradeOffer( BonusHandler< AccessoryItem > handler, int price ) { - super( handler ); - - this.price = price; - - handler.getConfig() - .define( "trade_price", Reader.integer(), s->this.price, ( s, v )->this.price = Range.of( 1, 32 ).clamp( v ) ); - - OFFERS.add( this ); - } - - public MerchantOffer toMerchantOffer() { - return new MerchantOffer( new ItemStack( this.getItem(), 1 ), new ItemStack( Items.EMERALD, this.getPrice() ), 2, 40, 0.05f ) { - @Override - public boolean satisfiedBy( ItemStack itemStack1, ItemStack itemStack2 ) { - return itemStack1.is( TradeOffer.this.getItem() ) && itemStack2.isEmpty(); - } - }; - } - - public int getPrice() { - return this.price; - } - - @AutoInstance - public static class Updater { - public Updater() { - OnWanderingTradesUpdated.listen( this::addRandom ); - } - - private void addRandom( OnWanderingTradesUpdated data ) { - data.offers.addAll( this.getOffers( offer->offer.getItem().getBoosterSlotsCount() == 1, 3 ) ); - data.offers.addAll( this.getOffers( offer->offer.getItem().getBoosterSlotsCount() == 2, 1 ) ); - } - - private List< MerchantOffer > getOffers( Predicate< TradeOffer > predicate, int count ) { - return Random.next( OFFERS.stream().filter( predicate ).map( TradeOffer::toMerchantOffer ).toList(), count ); - } - } -} diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/TradingDiscount.java b/common/src/main/java/com/majruszsaccessories/accessories/components/TradingDiscount.java index 7f0d5819..da48dac8 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/TradingDiscount.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/TradingDiscount.java @@ -3,10 +3,11 @@ import com.majruszlibrary.events.OnTradesUpdated; import com.majruszlibrary.math.Range; import com.majruszlibrary.platform.Side; +import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; import net.minecraft.world.item.trading.MerchantOffer; @@ -33,7 +34,7 @@ protected TradingDiscount( BonusHandler< AccessoryItem > handler, float multipli } private void decreasePrices( OnTradesUpdated data ) { - float discount = CustomConditions.getLastHolder().apply( this.multiplier ); + float discount = AccessoryHolder.get( data.player ).apply( this.multiplier ); for( MerchantOffer offer : data.offers ) { int price = offer.getBaseCostA().getCount(); float currentDiscount = ( float )offer.getSpecialPriceDiff() / price; @@ -45,7 +46,7 @@ private void decreasePrices( OnTradesUpdated data ) { } private void spawnEffects( OnTradesUpdated data ) { - CustomConditions.getLastHolder() + AccessoryHolder.get( data.player ) .getParticleEmitter() .count( 6 ) .sizeBased( data.villager ) diff --git a/common/src/main/java/com/majruszsaccessories/boosters/Dice.java b/common/src/main/java/com/majruszsaccessories/boosters/Dice.java index 763dcfd1..7050db04 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/Dice.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/Dice.java @@ -10,6 +10,7 @@ import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.common.BoosterHandler; +import com.majruszsaccessories.common.components.TradeOffer; import com.majruszsaccessories.items.BoosterItem; import net.minecraft.world.entity.monster.Guardian; @@ -19,7 +20,8 @@ public Dice() { super( MajruszsAccessories.DICE, Dice.class ); this.add( AccessoryDropChance.create( 0.2f ) ) - .add( GuardianDropChance.create() ); + .add( GuardianDropChance.create() ) + .add( TradeOffer.create() ); } static class GuardianDropChance extends BonusComponent< BoosterItem > { diff --git a/common/src/main/java/com/majruszsaccessories/boosters/Horseshoe.java b/common/src/main/java/com/majruszsaccessories/boosters/Horseshoe.java index 6d1ac130..2f0c667b 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/Horseshoe.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/Horseshoe.java @@ -10,6 +10,7 @@ import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.common.BoosterHandler; +import com.majruszsaccessories.common.components.TradeOffer; import com.majruszsaccessories.items.BoosterItem; import net.minecraft.world.entity.animal.horse.SkeletonHorse; import net.minecraft.world.entity.monster.Skeleton; @@ -20,7 +21,8 @@ public Horseshoe() { super( MajruszsAccessories.HORSESHOE, Horseshoe.class ); this.add( LuckBonus.create( 1 ) ) - .add( SkeletonHorsemanDropChance.create() ); + .add( SkeletonHorsemanDropChance.create() ) + .add( TradeOffer.create() ); } static class SkeletonHorsemanDropChance extends BonusComponent< BoosterItem > { diff --git a/common/src/main/java/com/majruszsaccessories/boosters/Jadeite.java b/common/src/main/java/com/majruszsaccessories/boosters/Jadeite.java deleted file mode 100644 index af867784..00000000 --- a/common/src/main/java/com/majruszsaccessories/boosters/Jadeite.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.majruszsaccessories.boosters; - -import com.majruszlibrary.annotation.AutoInstance; -import com.majruszlibrary.data.Reader; -import com.majruszlibrary.events.OnLootGenerated; -import com.majruszlibrary.events.base.Condition; -import com.majruszlibrary.math.Range; -import com.majruszsaccessories.MajruszsAccessories; -import com.majruszsaccessories.boosters.components.EfficiencyNegation; -import com.majruszsaccessories.common.BonusComponent; -import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.common.BoosterHandler; -import com.majruszsaccessories.items.BoosterItem; -import net.minecraft.world.entity.monster.ElderGuardian; - -@AutoInstance -public class Jadeite extends BoosterHandler { - public Jadeite() { - super( MajruszsAccessories.JADEITE, Jadeite.class ); - - this.add( EfficiencyNegation.create() ) - .add( ElderGuardianDropChance.create() ); - } - - static class ElderGuardianDropChance extends BonusComponent< BoosterItem > { - float chance = 0.334f; - - public static ISupplier< BoosterItem > create() { - return ElderGuardianDropChance::new; - } - - protected ElderGuardianDropChance( BonusHandler< BoosterItem > handler ) { - super( handler ); - - OnLootGenerated.listen( this::addToGeneratedLoot ) - .addCondition( Condition.isLogicalServer() ) - .addCondition( Condition.chance( ()->this.chance ) ) - .addCondition( data->data.lastDamagePlayer != null ) - .addCondition( data->data.entity instanceof ElderGuardian ); - - handler.getConfig() - .define( "elder_guardian_drop_chance", Reader.number(), s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); - } - } -} diff --git a/common/src/main/java/com/majruszsaccessories/boosters/Onyx.java b/common/src/main/java/com/majruszsaccessories/boosters/Onyx.java index 8f15a19d..5cb742fb 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/Onyx.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/Onyx.java @@ -10,6 +10,7 @@ import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.common.BoosterHandler; +import com.majruszsaccessories.common.components.TradeOffer; import com.majruszsaccessories.items.BoosterItem; import net.minecraft.world.entity.monster.warden.Warden; @@ -19,7 +20,8 @@ public Onyx() { super( MajruszsAccessories.ONYX, Onyx.class ); this.add( EfficiencyBonus.create( 0.09f ) ) - .add( WardenDropChance.create() ); + .add( WardenDropChance.create() ) + .add( TradeOffer.create() ); } static class WardenDropChance extends BonusComponent< BoosterItem > { diff --git a/common/src/main/java/com/majruszsaccessories/boosters/OwlFeather.java b/common/src/main/java/com/majruszsaccessories/boosters/OwlFeather.java index fde18a39..c362dabd 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/OwlFeather.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/OwlFeather.java @@ -10,6 +10,7 @@ import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.common.BoosterHandler; +import com.majruszsaccessories.common.components.TradeOffer; import com.majruszsaccessories.items.BoosterItem; import net.minecraft.world.entity.monster.Vex; @@ -19,7 +20,8 @@ public OwlFeather() { super( MajruszsAccessories.OWL_FEATHER, OwlFeather.class ); this.add( ExperienceBonus.create( 0.15f ) ) - .add( VexDropChance.create() ); + .add( VexDropChance.create() ) + .add( TradeOffer.create() ); } static class VexDropChance extends BonusComponent< BoosterItem > { diff --git a/common/src/main/java/com/majruszsaccessories/boosters/components/AccessoryDropChance.java b/common/src/main/java/com/majruszsaccessories/boosters/components/AccessoryDropChance.java index d2a5ce9f..e9a2c565 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/components/AccessoryDropChance.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/components/AccessoryDropChance.java @@ -4,8 +4,8 @@ import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.OnAccessoryDropChanceGet; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.OnAccessoryDropChanceGet; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.BoosterItem; import com.majruszsaccessories.tooltip.TooltipHelper; diff --git a/common/src/main/java/com/majruszsaccessories/boosters/components/BoosterIncompatibility.java b/common/src/main/java/com/majruszsaccessories/boosters/components/BoosterIncompatibility.java index ec4b6863..047f0b03 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/components/BoosterIncompatibility.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/components/BoosterIncompatibility.java @@ -3,7 +3,7 @@ import com.majruszlibrary.events.base.Condition; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.OnBoosterCompatibilityGet; +import com.majruszsaccessories.events.OnBoosterCompatibilityGet; import com.majruszsaccessories.items.BoosterItem; import java.util.function.Supplier; diff --git a/common/src/main/java/com/majruszsaccessories/boosters/components/EfficiencyBonus.java b/common/src/main/java/com/majruszsaccessories/boosters/components/EfficiencyBonus.java index ebd2eedd..87821a16 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/components/EfficiencyBonus.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/components/EfficiencyBonus.java @@ -4,7 +4,7 @@ import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.OnAccessoryExtraBonusGet; +import com.majruszsaccessories.events.OnAccessoryExtraBonusGet; import com.majruszsaccessories.items.BoosterItem; import com.majruszsaccessories.tooltip.TooltipHelper; @@ -21,7 +21,7 @@ protected EfficiencyBonus( BonusHandler< BoosterItem > handler, float bonus ) { this.bonus.set( bonus, Range.of( 0.0f, 1.0f ) ); OnAccessoryExtraBonusGet.listen( this::increaseEfficiency ) - .addCondition( data->data.holder.hasBooster( this.getItem() ) ); + .addCondition( data->data.holder.has( this.getItem() ) ); this.addTooltip( "majruszsaccessories.boosters.efficiency_bonus", TooltipHelper.asBooster( this::getItem ), TooltipHelper.asFixedPercent( this.bonus ) ); diff --git a/common/src/main/java/com/majruszsaccessories/boosters/components/EfficiencyNegation.java b/common/src/main/java/com/majruszsaccessories/boosters/components/EfficiencyNegation.java index a33d5224..da23835c 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/components/EfficiencyNegation.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/components/EfficiencyNegation.java @@ -2,7 +2,7 @@ import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; -import com.majruszsaccessories.contexts.OnAccessoryExtraBonusGet; +import com.majruszsaccessories.events.OnAccessoryExtraBonusGet; import com.majruszsaccessories.items.BoosterItem; import com.majruszsaccessories.tooltip.TooltipHelper; @@ -15,7 +15,7 @@ protected EfficiencyNegation( BonusHandler< BoosterItem > handler ) { super( handler ); OnAccessoryExtraBonusGet.listen( this::negateEfficiency ) - .addCondition( data->data.holder.hasBooster( this.getItem() ) ); + .addCondition( data->data.holder.has( this.getItem() ) ); this.addTooltip( "majruszsaccessories.boosters.efficiency_negation", TooltipHelper.asBooster( this::getItem ) ); } diff --git a/common/src/main/java/com/majruszsaccessories/boosters/components/ExperienceBonus.java b/common/src/main/java/com/majruszsaccessories/boosters/components/ExperienceBonus.java index fc4b11a4..3ae4c29f 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/components/ExperienceBonus.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/components/ExperienceBonus.java @@ -5,7 +5,7 @@ import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; -import com.majruszsaccessories.contexts.base.CustomConditions; +import com.majruszsaccessories.events.base.CustomConditions; import com.majruszsaccessories.items.BoosterItem; import com.majruszsaccessories.tooltip.TooltipHelper; diff --git a/common/src/main/java/com/majruszsaccessories/boosters/components/LuckBonus.java b/common/src/main/java/com/majruszsaccessories/boosters/components/LuckBonus.java index f701e8d6..097f0237 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/components/LuckBonus.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/components/LuckBonus.java @@ -37,8 +37,8 @@ protected LuckBonus( BonusHandler< BoosterItem > handler, int luck ) { } private void updateLuck( OnPlayerTicked data ) { - AccessoryHolder holder = AccessoryHolder.find( data.player, this.getItem() ); - int luck = holder.isValid() ? holder.apply( this.bonus ) : 0; + AccessoryHolder holder = AccessoryHolder.get( data.player ); + int luck = holder.has( this.getItem() ) ? holder.apply( this.bonus ) : 0; this.attribute.setValue( luck ).apply( data.player ); } diff --git a/common/src/main/java/com/majruszsaccessories/cards/GamblingCard.java b/common/src/main/java/com/majruszsaccessories/cards/GamblingCard.java new file mode 100644 index 00000000..092e16da --- /dev/null +++ b/common/src/main/java/com/majruszsaccessories/cards/GamblingCard.java @@ -0,0 +1,20 @@ +package com.majruszsaccessories.cards; + +import com.majruszlibrary.events.OnItemTooltip; +import com.majruszlibrary.text.TextHelper; +import com.majruszsaccessories.common.AccessoryHolder; +import com.majruszsaccessories.config.Config; +import com.majruszsaccessories.items.CardItem; +import net.minecraft.ChatFormatting; + +public class GamblingCard extends CardItem { + @Override + public void apply( AccessoryHolder holder ) { + holder.setBonus( Config.Efficiency.RANGE, AccessoryHolder.RandomType.NORMAL_DISTRIBUTION ); + } + + @Override + public void addTooltip( OnItemTooltip data ) { + data.components.add( TextHelper.translatable( "majruszsaccessories.cards.redraw" ).withStyle( ChatFormatting.GRAY ) ); + } +} diff --git a/common/src/main/java/com/majruszsaccessories/cards/RemovalCard.java b/common/src/main/java/com/majruszsaccessories/cards/RemovalCard.java new file mode 100644 index 00000000..abd12906 --- /dev/null +++ b/common/src/main/java/com/majruszsaccessories/cards/RemovalCard.java @@ -0,0 +1,29 @@ +package com.majruszsaccessories.cards; + +import com.majruszlibrary.events.OnItemTooltip; +import com.majruszlibrary.text.TextHelper; +import com.majruszsaccessories.common.AccessoryHolder; +import com.majruszsaccessories.items.CardItem; +import net.minecraft.ChatFormatting; +import net.minecraft.world.item.ItemStack; + +import java.util.List; + +public class RemovalCard extends CardItem { + @Override + public void apply( AccessoryHolder holder ) { + if( holder.hasAnyBooster() ) { + holder.removeBoosters(); + } + } + + @Override + public void addTooltip( OnItemTooltip data ) { + data.components.add( TextHelper.translatable( "majruszsaccessories.cards.remove" ).withStyle( ChatFormatting.GRAY ) ); + } + + @Override + public List< ItemStack > getCraftingRemainder( AccessoryHolder holder ) { + return holder.getBoosters().stream().map( ItemStack::new ).toList(); + } +} diff --git a/common/src/main/java/com/majruszsaccessories/cards/ReverseCard.java b/common/src/main/java/com/majruszsaccessories/cards/ReverseCard.java new file mode 100644 index 00000000..5d1c7786 --- /dev/null +++ b/common/src/main/java/com/majruszsaccessories/cards/ReverseCard.java @@ -0,0 +1,19 @@ +package com.majruszsaccessories.cards; + +import com.majruszlibrary.events.OnItemTooltip; +import com.majruszlibrary.text.TextHelper; +import com.majruszsaccessories.common.AccessoryHolder; +import com.majruszsaccessories.items.CardItem; +import net.minecraft.ChatFormatting; + +public class ReverseCard extends CardItem { + @Override + public void apply( AccessoryHolder holder ) { + holder.setBonus( -holder.getBaseBonus() ); + } + + @Override + public void addTooltip( OnItemTooltip data ) { + data.components.add( TextHelper.translatable( "majruszsaccessories.cards.negate" ).withStyle( ChatFormatting.GRAY ) ); + } +} diff --git a/common/src/main/java/com/majruszsaccessories/commands/SpawnAccessoryCommand.java b/common/src/main/java/com/majruszsaccessories/commands/SpawnAccessoryCommand.java index 91ffe02c..728f9608 100644 --- a/common/src/main/java/com/majruszsaccessories/commands/SpawnAccessoryCommand.java +++ b/common/src/main/java/com/majruszsaccessories/commands/SpawnAccessoryCommand.java @@ -8,7 +8,6 @@ import com.majruszlibrary.item.ItemHelper; import com.majruszlibrary.math.Range; import com.majruszlibrary.registry.Registries; -import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.config.Config; import com.majruszsaccessories.items.AccessoryItem; diff --git a/common/src/main/java/com/majruszsaccessories/common/AccessoryHandler.java b/common/src/main/java/com/majruszsaccessories/common/AccessoryHandler.java index e1c8e80c..192c67fe 100644 --- a/common/src/main/java/com/majruszsaccessories/common/AccessoryHandler.java +++ b/common/src/main/java/com/majruszsaccessories/common/AccessoryHandler.java @@ -6,7 +6,7 @@ import com.majruszlibrary.registry.RegistryObject; import com.majruszlibrary.text.TextHelper; import com.majruszsaccessories.config.Config; -import com.majruszsaccessories.contexts.OnAccessoryTooltip; +import com.majruszsaccessories.events.OnAccessoryTooltip; import com.majruszsaccessories.items.AccessoryItem; import net.minecraft.ChatFormatting; diff --git a/common/src/main/java/com/majruszsaccessories/common/AccessoryHolder.java b/common/src/main/java/com/majruszsaccessories/common/AccessoryHolder.java index e0dad1f0..5cff19e7 100644 --- a/common/src/main/java/com/majruszsaccessories/common/AccessoryHolder.java +++ b/common/src/main/java/com/majruszsaccessories/common/AccessoryHolder.java @@ -11,13 +11,13 @@ import com.majruszsaccessories.config.Config; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.config.RangedInteger; -import com.majruszsaccessories.contexts.OnAccessoryExtraBonusGet; +import com.majruszsaccessories.events.OnAccessoryExtraBonusGet; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.items.BoosterItem; +import com.majruszsaccessories.mixininterfaces.IMixinLivingEntity; import com.majruszsaccessories.particles.BonusParticleType; import net.minecraft.ChatFormatting; import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Mth; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -25,14 +25,21 @@ import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.function.Predicate; +import java.util.function.Supplier; public class AccessoryHolder { final ItemStack itemStack; final AccessoryItem item; final Data data; - public static AccessoryHolder find( LivingEntity entity, Predicate< ItemStack > predicate ) { + public static AccessoryHolder get( LivingEntity entity ) { + return entity != null ? ( ( IMixinLivingEntity )entity ).majruszsaccessories$getAccessoryHolder() : new AccessoryHolder( ItemStack.EMPTY ); + } + + public static AccessoryHolder find( LivingEntity entity ) { + Predicate< ItemStack > predicate = itemStack->itemStack.getItem() instanceof AccessoryItem; if( MajruszsAccessories.SLOT_INTEGRATION.isInstalled() ) { return new AccessoryHolder( MajruszsAccessories.SLOT_INTEGRATION.find( entity, predicate ) ); } else { @@ -45,22 +52,6 @@ public static AccessoryHolder find( LivingEntity entity, Predicate< ItemStack > } } - public static AccessoryHolder find( LivingEntity entity, AccessoryItem item ) { - return AccessoryHolder.find( entity, itemStack->itemStack.is( item ) ); - } - - public static AccessoryHolder find( LivingEntity entity, BoosterItem item ) { - return AccessoryHolder.find( entity, itemStack->AccessoryHolder.create( itemStack ).hasBooster( item ) ); - } - - public static boolean hasAccessory( LivingEntity entity, AccessoryItem item ) { - return AccessoryHolder.find( entity, item ).isValid(); - } - - public static boolean hasBooster( LivingEntity entity, BoosterItem item ) { - return AccessoryHolder.find( entity, item ).isValid(); - } - public static AccessoryHolder create( Item item ) { return new AccessoryHolder( new ItemStack( item ) ); } @@ -138,7 +129,7 @@ public float apply( RangedFloat value ) { public AccessoryHolder setRandomBonus() { if( this.hasBonusRangeDefined() ) { - return this.setBonus( Mth.lerp( Random.nextFloat( 0.0f, 1.0f ), this.data.range.from, this.data.range.to ) ); + return this.setBonus( Optional.ofNullable( this.data.randomType ).orElse( RandomType.RANDOM ).get( this.data.range ) ); } else { return this.setBonus( Config.Efficiency.getRandom() ); } @@ -152,18 +143,31 @@ public AccessoryHolder setBonus( float bonus ) { } ); } - public AccessoryHolder setBonus( Range< Float > bonus ) { + public AccessoryHolder setBonus( Range< Float > bonus, RandomType randomType ) { if( ( bonus.to - bonus.from ) > 1e-5f ) { - return this.save( ()->this.data.range = Range.of( AccessoryHolder.round( bonus.from ), AccessoryHolder.round( bonus.to ) ) ); + return this.save( ()->{ + this.data.baseBonus = null; + this.data.extraBonus = null; + this.data.randomType = randomType; + this.data.range = Range.of( AccessoryHolder.round( bonus.from ), AccessoryHolder.round( bonus.to ) ); + } ); } else { return this.setBonus( bonus.from ); } } + public AccessoryHolder setBonus( Range< Float > bonus ) { + return this.setBonus( bonus, null ); + } + public AccessoryHolder addBooster( BoosterItem item ) { return this.save( ()->this.data.boosters.add( new BoosterDef( item ) ) ); } + public AccessoryHolder removeBoosters() { + return this.save( ()->this.data.boosters.clear() ); + } + public float getBonus() { return AccessoryHolder.round( this.getBaseBonus() + this.getExtraBonus() ); } @@ -208,6 +212,10 @@ public ParticleEmitter getParticleEmitter() { return AccessoryHolder.getParticleEmitter( this.getBonus() ); } + public boolean is( AccessoryItem item ) { + return this.item == item; + } + public boolean isValid() { return this.item != null; } @@ -224,11 +232,11 @@ public boolean hasMaxBonus() { return this.getBaseBonus() == Config.Efficiency.RANGE.to; } - public boolean hasBooster( BoosterItem item ) { + public boolean has( BoosterItem item ) { return this.data.boosters.stream().anyMatch( booster->booster.item == item ); } - public boolean hasBooster() { + public boolean hasAnyBooster() { return !this.data.boosters.isEmpty(); } @@ -243,12 +251,28 @@ private static float round( float value ) { return Math.round( 100.0f * value ) / 100.0f; } + public enum RandomType { + RANDOM( ()->Random.nextFloat( 0.0f, 1.0f ) ), + NORMAL_DISTRIBUTION( ()->Config.Efficiency.getGaussianRatio() ); + + private final Supplier< Float > ratio; + + RandomType( Supplier< Float > ratio ) { + this.ratio = ratio; + } + + float get( Range< Float > range ) { + return range.lerp( this.ratio.get() ); + } + } + private static class Data { static { Serializables.get( Data.class ) .define( "Bonus", subconfig->{ subconfig.define( "Value", Reader.optional( Reader.number() ), s->s.baseBonus, ( s, v )->s.baseBonus = v ); subconfig.define( "ValueRange", Reader.optional( Reader.range( Reader.number() ) ), s->s.range, ( s, v )->s.range = v ); + subconfig.define( "ValueRandomType", Reader.optional( Reader.enumeration( RandomType::values ) ), s->s.randomType, ( s, v )->s.randomType = v ); subconfig.define( "Boosters", Reader.list( Reader.custom( BoosterDef::new ) ), s->s.boosters, ( s, v )->s.boosters = v ); } ); } @@ -256,11 +280,13 @@ private static class Data { Float baseBonus = null; Float extraBonus = 0.0f; Range< Float > range = null; + RandomType randomType = null; List< BoosterDef > boosters = List.of(); public Data( Data data ) { this.baseBonus = data.baseBonus; this.range = data.range != null ? Range.of( data.range.from, data.range.to ) : null; + this.randomType = data.randomType; this.boosters = new ArrayList<>( data.boosters ); } diff --git a/common/src/main/java/com/majruszsaccessories/common/BonusHandler.java b/common/src/main/java/com/majruszsaccessories/common/BonusHandler.java index 1a282cdb..0345033d 100644 --- a/common/src/main/java/com/majruszsaccessories/common/BonusHandler.java +++ b/common/src/main/java/com/majruszsaccessories/common/BonusHandler.java @@ -5,7 +5,7 @@ import com.majruszlibrary.data.Serializables; import com.majruszlibrary.events.OnItemDecorationsRendered; import com.majruszsaccessories.MajruszsAccessories; -import com.majruszsaccessories.contexts.OnAccessoryTooltip; +import com.majruszsaccessories.events.OnAccessoryTooltip; import com.majruszsaccessories.items.BoosterItem; import net.minecraft.ChatFormatting; import net.minecraft.world.item.Item; diff --git a/common/src/main/java/com/majruszsaccessories/common/BoosterHandler.java b/common/src/main/java/com/majruszsaccessories/common/BoosterHandler.java index 4d617fa3..cbe36643 100644 --- a/common/src/main/java/com/majruszsaccessories/common/BoosterHandler.java +++ b/common/src/main/java/com/majruszsaccessories/common/BoosterHandler.java @@ -4,8 +4,8 @@ import com.majruszlibrary.events.OnItemDecorationsRendered; import com.majruszlibrary.registry.RegistryObject; import com.majruszsaccessories.config.Config; -import com.majruszsaccessories.contexts.OnAccessoryTooltip; -import com.majruszsaccessories.contexts.OnBoosterTooltip; +import com.majruszsaccessories.events.OnAccessoryTooltip; +import com.majruszsaccessories.events.OnBoosterTooltip; import com.majruszsaccessories.items.BoosterItem; import net.minecraft.ChatFormatting; import net.minecraft.world.item.ItemStack; @@ -17,7 +17,7 @@ public BoosterHandler( RegistryObject< BoosterItem > item, Class< ? extends Boos super( item, clazz, item.getId() ); OnAccessoryTooltip.listen( this::addTooltip ) - .addCondition( data->data.holder.hasBooster( this.getItem() ) ); + .addCondition( data->data.holder.has( this.getItem() ) ); OnBoosterTooltip.listen( this::addTooltip ) .addCondition( data->data.booster.equals( this.getItem() ) ); diff --git a/common/src/main/java/com/majruszsaccessories/common/components/TradeOffer.java b/common/src/main/java/com/majruszsaccessories/common/components/TradeOffer.java new file mode 100644 index 00000000..907ed4fa --- /dev/null +++ b/common/src/main/java/com/majruszsaccessories/common/components/TradeOffer.java @@ -0,0 +1,55 @@ +package com.majruszsaccessories.common.components; + +import com.majruszlibrary.events.OnWanderingTradesUpdated; +import com.majruszlibrary.math.Random; +import com.majruszsaccessories.MajruszsAccessories; +import com.majruszsaccessories.common.BonusComponent; +import com.majruszsaccessories.common.BonusHandler; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.trading.MerchantOffer; + +import java.util.ArrayList; +import java.util.List; + +public class TradeOffer< Type extends Item > extends BonusComponent< Type > { + private static final List< TradeOffer< ? > > OFFERS = new ArrayList<>(); + + static { + OnWanderingTradesUpdated.listen( TradeOffer::addTrades ); + } + + public static < Type extends Item > ISupplier< Type > create() { + return TradeOffer::new; + } + + protected TradeOffer( BonusHandler< Type > handler ) { + super( handler ); + + OFFERS.add( this ); + } + + public MerchantOffer toMerchantOffer() { + return new MerchantOffer( new ItemStack( this.getItem(), 1 ), this.getItemStack(), 2, 40, 0.05f ) { + @Override + public boolean satisfiedBy( ItemStack itemStack1, ItemStack itemStack2 ) { + return itemStack1.is( TradeOffer.this.getItem() ) && itemStack2.isEmpty(); + } + }; + } + + private ItemStack getItemStack() { + return Random.next( List.of( + new ItemStack( MajruszsAccessories.GAMBLING_CARD.get(), 1 ), + new ItemStack( MajruszsAccessories.GAMBLING_CARD.get(), 1 ), + new ItemStack( MajruszsAccessories.REMOVAL_CARD.get(), 1 ), + new ItemStack( MajruszsAccessories.REVERSE_CARD.get(), 1 ), + new ItemStack( Items.EMERALD, 7 ) + ) ); + } + + private static void addTrades( OnWanderingTradesUpdated data ) { + data.offers.addAll( Random.next( OFFERS.stream().map( TradeOffer::toMerchantOffer ).toList(), 5 ) ); + } +} diff --git a/common/src/main/java/com/majruszsaccessories/config/Config.java b/common/src/main/java/com/majruszsaccessories/config/Config.java index 4be346d7..da14f2c6 100644 --- a/common/src/main/java/com/majruszsaccessories/config/Config.java +++ b/common/src/main/java/com/majruszsaccessories/config/Config.java @@ -37,9 +37,11 @@ public static float getRandom() { return RANGE.from; } - float ratio = ( float )( ( Random.nextGaussian() * STD + AVG - RANGE.from ) / ( RANGE.to - RANGE.from ) ); + return RANGE.lerp( Efficiency.getGaussianRatio() ); + } - return RANGE.lerp( Mth.clamp( ratio, 0.0f, 1.0f ) ); + public static float getGaussianRatio() { + return Mth.clamp( ( float )( ( Random.nextGaussian() * STD + AVG - RANGE.from ) / ( RANGE.to - RANGE.from ) ), 0.0f, 1.0f ); } } } diff --git a/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryDropChanceGet.java b/common/src/main/java/com/majruszsaccessories/events/OnAccessoryDropChanceGet.java similarity index 95% rename from common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryDropChanceGet.java rename to common/src/main/java/com/majruszsaccessories/events/OnAccessoryDropChanceGet.java index 516d667e..f51d0395 100644 --- a/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryDropChanceGet.java +++ b/common/src/main/java/com/majruszsaccessories/events/OnAccessoryDropChanceGet.java @@ -1,4 +1,4 @@ -package com.majruszsaccessories.contexts; +package com.majruszsaccessories.events; import com.majruszlibrary.events.base.Event; import com.majruszlibrary.events.base.Events; diff --git a/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryExtraBonusGet.java b/common/src/main/java/com/majruszsaccessories/events/OnAccessoryExtraBonusGet.java similarity index 93% rename from common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryExtraBonusGet.java rename to common/src/main/java/com/majruszsaccessories/events/OnAccessoryExtraBonusGet.java index d0ec41dd..5a876c8a 100644 --- a/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryExtraBonusGet.java +++ b/common/src/main/java/com/majruszsaccessories/events/OnAccessoryExtraBonusGet.java @@ -1,4 +1,4 @@ -package com.majruszsaccessories.contexts; +package com.majruszsaccessories.events; import com.majruszlibrary.events.base.Event; import com.majruszlibrary.events.base.Events; diff --git a/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryTooltip.java b/common/src/main/java/com/majruszsaccessories/events/OnAccessoryTooltip.java similarity index 94% rename from common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryTooltip.java rename to common/src/main/java/com/majruszsaccessories/events/OnAccessoryTooltip.java index 8890ffd0..b210e761 100644 --- a/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryTooltip.java +++ b/common/src/main/java/com/majruszsaccessories/events/OnAccessoryTooltip.java @@ -1,4 +1,4 @@ -package com.majruszsaccessories.contexts; +package com.majruszsaccessories.events; import com.majruszlibrary.events.base.Event; import com.majruszlibrary.events.base.Events; diff --git a/common/src/main/java/com/majruszsaccessories/contexts/OnBoosterCompatibilityGet.java b/common/src/main/java/com/majruszsaccessories/events/OnBoosterCompatibilityGet.java similarity index 94% rename from common/src/main/java/com/majruszsaccessories/contexts/OnBoosterCompatibilityGet.java rename to common/src/main/java/com/majruszsaccessories/events/OnBoosterCompatibilityGet.java index 10861acf..e44c5cd3 100644 --- a/common/src/main/java/com/majruszsaccessories/contexts/OnBoosterCompatibilityGet.java +++ b/common/src/main/java/com/majruszsaccessories/events/OnBoosterCompatibilityGet.java @@ -1,4 +1,4 @@ -package com.majruszsaccessories.contexts; +package com.majruszsaccessories.events; import com.majruszlibrary.events.base.Event; import com.majruszlibrary.events.base.Events; diff --git a/common/src/main/java/com/majruszsaccessories/contexts/OnBoosterTooltip.java b/common/src/main/java/com/majruszsaccessories/events/OnBoosterTooltip.java similarity index 93% rename from common/src/main/java/com/majruszsaccessories/contexts/OnBoosterTooltip.java rename to common/src/main/java/com/majruszsaccessories/events/OnBoosterTooltip.java index 07a55a8e..d31311e7 100644 --- a/common/src/main/java/com/majruszsaccessories/contexts/OnBoosterTooltip.java +++ b/common/src/main/java/com/majruszsaccessories/events/OnBoosterTooltip.java @@ -1,4 +1,4 @@ -package com.majruszsaccessories.contexts; +package com.majruszsaccessories.events; import com.majruszlibrary.events.base.Event; import com.majruszlibrary.events.base.Events; diff --git a/common/src/main/java/com/majruszsaccessories/contexts/base/CustomConditions.java b/common/src/main/java/com/majruszsaccessories/events/base/CustomConditions.java similarity index 52% rename from common/src/main/java/com/majruszsaccessories/contexts/base/CustomConditions.java rename to common/src/main/java/com/majruszsaccessories/events/base/CustomConditions.java index efcdd07e..23862e0b 100644 --- a/common/src/main/java/com/majruszsaccessories/contexts/base/CustomConditions.java +++ b/common/src/main/java/com/majruszsaccessories/events/base/CustomConditions.java @@ -1,38 +1,34 @@ -package com.majruszsaccessories.contexts.base; +package com.majruszsaccessories.events.base; import com.majruszlibrary.events.base.Condition; import com.majruszlibrary.events.base.Events; import com.majruszlibrary.math.Random; -import com.majruszlibrary.platform.LogicalSafe; import com.majruszsaccessories.common.AccessoryHolder; -import com.majruszsaccessories.contexts.OnAccessoryDropChanceGet; +import com.majruszsaccessories.events.OnAccessoryDropChanceGet; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.items.BoosterItem; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; import java.util.function.Function; import java.util.function.Supplier; public class CustomConditions { - private static final LogicalSafe< AccessoryHolder > HOLDER = LogicalSafe.of( ()->AccessoryHolder.create( ItemStack.EMPTY ) ); - public static < DataType > Condition< DataType > hasAccessory( Supplier< AccessoryItem > item, Function< DataType, LivingEntity > entity ) { - return Condition.predicate( data->CustomConditions.updateHolder( entity.apply( data ), item.get() ).isValid() ); + return Condition.predicate( data->AccessoryHolder.get( entity.apply( data ) ).is( item.get() ) ); } public static < DataType > Condition< DataType > hasBooster( Supplier< BoosterItem > item, Function< DataType, LivingEntity > entity ) { - return Condition.predicate( data->CustomConditions.updateHolder( entity.apply( data ), item.get() ).isValid() ); + return Condition.predicate( data->AccessoryHolder.get( entity.apply( data ) ).has( item.get() ) ); } public static < DataType > Condition< DataType > chance( Supplier< AccessoryItem > item, Function< DataType, LivingEntity > entity, Function< AccessoryHolder, Float > chance ) { return Condition.predicate( data->{ - AccessoryHolder holder = CustomConditions.updateHolder( entity.apply( data ), item.get() ); + AccessoryHolder holder = AccessoryHolder.get( entity.apply( data ) ); - return holder.isValid() && Random.check( chance.apply( holder ) ); + return holder.is( item.get() ) && Random.check( chance.apply( holder ) ); } ); } @@ -43,30 +39,4 @@ public static < DataType > Condition< DataType > dropChance( Function< DataType, public static < DataType > Condition< DataType > dropChance( Supplier< Float > chance, Function< DataType, Entity > entity ) { return CustomConditions.dropChance( data->chance.get(), entity ); } - - public static AccessoryHolder getLastHolder() { - return HOLDER.get(); - } - - private static AccessoryHolder updateHolder( LivingEntity entity, AccessoryItem item ) { - if( entity != null ) { - AccessoryHolder holder = AccessoryHolder.find( entity, item ); - HOLDER.set( holder ); - - return holder; - } - - return AccessoryHolder.create( ItemStack.EMPTY ); - } - - private static AccessoryHolder updateHolder( LivingEntity entity, BoosterItem item ) { - if( entity != null ) { - AccessoryHolder holder = AccessoryHolder.find( entity, item ); - HOLDER.set( holder ); - - return holder; - } - - return AccessoryHolder.create( ItemStack.EMPTY ); - } } diff --git a/common/src/main/java/com/majruszsaccessories/items/CardItem.java b/common/src/main/java/com/majruszsaccessories/items/CardItem.java new file mode 100644 index 00000000..21895ca4 --- /dev/null +++ b/common/src/main/java/com/majruszsaccessories/items/CardItem.java @@ -0,0 +1,38 @@ +package com.majruszsaccessories.items; + +import com.majruszlibrary.events.OnItemTooltip; +import com.majruszsaccessories.common.AccessoryHolder; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Rarity; + +import java.util.List; + +public abstract class CardItem extends Item { + static { + OnItemTooltip.listen( CardItem::tryToAddTooltip ); + } + + public CardItem() { + super( new Properties().rarity( Rarity.UNCOMMON ).stacksTo( 16 ) ); + } + + @Override + public boolean isFoil( ItemStack itemStack ) { + return true; + } + + public abstract void apply( AccessoryHolder holder ); + + public abstract void addTooltip( OnItemTooltip data ); + + public List< ItemStack > getCraftingRemainder( AccessoryHolder holder ) { + return List.of(); + } + + private static void tryToAddTooltip( OnItemTooltip data ) { + if( data.itemStack.getItem() instanceof CardItem card ) { + card.addTooltip( data ); + } + } +} diff --git a/common/src/main/java/com/majruszsaccessories/items/CreativeModeTabs.java b/common/src/main/java/com/majruszsaccessories/items/CreativeModeTabs.java index 30c0e372..94bcd305 100644 --- a/common/src/main/java/com/majruszsaccessories/items/CreativeModeTabs.java +++ b/common/src/main/java/com/majruszsaccessories/items/CreativeModeTabs.java @@ -64,7 +64,9 @@ private static void definePrimaryItems( CreativeModeTab.ItemDisplayParameters pa MajruszsAccessories.ONYX, MajruszsAccessories.HORSESHOE, MajruszsAccessories.GOLDEN_HORSESHOE, - MajruszsAccessories.JADEITE + MajruszsAccessories.GAMBLING_CARD, + MajruszsAccessories.REMOVAL_CARD, + MajruszsAccessories.REVERSE_CARD ).map( item->new ItemStack( item.get() ) ).forEach( output::accept ); } } diff --git a/common/src/main/java/com/majruszsaccessories/listeners/AccessoryObserver.java b/common/src/main/java/com/majruszsaccessories/listeners/AccessoryObserver.java index 9d862b53..08cdb2e3 100644 --- a/common/src/main/java/com/majruszsaccessories/listeners/AccessoryObserver.java +++ b/common/src/main/java/com/majruszsaccessories/listeners/AccessoryObserver.java @@ -1,23 +1,39 @@ package com.majruszsaccessories.listeners; import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.events.OnEntityTicked; import com.majruszlibrary.events.OnItemCrafted; +import com.majruszlibrary.events.OnItemEquipped; import com.majruszlibrary.events.OnLootGenerated; import com.majruszlibrary.events.base.Condition; import com.majruszlibrary.events.base.Priority; -import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.common.AccessoryHolder; -import net.minecraft.server.level.ServerPlayer; +import com.majruszsaccessories.items.AccessoryItem; +import com.majruszsaccessories.mixininterfaces.IMixinLivingEntity; @AutoInstance public class AccessoryObserver { public AccessoryObserver() { + OnItemEquipped.listen( this::tryToGiveRandomBonus ) + .addCondition( data->data.to.getItem() instanceof AccessoryItem ) + .priority( Priority.LOW ); + OnLootGenerated.listen( this::tryToGiveRandomBonus ) - .priority( Priority.LOWEST ); + .priority( Priority.LOW ); OnItemCrafted.listen( this::tryToGiveRandomBonus ) .addCondition( Condition.isLogicalServer() ) - .priority( Priority.LOWEST ); + .priority( Priority.LOW ); + + OnEntityTicked.listen( this::updateHolder ); + } + + private void tryToGiveRandomBonus( OnItemEquipped data ) { + // compatibility fix for mods that modify crafting behaviour etc. + AccessoryHolder holder = AccessoryHolder.create( data.to ); + if( holder.isValid() && !holder.hasBonusDefined() ) { + holder.setRandomBonus(); + } } private void tryToGiveRandomBonus( OnLootGenerated data ) { @@ -34,8 +50,9 @@ private void tryToGiveRandomBonus( OnItemCrafted data ) { if( holder.hasBonusRangeDefined() && !holder.hasBonusDefined() ) { holder.setRandomBonus(); } - if( holder.hasBooster() ) { - MajruszsAccessories.HELPER.triggerAchievement( ( ServerPlayer )data.player, "booster_used" ); - } + } + + private void updateHolder( OnEntityTicked data ) { + ( ( IMixinLivingEntity )data.entity ).majruszsaccessories$setAccessoryHolder( AccessoryHolder.find( data.entity ) ); } } diff --git a/common/src/main/java/com/majruszsaccessories/listeners/AccessoryTooltipUpdater.java b/common/src/main/java/com/majruszsaccessories/listeners/AccessoryTooltipUpdater.java index 9f7da295..1c909c74 100644 --- a/common/src/main/java/com/majruszsaccessories/listeners/AccessoryTooltipUpdater.java +++ b/common/src/main/java/com/majruszsaccessories/listeners/AccessoryTooltipUpdater.java @@ -10,7 +10,7 @@ import com.majruszlibrary.time.TimeHelper; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.common.AccessoryHolder; -import com.majruszsaccessories.contexts.OnAccessoryTooltip; +import com.majruszsaccessories.events.OnAccessoryTooltip; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; import net.minecraft.ChatFormatting; @@ -78,7 +78,7 @@ private List< Component > buildUseInfo( AccessoryHolder holder, @Nullable Player } private ChatFormatting getUseFormatting( AccessoryHolder holder, @Nullable Player player ) { - if( player != null && AccessoryHolder.find( player, holder.getItem() ).getItemStack() == holder.getItemStack() ) { + if( player != null && AccessoryHolder.get( player ) == holder ) { return ChatFormatting.GOLD; } else { return ChatFormatting.DARK_GRAY; diff --git a/common/src/main/java/com/majruszsaccessories/listeners/AdvancementProviders.java b/common/src/main/java/com/majruszsaccessories/listeners/AdvancementProviders.java new file mode 100644 index 00000000..d5090af7 --- /dev/null +++ b/common/src/main/java/com/majruszsaccessories/listeners/AdvancementProviders.java @@ -0,0 +1,28 @@ +package com.majruszsaccessories.listeners; + +import com.majruszlibrary.events.OnItemCrafted; +import com.majruszlibrary.events.base.Priority; +import com.majruszsaccessories.MajruszsAccessories; +import com.majruszsaccessories.common.AccessoryHolder; +import com.majruszsaccessories.items.AccessoryItem; +import net.minecraft.server.level.ServerPlayer; + +public class AdvancementProviders { + static { + OnItemCrafted.listen( AdvancementProviders::giveAdvancements ) + .addCondition( data->data.player instanceof ServerPlayer ) + .addCondition( data->data.itemStack.getItem() instanceof AccessoryItem ) + .priority( Priority.LOWEST ); + } + + private static void giveAdvancements( OnItemCrafted data ) { + ServerPlayer player = ( ServerPlayer )data.player; + AccessoryHolder holder = AccessoryHolder.create( data.itemStack ); + if( holder.hasAnyBooster() ) { + MajruszsAccessories.HELPER.triggerAchievement( player, "booster_used" ); + } + if( Math.abs( holder.getBonus() - 0.69 ) < 1e-5 ) { + MajruszsAccessories.HELPER.triggerAchievement( player, "booster_nice" ); + } + } +} diff --git a/common/src/main/java/com/majruszsaccessories/listeners/BoosterTooltipUpdater.java b/common/src/main/java/com/majruszsaccessories/listeners/BoosterTooltipUpdater.java index 1f080fa1..e0561f93 100644 --- a/common/src/main/java/com/majruszsaccessories/listeners/BoosterTooltipUpdater.java +++ b/common/src/main/java/com/majruszsaccessories/listeners/BoosterTooltipUpdater.java @@ -5,7 +5,7 @@ import com.majruszlibrary.events.base.Condition; import com.majruszlibrary.events.base.Events; import com.majruszlibrary.text.TextHelper; -import com.majruszsaccessories.contexts.OnBoosterTooltip; +import com.majruszsaccessories.events.OnBoosterTooltip; import com.majruszsaccessories.items.BoosterItem; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; diff --git a/common/src/main/java/com/majruszsaccessories/mixin/MixinLivingEntity.java b/common/src/main/java/com/majruszsaccessories/mixin/MixinLivingEntity.java new file mode 100644 index 00000000..5559a5ce --- /dev/null +++ b/common/src/main/java/com/majruszsaccessories/mixin/MixinLivingEntity.java @@ -0,0 +1,22 @@ +package com.majruszsaccessories.mixin; + +import com.majruszsaccessories.common.AccessoryHolder; +import com.majruszsaccessories.mixininterfaces.IMixinLivingEntity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin( LivingEntity.class ) +public abstract class MixinLivingEntity implements IMixinLivingEntity { + AccessoryHolder majruszsaccessories$accessoryHolder = AccessoryHolder.create( ItemStack.EMPTY ); + + @Override + public void majruszsaccessories$setAccessoryHolder( AccessoryHolder holder ) { + this.majruszsaccessories$accessoryHolder = holder; + } + + @Override + public AccessoryHolder majruszsaccessories$getAccessoryHolder() { + return this.majruszsaccessories$accessoryHolder; + } +} diff --git a/common/src/main/java/com/majruszsaccessories/mixininterfaces/IMixinLivingEntity.java b/common/src/main/java/com/majruszsaccessories/mixininterfaces/IMixinLivingEntity.java new file mode 100644 index 00000000..2e9a3eed --- /dev/null +++ b/common/src/main/java/com/majruszsaccessories/mixininterfaces/IMixinLivingEntity.java @@ -0,0 +1,9 @@ +package com.majruszsaccessories.mixininterfaces; + +import com.majruszsaccessories.common.AccessoryHolder; + +public interface IMixinLivingEntity { + void majruszsaccessories$setAccessoryHolder( AccessoryHolder holder ); + + AccessoryHolder majruszsaccessories$getAccessoryHolder(); +} diff --git a/common/src/main/java/com/majruszsaccessories/recipes/AccessoryRecipe.java b/common/src/main/java/com/majruszsaccessories/recipes/AccessoryRecipe.java index 669587ac..950164e0 100644 --- a/common/src/main/java/com/majruszsaccessories/recipes/AccessoryRecipe.java +++ b/common/src/main/java/com/majruszsaccessories/recipes/AccessoryRecipe.java @@ -42,7 +42,10 @@ public AccessoryRecipe( ResourceLocation id, AccessoryItem result, List< Accesso public boolean matches( CraftingContainer container, Level level ) { RecipeData data = RecipeData.build( container ); - return this.ingredients.stream().allMatch( data::hasAccessory ); + return data.getCardsSize() == 0 + && data.getBoostersSize() == 0 + && data.getAccessoriesSize() == this.ingredients.size() + && this.ingredients.stream().allMatch( data::hasAccessory ); } @Override diff --git a/common/src/main/java/com/majruszsaccessories/recipes/BoostAccessoriesRecipe.java b/common/src/main/java/com/majruszsaccessories/recipes/BoostAccessoryRecipe.java similarity index 83% rename from common/src/main/java/com/majruszsaccessories/recipes/BoostAccessoriesRecipe.java rename to common/src/main/java/com/majruszsaccessories/recipes/BoostAccessoryRecipe.java index 9a0ab13a..b0d1d666 100644 --- a/common/src/main/java/com/majruszsaccessories/recipes/BoostAccessoriesRecipe.java +++ b/common/src/main/java/com/majruszsaccessories/recipes/BoostAccessoryRecipe.java @@ -3,7 +3,7 @@ import com.majruszlibrary.events.base.Events; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.common.AccessoryHolder; -import com.majruszsaccessories.contexts.OnBoosterCompatibilityGet; +import com.majruszsaccessories.events.OnBoosterCompatibilityGet; import com.majruszsaccessories.items.BoosterItem; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceLocation; @@ -19,12 +19,12 @@ import java.util.List; import java.util.function.Supplier; -public class BoostAccessoriesRecipe extends CustomRecipe { +public class BoostAccessoryRecipe extends CustomRecipe { public static Supplier< RecipeSerializer< ? > > create() { - return ()->new SimpleCraftingRecipeSerializer<>( BoostAccessoriesRecipe::new ); + return ()->new SimpleCraftingRecipeSerializer<>( BoostAccessoryRecipe::new ); } - public BoostAccessoriesRecipe( ResourceLocation id, CraftingBookCategory category ) { + public BoostAccessoryRecipe( ResourceLocation id, CraftingBookCategory category ) { super( id, category ); } @@ -36,9 +36,10 @@ public boolean matches( CraftingContainer container, Level level ) { } AccessoryHolder holder = data.getAccessory( 0 ); - return data.getBoostersSize() > 0 + return data.getCardsSize() == 0 + && data.getBoostersSize() > 0 && data.getBoostersSize() <= holder.getBoosterSlotsLeft() - && BoostAccessoriesRecipe.areCompatible( data.boosters(), holder.getBoosters() ); + && BoostAccessoryRecipe.areCompatible( data.boosters(), holder.getBoosters() ); } @Override @@ -57,7 +58,7 @@ public boolean canCraftInDimensions( int width, int height ) { @Override public RecipeSerializer< ? > getSerializer() { - return MajruszsAccessories.BOOST_ACCESSORIES_RECIPE.get(); + return MajruszsAccessories.BOOST_ACCESSORY_RECIPE.get(); } private static boolean areCompatible( List< BoosterItem > a, List< BoosterItem > b ) { diff --git a/common/src/main/java/com/majruszsaccessories/recipes/CombineAccessoriesRecipe.java b/common/src/main/java/com/majruszsaccessories/recipes/CombineAccessoriesRecipe.java index 235b5c90..780744db 100644 --- a/common/src/main/java/com/majruszsaccessories/recipes/CombineAccessoriesRecipe.java +++ b/common/src/main/java/com/majruszsaccessories/recipes/CombineAccessoriesRecipe.java @@ -32,7 +32,8 @@ public boolean matches( CraftingContainer container, Level level ) { return data.getAccessoriesSize() > 1 && data.hasIdenticalItemTypes() && data.getMaxBonus() < Config.Efficiency.RANGE.to - && data.getBoostersSize() == 0; + && data.getBoostersSize() == 0 + && data.getCardsSize() == 0; } @Override diff --git a/common/src/main/java/com/majruszsaccessories/recipes/RecipeData.java b/common/src/main/java/com/majruszsaccessories/recipes/RecipeData.java index e625b9eb..a5943c6c 100644 --- a/common/src/main/java/com/majruszsaccessories/recipes/RecipeData.java +++ b/common/src/main/java/com/majruszsaccessories/recipes/RecipeData.java @@ -3,13 +3,14 @@ import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.items.BoosterItem; +import com.majruszsaccessories.items.CardItem; import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.item.ItemStack; import java.util.ArrayList; import java.util.List; -public record RecipeData( List< AccessoryHolder > accessories, List< BoosterItem > boosters ) { +public record RecipeData( List< AccessoryHolder > accessories, List< BoosterItem > boosters, List< CardItem > cards ) { public static RecipeData build( CraftingContainer container ) { RecipeData data = new RecipeData(); for( int i = 0; i < container.getContainerSize(); ++i ) { @@ -20,8 +21,10 @@ public static RecipeData build( CraftingContainer container ) { if( itemStack.getItem() instanceof AccessoryItem ) { data.accessories.add( AccessoryHolder.create( itemStack ) ); - } else if( itemStack.getItem() instanceof BoosterItem item ) { - data.boosters.add( item ); + } else if( itemStack.getItem() instanceof BoosterItem booster ) { + data.boosters.add( booster ); + } else if( itemStack.getItem() instanceof CardItem card ) { + data.cards.add( card ); } else { return new RecipeData(); } @@ -32,7 +35,7 @@ public static RecipeData build( CraftingContainer container ) { } public RecipeData() { - this( new ArrayList<>(), new ArrayList<>() ); + this( new ArrayList<>(), new ArrayList<>(), new ArrayList<>() ); } public AccessoryHolder getAccessory( int idx ) { @@ -43,6 +46,10 @@ public BoosterItem getBooster( int idx ) { return this.boosters.get( idx ); } + public CardItem getCard( int idx ) { + return this.cards.get( idx ); + } + float getStandardDeviation() { float average = this.getAverageBonus(); double variation = this.accessories.stream() @@ -72,6 +79,10 @@ int getBoostersSize() { return this.boosters.size(); } + int getCardsSize() { + return this.cards.size(); + } + boolean hasAccessory( AccessoryItem item ) { return this.accessories.stream().anyMatch( holder->holder.getItem().equals( item ) ); } diff --git a/common/src/main/java/com/majruszsaccessories/recipes/UseCardRecipe.java b/common/src/main/java/com/majruszsaccessories/recipes/UseCardRecipe.java new file mode 100644 index 00000000..5d84d09b --- /dev/null +++ b/common/src/main/java/com/majruszsaccessories/recipes/UseCardRecipe.java @@ -0,0 +1,67 @@ +package com.majruszsaccessories.recipes; + +import com.majruszsaccessories.MajruszsAccessories; +import com.majruszsaccessories.common.AccessoryHolder; +import net.minecraft.core.NonNullList; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingBookCategory; +import net.minecraft.world.item.crafting.CustomRecipe; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.SimpleCraftingRecipeSerializer; +import net.minecraft.world.level.Level; + +import java.util.List; +import java.util.function.Supplier; + +public class UseCardRecipe extends CustomRecipe { + public static Supplier< RecipeSerializer< ? > > create() { + return ()->new SimpleCraftingRecipeSerializer<>( UseCardRecipe::new ); + } + + public UseCardRecipe( ResourceLocation id, CraftingBookCategory category ) { + super( id, category ); + } + + @Override + public boolean matches( CraftingContainer container, Level level ) { + RecipeData data = RecipeData.build( container ); + + return data.getAccessoriesSize() == 1 + && data.getBoostersSize() == 0 + && data.getCardsSize() == 1; + } + + @Override + public ItemStack assemble( CraftingContainer container, RegistryAccess registryAccess ) { + RecipeData data = RecipeData.build( container ); + AccessoryHolder holder = data.getAccessory( 0 ).copy(); + data.getCard( 0 ).apply( holder ); + + return holder.getItemStack(); + } + + @Override + public NonNullList< ItemStack > getRemainingItems( CraftingContainer container ) { + RecipeData data = RecipeData.build( container ); + NonNullList< ItemStack > remainingItems = NonNullList.withSize( container.getContainerSize(), ItemStack.EMPTY ); + List< ItemStack > itemStacks = data.getCard( 0 ).getCraftingRemainder( data.getAccessory( 0 ) ); + for( int idx = 0; idx < itemStacks.size(); ++idx ) { + remainingItems.set( idx, itemStacks.get( idx ) ); + } + + return remainingItems; + } + + @Override + public boolean canCraftInDimensions( int width, int height ) { + return width * height >= 2; + } + + @Override + public RecipeSerializer< ? > getSerializer() { + return MajruszsAccessories.USE_CARD_RECIPE.get(); + } +} diff --git a/common/src/main/resources/assets/majruszsaccessories/lang/en_us.json b/common/src/main/resources/assets/majruszsaccessories/lang/en_us.json index 7ab91316..deff908a 100644 --- a/common/src/main/resources/assets/majruszsaccessories/lang/en_us.json +++ b/common/src/main/resources/assets/majruszsaccessories/lang/en_us.json @@ -9,12 +9,12 @@ "item.majruszsaccessories.dice": "Dice", "item.majruszsaccessories.discount_voucher": "Discount Voucher", "item.majruszsaccessories.dream_catcher": "Dream Catcher", + "item.majruszsaccessories.gambling_card": "Gambling Card", "item.majruszsaccessories.golden_dice": "Golden Dice", "item.majruszsaccessories.golden_horseshoe": "Golden Horseshoe", "item.majruszsaccessories.horseshoe": "Horseshoe", "item.majruszsaccessories.household_rune": "Household Rune", "item.majruszsaccessories.idol_of_fertility": "Idol of Fertility", - "item.majruszsaccessories.jadeite": "Jadeite", "item.majruszsaccessories.lucky_rock": "Lucky Rock", "item.majruszsaccessories.metal_lure": "Metal Lure", "item.majruszsaccessories.miner_guide": "Miner Guide", @@ -22,6 +22,8 @@ "item.majruszsaccessories.nature_rune": "Nature Rune", "item.majruszsaccessories.onyx": "Onyx", "item.majruszsaccessories.owl_feather": "Owl Feather", + "item.majruszsaccessories.removal_card": "Removal Card", + "item.majruszsaccessories.reverse_card": "Reverse Card", "item.majruszsaccessories.secret_ingredient": "Secret Ingredient", "item.majruszsaccessories.soul_of_minecraft": "Soul of Minecraft", "item.majruszsaccessories.swimmer_guide": "Swimmer Guide", @@ -57,7 +59,9 @@ "majruszsaccessories.boosters.experience_bonus": "%1$sIncreases experience gained by %2$s.", "majruszsaccessories.boosters.luck_bonus": "%1$sIncreases luck by %2$s.", "majruszsaccessories.boosters.efficiency_bonus": "%1$sIncreases efficiency bonus by %2$s.", - "majruszsaccessories.boosters.efficiency_negation": "%1$sNegates efficiency bonus.", + "majruszsaccessories.cards.redraw": "Redraws efficiency bonus.", + "majruszsaccessories.cards.remove": "Returns applied Accessory Boosters.", + "majruszsaccessories.cards.negate": "Negates efficiency bonus.", "advancements.majruszsaccessories.adventurer_kit.title": "Adventure Time", "advancements.majruszsaccessories.adventurer_kit.description": "Acquire an Adventurer Kit", "advancements.majruszsaccessories.ancient_scarab.title": "Is It Alive?", @@ -89,9 +93,11 @@ "advancements.majruszsaccessories.unbreakable_fishing_line.title": "Line Up For Fishes", "advancements.majruszsaccessories.unbreakable_fishing_line.description": "Acquire an Unbreakable Fishing Line", "advancements.majruszsaccessories.booster_dropped.title": "It Is Time For an Upgrade, Isn't It?", - "advancements.majruszsaccessories.booster_dropped.description": "Acquire Any Accessory Booster", + "advancements.majruszsaccessories.booster_dropped.description": "Acquire any Accessory Booster", "advancements.majruszsaccessories.booster_used.title": "What a Boost!", - "advancements.majruszsaccessories.booster_used.description": "Use Any Accessory Booster", + "advancements.majruszsaccessories.booster_used.description": "Use any Accessory Booster", + "advancements.majruszsaccessories.booster_nice.title": "Nice", + "advancements.majruszsaccessories.booster_nice.description": "Acquire 69% efficiency bonus on any Accessory", "trinkets.slot.legs.pocket": "Pocket", "curios.identifier.pocket": "Pocket" } \ No newline at end of file diff --git a/common/src/main/resources/assets/majruszsaccessories/lang/pl_pl.json b/common/src/main/resources/assets/majruszsaccessories/lang/pl_pl.json index 4e34efc2..3db90bc4 100644 --- a/common/src/main/resources/assets/majruszsaccessories/lang/pl_pl.json +++ b/common/src/main/resources/assets/majruszsaccessories/lang/pl_pl.json @@ -9,12 +9,12 @@ "item.majruszsaccessories.dice": "Kostka", "item.majruszsaccessories.discount_voucher": "Kupon rabatowy", "item.majruszsaccessories.dream_catcher": "Łapacz snów", + "item.majruszsaccessories.gambling_card": "Karta hazardowa", "item.majruszsaccessories.golden_dice": "Złota kostka", "item.majruszsaccessories.golden_horseshoe": "Złota podkowa", "item.majruszsaccessories.horseshoe": "Podkowa", "item.majruszsaccessories.household_rune": "Runa gospodarstwa domowego", "item.majruszsaccessories.idol_of_fertility": "Bożek płodności", - "item.majruszsaccessories.jadeite": "Jadeit", "item.majruszsaccessories.lucky_rock": "Szczęśliwy kamień", "item.majruszsaccessories.metal_lure": "Metalowa przynęta", "item.majruszsaccessories.miner_guide": "Przewodnik wydobywniczy", @@ -22,6 +22,8 @@ "item.majruszsaccessories.nature_rune": "Runa natury", "item.majruszsaccessories.onyx": "Onyks", "item.majruszsaccessories.owl_feather": "Pióro sowy", + "item.majruszsaccessories.removal_card": "Karta usunięcia", + "item.majruszsaccessories.reverse_card": "Karta rewersu", "item.majruszsaccessories.secret_ingredient": "Sekretny składnik", "item.majruszsaccessories.soul_of_minecraft": "Dusza Minecrafta", "item.majruszsaccessories.swimmer_guide": "Przewodnik pływacki", @@ -57,7 +59,9 @@ "majruszsaccessories.boosters.experience_bonus": "%1$sZwiększa zdobywane doświadczenie o %2$s.", "majruszsaccessories.boosters.luck_bonus": "%1$sZwiększa szczęście o %2$s.", "majruszsaccessories.boosters.efficiency_bonus": "%1$sZwiększa bonus wydajności o %2$s.", - "majruszsaccessories.boosters.efficiency_negation": "%1$sNeguje bonus wydajności.", + "majruszsaccessories.cards.redraw": "Losuje bonus wydajności na nowo.", + "majruszsaccessories.cards.remove": "Zwraca nałożone wzmacniacze akcesoriów.", + "majruszsaccessories.cards.negate": "Neguje bonus wydajności.", "advancements.majruszsaccessories.adventurer_kit.title": "Pora na przygodę", "advancements.majruszsaccessories.adventurer_kit.description": "Zdobądź zestaw podróżniczy", "advancements.majruszsaccessories.ancient_scarab.title": "Czy to żyje?", @@ -91,7 +95,9 @@ "advancements.majruszsaccessories.booster_dropped.title": "Czy to nie czas na wzmocnienie?", "advancements.majruszsaccessories.booster_dropped.description": "Zdobądź dowolny wzmacniacz akcesoriów", "advancements.majruszsaccessories.booster_used.title": "Co za wzmocnienie!", - "advancements.majruszsaccessories.booster_used.description": "Wykorzystaj dowolny wzmacniacz akcesoriów", + "advancements.majruszsaccessories.booster_used.description": "Użyj dowolny wzmacniacz akcesoriów", + "advancements.majruszsaccessories.booster_nice.title": "Nice", + "advancements.majruszsaccessories.booster_nice.description": "Zdobądź 69% bonusu wydajności na dowolnym z akcesoriów", "trinkets.slot.legs.pocket": "Kieszeń", "curios.identifier.pocket": "Kieszeń" } \ No newline at end of file diff --git a/common/src/main/resources/assets/majruszsaccessories/lang/zh_cn.json b/common/src/main/resources/assets/majruszsaccessories/lang/zh_cn.json index 044c3d5f..f1d8c93b 100644 --- a/common/src/main/resources/assets/majruszsaccessories/lang/zh_cn.json +++ b/common/src/main/resources/assets/majruszsaccessories/lang/zh_cn.json @@ -1,41 +1,97 @@ { - "itemGroup.majruszsaccessories.primary": "Majrusz的配件", + "itemGroup.majruszsaccessories.primary": "Majrusz的饰品", + "item.majruszsaccessories.adventurer_kit": "冒险者套件", + "item.majruszsaccessories.adventurer_rune": "冒险者符文", + "item.majruszsaccessories.ancient_scarab": "远古甲虫", + "item.majruszsaccessories.angler_rune": "垂钓者符文", "item.majruszsaccessories.angler_trophy": "垂钓者勋章", - "item.majruszsaccessories.certificate_of_taming": "驯服证书", - "item.majruszsaccessories.idol_of_fertility": "生育偶像", - "item.majruszsaccessories.lucky_rock": "幸运石", - "item.majruszsaccessories.secret_ingredient": "药剂秘方", - "item.majruszsaccessories.tamed_potato_beetle": "驯服的马铃薯甲虫", - "item.majruszsaccessories.white_flag": "白旗", - "item.majruszsaccessories.overworld_rune": "主世界符文", - "majruszsaccessories.items.accessory_item": "放在另一只手时生效", + "item.majruszsaccessories.certificate_of_taming": "驯化之证", + "item.majruszsaccessories.dice": "骰子", + "item.majruszsaccessories.discount_voucher": "折扣券", + "item.majruszsaccessories.dream_catcher": "捕梦网", + "item.majruszsaccessories.golden_dice": "黄金骰子", + "item.majruszsaccessories.golden_horseshoe": "黄金马蹄", + "item.majruszsaccessories.horseshoe": "马蹄", + "item.majruszsaccessories.household_rune": "皇家符文", + "item.majruszsaccessories.idol_of_fertility": "繁育神像", + "item.majruszsaccessories.jadeite": "翡翠", + "item.majruszsaccessories.lucky_rock": "幸运岩石", + "item.majruszsaccessories.metal_lure": "金属诱饵", + "item.majruszsaccessories.miner_guide": "矿工指南", + "item.majruszsaccessories.miner_rune": "矿工符文", + "item.majruszsaccessories.nature_rune": "自然符文", + "item.majruszsaccessories.onyx": "黑玛瑙", + "item.majruszsaccessories.owl_feather": "猫头鹰羽毛", + "item.majruszsaccessories.secret_ingredient": "药水秘方", + "item.majruszsaccessories.soul_of_minecraft": "世界之魂", + "item.majruszsaccessories.swimmer_guide": "游泳者指南", + "item.majruszsaccessories.tamed_potato_beetle": "被驯化的马铃薯甲虫", + "item.majruszsaccessories.tool_scraps": "工具残片", + "item.majruszsaccessories.unbreakable_fishing_line": "强力鱼线", + "majruszsaccessories.items.accessory_item": "放在副手时生效", "majruszsaccessories.items.bonus": "%1$s 效果加成", "majruszsaccessories.items.formula": "%1$s%2$s", - "majruszsaccessories.items.page": "--- 第 %1$s 页/共 %2$s 页 ---", - "majruszsaccessories.bonuses.fishing_luck": "在钓鱼时增加 %1$s 的幸运", - "majruszsaccessories.bonuses.extra_stone_loot": "在挖矿时会有 %1$s 的几率开采到额外的战利品", - "majruszsaccessories.bonuses.spawn_twins": "在繁殖动物时会有 %1$s 的几率产下双胞胎", - "majruszsaccessories.bonuses.potion_amplifier": "使制作的药水强上 %1$s 级", - "majruszsaccessories.bonuses.potion_duration": "将制作药水所需的时间缩短 %1$s。", - "majruszsaccessories.bonuses.potion_name": "蒸馏的药水", - "majruszsaccessories.bonuses.double_crops": "在收获时会有 %1$s 的几率掉落双倍的战利品", - "advancements.majruszsaccessories.adventurer_kit.title": "冒险时间到!", - "advancements.majruszsaccessories.adventurer_kit.description": "获取探险者手册", - "advancements.majruszsaccessories.angler_trophy.title": "多么苗条美丽的标本", - "advancements.majruszsaccessories.angler_trophy.description": "获取垂钓者勋章", - "advancements.majruszsaccessories.certificate_of_taming.title": "必须抓住所有生物!", - "advancements.majruszsaccessories.certificate_of_taming.description": "获得驯服证书", - "advancements.majruszsaccessories.idol_of_fertility.title": "动物周:双倍成长的动物们", - "advancements.majruszsaccessories.idol_of_fertility.description": "获得生育偶像", - "advancements.majruszsaccessories.lucky_rock.title": "形状完美的石头", - "advancements.majruszsaccessories.lucky_rock.description": "获得幸运石", + "majruszsaccessories.items.range": "[%1$s~%2$s]", + "majruszsaccessories.items.page": "--- 第 %1$s 页 / 共 %2$s 页 ---", + "majruszsaccessories.items.booster_tooltip": "饰品配件", + "majruszsaccessories.items.booster_name": "[%1$s]", + "majruszsaccessories.items.booster_empty": "[饰品配件槽位]", + "majruszsaccessories.bonuses.fishing_luck": "钓鱼时增加%1$s幸运", + "majruszsaccessories.bonuses.fishing_lure": "减少%1$s钓鱼时间", + "majruszsaccessories.bonuses.extra_stone_loot": "采集时增加%1$s额外掉落率", + "majruszsaccessories.bonuses.spawn_twins": "饲养的动物有%1$s概率产下两只幼崽", + "majruszsaccessories.bonuses.potion_amplifier": "使制作的药水额外提高%1$s级", + "majruszsaccessories.bonuses.potion_duration": "减少%1$s药水制作时间", + "majruszsaccessories.bonuses.potion_name": "蒸馏药水", + "majruszsaccessories.bonuses.animal_attributes": "驯服时增加%1$s动物属性", + "majruszsaccessories.bonuses.more_chest_loot": "距离出生点越远的箱子的战利品越丰富,每隔一个方块增加%1$s ,最多增加%2$s (总共增加 %3$s)", + "majruszsaccessories.bonuses.double_crops": "收获作物时有%1$s概率双倍收获", + "majruszsaccessories.bonuses.extra_archaeology_item": "对可疑的方块使用刷子时有%1$s概率获得额外物品", + "majruszsaccessories.bonuses.mine_bonus": "提高%1$s采集速度", + "majruszsaccessories.bonuses.swim_bonus": "提高%1$s游泳速度", + "majruszsaccessories.bonuses.extra_fishing_items": "垂钓时有%1$s概率钓到%2$s件物品", + "majruszsaccessories.bonuses.trading_discount": "交易时降低%1$s物品价格", + "majruszsaccessories.bonuses.free_durability_cost": "使用物品时有%1$s概率不消耗耐久值", + "majruszsaccessories.bonuses.sleep_bonuses": "醒来时给予%1$s个随机效果,持续%2$s秒", + "majruszsaccessories.boosters.drop_chance": "%1$s增加饰品%2$s掉落概率", + "majruszsaccessories.boosters.experience_bonus": "%1$s增加%2$s经验获取", + "majruszsaccessories.boosters.luck_bonus": "%1$s增加%2$s幸运", + "majruszsaccessories.boosters.efficiency_bonus": "%1$s增加%2$s饰品效果", + "majruszsaccessories.boosters.efficiency_negation": "%1$s将负值效果加成转换为正", + "advancements.majruszsaccessories.adventurer_kit.title": "冒险时间!", + "advancements.majruszsaccessories.adventurer_kit.description": "获得冒险者套件", + "advancements.majruszsaccessories.ancient_scarab.title": "它还活着吗?", + "advancements.majruszsaccessories.ancient_scarab.description": "获得远古甲虫", + "advancements.majruszsaccessories.angler_trophy.title": "多么美丽的标本!", + "advancements.majruszsaccessories.angler_trophy.description": "获得垂钓者勋章", + "advancements.majruszsaccessories.certificate_of_taming.title": "把它们都抓起来!", + "advancements.majruszsaccessories.certificate_of_taming.description": "获得驯化之证", + "advancements.majruszsaccessories.discount_voucher.title": "我的,都是我的!", + "advancements.majruszsaccessories.discount_voucher.description": "获得折扣券", + "advancements.majruszsaccessories.dream_catcher.title": "美梦啊!", + "advancements.majruszsaccessories.dream_catcher.description": "获得捕梦网", + "advancements.majruszsaccessories.idol_of_fertility.title": "动物周 - 动物生产翻倍", + "advancements.majruszsaccessories.idol_of_fertility.description": "获得繁育神像", + "advancements.majruszsaccessories.lucky_rock.title": "鬼斧神工的岩石", + "advancements.majruszsaccessories.lucky_rock.description": "获得幸运岩石", + "advancements.majruszsaccessories.metal_lure.title": "永不空军", + "advancements.majruszsaccessories.metal_lure.description": "获得金属诱饵", + "advancements.majruszsaccessories.miner_guide.title": "地下再无秘密", + "advancements.majruszsaccessories.miner_guide.description": "获得矿工指南", "advancements.majruszsaccessories.secret_ingredient.title": "一缕爱意", - "advancements.majruszsaccessories.secret_ingredient.description": "获得药剂秘方", - "advancements.majruszsaccessories.tamed_potato_beetle.title": "从敌人到朋友", - "advancements.majruszsaccessories.tamed_potato_beetle.description": "获得驯服的马铃薯甲虫", - "advancements.majruszsaccessories.white_flag.title": "暴力从来都是不可取的", - "advancements.majruszsaccessories.white_flag.description": "获得白旗", - "advancements.majruszsaccessories.overworld_rune.title": "世间再无秘密可言", - "advancements.majruszsaccessories.overworld_rune.description": "获得主世界符文", + "advancements.majruszsaccessories.secret_ingredient.description": "获得药水秘方", + "advancements.majruszsaccessories.swimmer_guide.title": "大海再无秘密", + "advancements.majruszsaccessories.swimmer_guide.description": "获得游泳者指南", + "advancements.majruszsaccessories.tamed_potato_beetle.title": "可以共存吗?", + "advancements.majruszsaccessories.tamed_potato_beetle.description": "获得被驯化的马铃薯甲虫", + "advancements.majruszsaccessories.tool_scraps.title": "回收利用!", + "advancements.majruszsaccessories.tool_scraps.description": "获得工具残片", + "advancements.majruszsaccessories.unbreakable_fishing_line.title": "钓的不错,到我了", + "advancements.majruszsaccessories.unbreakable_fishing_line.description": "获得强力鱼线", + "advancements.majruszsaccessories.booster_dropped.title": "是时候升级一下了,不是吗?", + "advancements.majruszsaccessories.booster_dropped.description": "获得任意饰品配件", + "advancements.majruszsaccessories.booster_used.title": "强大的助力!", + "advancements.majruszsaccessories.booster_used.description": "使用任意饰品配件", + "trinkets.slot.legs.pocket": "口袋", "curios.identifier.pocket": "口袋" } diff --git a/common/src/main/resources/assets/majruszsaccessories/models/item/gambling_card.json b/common/src/main/resources/assets/majruszsaccessories/models/item/gambling_card.json new file mode 100644 index 00000000..1f1dd97b --- /dev/null +++ b/common/src/main/resources/assets/majruszsaccessories/models/item/gambling_card.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "majruszsaccessories:item/gambling_card" + } +} diff --git a/common/src/main/resources/assets/majruszsaccessories/models/item/jadeite.json b/common/src/main/resources/assets/majruszsaccessories/models/item/removal_card.json similarity index 50% rename from common/src/main/resources/assets/majruszsaccessories/models/item/jadeite.json rename to common/src/main/resources/assets/majruszsaccessories/models/item/removal_card.json index 2109b904..bc5f88c0 100644 --- a/common/src/main/resources/assets/majruszsaccessories/models/item/jadeite.json +++ b/common/src/main/resources/assets/majruszsaccessories/models/item/removal_card.json @@ -1,6 +1,6 @@ { "parent": "item/generated", "textures": { - "layer0": "majruszsaccessories:item/jadeite" + "layer0": "majruszsaccessories:item/removal_card" } } diff --git a/common/src/main/resources/assets/majruszsaccessories/models/item/reverse_card.json b/common/src/main/resources/assets/majruszsaccessories/models/item/reverse_card.json new file mode 100644 index 00000000..9b32e5a8 --- /dev/null +++ b/common/src/main/resources/assets/majruszsaccessories/models/item/reverse_card.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "majruszsaccessories:item/reverse_card" + } +} diff --git a/common/src/main/resources/assets/majruszsaccessories/particles/bonus_strong.json b/common/src/main/resources/assets/majruszsaccessories/particles/bonus_strong.json deleted file mode 100644 index eb46c0d3..00000000 --- a/common/src/main/resources/assets/majruszsaccessories/particles/bonus_strong.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "textures": [ - "majruszsaccessories:bonus_1", - "majruszsaccessories:bonus_2", - "majruszsaccessories:bonus_3" - ] -} \ No newline at end of file diff --git a/common/src/main/resources/assets/majruszsaccessories/particles/bonus_weak.json b/common/src/main/resources/assets/majruszsaccessories/particles/bonus_weak.json deleted file mode 100644 index eb46c0d3..00000000 --- a/common/src/main/resources/assets/majruszsaccessories/particles/bonus_weak.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "textures": [ - "majruszsaccessories:bonus_1", - "majruszsaccessories:bonus_2", - "majruszsaccessories:bonus_3" - ] -} \ No newline at end of file diff --git a/common/src/main/resources/assets/majruszsaccessories/textures/item/gambling_card.png b/common/src/main/resources/assets/majruszsaccessories/textures/item/gambling_card.png new file mode 100644 index 00000000..cd13d420 Binary files /dev/null and b/common/src/main/resources/assets/majruszsaccessories/textures/item/gambling_card.png differ diff --git a/common/src/main/resources/assets/majruszsaccessories/textures/item/jadeite.png b/common/src/main/resources/assets/majruszsaccessories/textures/item/jadeite.png deleted file mode 100644 index fbe217da..00000000 Binary files a/common/src/main/resources/assets/majruszsaccessories/textures/item/jadeite.png and /dev/null differ diff --git a/common/src/main/resources/assets/majruszsaccessories/textures/item/removal_card.png b/common/src/main/resources/assets/majruszsaccessories/textures/item/removal_card.png new file mode 100644 index 00000000..0ae1a000 Binary files /dev/null and b/common/src/main/resources/assets/majruszsaccessories/textures/item/removal_card.png differ diff --git a/common/src/main/resources/assets/majruszsaccessories/textures/item/reverse_card.png b/common/src/main/resources/assets/majruszsaccessories/textures/item/reverse_card.png new file mode 100644 index 00000000..81ccabe5 Binary files /dev/null and b/common/src/main/resources/assets/majruszsaccessories/textures/item/reverse_card.png differ diff --git a/common/src/main/resources/data/majruszsaccessories/advancements/booster_dropped.json b/common/src/main/resources/data/majruszsaccessories/advancements/booster_dropped.json index 7c695541..1e92cb2f 100644 --- a/common/src/main/resources/data/majruszsaccessories/advancements/booster_dropped.json +++ b/common/src/main/resources/data/majruszsaccessories/advancements/booster_dropped.json @@ -2,8 +2,7 @@ "parent": "minecraft:adventure/root", "display": { "icon": { - "item": "majruszsaccessories:dice", - "nbt": "{Bonus:{Booster:\"any\"}}" + "item": "majruszsaccessories:dice" }, "title": { "translate": "advancements.majruszsaccessories.booster_dropped.title" @@ -30,7 +29,8 @@ "majruszsaccessories:golden_dice", "majruszsaccessories:owl_feather", "majruszsaccessories:horseshoe", - "majruszsaccessories:golden_horseshoe" + "majruszsaccessories:golden_horseshoe", + "majruszsaccessories:onyx" ] } ] diff --git a/common/src/main/resources/data/majruszsaccessories/advancements/booster_nice.json b/common/src/main/resources/data/majruszsaccessories/advancements/booster_nice.json new file mode 100644 index 00000000..f61710a0 --- /dev/null +++ b/common/src/main/resources/data/majruszsaccessories/advancements/booster_nice.json @@ -0,0 +1,34 @@ +{ + "parent": "majruszsaccessories:booster_dropped", + "display": { + "icon": { + "item": "majruszsaccessories:onyx" + }, + "title": { + "translate": "advancements.majruszsaccessories.booster_nice.title" + }, + "description": { + "translate": "advancements.majruszsaccessories.booster_nice.description" + }, + "frame": "challenge", + "show_toast": true, + "announce_to_chat": true, + "hidden": false + }, + "rewards": { + "experience": 100 + }, + "criteria": { + "booster_nice": { + "trigger": "majruszsaccessories:basic_trigger", + "conditions": { + "type": "booster_nice" + } + } + }, + "requirements": [ + [ + "booster_nice" + ] + ] +} \ No newline at end of file diff --git a/common/src/main/resources/data/majruszsaccessories/advancements/booster_used.json b/common/src/main/resources/data/majruszsaccessories/advancements/booster_used.json index e021e3bb..f49679d7 100644 --- a/common/src/main/resources/data/majruszsaccessories/advancements/booster_used.json +++ b/common/src/main/resources/data/majruszsaccessories/advancements/booster_used.json @@ -2,8 +2,7 @@ "parent": "majruszsaccessories:booster_dropped", "display": { "icon": { - "item": "majruszsaccessories:dice", - "nbt": "{Bonus:{Booster:\"any\"}}" + "item": "majruszsaccessories:dice" }, "title": { "translate": "advancements.majruszsaccessories.booster_used.title" diff --git a/common/src/main/resources/data/majruszsaccessories/loot_tables/gameplay/nether_accessories.json b/common/src/main/resources/data/majruszsaccessories/loot_tables/gameplay/nether_accessories.json index ac9a5b36..b5bbc8ca 100644 --- a/common/src/main/resources/data/majruszsaccessories/loot_tables/gameplay/nether_accessories.json +++ b/common/src/main/resources/data/majruszsaccessories/loot_tables/gameplay/nether_accessories.json @@ -12,10 +12,6 @@ "type": "minecraft:item", "name": "majruszsaccessories:horseshoe" }, - { - "type": "minecraft:item", - "name": "majruszsaccessories:jadeite" - }, { "type": "minecraft:item", "name": "majruszsaccessories:onyx" diff --git a/common/src/main/resources/data/majruszsaccessories/recipes/boost_accessories.json b/common/src/main/resources/data/majruszsaccessories/recipes/boost_accessories.json deleted file mode 100644 index 22452b23..00000000 --- a/common/src/main/resources/data/majruszsaccessories/recipes/boost_accessories.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "majruszsaccessories:crafting_boost_accessories" -} \ No newline at end of file diff --git a/common/src/main/resources/data/majruszsaccessories/recipes/boost_accessory.json b/common/src/main/resources/data/majruszsaccessories/recipes/boost_accessory.json new file mode 100644 index 00000000..b24414ed --- /dev/null +++ b/common/src/main/resources/data/majruszsaccessories/recipes/boost_accessory.json @@ -0,0 +1,3 @@ +{ + "type": "majruszsaccessories:crafting_boost_accessory" +} \ No newline at end of file diff --git a/common/src/main/resources/data/majruszsaccessories/recipes/use_card.json b/common/src/main/resources/data/majruszsaccessories/recipes/use_card.json new file mode 100644 index 00000000..218940d3 --- /dev/null +++ b/common/src/main/resources/data/majruszsaccessories/recipes/use_card.json @@ -0,0 +1,3 @@ +{ + "type": "majruszsaccessories:crafting_use_card" +} \ No newline at end of file diff --git a/common/src/main/resources/majruszsaccessories-common.mixins.json b/common/src/main/resources/majruszsaccessories-common.mixins.json new file mode 100644 index 00000000..b7240ab5 --- /dev/null +++ b/common/src/main/resources/majruszsaccessories-common.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "package": "com.majruszsaccessories.mixin", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "refmap": "majruszsaccessories.refmap.json", + "client": [], + "mixins": [ + "MixinLivingEntity" + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 633e9e66..88eb6186 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -16,6 +16,9 @@ "entrypoints": { "main": [ "com.${mod_id}.Initializer" ] }, + "mixins": [ + "${mod_id}-common.mixins.json" + ], "depends": { "fabric": "*", "minecraft": "${fabric_minecraft_version_range}", diff --git a/forge/build.gradle b/forge/build.gradle index e8306f33..c6187074 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -138,6 +138,11 @@ jar { } } +mixin { + add sourceSets.main, "${mod_id}.refmap.json" + config "${mod_id}-common.mixins.json" +} + processResources { from project(':common').sourceSets.main.resources filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { diff --git a/gradle.properties b/gradle.properties index 3f119cbc..7a50cef9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ minecraft_version=1.20.1 # Mod mod_id=majruszsaccessories mod_archives_name=majruszs-accessories -mod_version=1.3.4 +mod_version=1.4.0 mod_display_name=Majrusz's Accessories mod_description=Mod that adds new special accessories to make certain aspects of the game more enjoyable. mod_authors=Majrusz diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 84671608..e9b8e393 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -138,6 +138,11 @@ jar { } } +mixin { + add sourceSets.main, "${mod_id}.refmap.json" + config "${mod_id}-common.mixins.json" +} + processResources { from project(':common').sourceSets.main.resources filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {