Skip to content

Commit

Permalink
Merged 1.3.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Majrusz authored Nov 6, 2023
2 parents f3dd05e + 795b7a9 commit 45a39cb
Show file tree
Hide file tree
Showing 56 changed files with 235 additions and 209 deletions.
3 changes: 1 addition & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
- fixed compatibility crash with Easy Villagers (reported by @Clonephaze)
- fixed bug with accessory particles being spawned on wrong child when breeding with Idol of Fertility
- changed required Majrusz Library version from 6.0.0+ to 6.1.0+
Binary file removed common/libs/majrusz-library-common-1.20.1-6.0.0.jar
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.majruszsaccessories.items.BoosterOverlay;
import com.majruszsaccessories.items.CreativeModeTabs;
import com.majruszsaccessories.particles.BonusParticle;
import com.majruszsaccessories.particles.BonusParticleType;
import com.majruszsaccessories.recipes.AccessoryRecipe;
import com.majruszsaccessories.recipes.BoostAccessoriesRecipe;
import com.majruszsaccessories.recipes.CombineAccessoriesRecipe;
Expand All @@ -28,12 +29,8 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.crafting.RecipeSerializer;

import java.util.List;
import java.util.function.Supplier;

public class MajruszsAccessories {
public static final String MOD_ID = "majruszsaccessories";
public static final ModHelper HELPER = ModHelper.create( MOD_ID );
Expand Down Expand Up @@ -90,9 +87,7 @@ public class MajruszsAccessories {
public static final RegistryObject< RecipeSerializer< ? > > BOOST_ACCESSORIES_RECIPE = RECIPES.create( "crafting_boost_accessories", BoostAccessoriesRecipe.create() );

// Particles
public static final RegistryObject< SimpleParticleType > BONUS_WEAK_PARTICLE = PARTICLES.create( "bonus_weak", ()->new SimpleParticleType( true ) {} );
public static final RegistryObject< SimpleParticleType > BONUS_NORMAL_PARTICLE = PARTICLES.create( "bonus_normal", ()->new SimpleParticleType( true ) {} );
public static final RegistryObject< SimpleParticleType > BONUS_STRONG_PARTICLE = PARTICLES.create( "bonus_strong", ()->new SimpleParticleType( true ) {} );
public static final RegistryObject< BonusParticleType > BONUS_PARTICLE = PARTICLES.create( "bonus_normal", BonusParticleType::new );

// Creative Mode Tabs
public static final RegistryObject< CreativeModeTab > CREATIVE_MODE_TAB = CREATIVE_MODE_TABS.create( "primary", CreativeModeTabs.primary() );
Expand All @@ -111,19 +106,15 @@ public class MajruszsAccessories {
}

private static void setDefaultEmitters( OnGameInitialized data ) {
for( Supplier< SimpleParticleType > particle : List.of( BONUS_WEAK_PARTICLE, BONUS_NORMAL_PARTICLE, BONUS_STRONG_PARTICLE ) ) {
ParticleEmitter.setDefault( particle.get(), new ParticleEmitter.Properties( ParticleEmitter.offset( 0.25f ), ()->Random.nextSign() * Random.nextFloat( 0.005f, 0.001f ) ) );
}
ParticleEmitter.setDefault( BONUS_PARTICLE.get(), new ParticleEmitter.Properties( ParticleEmitter.offset( 0.25f ), ()->Random.nextSign() * Random.nextFloat( 0.005f, 0.001f ) ) );
}

private MajruszsAccessories() {}

@OnlyIn( Dist.CLIENT )
public static class Client {
static {
OnParticlesRegistered.listen( data->data.register( BONUS_WEAK_PARTICLE.get(), spriteSet->new BonusParticle.Factory( spriteSet, Rarity.UNCOMMON.color.getColor() ) ) );
OnParticlesRegistered.listen( data->data.register( BONUS_NORMAL_PARTICLE.get(), spriteSet->new BonusParticle.Factory( spriteSet, Rarity.RARE.color.getColor() ) ) );
OnParticlesRegistered.listen( data->data.register( BONUS_STRONG_PARTICLE.get(), spriteSet->new BonusParticle.Factory( spriteSet, Rarity.EPIC.color.getColor() ) ) );
OnParticlesRegistered.listen( data->data.register( BONUS_PARTICLE.get(), BonusParticle.Factory::new ) );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ protected AnyChestDropChance( BonusHandler< AccessoryItem > handler ) {
MoreChestLoot.OnChestOpened.listen( this::addToGeneratedLoot )
.addCondition( CustomConditions.dropChance( ()->this.chance, data->data.entity ) );

Serializable config = handler.getConfig();
config.defineFloat( "any_chest_spawn_chance", ()->this.chance, x->this.chance = Range.CHANCE.clamp( x ) );
Serializable< ? > config = handler.getConfig();
config.defineFloat( "any_chest_spawn_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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", ()->this.chance, x->this.chance = Range.CHANCE.clamp( x ) );
config.defineLocation( "suspicious_block_ids", ()->this.locations, x->this.locations = x );
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 );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ protected FishingDropChance( BonusHandler< AccessoryItem > handler, float chance
this.fishingChance = chance;

OnItemFished.listen( this::onFished )
.addCondition( CustomConditions.dropChance( ()->this.fishingChance, data->data.player ) );
.addCondition( CustomConditions.dropChance( s->this.fishingChance, data->data.player ) );

Serializable config = handler.getConfig();
config.defineFloat( "fishing_drop_chance", ()->this.fishingChance, x->this.fishingChance = Range.CHANCE.clamp( x ) );
Serializable< ? > config = handler.getConfig();
config.defineFloat( "fishing_drop_chance", s->this.fishingChance, ( s, v )->this.fishingChance = Range.CHANCE.clamp( v ) );
}

private void onFished( OnItemFished data ) {
Expand Down Expand Up @@ -74,11 +74,11 @@ 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( CustomConditions.dropChance( ()->this.fishChance, data->data.killer ) );
.addCondition( CustomConditions.dropChance( s->this.fishChance, data->data.killer ) );

Serializable config = handler.getConfig();
config.defineFloat( "fish_drop_chance", ()->this.fishChance, x->this.fishChance = Range.CHANCE.clamp( x ) );
config.defineLocation( "fish_ids", ()->this.lootIds, x->this.lootIds = x );
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 );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ protected TamingDropChance( BonusHandler< AccessoryItem > handler ) {
super( handler );

OnAnimalTamed.listen( this::spawnCertificate )
.addCondition( CustomConditions.dropChance( ()->this.chance, data->data.tamer ) );
.addCondition( CustomConditions.dropChance( s->this.chance, data->data.tamer ) );

Serializable config = handler.getConfig();
config.defineFloat( "taming_drop_chance", ()->this.chance, x->this.chance = Range.CHANCE.clamp( x ) );
Serializable< ? > config = handler.getConfig();
config.defineFloat( "taming_drop_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) );
}

private void spawnCertificate( OnAnimalTamed data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ protected TradingDropChance( BonusHandler< AccessoryItem > handler ) {
super( handler );

OnItemTraded.listen( this::spawnAccessory )
.addCondition( CustomConditions.dropChance( ()->this.chance, data->data.player ) );
.addCondition( CustomConditions.dropChance( s->this.chance, data->data.player ) );

Serializable config = handler.getConfig();
config.defineFloat( "trading_drop_chance", ()->this.chance, x->this.chance = Range.CHANCE.clamp( x ) );
Serializable< ? > config = handler.getConfig();
config.defineFloat( "trading_drop_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) );
}

private void spawnAccessory( OnItemTraded data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ protected SleepingDropChance( BonusHandler< AccessoryItem > handler ) {
OnPlayerWakedUp.listen( this::spawnAccessory )
.addCondition( Condition.isLogicalServer() )
.addCondition( data->!data.wasSleepStoppedManually )
.addCondition( CustomConditions.dropChance( ()->this.chance, data->data.player ) );
.addCondition( CustomConditions.dropChance( s->this.chance, data->data.player ) );

Serializable config = handler.getConfig();
config.defineFloat( "sleeping_drop_chance", ()->this.chance, x->this.chance = Range.CHANCE.clamp( x ) );
Serializable< ? > config = handler.getConfig();
config.defineFloat( "sleeping_drop_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) );
}

private void spawnAccessory( OnPlayerWakedUp data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ protected BreedingDropChance( BonusHandler< AccessoryItem > handler ) {
OnBabySpawned.listen( this::spawnTotem )
.addCondition( Condition.isLogicalServer() )
.addCondition( Condition.predicate( data->data.player != null ) )
.addCondition( CustomConditions.dropChance( ()->this.chance, data->data.player ) );
.addCondition( CustomConditions.dropChance( s->this.chance, data->data.player ) );

Serializable config = handler.getConfig();
config.defineFloat( "breeding_drop_chance", ()->this.chance, x->this.chance = Range.CHANCE.clamp( x ) );
Serializable< ? > config = handler.getConfig();
config.defineFloat( "breeding_drop_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) );
}

private void spawnTotem( OnBabySpawned data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ protected MiningDropChance( BonusHandler< AccessoryItem > handler ) {
super( handler );

MiningExtraItem.OnStoneMined.listen( this::addToGeneratedLoot )
.addCondition( CustomConditions.dropChance( ()->this.chance, data->data.entity ) );
.addCondition( CustomConditions.dropChance( s->this.chance, data->data.entity ) );

Serializable config = handler.getConfig();
config.defineFloat( "mining_drop_chance", ()->this.chance, x->this.chance = Range.CHANCE.clamp( x ) );
Serializable< ? > config = handler.getConfig();
config.defineFloat( "mining_drop_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ protected UndergroundChestDropChance( BonusHandler< AccessoryItem > handler ) {
OnLootGenerated.listen( this::addToGeneratedLoot )
.addCondition( data->data.origin != null && data.origin.y < 50.0f )
.addCondition( data->data.lootId.toString().contains( "chest" ) )
.addCondition( CustomConditions.dropChance( ()->this.chance, data->data.entity ) );
.addCondition( CustomConditions.dropChance( s->this.chance, data->data.entity ) );

Serializable config = handler.getConfig();
config.defineFloat( "underground_chest_spawn_chance", ()->this.chance, x->this.chance = Range.CHANCE.clamp( x ) );
Serializable< ? > config = handler.getConfig();
config.defineFloat( "underground_chest_spawn_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ protected BrewingDropChance( BonusHandler< AccessoryItem > handler ) {
super( handler );

OnItemBrewed.listen( this::spawnAccessory )
.addCondition( CustomConditions.dropChance( ()->this.chance, data->LevelHelper.getNearestPlayer( data.getLevel(), data.blockPos, 30.0f ) ) );
.addCondition( CustomConditions.dropChance( s->this.chance, data->LevelHelper.getNearestPlayer( data.getLevel(), data.blockPos, 30.0f ) ) );

Serializable config = handler.getConfig();
config.defineFloat( "brewing_drop_chance", ()->this.chance, x->this.chance = Range.CHANCE.clamp( x ) );
Serializable< ? > config = handler.getConfig();
config.defineFloat( "brewing_drop_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) );
}

private void spawnAccessory( OnItemBrewed data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,7 @@
import com.majruszsaccessories.MajruszsAccessories;
import com.majruszsaccessories.accessories.components.*;
import com.majruszsaccessories.common.AccessoryHandler;
import com.majruszsaccessories.common.BonusComponent;
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 SoulOfMinecraft extends AccessoryHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ protected UnderwaterChestDropChance( BonusHandler< AccessoryItem > handler ) {
.addCondition( data->data.origin != null )
.addCondition( data->BlockHelper.getState( data.getLevel(), data.origin ).getFluidState().isSourceOfType( Fluids.WATER ) )
.addCondition( data->data.lootId.toString().contains( "chest" ) )
.addCondition( CustomConditions.dropChance( ()->this.chance, data->data.entity ) );
.addCondition( CustomConditions.dropChance( s->this.chance, data->data.entity ) );

Serializable config = handler.getConfig();
config.defineFloat( "underwater_chest_spawn_chance", ()->this.chance, x->this.chance = Range.CHANCE.clamp( x ) );
Serializable< ? > config = handler.getConfig();
config.defineFloat( "underwater_chest_spawn_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ protected HarvestingDropChance( BonusHandler< AccessoryItem > handler ) {
return Contexts.dispatch( new OnAccessoryDropChanceGet( chance, data.entity ) ).check();
} );

Serializable config = handler.getConfig();
config.defineCustom( "harvesting_drop", subconfig->{
subconfig.defineFloat( "chance", ()->this.chance, x->this.chance = Range.CHANCE.clamp( x ) );
subconfig.defineFloat( "potato_multiplier", ()->this.potatoMultiplier, x->this.potatoMultiplier = Range.of( 1.0f, 10.0f ).clamp( x ) );
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 ) );
} );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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", ()->this.multiplier, x->this.multiplier = Range.CHANCE.clamp( x ) );
Serializable< ? > config = handler.getConfig();
config.defineFloat( "durability_drop_chance_multiplier", s->this.multiplier, ( s, v )->this.multiplier = Range.CHANCE.clamp( v ) );
}

private void spawnScraps( OnItemDamaged data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ protected BreedingTwins( BonusHandler< AccessoryItem > handler, float chance ) {

this.addTooltip( "majruszsaccessories.bonuses.spawn_twins", TooltipHelper.asPercent( this.chance ) );

Serializable config = handler.getConfig();
config.defineCustom( "breeding_twins", this.chance::define );
Serializable< ? > config = handler.getConfig();
config.define( "breeding_twins", this.chance::define );
}

private void spawnTwins( OnBabySpawned data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ protected BrushingExtraItem( BonusHandler< AccessoryItem > handler, float chance

this.addTooltip( "majruszsaccessories.bonuses.extra_archaeology_item", TooltipHelper.asPercent( this.chance ) );

Serializable config = handler.getConfig();
config.defineCustom( "extra_archaeology_item", this.chance::define );
Serializable< ? > config = handler.getConfig();
config.define( "extra_archaeology_item", this.chance::define );
}

private void addExtraLoot( OnItemBrushed data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ 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.defineCustom( "extra_fishing_item", subconfig->{
Serializable< ? > config = handler.getConfig();
config.define( "extra_fishing_item", subconfig->{
this.chance.define( subconfig );
this.count.define( subconfig );
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ protected FishingLuckBonus( BonusHandler< AccessoryItem > handler, int luck ) {

this.addTooltip( "majruszsaccessories.bonuses.fishing_luck", TooltipHelper.asValue( this.luck ) );

Serializable config = handler.getConfig();
config.defineCustom( "fishing_luck", this.luck::define );
Serializable< ? > config = handler.getConfig();
config.define( "fishing_luck", this.luck::define );
}

private void updateLuck( OnPlayerTicked data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ protected FishingLureBonus( BonusHandler< AccessoryItem > handler, float bonus )

this.addTooltip( "majruszsaccessories.bonuses.fishing_lure", TooltipHelper.asPercent( this.multiplier ) );

Serializable config = handler.getConfig();
config.defineCustom( "fishing_time", this.multiplier::define );
Serializable< ? > config = handler.getConfig();
config.define( "fishing_time", this.multiplier::define );
}

private void decreaseFishingTime( OnFishingTimeGet data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ protected HarvestingDoubleCrops( BonusHandler< AccessoryItem > handler, float ch

this.addTooltip( "majruszsaccessories.bonuses.double_crops", TooltipHelper.asPercent( this.chance ) );

Serializable config = handler.getConfig();
config.defineCustom( "double_crops", this.chance::define );
Serializable< ? > config = handler.getConfig();
config.define( "double_crops", this.chance::define );
}

private void doubleLoot( OnLootGenerated data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ protected MiningDurabilityBonus( BonusHandler< AccessoryItem > handler, float bo

this.addTooltip( "majruszsaccessories.bonuses.free_durability_cost", TooltipHelper.asPercent( this.chance ) );

Serializable config = handler.getConfig();
config.defineCustom( "mining_free_durability_use", this.chance::define );
Serializable< ? > config = handler.getConfig();
config.define( "mining_free_durability_use", this.chance::define );
}

private void decreaseDurabilityCost( OnItemDamaged data ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class MiningExtraItem extends BonusComponent< AccessoryItem > {
RangedFloat chance = new RangedFloat().id( "chance" ).maxRange( Range.CHANCE );
Map< String, ResourceLocation > lootIds = DefaultMap.of(
DefaultMap.entry( "default", MajruszsAccessories.HELPER.getLocation( "gameplay/lucky_rock_default" ) ),
DefaultMap.defaultEntry( MajruszsAccessories.HELPER.getLocation( "gameplay/lucky_rock_default" ) ),
DefaultMap.entry( "minecraft:the_nether", MajruszsAccessories.HELPER.getLocation( "gameplay/lucky_rock_nether" ) ),
DefaultMap.entry( "minecraft:the_end", MajruszsAccessories.HELPER.getLocation( "gameplay/lucky_rock_end" ) )
);
Expand All @@ -45,10 +45,10 @@ protected MiningExtraItem( BonusHandler< AccessoryItem > handler, float chance )

this.addTooltip( "majruszsaccessories.bonuses.extra_stone_loot", TooltipHelper.asPercent( this.chance ) );

Serializable config = handler.getConfig();
config.defineCustom( "extra_mining_item", subconfig->{
Serializable< ? > config = handler.getConfig();
config.define( "extra_mining_item", subconfig->{
this.chance.define( subconfig );
subconfig.defineLocation( "loot_ids", ()->this.lootIds, x->this.lootIds = DefaultMap.of( x ) );
subconfig.defineLocationMap( "loot_ids", s->this.lootIds, ( s, v )->this.lootIds = DefaultMap.of( v ) );
} );
}

Expand Down
Loading

0 comments on commit 45a39cb

Please sign in to comment.