diff --git a/changelog.md b/changelog.md index 6fe534d1..811f89b9 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1 @@ -- changed required Majrusz Library version from 6.1.0+ to 6.1.7+ -- fixed game crash `java.lang.NullPointerException: Registry Object not present` (reported by @Note, @PlayfulPiano) -- fixed exploit with duplicating items and chests (reported by @Ladocterus, @HeavyDeception) \ No newline at end of file +- changed required Majrusz Library version from 6.1.7+ to 7.0.0+ \ No newline at end of file diff --git a/common/build.gradle b/common/build.gradle index 5de09f1b..2a40decd 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -19,7 +19,7 @@ repositories { dependencies { compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5' - implementation "com.mlib:majrusz-library-common:${mlib_version}" + implementation "com.majruszlibrary:majrusz-library-common:${majruszlibrary_version}" } java { diff --git a/common/libs/majrusz-library-common-1.20.1-6.1.7.jar b/common/libs/majrusz-library-common-1.20.1-6.1.7.jar deleted file mode 100644 index 51b728ee..00000000 Binary files a/common/libs/majrusz-library-common-1.20.1-6.1.7.jar and /dev/null differ diff --git a/common/libs/majrusz-library-common-1.20.1-7.0.0.jar b/common/libs/majrusz-library-common-1.20.1-7.0.0.jar new file mode 100644 index 00000000..a16f812b Binary files /dev/null and b/common/libs/majrusz-library-common-1.20.1-7.0.0.jar differ diff --git a/common/src/main/java/com/majruszsaccessories/MajruszsAccessories.java b/common/src/main/java/com/majruszsaccessories/MajruszsAccessories.java index 5f7eb32f..37a74f6d 100644 --- a/common/src/main/java/com/majruszsaccessories/MajruszsAccessories.java +++ b/common/src/main/java/com/majruszsaccessories/MajruszsAccessories.java @@ -1,5 +1,16 @@ package com.majruszsaccessories; +import com.majruszlibrary.annotation.Dist; +import com.majruszlibrary.annotation.OnlyIn; +import com.majruszlibrary.emitter.ParticleEmitter; +import com.majruszlibrary.events.OnGameInitialized; +import com.majruszlibrary.math.Random; +import com.majruszlibrary.modhelper.ModHelper; +import com.majruszlibrary.network.NetworkObject; +import com.majruszlibrary.platform.Services; +import com.majruszlibrary.registry.Custom; +import com.majruszlibrary.registry.RegistryGroup; +import com.majruszlibrary.registry.RegistryObject; import com.majruszsaccessories.accessories.components.MoreChestLoot; import com.majruszsaccessories.config.Config; import com.majruszsaccessories.integration.ISlotPlatform; @@ -12,17 +23,6 @@ import com.majruszsaccessories.recipes.AccessoryRecipe; import com.majruszsaccessories.recipes.BoostAccessoriesRecipe; import com.majruszsaccessories.recipes.CombineAccessoriesRecipe; -import com.mlib.annotation.Dist; -import com.mlib.annotation.OnlyIn; -import com.mlib.contexts.OnGameInitialized; -import com.mlib.emitter.ParticleEmitter; -import com.mlib.math.Random; -import com.mlib.modhelper.ModHelper; -import com.mlib.network.NetworkObject; -import com.mlib.platform.Services; -import com.mlib.registry.Custom; -import com.mlib.registry.RegistryGroup; -import com.mlib.registry.RegistryObject; import net.minecraft.core.particles.ParticleType; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; @@ -35,7 +35,9 @@ public class MajruszsAccessories { public static final ModHelper HELPER = ModHelper.create( MOD_ID ); // Configs - public static final Config CONFIG = HELPER.config( Config::new ).autoSync().create(); + static { + HELPER.config( Config.class ).autoSync().create(); + } // Registry Groups public static final RegistryGroup< Item > ITEMS = HELPER.create( BuiltInRegistries.ITEM ); diff --git a/common/src/main/java/com/majruszsaccessories/accessories/AdventurerKit.java b/common/src/main/java/com/majruszsaccessories/accessories/AdventurerKit.java index d52bad50..9242c2a6 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/AdventurerKit.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/AdventurerKit.java @@ -1,5 +1,8 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.MoreChestLoot; import com.majruszsaccessories.accessories.components.TradeOffer; @@ -8,14 +11,11 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.data.Serializable; -import com.mlib.math.Range; @AutoInstance public class AdventurerKit extends AccessoryHandler { public AdventurerKit() { - super( MajruszsAccessories.ADVENTURER_KIT ); + super( MajruszsAccessories.ADVENTURER_KIT, AdventurerKit.class ); this.add( MoreChestLoot.create( 1.2f ) ) .add( AnyChestDropChance.create() ) @@ -35,8 +35,8 @@ protected AnyChestDropChance( BonusHandler< AccessoryItem > handler ) { MoreChestLoot.OnChestOpened.listen( this::addToGeneratedLoot ) .addCondition( CustomConditions.dropChance( ()->this.chance, data->MoreChestLoot.OnChestOpened.findPlayer( data ).orElse( null ) ) ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "any_chest_spawn_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); + handler.getConfig() + .define( "any_chest_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/AdventurerRune.java b/common/src/main/java/com/majruszsaccessories/accessories/AdventurerRune.java index 9397581f..05c7fe89 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/AdventurerRune.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/AdventurerRune.java @@ -1,17 +1,17 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; import com.majruszsaccessories.MajruszsAccessories; 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; -import com.mlib.annotation.AutoInstance; @AutoInstance public class AdventurerRune extends AccessoryHandler { public AdventurerRune() { - super( MajruszsAccessories.ADVENTURER_RUNE ); + super( MajruszsAccessories.ADVENTURER_RUNE, AdventurerRune.class ); this.add( MoreChestLoot.create( 1.5f ) ) .add( BrushingExtraItem.create( 0.2f ) ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/AncientScarab.java b/common/src/main/java/com/majruszsaccessories/accessories/AncientScarab.java index 17d23341..2c6b78d2 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/AncientScarab.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/AncientScarab.java @@ -1,5 +1,10 @@ package com.majruszsaccessories.accessories; +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.accessories.components.BrushingExtraItem; import com.majruszsaccessories.accessories.components.TradeOffer; @@ -8,11 +13,6 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializable; -import com.mlib.math.Range; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.storage.loot.BuiltInLootTables; @@ -22,7 +22,7 @@ @AutoInstance public class AncientScarab extends AccessoryHandler { public AncientScarab() { - super( MajruszsAccessories.ANCIENT_SCARAB ); + super( MajruszsAccessories.ANCIENT_SCARAB, AncientScarab.class ); this.add( BrushingExtraItem.create( 0.16f ) ) .add( SuspiciousBlocksDropChance.create() ) @@ -54,9 +54,9 @@ protected SuspiciousBlocksDropChance( BonusHandler< AccessoryItem > handler ) { .addCondition( data->this.locations.contains( data.lootId ) ) .addCondition( data->data.origin != null ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "suspicious_block_spawn_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); - config.defineLocationList( "suspicious_block_ids", s->this.locations, ( s, v )->this.locations = v ); + handler.getConfig() + .define( "suspicious_block_spawn_chance", Reader.number(), s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ) + .define( "suspicious_block_ids", Reader.list( Reader.location() ), s->this.locations, ( s, v )->this.locations = v ); } } } diff --git a/common/src/main/java/com/majruszsaccessories/accessories/AnglerRune.java b/common/src/main/java/com/majruszsaccessories/accessories/AnglerRune.java index 2f2a324b..a8fdb91d 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/AnglerRune.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/AnglerRune.java @@ -1,17 +1,17 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; import com.majruszsaccessories.MajruszsAccessories; 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; -import com.mlib.annotation.AutoInstance; @AutoInstance public class AnglerRune extends AccessoryHandler { public AnglerRune() { - super( MajruszsAccessories.ANGLER_RUNE ); + super( MajruszsAccessories.ANGLER_RUNE, AnglerRune.class ); this.add( FishingLuckBonus.create( 3 ) ) .add( FishingLureBonus.create( 0.25f ) ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/AnglerTrophy.java b/common/src/main/java/com/majruszsaccessories/accessories/AnglerTrophy.java index 5147dc0e..06ec9aaf 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/AnglerTrophy.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/AnglerTrophy.java @@ -1,5 +1,11 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.events.OnItemFished; +import com.majruszlibrary.events.OnLootGenerated; +import com.majruszlibrary.math.Range; +import com.majruszlibrary.registry.Registries; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.FishingLuckBonus; import com.majruszsaccessories.accessories.components.TradeOffer; @@ -8,12 +14,6 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnItemFished; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.data.Serializable; -import com.mlib.math.Range; -import com.mlib.registry.Registries; import net.minecraft.resources.ResourceLocation; import java.util.List; @@ -22,7 +22,7 @@ @AutoInstance public class AnglerTrophy extends AccessoryHandler { public AnglerTrophy() { - super( MajruszsAccessories.ANGLER_TROPHY ); + super( MajruszsAccessories.ANGLER_TROPHY, AnglerTrophy.class ); this.add( FishingLuckBonus.create( 3 ) ) .add( FishingDropChance.create( 0.01f ) ) @@ -44,8 +44,8 @@ protected FishingDropChance( BonusHandler< AccessoryItem > handler, float chance OnItemFished.listen( this::onFished ) .addCondition( CustomConditions.dropChance( s->this.fishingChance, data->data.player ) ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "fishing_drop_chance", s->this.fishingChance, ( s, v )->this.fishingChance = Range.CHANCE.clamp( v ) ); + handler.getConfig() + .define( "fishing_drop_chance", Reader.number(), s->this.fishingChance, ( s, v )->this.fishingChance = Range.CHANCE.clamp( v ) ); } private void onFished( OnItemFished data ) { @@ -73,12 +73,12 @@ protected FishDropChance( BonusHandler< AccessoryItem > handler, float chance ) OnLootGenerated.listen( this::addToGeneratedLoot ) .addCondition( data->data.entity != null ) - .addCondition( data->this.lootIds.contains( Registries.get( data.entity.getType() ) ) ) + .addCondition( data->this.lootIds.contains( Registries.ENTITY_TYPES.getId( data.entity.getType() ) ) ) .addCondition( CustomConditions.dropChance( s->this.fishChance, data->data.killer ) ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "fish_drop_chance", s->this.fishChance, ( s, v )->this.fishChance = Range.CHANCE.clamp( v ) ); - config.defineLocationList( "fish_ids", s->this.lootIds, ( s, v )->this.lootIds = v ); + handler.getConfig() + .define( "fish_drop_chance", Reader.number(), s->this.fishChance, ( s, v )->this.fishChance = Range.CHANCE.clamp( v ) ) + .define( "fish_ids", Reader.list( Reader.location() ), s->this.lootIds, ( s, v )->this.lootIds = v ); } } } diff --git a/common/src/main/java/com/majruszsaccessories/accessories/CertificateOfTaming.java b/common/src/main/java/com/majruszsaccessories/accessories/CertificateOfTaming.java index e8ad8022..ff47065c 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/CertificateOfTaming.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/CertificateOfTaming.java @@ -1,5 +1,9 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.events.OnAnimalTamed; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.TamingStrongerAnimals; import com.majruszsaccessories.accessories.components.TradeOffer; @@ -8,15 +12,11 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnAnimalTamed; -import com.mlib.data.Serializable; -import com.mlib.math.Range; @AutoInstance public class CertificateOfTaming extends AccessoryHandler { public CertificateOfTaming() { - super( MajruszsAccessories.CERTIFICATE_OF_TAMING ); + super( MajruszsAccessories.CERTIFICATE_OF_TAMING, CertificateOfTaming.class ); this.add( TamingStrongerAnimals.create( 0.2f ) ) .add( TamingDropChance.create() ) @@ -36,8 +36,8 @@ protected TamingDropChance( BonusHandler< AccessoryItem > handler ) { OnAnimalTamed.listen( this::spawnCertificate ) .addCondition( CustomConditions.dropChance( s->this.chance, data->data.tamer ) ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "taming_drop_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); + handler.getConfig() + .define( "taming_drop_chance", Reader.number(), s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); } private void spawnCertificate( OnAnimalTamed data ) { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/DiscountVoucher.java b/common/src/main/java/com/majruszsaccessories/accessories/DiscountVoucher.java index 0f182c18..56fa194c 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/DiscountVoucher.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/DiscountVoucher.java @@ -1,5 +1,10 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.events.OnItemTraded; +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; @@ -8,16 +13,11 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnItemTraded; -import com.mlib.data.Serializable; -import com.mlib.math.AnyPos; -import com.mlib.math.Range; @AutoInstance public class DiscountVoucher extends AccessoryHandler { public DiscountVoucher() { - super( MajruszsAccessories.DISCOUNT_VOUCHER ); + super( MajruszsAccessories.DISCOUNT_VOUCHER, DiscountVoucher.class ); this.add( TradingDiscount.create( 0.12f ) ) .add( TradingDropChance.create() ) @@ -37,8 +37,8 @@ protected TradingDropChance( BonusHandler< AccessoryItem > handler ) { OnItemTraded.listen( this::spawnAccessory ) .addCondition( CustomConditions.dropChance( s->this.chance, data->data.player ) ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "trading_drop_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); + handler.getConfig() + .define( "trading_drop_chance", Reader.number(), s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); } private void spawnAccessory( OnItemTraded data ) { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/DreamCatcher.java b/common/src/main/java/com/majruszsaccessories/accessories/DreamCatcher.java index 54149897..19928cfc 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/DreamCatcher.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/DreamCatcher.java @@ -1,5 +1,10 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.events.OnPlayerWakedUp; +import com.majruszlibrary.events.base.Condition; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.SleepingBonuses; import com.majruszsaccessories.accessories.components.TradeOffer; @@ -8,16 +13,11 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnPlayerWakedUp; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializable; -import com.mlib.math.Range; @AutoInstance public class DreamCatcher extends AccessoryHandler { public DreamCatcher() { - super( MajruszsAccessories.DREAM_CATCHER ); + super( MajruszsAccessories.DREAM_CATCHER, DreamCatcher.class ); this.add( SleepingBonuses.create( 1, 300 ) ) .add( SleepingDropChance.create() ) @@ -39,8 +39,8 @@ protected SleepingDropChance( BonusHandler< AccessoryItem > handler ) { .addCondition( data->!data.wasSleepStoppedManually ) .addCondition( CustomConditions.dropChance( s->this.chance, data->data.player ) ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "sleeping_drop_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); + handler.getConfig() + .define( "sleeping_drop_chance", Reader.number(), s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); } private void spawnAccessory( OnPlayerWakedUp data ) { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/HouseholdRune.java b/common/src/main/java/com/majruszsaccessories/accessories/HouseholdRune.java index 32fa6f19..220aeac8 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/HouseholdRune.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/HouseholdRune.java @@ -1,17 +1,17 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; 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; -import com.mlib.annotation.AutoInstance; @AutoInstance public class HouseholdRune extends AccessoryHandler { public HouseholdRune() { - super( MajruszsAccessories.HOUSEHOLD_RUNE ); + super( MajruszsAccessories.HOUSEHOLD_RUNE, HouseholdRune.class ); this.add( TradingDiscount.create( 0.15f ) ) .add( SleepingBonuses.create( 1, 360 ) ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/IdolOfFertility.java b/common/src/main/java/com/majruszsaccessories/accessories/IdolOfFertility.java index 23c4a2c0..173e4937 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/IdolOfFertility.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/IdolOfFertility.java @@ -1,5 +1,10 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.events.OnBabySpawned; +import com.majruszlibrary.events.base.Condition; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.BreedingTwins; import com.majruszsaccessories.accessories.components.TradeOffer; @@ -8,16 +13,11 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnBabySpawned; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializable; -import com.mlib.math.Range; @AutoInstance public class IdolOfFertility extends AccessoryHandler { public IdolOfFertility() { - super( MajruszsAccessories.IDOL_OF_FERTILITY ); + super( MajruszsAccessories.IDOL_OF_FERTILITY, IdolOfFertility.class ); this.add( BreedingTwins.create( 0.25f ) ) .add( BreedingDropChance.create() ) @@ -39,8 +39,8 @@ protected BreedingDropChance( BonusHandler< AccessoryItem > handler ) { .addCondition( Condition.predicate( data->data.player != null ) ) .addCondition( CustomConditions.dropChance( s->this.chance, data->data.player ) ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "breeding_drop_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); + handler.getConfig() + .define( "breeding_drop_chance", Reader.number(), s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); } private void spawnTotem( OnBabySpawned data ) { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/LuckyRock.java b/common/src/main/java/com/majruszsaccessories/accessories/LuckyRock.java index 57263e9e..79d205c7 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/LuckyRock.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/LuckyRock.java @@ -1,5 +1,8 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.MiningExtraItem; import com.majruszsaccessories.accessories.components.TradeOffer; @@ -8,14 +11,11 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.data.Serializable; -import com.mlib.math.Range; @AutoInstance public class LuckyRock extends AccessoryHandler { public LuckyRock() { - super( MajruszsAccessories.LUCKY_ROCK ); + super( MajruszsAccessories.LUCKY_ROCK, LuckyRock.class ); this.add( MiningExtraItem.create( 0.03f ) ) .add( MiningDropChance.create() ) @@ -35,8 +35,8 @@ protected MiningDropChance( BonusHandler< AccessoryItem > handler ) { MiningExtraItem.OnStoneMined.listen( this::addToGeneratedLoot ) .addCondition( CustomConditions.dropChance( s->this.chance, data->data.entity ) ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "mining_drop_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); + handler.getConfig() + .define( "mining_drop_chance", Reader.number(), s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); } } } diff --git a/common/src/main/java/com/majruszsaccessories/accessories/MetalLure.java b/common/src/main/java/com/majruszsaccessories/accessories/MetalLure.java index b76ed743..f81ccf18 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/MetalLure.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/MetalLure.java @@ -1,15 +1,15 @@ package com.majruszsaccessories.accessories; +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.mlib.annotation.AutoInstance; @AutoInstance public class MetalLure extends AccessoryHandler { public MetalLure() { - super( MajruszsAccessories.METAL_LURE ); + super( MajruszsAccessories.METAL_LURE, MetalLure.class ); this.add( FishingExtraItems.create( 0.2f, 2 ) ) .add( AnglerTrophy.FishDropChance.create( 0.01f ) ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/MinerGuide.java b/common/src/main/java/com/majruszsaccessories/accessories/MinerGuide.java index f28499ff..735b356c 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/MinerGuide.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/MinerGuide.java @@ -1,5 +1,9 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.events.OnLootGenerated; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.MiningSpeedBonus; import com.majruszsaccessories.accessories.components.TradeOffer; @@ -8,15 +12,11 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.data.Serializable; -import com.mlib.math.Range; @AutoInstance public class MinerGuide extends AccessoryHandler { public MinerGuide() { - super( MajruszsAccessories.MINER_GUIDE ); + super( MajruszsAccessories.MINER_GUIDE, MinerGuide.class ); this.add( MiningSpeedBonus.create( 0.1f ) ) .add( UndergroundChestDropChance.create() ) @@ -38,8 +38,8 @@ protected UndergroundChestDropChance( BonusHandler< AccessoryItem > handler ) { .addCondition( data->data.lootId.toString().contains( "chest" ) ) .addCondition( CustomConditions.dropChance( s->this.chance, data->data.entity ) ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "underground_chest_spawn_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); + handler.getConfig() + .define( "underground_chest_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/MinerRune.java b/common/src/main/java/com/majruszsaccessories/accessories/MinerRune.java index 5dc6835d..b98a34fa 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/MinerRune.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/MinerRune.java @@ -1,17 +1,17 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; import com.majruszsaccessories.MajruszsAccessories; 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; -import com.mlib.annotation.AutoInstance; @AutoInstance public class MinerRune extends AccessoryHandler { public MinerRune() { - super( MajruszsAccessories.MINER_RUNE ); + super( MajruszsAccessories.MINER_RUNE, MinerRune.class ); this.add( MiningExtraItem.create( 0.04f ) ) .add( MiningSpeedBonus.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 4b440560..ba92af5b 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/NatureRune.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/NatureRune.java @@ -1,17 +1,17 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; import com.majruszsaccessories.MajruszsAccessories; 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; -import com.mlib.annotation.AutoInstance; @AutoInstance public class NatureRune extends AccessoryHandler { public NatureRune() { - super( MajruszsAccessories.NATURE_RUNE ); + super( MajruszsAccessories.NATURE_RUNE, NatureRune.class ); this.add( TamingStrongerAnimals.create( 0.25f ) ) .add( BreedingTwins.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 45d60997..abe2c2e7 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/SecretIngredient.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/SecretIngredient.java @@ -1,5 +1,11 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.events.OnItemBrewed; +import com.majruszlibrary.level.LevelHelper; +import com.majruszlibrary.math.AnyPos; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.StrongerPotions; import com.majruszsaccessories.accessories.components.TradeOffer; @@ -8,17 +14,11 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnItemBrewed; -import com.mlib.data.Serializable; -import com.mlib.level.LevelHelper; -import com.mlib.math.AnyPos; -import com.mlib.math.Range; @AutoInstance public class SecretIngredient extends AccessoryHandler { public SecretIngredient() { - super( MajruszsAccessories.SECRET_INGREDIENT ); + super( MajruszsAccessories.SECRET_INGREDIENT, SecretIngredient.class ); this.add( StrongerPotions.create( 0.6f, 1 ) ) .add( BrewingDropChance.create() ) @@ -38,8 +38,8 @@ protected BrewingDropChance( BonusHandler< AccessoryItem > handler ) { OnItemBrewed.listen( this::spawnAccessory ) .addCondition( CustomConditions.dropChance( s->this.chance, data->LevelHelper.getNearestPlayer( data.getLevel(), data.blockPos, 30.0f ) ) ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "brewing_drop_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); + handler.getConfig() + .define( "brewing_drop_chance", Reader.number(), s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); } private void spawnAccessory( OnItemBrewed data ) { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/SoulOfMinecraft.java b/common/src/main/java/com/majruszsaccessories/accessories/SoulOfMinecraft.java index 42155d0f..50bda7c3 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/SoulOfMinecraft.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/SoulOfMinecraft.java @@ -1,14 +1,14 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.*; import com.majruszsaccessories.common.AccessoryHandler; -import com.mlib.annotation.AutoInstance; @AutoInstance public class SoulOfMinecraft extends AccessoryHandler { public SoulOfMinecraft() { - super( MajruszsAccessories.SOUL_OF_MINECRAFT ); + super( MajruszsAccessories.SOUL_OF_MINECRAFT, SoulOfMinecraft.class ); this.add( MoreChestLoot.create( 1.8f ) ) .add( BrushingExtraItem.create( 0.24f ) ) diff --git a/common/src/main/java/com/majruszsaccessories/accessories/SwimmerGuide.java b/common/src/main/java/com/majruszsaccessories/accessories/SwimmerGuide.java index 8b8beb6c..04306124 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/SwimmerGuide.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/SwimmerGuide.java @@ -1,5 +1,11 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.events.OnLootGenerated; +import com.majruszlibrary.events.base.Condition; +import com.majruszlibrary.level.BlockHelper; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.SwimmingSpeedBonus; import com.majruszsaccessories.accessories.components.TradeOffer; @@ -8,18 +14,12 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializable; -import com.mlib.level.BlockHelper; -import com.mlib.math.Range; import net.minecraft.world.level.material.Fluids; @AutoInstance public class SwimmerGuide extends AccessoryHandler { public SwimmerGuide() { - super( MajruszsAccessories.SWIMMER_GUIDE ); + super( MajruszsAccessories.SWIMMER_GUIDE, SwimmerGuide.class ); this.add( SwimmingSpeedBonus.create( 0.2f ) ) .add( UnderwaterChestDropChance.create() ) @@ -43,8 +43,8 @@ protected UnderwaterChestDropChance( BonusHandler< AccessoryItem > handler ) { .addCondition( data->data.lootId.toString().contains( "chest" ) ) .addCondition( CustomConditions.dropChance( s->this.chance, data->data.entity ) ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "underwater_chest_spawn_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); + handler.getConfig() + .define( "underwater_chest_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 aa644d95..2d5b0ccb 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/TamedPotatoBeetle.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/TamedPotatoBeetle.java @@ -1,5 +1,9 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.events.base.Events; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.HarvestingDoubleCrops; import com.majruszsaccessories.accessories.components.TradeOffer; @@ -8,16 +12,12 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.OnAccessoryDropChanceGet; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.base.Contexts; -import com.mlib.data.Serializable; -import com.mlib.math.Range; import net.minecraft.world.level.block.Blocks; @AutoInstance public class TamedPotatoBeetle extends AccessoryHandler { public TamedPotatoBeetle() { - super( MajruszsAccessories.TAMED_POTATO_BEETLE ); + super( MajruszsAccessories.TAMED_POTATO_BEETLE, TamedPotatoBeetle.class ); this.add( HarvestingDoubleCrops.create( 0.25f ) ) .add( HarvestingDropChance.create() ) @@ -42,14 +42,15 @@ protected HarvestingDropChance( BonusHandler< AccessoryItem > handler ) { chance *= this.potatoMultiplier; } - return Contexts.dispatch( new OnAccessoryDropChanceGet( chance, data.entity ) ).check(); + return Events.dispatch( new OnAccessoryDropChanceGet( chance, data.entity ) ).check(); } ); - Serializable< ? > config = handler.getConfig(); - config.define( "harvesting_drop", subconfig->{ - subconfig.defineFloat( "chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); - subconfig.defineFloat( "potato_multiplier", s->this.potatoMultiplier, ( s, v )->this.potatoMultiplier = Range.of( 1.0f, 10.0f ).clamp( v ) ); - } ); + handler.getConfig() + .define( "harvesting_drop", subconfig->{ + subconfig.define( "harvesting_chance", Reader.number(), s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) ); + subconfig.define( "potato_multiplier", Reader.number(), s->this.potatoMultiplier, ( s, v )->this.potatoMultiplier = Range.of( 1.0f, 10.0f ) + .clamp( v ) ); + } ); } } } diff --git a/common/src/main/java/com/majruszsaccessories/accessories/ToolScraps.java b/common/src/main/java/com/majruszsaccessories/accessories/ToolScraps.java index dbfad021..186aa428 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/ToolScraps.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/ToolScraps.java @@ -1,5 +1,11 @@ package com.majruszsaccessories.accessories; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.events.OnItemDamaged; +import com.majruszlibrary.events.base.Priority; +import com.majruszlibrary.math.AnyPos; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.accessories.components.MiningDurabilityBonus; import com.majruszsaccessories.accessories.components.TradeOffer; @@ -8,17 +14,11 @@ import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnItemDamaged; -import com.mlib.contexts.base.Priority; -import com.mlib.data.Serializable; -import com.mlib.math.AnyPos; -import com.mlib.math.Range; @AutoInstance public class ToolScraps extends AccessoryHandler { public ToolScraps() { - super( MajruszsAccessories.TOOL_SCRAPS ); + super( MajruszsAccessories.TOOL_SCRAPS, ToolScraps.class ); this.add( MiningDurabilityBonus.create( 0.1f ) ) .add( MiningDropChance.create() ) @@ -40,8 +40,8 @@ protected MiningDropChance( BonusHandler< AccessoryItem > handler ) { .addCondition( OnItemDamaged::isAboutToBroke ) .addCondition( CustomConditions.dropChance( data->this.multiplier * data.itemStack.getMaxDamage(), data->data.player ) ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "durability_drop_chance_multiplier", s->this.multiplier, ( s, v )->this.multiplier = Range.CHANCE.clamp( v ) ); + handler.getConfig() + .define( "durability_drop_chance_multiplier", Reader.number(), s->this.multiplier, ( s, v )->this.multiplier = Range.CHANCE.clamp( v ) ); } private void spawnScraps( OnItemDamaged data ) { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/UnbreakableFishingLine.java b/common/src/main/java/com/majruszsaccessories/accessories/UnbreakableFishingLine.java index 0b30f715..8a657a02 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/UnbreakableFishingLine.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/UnbreakableFishingLine.java @@ -1,15 +1,15 @@ package com.majruszsaccessories.accessories; +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.mlib.annotation.AutoInstance; @AutoInstance public class UnbreakableFishingLine extends AccessoryHandler { public UnbreakableFishingLine() { - super( MajruszsAccessories.UNBREAKABLE_FISHING_LINE ); + super( MajruszsAccessories.UNBREAKABLE_FISHING_LINE, UnbreakableFishingLine.class ); this.add( FishingLureBonus.create( 0.2f ) ) .add( AnglerTrophy.FishingDropChance.create( 0.005f ) ) 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 a748be7c..040b291d 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/BreedingTwins.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/BreedingTwins.java @@ -1,15 +1,14 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.events.OnBabySpawned; +import com.majruszlibrary.events.base.Condition; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnBabySpawned; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializable; -import com.mlib.math.Range; import net.minecraft.world.entity.AgeableMob; public class BreedingTwins extends BonusComponent< AccessoryItem > { @@ -31,8 +30,8 @@ protected BreedingTwins( BonusHandler< AccessoryItem > handler, float chance ) { this.addTooltip( "majruszsaccessories.bonuses.spawn_twins", TooltipHelper.asPercent( this.chance ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "breeding_twins", this.chance::define ); + handler.getConfig() + .define( "breeding_twins", this.chance::define ); } private void spawnTwins( OnBabySpawned data ) { 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 5d298718..35aca211 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/BrushingExtraItem.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/BrushingExtraItem.java @@ -1,17 +1,16 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.events.OnItemBrushed; +import com.majruszlibrary.item.LootHelper; +import com.majruszlibrary.level.LevelHelper; +import com.majruszlibrary.math.AnyPos; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnItemBrushed; -import com.mlib.data.Serializable; -import com.mlib.item.LootHelper; -import com.mlib.level.LevelHelper; -import com.mlib.math.AnyPos; -import com.mlib.math.Range; import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.Vec3; @@ -35,8 +34,8 @@ protected BrushingExtraItem( BonusHandler< AccessoryItem > handler, float chance this.addTooltip( "majruszsaccessories.bonuses.extra_archaeology_item", TooltipHelper.asPercent( this.chance ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "extra_archaeology_item", this.chance::define ); + handler.getConfig() + .define( "extra_archaeology_item", this.chance::define ); } private void addExtraLoot( OnItemBrushed data ) { 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 06aae1f7..67321cdc 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/FishingExtraItems.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/FishingExtraItems.java @@ -1,5 +1,11 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.emitter.ParticleEmitter; +import com.majruszlibrary.events.OnFishingExtraItemsGet; +import com.majruszlibrary.item.LootHelper; +import com.majruszlibrary.level.LevelHelper; +import com.majruszlibrary.math.AnyPos; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; @@ -7,13 +13,6 @@ import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnFishingExtraItemsGet; -import com.mlib.data.Serializable; -import com.mlib.emitter.ParticleEmitter; -import com.mlib.item.LootHelper; -import com.mlib.level.LevelHelper; -import com.mlib.math.AnyPos; -import com.mlib.math.Range; import net.minecraft.core.BlockPos; import net.minecraft.world.level.storage.loot.BuiltInLootTables; @@ -36,11 +35,11 @@ protected FishingExtraItems( BonusHandler< AccessoryItem > handler, float chance this.addTooltip( "majruszsaccessories.bonuses.extra_fishing_items", TooltipHelper.asPercent( this.chance ), TooltipHelper.asValue( this.count ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "extra_fishing_item", subconfig->{ - this.chance.define( subconfig ); - this.count.define( subconfig ); - } ); + handler.getConfig() + .define( "extra_fishing_item", subconfig->{ + this.chance.define( subconfig ); + this.count.define( subconfig ); + } ); } private void addExtraFishes( OnFishingExtraItemsGet data ) { 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 e7ef6478..05a0a56e 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/FishingLuckBonus.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/FishingLuckBonus.java @@ -1,5 +1,13 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.emitter.ParticleEmitter; +import com.majruszlibrary.entity.AttributeHandler; +import com.majruszlibrary.events.OnItemFished; +import com.majruszlibrary.events.OnPlayerTicked; +import com.majruszlibrary.events.base.Condition; +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; @@ -7,15 +15,6 @@ import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnItemFished; -import com.mlib.contexts.OnPlayerTicked; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializable; -import com.mlib.emitter.ParticleEmitter; -import com.mlib.entity.AttributeHandler; -import com.mlib.level.LevelHelper; -import com.mlib.math.AnyPos; -import com.mlib.math.Range; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.Attributes; @@ -45,8 +44,8 @@ protected FishingLuckBonus( BonusHandler< AccessoryItem > handler, int luck ) { this.addTooltip( "majruszsaccessories.bonuses.fishing_luck", TooltipHelper.asValue( this.luck ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "fishing_luck", this.luck::define ); + handler.getConfig() + .define( "fishing_luck", this.luck::define ); } private void updateLuck( OnPlayerTicked data ) { 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 b96da2e0..a962233b 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/FishingLureBonus.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/FishingLureBonus.java @@ -1,17 +1,16 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.emitter.ParticleEmitter; +import com.majruszlibrary.events.OnFishingTimeGet; +import com.majruszlibrary.level.LevelHelper; +import com.majruszlibrary.math.AnyPos; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnFishingTimeGet; -import com.mlib.data.Serializable; -import com.mlib.emitter.ParticleEmitter; -import com.mlib.level.LevelHelper; -import com.mlib.math.AnyPos; -import com.mlib.math.Range; import net.minecraft.core.BlockPos; public class FishingLureBonus extends BonusComponent< AccessoryItem > { @@ -31,8 +30,8 @@ protected FishingLureBonus( BonusHandler< AccessoryItem > handler, float bonus ) this.addTooltip( "majruszsaccessories.bonuses.fishing_lure", TooltipHelper.asPercent( this.multiplier ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "fishing_time", this.multiplier::define ); + handler.getConfig() + .define( "fishing_time", this.multiplier::define ); } private void decreaseFishingTime( OnFishingTimeGet data ) { 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 31fb191c..a3d1a1e9 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/HarvestingDoubleCrops.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/HarvestingDoubleCrops.java @@ -1,17 +1,16 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.events.OnLootGenerated; +import com.majruszlibrary.events.base.Condition; +import com.majruszlibrary.events.base.Event; +import com.majruszlibrary.level.BlockHelper; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.contexts.base.Condition; -import com.mlib.contexts.base.Context; -import com.mlib.data.Serializable; -import com.mlib.level.BlockHelper; -import com.mlib.math.Range; import net.minecraft.world.entity.LivingEntity; import java.util.ArrayList; @@ -34,8 +33,8 @@ protected HarvestingDoubleCrops( BonusHandler< AccessoryItem > handler, float ch this.addTooltip( "majruszsaccessories.bonuses.double_crops", TooltipHelper.asPercent( this.chance ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "double_crops", this.chance::define ); + handler.getConfig() + .define( "double_crops", this.chance::define ); } private void doubleLoot( OnLootGenerated data ) { @@ -52,7 +51,7 @@ private void spawnEffects( OnLootGenerated data ) { } public static class OnCropHarvested { - public static Context< OnLootGenerated > listen( Consumer< OnLootGenerated > consumer ) { + public static Event< OnLootGenerated > listen( Consumer< OnLootGenerated > consumer ) { return OnLootGenerated.listen( consumer ) .addCondition( Condition.isLogicalServer() ) .addCondition( data->data.origin != null ) 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 a3df428b..7da64174 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/MiningDurabilityBonus.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/MiningDurabilityBonus.java @@ -1,14 +1,13 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.events.OnItemDamaged; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnItemDamaged; -import com.mlib.data.Serializable; -import com.mlib.math.Range; public class MiningDurabilityBonus extends BonusComponent< AccessoryItem > { RangedFloat chance = new RangedFloat().id( "chance" ).maxRange( Range.CHANCE ); @@ -27,8 +26,8 @@ protected MiningDurabilityBonus( BonusHandler< AccessoryItem > handler, float bo this.addTooltip( "majruszsaccessories.bonuses.free_durability_cost", TooltipHelper.asPercent( this.chance ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "mining_free_durability_use", this.chance::define ); + handler.getConfig() + .define( "mining_free_durability_use", this.chance::define ); } private void decreaseDurabilityCost( OnItemDamaged data ) { 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 2a0d43bd..242fe7ac 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/MiningExtraItem.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/MiningExtraItem.java @@ -1,5 +1,13 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.collection.DefaultMap; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.emitter.ParticleEmitter; +import com.majruszlibrary.events.OnLootGenerated; +import com.majruszlibrary.events.base.Condition; +import com.majruszlibrary.events.base.Event; +import com.majruszlibrary.item.LootHelper; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; @@ -7,14 +15,6 @@ import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.collection.DefaultMap; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.contexts.base.Condition; -import com.mlib.contexts.base.Context; -import com.mlib.data.Serializable; -import com.mlib.emitter.ParticleEmitter; -import com.mlib.item.LootHelper; -import com.mlib.math.Range; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.BlockTags; import net.minecraft.world.entity.LivingEntity; @@ -45,11 +45,11 @@ protected MiningExtraItem( BonusHandler< AccessoryItem > handler, float chance ) this.addTooltip( "majruszsaccessories.bonuses.extra_stone_loot", TooltipHelper.asPercent( this.chance ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "extra_mining_item", subconfig->{ - this.chance.define( subconfig ); - subconfig.defineLocationMap( "loot_ids", s->this.lootIds, ( s, v )->this.lootIds = DefaultMap.of( v ) ); - } ); + handler.getConfig() + .define( "extra_mining_item", subconfig->{ + this.chance.define( subconfig ); + subconfig.define( "loot_ids", Reader.map( Reader.location() ), s->this.lootIds, ( s, v )->this.lootIds = DefaultMap.of( v ) ); + } ); } private void addExtraLoot( OnLootGenerated data ) { @@ -70,7 +70,7 @@ private void spawnEffects( OnLootGenerated data ) { } public static class OnStoneMined { - public static Context< OnLootGenerated > listen( Consumer< OnLootGenerated > consumer ) { + public static Event< OnLootGenerated > listen( Consumer< OnLootGenerated > consumer ) { return OnLootGenerated.listen( consumer ) .addCondition( Condition.isLogicalServer() ) .addCondition( data->data.blockState != null ) 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 4161376e..0a71da1e 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/MiningSpeedBonus.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/MiningSpeedBonus.java @@ -1,17 +1,16 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.events.OnBreakSpeedGet; +import com.majruszlibrary.events.OnItemSwingDurationGet; +import com.majruszlibrary.math.Random; +import com.majruszlibrary.math.Range; +import com.majruszlibrary.time.TimeHelper; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnBreakSpeedGet; -import com.mlib.contexts.OnItemSwingDurationGet; -import com.mlib.data.Serializable; -import com.mlib.math.Random; -import com.mlib.math.Range; -import com.mlib.time.TimeHelper; import net.minecraft.server.level.ServerLevel; public class MiningSpeedBonus extends BonusComponent< AccessoryItem > { @@ -34,8 +33,8 @@ protected MiningSpeedBonus( BonusHandler< AccessoryItem > handler, float bonus ) this.addTooltip( "majruszsaccessories.bonuses.mine_bonus", TooltipHelper.asPercent( this.speedMultiplier ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "mining_speed_bonus", this.speedMultiplier::define ); + handler.getConfig() + .define( "mining_speed_bonus", this.speedMultiplier::define ); } private void increaseMineSpeed( OnBreakSpeedGet data ) { 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 17ab49f2..deedef92 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/MoreChestLoot.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/MoreChestLoot.java @@ -1,5 +1,20 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.annotation.Dist; +import com.majruszlibrary.annotation.OnlyIn; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.data.Serializables; +import com.majruszlibrary.emitter.ParticleEmitter; +import com.majruszlibrary.events.OnLootGenerated; +import com.majruszlibrary.events.OnPlayerTicked; +import com.majruszlibrary.events.base.Condition; +import com.majruszlibrary.events.base.Event; +import com.majruszlibrary.level.LevelHelper; +import com.majruszlibrary.math.Random; +import com.majruszlibrary.math.Range; +import com.majruszlibrary.platform.Side; +import com.majruszlibrary.text.TextHelper; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; @@ -8,21 +23,6 @@ import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.ITooltipProvider; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.annotation.AutoInstance; -import com.mlib.annotation.Dist; -import com.mlib.annotation.OnlyIn; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.contexts.OnPlayerTicked; -import com.mlib.contexts.base.Condition; -import com.mlib.contexts.base.Context; -import com.mlib.data.Serializable; -import com.mlib.data.Serializables; -import com.mlib.emitter.ParticleEmitter; -import com.mlib.level.LevelHelper; -import com.mlib.math.Random; -import com.mlib.math.Range; -import com.mlib.platform.Side; -import com.mlib.text.TextHelper; import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.Mth; import net.minecraft.world.item.ItemStack; @@ -48,8 +48,8 @@ protected MoreChestLoot( BonusHandler< AccessoryItem > handler, float sizeMultip this.addTooltip( "majruszsaccessories.bonuses.more_chest_loot", this.getPerPercentInfo(), this.getPercentInfo(), this.getCurrentInfo() ); - Serializable< ? > config = handler.getConfig(); - config.define( "chest_size_bonus", this.sizeMultiplier::define ); + handler.getConfig() + .define( "chest_size_bonus", this.sizeMultiplier::define ); } private void addExtraLoot( OnLootGenerated data ) { @@ -96,7 +96,7 @@ private static float getDistanceBonus( ServerPlayer player ) { } public static class OnChestOpened { - public static Context< OnLootGenerated > listen( Consumer< OnLootGenerated > consumer ) { + public static Event< OnLootGenerated > listen( Consumer< OnLootGenerated > consumer ) { return OnLootGenerated.listen( consumer ) .addCondition( Condition.isLogicalServer() ) .addCondition( data->data.lootId.toString().contains( "chests/" ) ); @@ -118,7 +118,7 @@ public static Optional< ServerPlayer > findPlayer( OnLootGenerated data ) { public static class BonusInfo { static { Serializables.get( BonusInfo.class ) - .defineFloat( "bonus", s->s.bonus, ( s, v )->s.bonus = v ); + .define( "bonus", Reader.number(), s->s.bonus, ( s, v )->s.bonus = v ); Side.runOnClient( ()->()->MajruszsAccessories.MORE_CHEST_LOOT.addClientCallback( BonusInfo::onClient ) ); } 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 685cff8f..e35576d3 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/SleepingBonuses.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/SleepingBonuses.java @@ -1,5 +1,12 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.data.Serializables; +import com.majruszlibrary.events.OnPlayerWakedUp; +import com.majruszlibrary.events.base.Condition; +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; @@ -7,13 +14,6 @@ import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnPlayerWakedUp; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializable; -import com.mlib.data.Serializables; -import com.mlib.math.Random; -import com.mlib.math.Range; -import com.mlib.time.TimeHelper; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; @@ -50,12 +50,12 @@ protected SleepingBonuses( BonusHandler< AccessoryItem > handler, int count, int this.addTooltip( "majruszsaccessories.bonuses.sleep_bonuses", TooltipHelper.asValue( this.count ), TooltipHelper.asValue( this.duration ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "sleep_bonuses", subconfig->{ - this.count.define( subconfig ); - this.duration.define( subconfig ); - subconfig.defineCustomList( "effects", s->this.effects, ( s, v )->this.effects = v, EffectDef::new ); - } ); + handler.getConfig() + .define( "sleep_bonuses", subconfig->{ + this.count.define( subconfig ); + this.duration.define( subconfig ); + subconfig.define( "effects", Reader.list( Reader.custom( EffectDef::new ) ), s->this.effects, ( s, v )->this.effects = v ); + } ); } private void applyBonuses( OnPlayerWakedUp data ) { @@ -88,8 +88,8 @@ private void spawnEffects( OnPlayerWakedUp data ) { private static class EffectDef { static { Serializables.get( EffectDef.class ) - .defineEffect( "id", s->s.effect, ( s, v )->s.effect = v ) - .defineInteger( "amplifier", s->s.amplifier, ( s, v )->s.amplifier = v ); + .define( "id", Reader.mobEffect(), s->s.effect, ( s, v )->s.effect = v ) + .define( "amplifier", Reader.integer(), s->s.amplifier, ( s, v )->s.amplifier = v ); } private MobEffect effect; 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 b1fd45a7..04394eef 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/StrongerPotions.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/StrongerPotions.java @@ -1,5 +1,11 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.data.Serializables; +import com.majruszlibrary.events.OnItemBrewed; +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; @@ -8,12 +14,6 @@ import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnItemBrewed; -import com.mlib.data.Serializable; -import com.mlib.data.Serializables; -import com.mlib.level.LevelHelper; -import com.mlib.math.AnyPos; -import com.mlib.math.Range; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -42,11 +42,11 @@ protected StrongerPotions( BonusHandler< AccessoryItem > handler, float duration this.addTooltip( "majruszsaccessories.bonuses.potion_amplifier", TooltipHelper.asValue( this.amplifier ) ); this.addTooltip( "majruszsaccessories.bonuses.potion_duration", TooltipHelper.asPercent( this.durationPenalty ).bonusMultiplier( -1.0f ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "stronger_potion", subconfig->{ - this.durationPenalty.define( subconfig ); - this.amplifier.define( subconfig ); - } ); + handler.getConfig() + .define( "stronger_potion", subconfig->{ + this.durationPenalty.define( subconfig ); + this.amplifier.define( subconfig ); + } ); } private void boostPotions( OnItemBrewed data ) { @@ -88,7 +88,7 @@ private static class Data { static { Serializables.get( Data.class ) .define( "display", config->{ - config.defineString( "Name", s->s.name, ( s, v )->s.name = v ); + config.define( "Name", Reader.string(), s->s.name, ( s, v )->s.name = v ); } ); } 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 2fe71ff6..27b14821 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/SwimmingSpeedBonus.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/SwimmingSpeedBonus.java @@ -1,15 +1,14 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.events.OnEntitySwimSpeedMultiplierGet; +import com.majruszlibrary.math.Range; +import com.majruszlibrary.time.TimeHelper; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnEntitySwimSpeedMultiplierGet; -import com.mlib.data.Serializable; -import com.mlib.math.Range; -import com.mlib.time.TimeHelper; import net.minecraft.server.level.ServerLevel; public class SwimmingSpeedBonus extends BonusComponent< AccessoryItem > { @@ -29,8 +28,8 @@ protected SwimmingSpeedBonus( BonusHandler< AccessoryItem > handler, float bonus this.addTooltip( "majruszsaccessories.bonuses.swim_bonus", TooltipHelper.asPercent( this.multiplier ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "swim_speed", this.multiplier::define ); + handler.getConfig() + .define( "swim_speed", this.multiplier::define ); } private void increaseSwimSpeed( OnEntitySwimSpeedMultiplierGet data ) { 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 4ceddf3e..2e7689c3 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/TamingStrongerAnimals.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/TamingStrongerAnimals.java @@ -1,16 +1,15 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.entity.AttributeHandler; +import com.majruszlibrary.events.OnAnimalTamed; +import com.majruszlibrary.events.base.Condition; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnAnimalTamed; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializable; -import com.mlib.entity.AttributeHandler; -import com.mlib.math.Range; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.horse.Horse; @@ -41,8 +40,8 @@ protected TamingStrongerAnimals( BonusHandler< AccessoryItem > handler, float bo this.addTooltip( "majruszsaccessories.bonuses.animal_attributes", TooltipHelper.asPercent( this.bonus ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "animal_bonus", this.bonus::define ); + handler.getConfig() + .define( "animal_bonus", this.bonus::define ); } private void applyBonuses( OnAnimalTamed data ) { diff --git a/common/src/main/java/com/majruszsaccessories/accessories/components/TradeOffer.java b/common/src/main/java/com/majruszsaccessories/accessories/components/TradeOffer.java index be3f8b7d..3b357330 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/TradeOffer.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/TradeOffer.java @@ -1,13 +1,13 @@ 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 com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnWanderingTradesUpdated; -import com.mlib.data.Serializable; -import com.mlib.math.Random; -import com.mlib.math.Range; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.trading.MerchantOffer; @@ -29,8 +29,8 @@ protected TradeOffer( BonusHandler< AccessoryItem > handler, int price ) { this.price = price; - Serializable< ? > config = handler.getConfig(); - config.defineInteger( "trade_price", s->this.price, ( s, v )->this.price = Range.of( 1, 32 ).clamp( v ) ); + handler.getConfig() + .define( "trade_price", Reader.integer(), s->this.price, ( s, v )->this.price = Range.of( 1, 32 ).clamp( v ) ); OFFERS.add( this ); } 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 e8f51f65..7f0d5819 100644 --- a/common/src/main/java/com/majruszsaccessories/accessories/components/TradingDiscount.java +++ b/common/src/main/java/com/majruszsaccessories/accessories/components/TradingDiscount.java @@ -1,15 +1,14 @@ package com.majruszsaccessories.accessories.components; +import com.majruszlibrary.events.OnTradesUpdated; +import com.majruszlibrary.math.Range; +import com.majruszlibrary.platform.Side; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnTradesUpdated; -import com.mlib.data.Serializable; -import com.mlib.math.Range; -import com.mlib.platform.Side; import net.minecraft.world.item.trading.MerchantOffer; public class TradingDiscount extends BonusComponent< AccessoryItem > { @@ -29,8 +28,8 @@ protected TradingDiscount( BonusHandler< AccessoryItem > handler, float multipli this.addTooltip( "majruszsaccessories.bonuses.trading_discount", TooltipHelper.asPercent( this.multiplier ) ); - Serializable< ? > config = handler.getConfig(); - config.define( "trading_discount", this.multiplier::define ); + handler.getConfig() + .define( "trading_discount", this.multiplier::define ); } private void decreasePrices( OnTradesUpdated data ) { diff --git a/common/src/main/java/com/majruszsaccessories/boosters/Dice.java b/common/src/main/java/com/majruszsaccessories/boosters/Dice.java index c1bbc1df..763dcfd1 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/Dice.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/Dice.java @@ -1,21 +1,22 @@ 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.AccessoryDropChance; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.common.BoosterHandler; import com.majruszsaccessories.items.BoosterItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializable; import net.minecraft.world.entity.monster.Guardian; @AutoInstance public class Dice extends BoosterHandler { public Dice() { - super( MajruszsAccessories.DICE ); + super( MajruszsAccessories.DICE, Dice.class ); this.add( AccessoryDropChance.create( 0.2f ) ) .add( GuardianDropChance.create() ); @@ -37,8 +38,8 @@ protected GuardianDropChance( BonusHandler< BoosterItem > handler ) { .addCondition( data->data.lastDamagePlayer != null ) .addCondition( data->data.entity instanceof Guardian ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "guardian_drop_chance", s->this.chance, ( s, v )->this.chance = v ); + handler.getConfig() + .define( "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/GoldenDice.java b/common/src/main/java/com/majruszsaccessories/boosters/GoldenDice.java index 7ab30c95..def982fd 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/GoldenDice.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/GoldenDice.java @@ -1,15 +1,15 @@ package com.majruszsaccessories.boosters; +import com.majruszlibrary.annotation.AutoInstance; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.boosters.components.AccessoryDropChance; import com.majruszsaccessories.boosters.components.BoosterIncompatibility; import com.majruszsaccessories.common.BoosterHandler; -import com.mlib.annotation.AutoInstance; @AutoInstance public class GoldenDice extends BoosterHandler { public GoldenDice() { - super( MajruszsAccessories.GOLDEN_DICE ); + super( MajruszsAccessories.GOLDEN_DICE, GoldenDice.class ); this.add( AccessoryDropChance.create( 0.4f ) ) .add( BoosterIncompatibility.create( MajruszsAccessories.DICE ) ); diff --git a/common/src/main/java/com/majruszsaccessories/boosters/GoldenHorseshoe.java b/common/src/main/java/com/majruszsaccessories/boosters/GoldenHorseshoe.java index b206b862..f2e9cd6e 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/GoldenHorseshoe.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/GoldenHorseshoe.java @@ -1,15 +1,15 @@ package com.majruszsaccessories.boosters; +import com.majruszlibrary.annotation.AutoInstance; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.boosters.components.BoosterIncompatibility; import com.majruszsaccessories.boosters.components.LuckBonus; import com.majruszsaccessories.common.BoosterHandler; -import com.mlib.annotation.AutoInstance; @AutoInstance public class GoldenHorseshoe extends BoosterHandler { public GoldenHorseshoe() { - super( MajruszsAccessories.GOLDEN_HORSESHOE ); + super( MajruszsAccessories.GOLDEN_HORSESHOE, GoldenHorseshoe.class ); this.add( LuckBonus.create( 2 ) ) .add( BoosterIncompatibility.create( MajruszsAccessories.HORSESHOE ) ); diff --git a/common/src/main/java/com/majruszsaccessories/boosters/Horseshoe.java b/common/src/main/java/com/majruszsaccessories/boosters/Horseshoe.java index b42741b0..6d1ac130 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/Horseshoe.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/Horseshoe.java @@ -1,22 +1,23 @@ 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.LuckBonus; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.common.BoosterHandler; import com.majruszsaccessories.items.BoosterItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializable; import net.minecraft.world.entity.animal.horse.SkeletonHorse; import net.minecraft.world.entity.monster.Skeleton; @AutoInstance public class Horseshoe extends BoosterHandler { public Horseshoe() { - super( MajruszsAccessories.HORSESHOE ); + super( MajruszsAccessories.HORSESHOE, Horseshoe.class ); this.add( LuckBonus.create( 1 ) ) .add( SkeletonHorsemanDropChance.create() ); @@ -38,8 +39,8 @@ protected SkeletonHorsemanDropChance( BonusHandler< BoosterItem > handler ) { .addCondition( data->data.lastDamagePlayer != null ) .addCondition( data->data.entity instanceof Skeleton skeleton && skeleton.getRootVehicle() instanceof SkeletonHorse ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "skeleton_horseman_drop_chance", s->this.chance, ( s, v )->this.chance = v ); + handler.getConfig() + .define( "skeleton_horseman_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/Jadeite.java b/common/src/main/java/com/majruszsaccessories/boosters/Jadeite.java index b705b680..af867784 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/Jadeite.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/Jadeite.java @@ -1,21 +1,22 @@ 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 com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializable; import net.minecraft.world.entity.monster.ElderGuardian; @AutoInstance public class Jadeite extends BoosterHandler { public Jadeite() { - super( MajruszsAccessories.JADEITE ); + super( MajruszsAccessories.JADEITE, Jadeite.class ); this.add( EfficiencyNegation.create() ) .add( ElderGuardianDropChance.create() ); @@ -37,8 +38,8 @@ protected ElderGuardianDropChance( BonusHandler< BoosterItem > handler ) { .addCondition( data->data.lastDamagePlayer != null ) .addCondition( data->data.entity instanceof ElderGuardian ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "elder_guardian_drop_chance", s->this.chance, ( s, v )->this.chance = v ); + 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 4af519bf..8f15a19d 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/Onyx.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/Onyx.java @@ -1,21 +1,22 @@ 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.EfficiencyBonus; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.common.BoosterHandler; import com.majruszsaccessories.items.BoosterItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializable; import net.minecraft.world.entity.monster.warden.Warden; @AutoInstance public class Onyx extends BoosterHandler { public Onyx() { - super( MajruszsAccessories.ONYX ); + super( MajruszsAccessories.ONYX, Onyx.class ); this.add( EfficiencyBonus.create( 0.09f ) ) .add( WardenDropChance.create() ); @@ -37,8 +38,8 @@ protected WardenDropChance( BonusHandler< BoosterItem > handler ) { .addCondition( data->data.lastDamagePlayer != null ) .addCondition( data->data.entity instanceof Warden ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "warden_drop_chance", s->this.chance, ( s, v )->this.chance = v ); + handler.getConfig() + .define( "warden_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/OwlFeather.java b/common/src/main/java/com/majruszsaccessories/boosters/OwlFeather.java index f3387619..fde18a39 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/OwlFeather.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/OwlFeather.java @@ -1,21 +1,22 @@ 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.ExperienceBonus; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.common.BoosterHandler; import com.majruszsaccessories.items.BoosterItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializable; import net.minecraft.world.entity.monster.Vex; @AutoInstance public class OwlFeather extends BoosterHandler { public OwlFeather() { - super( MajruszsAccessories.OWL_FEATHER ); + super( MajruszsAccessories.OWL_FEATHER, OwlFeather.class ); this.add( ExperienceBonus.create( 0.15f ) ) .add( VexDropChance.create() ); @@ -37,8 +38,8 @@ protected VexDropChance( BonusHandler< BoosterItem > handler ) { .addCondition( data->data.lastDamagePlayer != null ) .addCondition( data->data.entity instanceof Vex ); - Serializable< ? > config = handler.getConfig(); - config.defineFloat( "vex_drop_chance", s->this.chance, ( s, v )->this.chance = v ); + handler.getConfig() + .define( "vex_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/components/AccessoryDropChance.java b/common/src/main/java/com/majruszsaccessories/boosters/components/AccessoryDropChance.java index 3e7389d9..d2a5ce9f 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/components/AccessoryDropChance.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/components/AccessoryDropChance.java @@ -1,5 +1,6 @@ package com.majruszsaccessories.boosters.components; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; @@ -7,7 +8,6 @@ import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.BoosterItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.math.Range; public class AccessoryDropChance extends BonusComponent< BoosterItem > { RangedFloat multiplier = new RangedFloat().id( "accessory_drop_chance_multiplier" ); 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 78899c60..ec4b6863 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/components/BoosterIncompatibility.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/components/BoosterIncompatibility.java @@ -1,10 +1,10 @@ package com.majruszsaccessories.boosters.components; +import com.majruszlibrary.events.base.Condition; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.contexts.OnBoosterCompatibilityGet; import com.majruszsaccessories.items.BoosterItem; -import com.mlib.contexts.base.Condition; 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 ea0f203a..ebd2eedd 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/components/EfficiencyBonus.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/components/EfficiencyBonus.java @@ -1,12 +1,12 @@ package com.majruszsaccessories.boosters.components; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.contexts.OnAccessoryExtraBonusGet; import com.majruszsaccessories.items.BoosterItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.math.Range; public class EfficiencyBonus extends BonusComponent< BoosterItem > { RangedFloat bonus = new RangedFloat().id( "efficiency_bonus" ); 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 ecbdb87d..fc4b11a4 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/components/ExperienceBonus.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/components/ExperienceBonus.java @@ -1,13 +1,13 @@ package com.majruszsaccessories.boosters.components; +import com.majruszlibrary.events.OnExpOrbPickedUp; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.common.BonusComponent; import com.majruszsaccessories.common.BonusHandler; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.contexts.base.CustomConditions; import com.majruszsaccessories.items.BoosterItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnExpOrbPickedUp; -import com.mlib.math.Range; public class ExperienceBonus extends BonusComponent< BoosterItem > { RangedFloat bonus = new RangedFloat().id( "experience_bonus" ); 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 9b4da8c0..f701e8d6 100644 --- a/common/src/main/java/com/majruszsaccessories/boosters/components/LuckBonus.java +++ b/common/src/main/java/com/majruszsaccessories/boosters/components/LuckBonus.java @@ -1,15 +1,15 @@ package com.majruszsaccessories.boosters.components; +import com.majruszlibrary.entity.AttributeHandler; +import com.majruszlibrary.events.OnPlayerTicked; +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.RangedInteger; import com.majruszsaccessories.items.BoosterItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.contexts.OnPlayerTicked; -import com.mlib.contexts.base.Condition; -import com.mlib.entity.AttributeHandler; -import com.mlib.math.Range; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.Attributes; diff --git a/common/src/main/java/com/majruszsaccessories/commands/SpawnAccessoryCommand.java b/common/src/main/java/com/majruszsaccessories/commands/SpawnAccessoryCommand.java index a26fc0d2..91ffe02c 100644 --- a/common/src/main/java/com/majruszsaccessories/commands/SpawnAccessoryCommand.java +++ b/common/src/main/java/com/majruszsaccessories/commands/SpawnAccessoryCommand.java @@ -1,16 +1,17 @@ package com.majruszsaccessories.commands; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.command.Command; +import com.majruszlibrary.command.CommandData; +import com.majruszlibrary.command.IParameter; +import com.majruszlibrary.events.OnGameInitialized; +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; -import com.mlib.annotation.AutoInstance; -import com.mlib.command.Command; -import com.mlib.command.CommandData; -import com.mlib.command.IParameter; -import com.mlib.contexts.OnGameInitialized; -import com.mlib.item.ItemHelper; -import com.mlib.math.Range; -import com.mlib.registry.Registries; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; @@ -49,16 +50,16 @@ public SpawnAccessoryCommand() { private int giveAccessory( CommandData data ) throws CommandSyntaxException { List< ? extends Entity > entities = data.get( ENTITIES ); - Item item = Registries.getItem( data.get( ID ) ); + Item item = Registries.ITEMS.get( data.get( ID ) ); Optional< Float > bonus = data.getOptional( BONUS ); int count = data.getOptional( COUNT ).orElse( 1 ); for( Entity entity : entities ) { if( entity instanceof Player player ) { for( int i = 0; i < count; ++i ) { AccessoryHolder holder = AccessoryHolder.create( new ItemStack( item ) ); - holder.setBonus( bonus.orElseGet( ()->MajruszsAccessories.CONFIG.efficiency.getRandom() ) ); + holder.setBonus( bonus.orElseGet( Config.Efficiency::getRandom ) ); - ItemHelper.giveToPlayer( holder.getItemStack(), player, player.level() ); + ItemHelper.giveToPlayer( holder.getItemStack(), player ); } } } @@ -67,9 +68,9 @@ private int giveAccessory( CommandData data ) throws CommandSyntaxException { } private void createSuggestions( OnGameInitialized data ) { - for( Item item : Registries.getItems() ) { + for( Item item : Registries.ITEMS ) { if( item instanceof AccessoryItem ) { - ID_SUGGESTIONS.add( Registries.get( item ) ); + ID_SUGGESTIONS.add( Registries.ITEMS.getId( item ) ); } } } diff --git a/common/src/main/java/com/majruszsaccessories/common/AccessoryHandler.java b/common/src/main/java/com/majruszsaccessories/common/AccessoryHandler.java index ae514342..e1c8e80c 100644 --- a/common/src/main/java/com/majruszsaccessories/common/AccessoryHandler.java +++ b/common/src/main/java/com/majruszsaccessories/common/AccessoryHandler.java @@ -1,17 +1,18 @@ package com.majruszsaccessories.common; +import com.majruszlibrary.data.Serializables; +import com.majruszlibrary.events.OnItemDecorationsRendered; +import com.majruszlibrary.events.base.Priority; +import com.majruszlibrary.registry.RegistryObject; +import com.majruszlibrary.text.TextHelper; import com.majruszsaccessories.config.Config; import com.majruszsaccessories.contexts.OnAccessoryTooltip; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.contexts.OnItemDecorationsRendered; -import com.mlib.contexts.base.Priority; -import com.mlib.registry.RegistryObject; -import com.mlib.text.TextHelper; import net.minecraft.ChatFormatting; public class AccessoryHandler extends BonusHandler< AccessoryItem > { - public AccessoryHandler( RegistryObject< AccessoryItem > item ) { - super( item, Config.Accessories.class, item.getId() ); + public AccessoryHandler( RegistryObject< AccessoryItem > item, Class< ? extends AccessoryHandler > clazz ) { + super( item, clazz, item.getId() ); OnAccessoryTooltip.listen( this::addTooltip ) .addCondition( data->data.holder.getItem().equals( this.getItem() ) ); @@ -22,6 +23,9 @@ public AccessoryHandler( RegistryObject< AccessoryItem > item ) { OnItemDecorationsRendered.listen( this::addBoosterIcon ) .addCondition( data->data.itemStack.is( this.getItem() ) ); + + Serializables.getStatic( Config.Accessories.class ) + .define( item.getId(), clazz ); } private void addEmptyBoostersTooltip( OnAccessoryTooltip data ) { diff --git a/common/src/main/java/com/majruszsaccessories/common/AccessoryHolder.java b/common/src/main/java/com/majruszsaccessories/common/AccessoryHolder.java index 29beee4c..e0dad1f0 100644 --- a/common/src/main/java/com/majruszsaccessories/common/AccessoryHolder.java +++ b/common/src/main/java/com/majruszsaccessories/common/AccessoryHolder.java @@ -1,18 +1,20 @@ package com.majruszsaccessories.common; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.data.Serializables; +import com.majruszlibrary.emitter.ParticleEmitter; +import com.majruszlibrary.events.base.Events; +import com.majruszlibrary.math.Random; +import com.majruszlibrary.math.Range; +import com.majruszlibrary.registry.Registries; import com.majruszsaccessories.MajruszsAccessories; +import com.majruszsaccessories.config.Config; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.config.RangedInteger; import com.majruszsaccessories.contexts.OnAccessoryExtraBonusGet; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.items.BoosterItem; import com.majruszsaccessories.particles.BonusParticleType; -import com.mlib.contexts.base.Contexts; -import com.mlib.data.Serializables; -import com.mlib.emitter.ParticleEmitter; -import com.mlib.math.Random; -import com.mlib.math.Range; -import com.mlib.registry.Registries; import net.minecraft.ChatFormatting; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; @@ -76,9 +78,9 @@ public static float apply( float bonus, RangedFloat value, float multiplier ) { } public static ChatFormatting getBonusFormatting( float bonus ) { - if( bonus > MajruszsAccessories.CONFIG.efficiency.range.to ) { + if( bonus > Config.Efficiency.RANGE.to ) { return ChatFormatting.DARK_AQUA; - } else if( bonus == MajruszsAccessories.CONFIG.efficiency.range.to ) { + } else if( bonus == Config.Efficiency.RANGE.to ) { return ChatFormatting.GOLD; } else if( bonus > 0.0f ) { return ChatFormatting.GREEN; @@ -90,7 +92,7 @@ public static ChatFormatting getBonusFormatting( float bonus ) { } public static Rarity getRarity( float bonus ) { - if( bonus >= MajruszsAccessories.CONFIG.efficiency.range.to ) { + if( bonus >= Config.Efficiency.RANGE.to ) { return Rarity.EPIC; } else if( bonus >= 0.0f ) { return Rarity.RARE; @@ -107,7 +109,7 @@ private AccessoryHolder( ItemStack itemStack, Data data ) { this.itemStack = itemStack; this.item = itemStack.getItem() instanceof AccessoryItem item ? item : null; this.data = data; - this.data.extraBonus = AccessoryHolder.round( Contexts.dispatch( new OnAccessoryExtraBonusGet( this ) ).bonus ); + this.data.extraBonus = AccessoryHolder.round( Events.dispatch( new OnAccessoryExtraBonusGet( this ) ).bonus ); } private AccessoryHolder( ItemStack itemStack ) { @@ -138,14 +140,14 @@ 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 ) ); } else { - return this.setBonus( MajruszsAccessories.CONFIG.efficiency.getRandom() ); + return this.setBonus( Config.Efficiency.getRandom() ); } } public AccessoryHolder setBonus( float bonus ) { return this.save( ()->{ this.data.baseBonus = AccessoryHolder.round( bonus ); - this.data.extraBonus = AccessoryHolder.round( Contexts.dispatch( new OnAccessoryExtraBonusGet( this ) ).bonus ); + this.data.extraBonus = AccessoryHolder.round( Events.dispatch( new OnAccessoryExtraBonusGet( this ) ).bonus ); this.data.range = null; } ); } @@ -219,7 +221,7 @@ public boolean hasBonusRangeDefined() { } public boolean hasMaxBonus() { - return this.getBaseBonus() == MajruszsAccessories.CONFIG.efficiency.range.to; + return this.getBaseBonus() == Config.Efficiency.RANGE.to; } public boolean hasBooster( BoosterItem item ) { @@ -245,9 +247,9 @@ private static class Data { static { Serializables.get( Data.class ) .define( "Bonus", subconfig->{ - subconfig.defineFloat( "Value", s->s.baseBonus, ( s, v )->s.baseBonus = v ); - subconfig.defineFloatRange( "ValueRange", s->s.range, ( s, v )->s.range = v ); - subconfig.defineCustomList( "Boosters", s->s.boosters, ( s, v )->s.boosters = v, BoosterDef::new ); + 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( "Boosters", Reader.list( Reader.custom( BoosterDef::new ) ), s->s.boosters, ( s, v )->s.boosters = v ); } ); } @@ -268,8 +270,8 @@ public Data() {} private static class BoosterDef { static { Serializables.get( BoosterDef.class ) - .defineLocation( "Id", s->s.id, ( s, v )->{ - s.item = Registries.getItem( v ) instanceof BoosterItem booster ? booster : null; + .define( "Id", Reader.location(), s->s.id, ( s, v )->{ + s.item = Registries.ITEMS.get( v ) instanceof BoosterItem booster ? booster : null; s.id = v; } ); } @@ -279,7 +281,7 @@ private static class BoosterDef { public BoosterDef( BoosterItem item ) { this.item = item; - this.id = Registries.get( item ); + this.id = Registries.ITEMS.getId( item ); } public BoosterDef() {} diff --git a/common/src/main/java/com/majruszsaccessories/common/BonusComponent.java b/common/src/main/java/com/majruszsaccessories/common/BonusComponent.java index 50dd43c5..cd7ace31 100644 --- a/common/src/main/java/com/majruszsaccessories/common/BonusComponent.java +++ b/common/src/main/java/com/majruszsaccessories/common/BonusComponent.java @@ -1,10 +1,10 @@ package com.majruszsaccessories.common; +import com.majruszlibrary.events.OnLootGenerated; +import com.majruszlibrary.level.LevelHelper; +import com.majruszlibrary.math.AnyPos; +import com.majruszlibrary.text.TextHelper; import com.majruszsaccessories.tooltip.ITooltipProvider; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.level.LevelHelper; -import com.mlib.math.AnyPos; -import com.mlib.text.TextHelper; import net.minecraft.network.chat.MutableComponent; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; diff --git a/common/src/main/java/com/majruszsaccessories/common/BonusHandler.java b/common/src/main/java/com/majruszsaccessories/common/BonusHandler.java index 33a33c18..1a282cdb 100644 --- a/common/src/main/java/com/majruszsaccessories/common/BonusHandler.java +++ b/common/src/main/java/com/majruszsaccessories/common/BonusHandler.java @@ -1,12 +1,12 @@ package com.majruszsaccessories.common; +import com.majruszlibrary.client.ClientHelper; +import com.majruszlibrary.data.SerializableClass; +import com.majruszlibrary.data.Serializables; +import com.majruszlibrary.events.OnItemDecorationsRendered; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.contexts.OnAccessoryTooltip; import com.majruszsaccessories.items.BoosterItem; -import com.mlib.client.ClientHelper; -import com.mlib.contexts.OnItemDecorationsRendered; -import com.mlib.data.Serializable; -import com.mlib.data.Serializables; import net.minecraft.ChatFormatting; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -19,16 +19,13 @@ public class BonusHandler< Type extends Item > { protected final List< BonusComponent< Type > > components = new ArrayList<>(); protected final Supplier< Type > item; - protected final Serializable< ? > config; + protected final Class< ? > clazz; protected final String id; - public BonusHandler( Supplier< Type > item, Class< ? > config, String id ) { + public BonusHandler( Supplier< Type > item, Class< ? > clazz, String id ) { this.item = item; - this.config = new Serializable<>(); + this.clazz = clazz; this.id = id; - - Serializables.get( config ) - .defineCustom( id, ()->this.config ); } public BonusHandler< Type > add( BonusComponent.ISupplier< Type > supplier ) { @@ -45,8 +42,8 @@ public Type getItem() { return this.item.get(); } - public Serializable< ? > getConfig() { - return this.config; + public SerializableClass< ? > getConfig() { + return Serializables.getStatic( this.clazz ); } public String getId() { diff --git a/common/src/main/java/com/majruszsaccessories/common/BoosterHandler.java b/common/src/main/java/com/majruszsaccessories/common/BoosterHandler.java index adc016fc..4d617fa3 100644 --- a/common/src/main/java/com/majruszsaccessories/common/BoosterHandler.java +++ b/common/src/main/java/com/majruszsaccessories/common/BoosterHandler.java @@ -1,19 +1,20 @@ package com.majruszsaccessories.common; +import com.majruszlibrary.data.Serializables; +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.items.BoosterItem; -import com.mlib.contexts.OnItemDecorationsRendered; -import com.mlib.registry.RegistryObject; import net.minecraft.ChatFormatting; import net.minecraft.world.item.ItemStack; import java.util.List; public class BoosterHandler extends BonusHandler< BoosterItem > { - public BoosterHandler( RegistryObject< BoosterItem > item ) { - super( item, Config.Boosters.class, item.getId() ); + public BoosterHandler( RegistryObject< BoosterItem > item, Class< ? extends BoosterHandler > clazz ) { + super( item, clazz, item.getId() ); OnAccessoryTooltip.listen( this::addTooltip ) .addCondition( data->data.holder.hasBooster( this.getItem() ) ); @@ -23,6 +24,9 @@ public BoosterHandler( RegistryObject< BoosterItem > item ) { OnItemDecorationsRendered.listen( this::addBoosterIcon ) .addCondition( data->data.itemStack.is( this.getItem() ) ); + + Serializables.getStatic( Config.Boosters.class ) + .define( item.getId(), clazz ); } protected void addTooltip( OnBoosterTooltip data ) { diff --git a/common/src/main/java/com/majruszsaccessories/config/Config.java b/common/src/main/java/com/majruszsaccessories/config/Config.java index 9aa58b27..4be346d7 100644 --- a/common/src/main/java/com/majruszsaccessories/config/Config.java +++ b/common/src/main/java/com/majruszsaccessories/config/Config.java @@ -1,22 +1,26 @@ package com.majruszsaccessories.config; -import com.mlib.data.Serializables; -import com.mlib.math.Random; -import com.mlib.math.Range; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.data.Serializables; +import com.majruszlibrary.math.Random; +import com.majruszlibrary.math.Range; import net.minecraft.util.Mth; -public class Config extends com.mlib.data.Config { - public Accessories accessories = new Accessories(); - public Boosters boosters = new Boosters(); - public Efficiency efficiency = new Efficiency(); +public class Config { + static { + Serializables.getStatic( Config.class ) + .define( "accessories", Accessories.class ) + .define( "boosters", Boosters.class ) + .define( "efficiency", Efficiency.class ); - public Config( String name ) { - super( name ); + Serializables.getStatic( Accessories.class ); - Serializables.get( Config.class ) - .defineCustom( "accessories", ()->this.accessories ) - .defineCustom( "boosters", ()->this.boosters ) - .defineCustom( "efficiency", ()->this.efficiency ); + Serializables.getStatic( Boosters.class ); + + Serializables.getStatic( Efficiency.class ) + .define( "range", Reader.range( Reader.number() ), ()->Efficiency.RANGE, v->Efficiency.RANGE = Range.of( -1.0f, 10.0f ).clamp( v ) ) + .define( "average", Reader.number(), ()->Efficiency.AVG, v->Efficiency.AVG = Range.of( -1.0f, 10.0f ).clamp( v ) ) + .define( "standard_deviation", Reader.number(), ()->Efficiency.STD, v->Efficiency.STD = Range.of( -1.0f, 10.0f ).clamp( v ) ); } public static class Accessories {} @@ -24,25 +28,18 @@ public static class Accessories {} public static class Boosters {} public static class Efficiency { - static { - Serializables.get( Efficiency.class ) - .defineFloatRange( "range", s->s.range, ( s, v )->s.range = Range.of( -1.0f, 10.0f ).clamp( v ) ) - .defineFloat( "average", s->s.avg, ( s, v )->s.avg = Range.of( -1.0f, 10.0f ).clamp( v ) ) - .defineFloat( "standard_deviation", s->s.std, ( s, v )->s.std = Range.of( -1.0f, 10.0f ).clamp( v ) ); - } - - public Range< Float > range = Range.of( -0.6f, 0.6f ); - public float avg = 0.0f; - public float std = 0.2f; + public static Range< Float > RANGE = Range.of( -0.6f, 0.6f ); + public static float AVG = 0.0f; + public static float STD = 0.2f; - public float getRandom() { - if( Math.abs( this.range.to - this.range.from ) < 1e-5 ) { - return this.range.from; + public static float getRandom() { + if( Math.abs( RANGE.to - RANGE.from ) < 1e-5 ) { + return RANGE.from; } - float ratio = ( float )( ( Random.nextGaussian() * this.std + this.avg - this.range.from ) / ( this.range.to - this.range.from ) ); + float ratio = ( float )( ( Random.nextGaussian() * STD + AVG - RANGE.from ) / ( RANGE.to - RANGE.from ) ); - return this.range.lerp( Mth.clamp( ratio, 0.0f, 1.0f ) ); + return RANGE.lerp( Mth.clamp( ratio, 0.0f, 1.0f ) ); } } } diff --git a/common/src/main/java/com/majruszsaccessories/config/RangedFloat.java b/common/src/main/java/com/majruszsaccessories/config/RangedFloat.java index cd9b287c..8af29d43 100644 --- a/common/src/main/java/com/majruszsaccessories/config/RangedFloat.java +++ b/common/src/main/java/com/majruszsaccessories/config/RangedFloat.java @@ -1,7 +1,8 @@ package com.majruszsaccessories.config; -import com.mlib.data.Serializable; -import com.mlib.math.Range; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.data.SerializableObject; +import com.majruszlibrary.math.Range; public class RangedFloat { private float value; @@ -26,10 +27,10 @@ public void set( float value, Range< Float > range ) { this.range = range; } - public void define( Serializable< ? > serializable ) { - serializable.defineFloat( this.id, s->this.value, ( s, v )->this.value = this.range.clamp( v ) ); + public void define( SerializableObject< ? > serializable ) { + serializable.define( this.id, Reader.number(), s->this.value, ( s, v )->this.value = this.range.clamp( v ) ); if( this.maxRange != null ) { - serializable.defineFloatRange( "%s_range".formatted( this.id ), s->this.range, ( s, v )->this.range = this.maxRange.clamp( v ) ); + serializable.define( "%s_range".formatted( this.id ), Reader.range( Reader.number() ), s->this.range, ( s, v )->this.range = this.maxRange.clamp( v ) ); } } diff --git a/common/src/main/java/com/majruszsaccessories/config/RangedInteger.java b/common/src/main/java/com/majruszsaccessories/config/RangedInteger.java index 6103661d..60c4b388 100644 --- a/common/src/main/java/com/majruszsaccessories/config/RangedInteger.java +++ b/common/src/main/java/com/majruszsaccessories/config/RangedInteger.java @@ -1,7 +1,8 @@ package com.majruszsaccessories.config; -import com.mlib.data.Serializable; -import com.mlib.math.Range; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.data.SerializableObject; +import com.majruszlibrary.math.Range; public class RangedInteger { private Integer value; @@ -26,10 +27,10 @@ public void set( int value, Range< Integer > range ) { this.range = range; } - public void define( Serializable< ? > serializable ) { - serializable.defineInteger( this.id, s->this.value, ( s, v )->this.value = this.range.clamp( v ) ); + public void define( SerializableObject< ? > serializable ) { + serializable.define( this.id, Reader.integer(), s->this.value, ( s, v )->this.value = this.range.clamp( v ) ); if( this.maxRange != null ) { - serializable.defineIntegerRange( "%s_range".formatted( this.id ), s->this.range, ( s, v )->this.range = this.maxRange.clamp( v ) ); + serializable.define( "%s_range".formatted( this.id ), Reader.range( Reader.integer() ), s->this.range, ( s, v )->this.range = this.maxRange.clamp( v ) ); } } diff --git a/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryDropChanceGet.java b/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryDropChanceGet.java index a7d1a546..516d667e 100644 --- a/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryDropChanceGet.java +++ b/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryDropChanceGet.java @@ -1,8 +1,8 @@ package com.majruszsaccessories.contexts; -import com.mlib.contexts.base.Context; -import com.mlib.contexts.base.Contexts; -import com.mlib.math.Random; +import com.majruszlibrary.events.base.Event; +import com.majruszlibrary.events.base.Events; +import com.majruszlibrary.math.Random; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; @@ -15,8 +15,8 @@ public class OnAccessoryDropChanceGet { public float chance; public final @Nullable Player player; - public static Context< OnAccessoryDropChanceGet > listen( Consumer< OnAccessoryDropChanceGet > consumer ) { - return Contexts.get( OnAccessoryDropChanceGet.class ).add( consumer ); + public static Event< OnAccessoryDropChanceGet > listen( Consumer< OnAccessoryDropChanceGet > consumer ) { + return Events.get( OnAccessoryDropChanceGet.class ).add( consumer ); } public OnAccessoryDropChanceGet( float chance, @Nullable Entity entity ) { diff --git a/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryExtraBonusGet.java b/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryExtraBonusGet.java index d8941396..d0ec41dd 100644 --- a/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryExtraBonusGet.java +++ b/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryExtraBonusGet.java @@ -1,8 +1,8 @@ package com.majruszsaccessories.contexts; +import com.majruszlibrary.events.base.Event; +import com.majruszlibrary.events.base.Events; import com.majruszsaccessories.common.AccessoryHolder; -import com.mlib.contexts.base.Context; -import com.mlib.contexts.base.Contexts; import java.util.function.Consumer; @@ -11,8 +11,8 @@ public class OnAccessoryExtraBonusGet { public final float original = 0.0f; public float bonus = 0.0f; - public static Context< OnAccessoryExtraBonusGet > listen( Consumer< OnAccessoryExtraBonusGet > consumer ) { - return Contexts.get( OnAccessoryExtraBonusGet.class ).add( consumer ); + public static Event< OnAccessoryExtraBonusGet > listen( Consumer< OnAccessoryExtraBonusGet > consumer ) { + return Events.get( OnAccessoryExtraBonusGet.class ).add( consumer ); } public OnAccessoryExtraBonusGet( AccessoryHolder holder ) { diff --git a/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryTooltip.java b/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryTooltip.java index 8d65e586..8890ffd0 100644 --- a/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryTooltip.java +++ b/common/src/main/java/com/majruszsaccessories/contexts/OnAccessoryTooltip.java @@ -1,8 +1,8 @@ package com.majruszsaccessories.contexts; +import com.majruszlibrary.events.base.Event; +import com.majruszlibrary.events.base.Events; import com.majruszsaccessories.common.AccessoryHolder; -import com.mlib.contexts.base.Context; -import com.mlib.contexts.base.Contexts; import net.minecraft.network.chat.Component; import java.util.ArrayList; @@ -13,8 +13,8 @@ public class OnAccessoryTooltip { public final List< Component > components = new ArrayList<>(); public final AccessoryHolder holder; - public static Context< OnAccessoryTooltip > listen( Consumer< OnAccessoryTooltip > consumer ) { - return Contexts.get( OnAccessoryTooltip.class ).add( consumer ); + public static Event< OnAccessoryTooltip > listen( Consumer< OnAccessoryTooltip > consumer ) { + return Events.get( OnAccessoryTooltip.class ).add( consumer ); } public OnAccessoryTooltip( AccessoryHolder holder ) { diff --git a/common/src/main/java/com/majruszsaccessories/contexts/OnBoosterCompatibilityGet.java b/common/src/main/java/com/majruszsaccessories/contexts/OnBoosterCompatibilityGet.java index 8131c8e4..10861acf 100644 --- a/common/src/main/java/com/majruszsaccessories/contexts/OnBoosterCompatibilityGet.java +++ b/common/src/main/java/com/majruszsaccessories/contexts/OnBoosterCompatibilityGet.java @@ -1,8 +1,8 @@ package com.majruszsaccessories.contexts; +import com.majruszlibrary.events.base.Event; +import com.majruszlibrary.events.base.Events; import com.majruszsaccessories.items.BoosterItem; -import com.mlib.contexts.base.Context; -import com.mlib.contexts.base.Contexts; import java.util.function.Consumer; @@ -11,8 +11,8 @@ public class OnBoosterCompatibilityGet { public final BoosterItem b; private boolean areIncompatible; - public static Context< OnBoosterCompatibilityGet > listen( Consumer< OnBoosterCompatibilityGet > consumer ) { - return Contexts.get( OnBoosterCompatibilityGet.class ).add( consumer ); + public static Event< OnBoosterCompatibilityGet > listen( Consumer< OnBoosterCompatibilityGet > consumer ) { + return Events.get( OnBoosterCompatibilityGet.class ).add( consumer ); } public OnBoosterCompatibilityGet( BoosterItem a, BoosterItem b ) { diff --git a/common/src/main/java/com/majruszsaccessories/contexts/OnBoosterTooltip.java b/common/src/main/java/com/majruszsaccessories/contexts/OnBoosterTooltip.java index 1a47dd94..07a55a8e 100644 --- a/common/src/main/java/com/majruszsaccessories/contexts/OnBoosterTooltip.java +++ b/common/src/main/java/com/majruszsaccessories/contexts/OnBoosterTooltip.java @@ -1,8 +1,8 @@ package com.majruszsaccessories.contexts; +import com.majruszlibrary.events.base.Event; +import com.majruszlibrary.events.base.Events; import com.majruszsaccessories.items.BoosterItem; -import com.mlib.contexts.base.Context; -import com.mlib.contexts.base.Contexts; import net.minecraft.network.chat.Component; import java.util.ArrayList; @@ -13,8 +13,8 @@ public class OnBoosterTooltip { public final List< Component > components = new ArrayList<>(); public final BoosterItem booster; - public static Context< OnBoosterTooltip > listen( Consumer< OnBoosterTooltip > consumer ) { - return Contexts.get( OnBoosterTooltip.class ).add( consumer ); + public static Event< OnBoosterTooltip > listen( Consumer< OnBoosterTooltip > consumer ) { + return Events.get( OnBoosterTooltip.class ).add( consumer ); } public OnBoosterTooltip( BoosterItem booster ) { diff --git a/common/src/main/java/com/majruszsaccessories/contexts/base/CustomConditions.java b/common/src/main/java/com/majruszsaccessories/contexts/base/CustomConditions.java index 43ac0d62..efcdd07e 100644 --- a/common/src/main/java/com/majruszsaccessories/contexts/base/CustomConditions.java +++ b/common/src/main/java/com/majruszsaccessories/contexts/base/CustomConditions.java @@ -1,13 +1,13 @@ package com.majruszsaccessories.contexts.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.items.AccessoryItem; import com.majruszsaccessories.items.BoosterItem; -import com.mlib.contexts.base.Condition; -import com.mlib.contexts.base.Contexts; -import com.mlib.math.Random; -import com.mlib.platform.LogicalSafe; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; @@ -37,7 +37,7 @@ public static < DataType > Condition< DataType > chance( Supplier< AccessoryItem } public static < DataType > Condition< DataType > dropChance( Function< DataType, Float > chance, Function< DataType, Entity > entity ) { - return Condition.predicate( data->Contexts.dispatch( new OnAccessoryDropChanceGet( chance.apply( data ), entity.apply( data ) ) ).check() ); + return Condition.predicate( data->Events.dispatch( new OnAccessoryDropChanceGet( chance.apply( data ), entity.apply( data ) ) ).check() ); } public static < DataType > Condition< DataType > dropChance( Supplier< Float > chance, Function< DataType, Entity > entity ) { diff --git a/common/src/main/java/com/majruszsaccessories/items/CreativeModeTabs.java b/common/src/main/java/com/majruszsaccessories/items/CreativeModeTabs.java index 0a597d9c..30c0e372 100644 --- a/common/src/main/java/com/majruszsaccessories/items/CreativeModeTabs.java +++ b/common/src/main/java/com/majruszsaccessories/items/CreativeModeTabs.java @@ -1,10 +1,11 @@ package com.majruszsaccessories.items; +import com.majruszlibrary.item.CreativeModeTabHelper; +import com.majruszlibrary.registry.Registries; +import com.majruszlibrary.text.TextHelper; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.common.AccessoryHolder; -import com.mlib.item.CreativeModeTabHelper; -import com.mlib.registry.Registries; -import com.mlib.text.TextHelper; +import com.majruszsaccessories.config.Config; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import net.minecraft.world.item.CreativeModeTab; @@ -31,7 +32,7 @@ public static Supplier< CreativeModeTab > primary() { private static List< Item > getPrimaryIcons() { List< Item > items = new ArrayList<>(); - for( Item item : Registries.getItems() ) { + for( Item item : Registries.ITEMS ) { if( item instanceof AccessoryItem ) { items.add( item ); } @@ -42,7 +43,7 @@ private static List< Item > getPrimaryIcons() { private static void definePrimaryItems( CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output ) { List< AccessoryItem > accessories = new ArrayList<>(); - for( Item item : Registries.getItems() ) { + for( Item item : Registries.ITEMS ) { if( item instanceof AccessoryItem accessory ) { accessories.add( accessory ); } @@ -50,7 +51,7 @@ private static void definePrimaryItems( CreativeModeTab.ItemDisplayParameters pa accessories.sort( Comparator.comparingInt( AccessoryItem::getBoosterSlotsCount ) ); for( AccessoryItem accessory : accessories ) { for( int i = 0; i < 9; ++i ) { - float bonus = Mth.lerp( i / 8.0f, MajruszsAccessories.CONFIG.efficiency.range.from, MajruszsAccessories.CONFIG.efficiency.range.to ); + float bonus = Mth.lerp( i / 8.0f, Config.Efficiency.RANGE.from, Config.Efficiency.RANGE.to ); output.accept( AccessoryHolder.create( accessory ).setBonus( bonus ).getItemStack() ); } diff --git a/common/src/main/java/com/majruszsaccessories/listeners/AccessoryObserver.java b/common/src/main/java/com/majruszsaccessories/listeners/AccessoryObserver.java index f0d07746..9d862b53 100644 --- a/common/src/main/java/com/majruszsaccessories/listeners/AccessoryObserver.java +++ b/common/src/main/java/com/majruszsaccessories/listeners/AccessoryObserver.java @@ -1,12 +1,12 @@ package com.majruszsaccessories.listeners; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.events.OnItemCrafted; +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 com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnItemCrafted; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.contexts.base.Condition; -import com.mlib.contexts.base.Priority; import net.minecraft.server.level.ServerPlayer; @AutoInstance diff --git a/common/src/main/java/com/majruszsaccessories/listeners/AccessoryTooltipUpdater.java b/common/src/main/java/com/majruszsaccessories/listeners/AccessoryTooltipUpdater.java index 5e66ecca..9f7da295 100644 --- a/common/src/main/java/com/majruszsaccessories/listeners/AccessoryTooltipUpdater.java +++ b/common/src/main/java/com/majruszsaccessories/listeners/AccessoryTooltipUpdater.java @@ -1,18 +1,18 @@ package com.majruszsaccessories.listeners; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.client.ClientHelper; +import com.majruszlibrary.events.OnItemTooltip; +import com.majruszlibrary.events.base.Condition; +import com.majruszlibrary.events.base.Events; +import com.majruszlibrary.math.Range; +import com.majruszlibrary.text.TextHelper; +import com.majruszlibrary.time.TimeHelper; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.contexts.OnAccessoryTooltip; import com.majruszsaccessories.items.AccessoryItem; import com.majruszsaccessories.tooltip.TooltipHelper; -import com.mlib.annotation.AutoInstance; -import com.mlib.client.ClientHelper; -import com.mlib.contexts.OnItemTooltip; -import com.mlib.contexts.base.Condition; -import com.mlib.contexts.base.Contexts; -import com.mlib.math.Range; -import com.mlib.text.TextHelper; -import com.mlib.time.TimeHelper; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; @@ -86,7 +86,7 @@ private ChatFormatting getUseFormatting( AccessoryHolder holder, @Nullable Playe } private List< Component > buildEffectsInfo( AccessoryHolder holder ) { - OnAccessoryTooltip tooltipData = Contexts.dispatch( new OnAccessoryTooltip( holder ) ); + OnAccessoryTooltip tooltipData = Events.dispatch( new OnAccessoryTooltip( holder ) ); boolean cannotFitSinglePage = tooltipData.components.size() > PAGE_SIZE; if( cannotFitSinglePage ) { return this.getCurrentPageSublist( tooltipData.components ); diff --git a/common/src/main/java/com/majruszsaccessories/listeners/BoosterDropper.java b/common/src/main/java/com/majruszsaccessories/listeners/BoosterDropper.java index be390ab7..bbffcc29 100644 --- a/common/src/main/java/com/majruszsaccessories/listeners/BoosterDropper.java +++ b/common/src/main/java/com/majruszsaccessories/listeners/BoosterDropper.java @@ -1,15 +1,16 @@ package com.majruszsaccessories.listeners; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.data.Serializables; +import com.majruszlibrary.entity.EntityHelper; +import com.majruszlibrary.events.OnLootGenerated; +import com.majruszlibrary.events.base.Condition; +import com.majruszlibrary.item.LootHelper; +import com.majruszlibrary.level.BlockHelper; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.config.Config; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnLootGenerated; -import com.mlib.contexts.base.Condition; -import com.mlib.data.Serializables; -import com.mlib.entity.EntityHelper; -import com.mlib.item.LootHelper; -import com.mlib.level.BlockHelper; -import com.mlib.math.Range; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; @@ -42,9 +43,9 @@ public BoosterDropper() { .addCondition( Condition.predicate( data->EntityHelper.isIn( data.killer, Level.NETHER ) ) ); Serializables.get( Config.Boosters.class ) - .defineLocation( "loot_table", s->this.lootTable, ( s, v )->this.lootTable = v ) - .defineFloat( "nether_chest_chance", s->this.chestChance, ( s, v )->this.chestChance = Range.CHANCE.clamp( v ) ) - .defineFloat( "nether_mob_chance", s->this.mobChance, ( s, v )->this.mobChance = Range.CHANCE.clamp( v ) ); + .define( "loot_table", Reader.location(), s->this.lootTable, ( s, v )->this.lootTable = v ) + .define( "nether_chest_chance", Reader.number(), s->this.chestChance, ( s, v )->this.chestChance = Range.CHANCE.clamp( v ) ) + .define( "nether_mob_chance", Reader.number(), s->this.mobChance, ( s, v )->this.mobChance = Range.CHANCE.clamp( v ) ); } private void spawnBoosterInChest( OnLootGenerated data ) { diff --git a/common/src/main/java/com/majruszsaccessories/listeners/BoosterTooltipUpdater.java b/common/src/main/java/com/majruszsaccessories/listeners/BoosterTooltipUpdater.java index 0f5b0e49..1f080fa1 100644 --- a/common/src/main/java/com/majruszsaccessories/listeners/BoosterTooltipUpdater.java +++ b/common/src/main/java/com/majruszsaccessories/listeners/BoosterTooltipUpdater.java @@ -1,12 +1,12 @@ package com.majruszsaccessories.listeners; +import com.majruszlibrary.annotation.AutoInstance; +import com.majruszlibrary.events.OnItemTooltip; +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.items.BoosterItem; -import com.mlib.annotation.AutoInstance; -import com.mlib.contexts.OnItemTooltip; -import com.mlib.contexts.base.Condition; -import com.mlib.contexts.base.Contexts; -import com.mlib.text.TextHelper; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; @@ -29,7 +29,7 @@ private List< Component > buildGenericInfo() { } private List< Component > buildEffectsInfo( OnItemTooltip data ) { - return Contexts.dispatch( new OnBoosterTooltip( ( BoosterItem )data.itemStack.getItem() ) ).components; + return Events.dispatch( new OnBoosterTooltip( ( BoosterItem )data.itemStack.getItem() ) ).components; } static final class Tooltips { diff --git a/common/src/main/java/com/majruszsaccessories/particles/BonusParticle.java b/common/src/main/java/com/majruszsaccessories/particles/BonusParticle.java index da21c546..7688c905 100644 --- a/common/src/main/java/com/majruszsaccessories/particles/BonusParticle.java +++ b/common/src/main/java/com/majruszsaccessories/particles/BonusParticle.java @@ -1,10 +1,10 @@ package com.majruszsaccessories.particles; -import com.mlib.annotation.Dist; -import com.mlib.annotation.OnlyIn; -import com.mlib.client.CustomParticle; -import com.mlib.math.Random; -import com.mlib.time.TimeHelper; +import com.majruszlibrary.annotation.Dist; +import com.majruszlibrary.annotation.OnlyIn; +import com.majruszlibrary.client.CustomParticle; +import com.majruszlibrary.math.Random; +import com.majruszlibrary.time.TimeHelper; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.particle.ParticleRenderType; import net.minecraft.client.particle.SpriteSet; diff --git a/common/src/main/java/com/majruszsaccessories/particles/BonusParticleType.java b/common/src/main/java/com/majruszsaccessories/particles/BonusParticleType.java index 48141470..9b73edbb 100644 --- a/common/src/main/java/com/majruszsaccessories/particles/BonusParticleType.java +++ b/common/src/main/java/com/majruszsaccessories/particles/BonusParticleType.java @@ -1,25 +1,26 @@ package com.majruszsaccessories.particles; +import com.majruszlibrary.data.Reader; +import com.majruszlibrary.data.Serializables; +import com.majruszlibrary.particles.CustomParticleOptions; +import com.majruszlibrary.particles.CustomParticleType; import com.majruszsaccessories.MajruszsAccessories; -import com.mlib.data.Serializables; -import com.mlib.particles.CustomParticleOptions; -import com.mlib.particles.CustomParticleType; public class BonusParticleType extends CustomParticleType< BonusParticleType.Options > { static { Serializables.get( Options.class ) - .defineInteger( "color", s->s.color, ( s, v )->s.color = v ); + .define( "color", Reader.integer(), s->s.color, ( s, v )->s.color = v ); } public BonusParticleType() { - super( Options.class, Options::new ); + super( Options::new ); } public static class Options extends CustomParticleOptions< Options > { public int color; public Options() { - super( Options.class, MajruszsAccessories.BONUS_PARTICLE ); + super( MajruszsAccessories.BONUS_PARTICLE ); } public Options( int color ) { diff --git a/common/src/main/java/com/majruszsaccessories/recipes/AccessoryRecipe.java b/common/src/main/java/com/majruszsaccessories/recipes/AccessoryRecipe.java index 4ee5c97b..669587ac 100644 --- a/common/src/main/java/com/majruszsaccessories/recipes/AccessoryRecipe.java +++ b/common/src/main/java/com/majruszsaccessories/recipes/AccessoryRecipe.java @@ -3,10 +3,11 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.common.AccessoryHolder; +import com.majruszsaccessories.config.Config; import com.majruszsaccessories.items.AccessoryItem; -import com.mlib.math.Range; import net.minecraft.core.RegistryAccess; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; @@ -49,8 +50,8 @@ public ItemStack assemble( CraftingContainer container, RegistryAccess registryA RecipeData data = RecipeData.build( container ); float average = data.getAverageBonus(); float std = data.getStandardDeviation(); - float minBonus = MajruszsAccessories.CONFIG.efficiency.range.clamp( average - std ); - float maxBonus = MajruszsAccessories.CONFIG.efficiency.range.clamp( average + std ); + float minBonus = Config.Efficiency.RANGE.clamp( average - std ); + float maxBonus = Config.Efficiency.RANGE.clamp( average + std ); return AccessoryHolder.create( this.result ).setBonus( Range.of( minBonus, maxBonus ) ).getItemStack(); } diff --git a/common/src/main/java/com/majruszsaccessories/recipes/BoostAccessoriesRecipe.java b/common/src/main/java/com/majruszsaccessories/recipes/BoostAccessoriesRecipe.java index 79594f92..9a0ab13a 100644 --- a/common/src/main/java/com/majruszsaccessories/recipes/BoostAccessoriesRecipe.java +++ b/common/src/main/java/com/majruszsaccessories/recipes/BoostAccessoriesRecipe.java @@ -1,10 +1,10 @@ package com.majruszsaccessories.recipes; +import com.majruszlibrary.events.base.Events; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.contexts.OnBoosterCompatibilityGet; import com.majruszsaccessories.items.BoosterItem; -import com.mlib.contexts.base.Contexts; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.CraftingContainer; @@ -65,7 +65,7 @@ private static boolean areCompatible( List< BoosterItem > a, List< BoosterItem > items.addAll( b ); for( int i = 0; i < items.size(); ++i ) { for( int j = i + 1; j < items.size(); ++j ) { - if( Contexts.dispatch( new OnBoosterCompatibilityGet( items.get( i ), items.get( j ) ) ).areIncompatible() ) { + if( Events.dispatch( new OnBoosterCompatibilityGet( items.get( i ), items.get( j ) ) ).areIncompatible() ) { return false; } } diff --git a/common/src/main/java/com/majruszsaccessories/recipes/CombineAccessoriesRecipe.java b/common/src/main/java/com/majruszsaccessories/recipes/CombineAccessoriesRecipe.java index 2f9c4877..235b5c90 100644 --- a/common/src/main/java/com/majruszsaccessories/recipes/CombineAccessoriesRecipe.java +++ b/common/src/main/java/com/majruszsaccessories/recipes/CombineAccessoriesRecipe.java @@ -1,8 +1,9 @@ package com.majruszsaccessories.recipes; +import com.majruszlibrary.math.Range; import com.majruszsaccessories.MajruszsAccessories; import com.majruszsaccessories.common.AccessoryHolder; -import com.mlib.math.Range; +import com.majruszsaccessories.config.Config; import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.CraftingContainer; @@ -30,7 +31,7 @@ public boolean matches( CraftingContainer container, Level level ) { return data.getAccessoriesSize() > 1 && data.hasIdenticalItemTypes() - && data.getMaxBonus() < MajruszsAccessories.CONFIG.efficiency.range.to + && data.getMaxBonus() < Config.Efficiency.RANGE.to && data.getBoostersSize() == 0; } @@ -38,8 +39,8 @@ public boolean matches( CraftingContainer container, Level level ) { public ItemStack assemble( CraftingContainer container, RegistryAccess registryAccess ) { RecipeData data = RecipeData.build( container ); float craftingMaxBonus = data.getMaxBonus(); - float minBonus = MajruszsAccessories.CONFIG.efficiency.range.clamp( craftingMaxBonus - 0.02f * ( data.getAccessoriesSize() - 1 ) ); - float maxBonus = MajruszsAccessories.CONFIG.efficiency.range.clamp( craftingMaxBonus + 0.07f * ( data.getAccessoriesSize() - 1 ) ); + float minBonus = Config.Efficiency.RANGE.clamp( craftingMaxBonus - 0.02f * ( data.getAccessoriesSize() - 1 ) ); + float maxBonus = Config.Efficiency.RANGE.clamp( craftingMaxBonus + 0.07f * ( data.getAccessoriesSize() - 1 ) ); return AccessoryHolder.create( data.getAccessory( 0 ).getItem() ).setBonus( Range.of( minBonus, maxBonus ) ).getItemStack(); } diff --git a/common/src/main/java/com/majruszsaccessories/tooltip/TooltipHelper.java b/common/src/main/java/com/majruszsaccessories/tooltip/TooltipHelper.java index bf931efa..b2e41713 100644 --- a/common/src/main/java/com/majruszsaccessories/tooltip/TooltipHelper.java +++ b/common/src/main/java/com/majruszsaccessories/tooltip/TooltipHelper.java @@ -1,11 +1,11 @@ package com.majruszsaccessories.tooltip; +import com.majruszlibrary.math.Range; +import com.majruszlibrary.text.TextHelper; import com.majruszsaccessories.common.AccessoryHolder; import com.majruszsaccessories.config.RangedFloat; import com.majruszsaccessories.config.RangedInteger; import com.majruszsaccessories.items.BoosterItem; -import com.mlib.math.Range; -import com.mlib.text.TextHelper; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.MutableComponent; import net.minecraft.world.entity.EntityType; diff --git a/fabric/build.gradle b/fabric/build.gradle index 90aa1434..f5e6d319 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -47,8 +47,8 @@ project(':common') { filter { String line -> line.replaceAll('@OnlyIn', '@Environment') .replaceAll('Dist.CLIENT', 'EnvType.CLIENT') - .replaceAll('com.mlib.annotation.Dist', 'net.fabricmc.api.EnvType') - .replaceAll('com.mlib.annotation.OnlyIn', 'net.fabricmc.api.Environment') + .replaceAll('com.majruszlibrary.annotation.Dist', 'net.fabricmc.api.EnvType') + .replaceAll('com.majruszlibrary.annotation.OnlyIn', 'net.fabricmc.api.Environment') } } @@ -74,7 +74,7 @@ tasks.withType(JavaCompile) { dependencies { minecraft "com.mojang:minecraft:${minecraft_version}" mappings loom.officialMojangMappings() - modImplementation "com.mlib:majrusz-library-fabric:${mlib_version}" + modImplementation "com.majruszlibrary:majrusz-library-fabric:${majruszlibrary_version}" modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}" modImplementation "dev.emi:trinkets:${fabric_trinkets_version}" diff --git a/fabric/libs/majrusz-library-fabric-1.20.1-6.1.7.jar b/fabric/libs/majrusz-library-fabric-1.20.1-6.1.7.jar deleted file mode 100644 index 3f548cb8..00000000 Binary files a/fabric/libs/majrusz-library-fabric-1.20.1-6.1.7.jar and /dev/null differ diff --git a/fabric/libs/majrusz-library-fabric-1.20.1-7.0.0.jar b/fabric/libs/majrusz-library-fabric-1.20.1-7.0.0.jar new file mode 100644 index 00000000..5a7e2b51 Binary files /dev/null and b/fabric/libs/majrusz-library-fabric-1.20.1-7.0.0.jar differ diff --git a/fabric/src/main/java/com/majruszsaccessories/integration/SlotFabric.java b/fabric/src/main/java/com/majruszsaccessories/integration/SlotFabric.java index 288b692f..2e381391 100644 --- a/fabric/src/main/java/com/majruszsaccessories/integration/SlotFabric.java +++ b/fabric/src/main/java/com/majruszsaccessories/integration/SlotFabric.java @@ -1,6 +1,6 @@ package com.majruszsaccessories.integration; -import com.mlib.platform.Integration; +import com.majruszlibrary.platform.Integration; import dev.emi.trinkets.api.TrinketComponent; import dev.emi.trinkets.api.TrinketsApi; import net.minecraft.util.Tuple; diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 314a1f62..633e9e66 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -18,8 +18,8 @@ }, "depends": { "fabric": "*", - "minecraft": ">=${minecraft_version}", - "mlib": "${fabric_mlib_version_range}" + "minecraft": "${fabric_minecraft_version_range}", + "majruszlibrary": "${fabric_majruszlibrary_version_range}" }, "custom": { "update": "${mod_update}" diff --git a/forge/build.gradle b/forge/build.gradle index b1d3595f..e8306f33 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -41,8 +41,8 @@ project(':common') { duplicatesStrategy = DuplicatesStrategy.INCLUDE filter { - String line -> line.replaceAll('com.mlib.annotation.Dist', 'net.minecraftforge.api.distmarker.Dist') - .replaceAll('com.mlib.annotation.OnlyIn', 'net.minecraftforge.api.distmarker.OnlyIn') + String line -> line.replaceAll('com.majruszlibrary.annotation.Dist', 'net.minecraftforge.api.distmarker.Dist') + .replaceAll('com.majruszlibrary.annotation.OnlyIn', 'net.minecraftforge.api.distmarker.OnlyIn') } } @@ -111,7 +111,7 @@ java { dependencies { minecraft "net.minecraftforge:forge:${forge_version}" compileOnly project(':common') - implementation fg.deobf("com.mlib:majrusz-library-forge:${mlib_version}") + implementation fg.deobf("com.majruszlibrary:majrusz-library-forge:${majruszlibrary_version}") runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${forge_curios_version}") compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${forge_curios_version}:api") diff --git a/forge/libs/majrusz-library-forge-1.20.1-6.1.7.jar b/forge/libs/majrusz-library-forge-1.20.1-6.1.7.jar deleted file mode 100644 index 7515b112..00000000 Binary files a/forge/libs/majrusz-library-forge-1.20.1-6.1.7.jar and /dev/null differ diff --git a/forge/libs/majrusz-library-forge-1.20.1-7.0.0.jar b/forge/libs/majrusz-library-forge-1.20.1-7.0.0.jar new file mode 100644 index 00000000..1ec35ada Binary files /dev/null and b/forge/libs/majrusz-library-forge-1.20.1-7.0.0.jar differ diff --git a/forge/src/main/java/com/majruszsaccessories/integration/SlotForge.java b/forge/src/main/java/com/majruszsaccessories/integration/SlotForge.java index 63163d78..9f93a7ec 100644 --- a/forge/src/main/java/com/majruszsaccessories/integration/SlotForge.java +++ b/forge/src/main/java/com/majruszsaccessories/integration/SlotForge.java @@ -1,6 +1,6 @@ package com.majruszsaccessories.integration; -import com.mlib.platform.Integration; +import com.majruszlibrary.platform.Integration; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import top.theillusivec4.curios.api.CuriosApi; diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 6722ae3c..510bfdb0 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -23,14 +23,14 @@ issueTrackerURL = "${mod_issues}" [[dependencies.${ mod_id }]] modId = "minecraft" mandatory = true - versionRange = "${minecraft_version_range}" + versionRange = "${forge_minecraft_version_range}" ordering = "NONE" side = "BOTH" [[dependencies.${ mod_id }]] - modId = "mlib" + modId = "majruszlibrary" mandatory = true - versionRange = "${forge_mlib_version_range}" + versionRange = "${forge_majruszlibrary_version_range}" ordering = "NONE" side = "BOTH" diff --git a/gradle.properties b/gradle.properties index c693ade7..3f119cbc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,12 +3,11 @@ org.gradle.jvmargs=-Xmx4G # Minecraft minecraft_version=1.20.1 -minecraft_version_range=[1.20.1,) # Mod mod_id=majruszsaccessories mod_archives_name=majruszs-accessories -mod_version=1.3.3 +mod_version=1.3.4 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 @@ -23,7 +22,8 @@ mod_logo=logo.png forge_version=1.20.1-47.1.0 forge_version_loader=[47,) forge_version_range=[47.1,) -forge_mlib_version_range=[6.1.7,7.0.0) +forge_minecraft_version_range=[1.20.1,) +forge_majruszlibrary_version_range=[7.0.0,8.0.0) forge_curios_version=5.2.0-beta.3+1.20.1 forge_curios_version_range=[5.2.0-beta.3+1.20.1,) @@ -31,19 +31,21 @@ forge_curios_version_range=[5.2.0-beta.3+1.20.1,) neoforge_version=1.20.1-47.1.76 neoforge_version_loader=[47,) neoforge_version_range=1.20.1-47.1.76 -neoforge_mlib_version_range=[6.1.7,7.0.0) +neoforge_minecraft_version_range=[1.20.1,) +neoforge_majruszlibrary_version_range=[7.0.0,8.0.0) neoforge_curios_version=5.2.0-beta.3+1.20.1 neoforge_curios_version_range=[5.2.0-beta.3+1.20.1,) # Fabric fabric_loader_version=0.14.22 fabric_api_version=0.89.0+1.20.1 -fabric_mlib_version_range=>=6.1.7 +fabric_minecraft_version_range=>=1.20.1 +fabric_majruszlibrary_version_range=>=7.0.0 fabric_trinkets_version=3.7.0 fabric_cca_version=5.2.0 # Majrusz Library -mlib_version=1.20.1-6.1.7 +majruszlibrary_version=1.20.1-7.0.0 # Publishing modrinth_project_id=6roN0iTa diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 817c17c5..84671608 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -41,8 +41,8 @@ project(':common') { duplicatesStrategy = DuplicatesStrategy.INCLUDE filter { - String line -> line.replaceAll('com.mlib.annotation.Dist', 'net.minecraftforge.api.distmarker.Dist') - .replaceAll('com.mlib.annotation.OnlyIn', 'net.minecraftforge.api.distmarker.OnlyIn') + String line -> line.replaceAll('com.majruszlibrary.annotation.Dist', 'net.minecraftforge.api.distmarker.Dist') + .replaceAll('com.majruszlibrary.annotation.OnlyIn', 'net.minecraftforge.api.distmarker.OnlyIn') } } @@ -110,7 +110,7 @@ java { dependencies { minecraft "net.neoforged:forge:${neoforge_version}" - implementation fg.deobf("com.mlib:majrusz-library-neoforge:${mlib_version}") + implementation fg.deobf("com.majruszlibrary:majrusz-library-neoforge:${majruszlibrary_version}") compileOnly project(':common') runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${neoforge_curios_version}") compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${neoforge_curios_version}:api") diff --git a/neoforge/libs/majrusz-library-neoforge-1.20.1-6.1.7.jar b/neoforge/libs/majrusz-library-neoforge-1.20.1-6.1.7.jar deleted file mode 100644 index b0b0bd9e..00000000 Binary files a/neoforge/libs/majrusz-library-neoforge-1.20.1-6.1.7.jar and /dev/null differ diff --git a/neoforge/libs/majrusz-library-neoforge-1.20.1-7.0.0.jar b/neoforge/libs/majrusz-library-neoforge-1.20.1-7.0.0.jar new file mode 100644 index 00000000..074865ed Binary files /dev/null and b/neoforge/libs/majrusz-library-neoforge-1.20.1-7.0.0.jar differ diff --git a/neoforge/src/main/java/com/majruszsaccessories/integration/SlotNeoForge.java b/neoforge/src/main/java/com/majruszsaccessories/integration/SlotNeoForge.java index d0c2753e..09a3ab0a 100644 --- a/neoforge/src/main/java/com/majruszsaccessories/integration/SlotNeoForge.java +++ b/neoforge/src/main/java/com/majruszsaccessories/integration/SlotNeoForge.java @@ -1,6 +1,6 @@ package com.majruszsaccessories.integration; -import com.mlib.platform.Integration; +import com.majruszlibrary.platform.Integration; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import top.theillusivec4.curios.api.CuriosApi; diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml index d148d93d..94fb9b51 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -23,14 +23,14 @@ issueTrackerURL = "${mod_issues}" [[dependencies.${ mod_id }]] modId = "minecraft" mandatory = true - versionRange = "${minecraft_version_range}" + versionRange = "${neoforge_minecraft_version_range}" ordering = "NONE" side = "BOTH" [[dependencies.${ mod_id }]] - modId = "mlib" + modId = "majruszlibrary" mandatory = true - versionRange = "${neoforge_mlib_version_range}" + versionRange = "${neoforge_majruszlibrary_version_range}" ordering = "NONE" side = "BOTH"