Skip to content

Commit

Permalink
Merged 1.10.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Majrusz authored Dec 2, 2023
2 parents 262ac94 + cbe2deb commit 40e8874
Show file tree
Hide file tree
Showing 49 changed files with 396 additions and 374 deletions.
5 changes: 1 addition & 4 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +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 @Maddogkyler, @Note, @'RQ)
- fixed Korean translation not working properly
- fixed bug when right-clicking a hoe with Harvester enchantment not working properly on a server
- changed required Majrusz Library version from 6.1.7+ to 7.0.0+
5 changes: 2 additions & 3 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ 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 {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8'
options.release = 17
}
Binary file removed common/libs/majrusz-library-common-1.20.1-6.1.7.jar
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.majruszsenchantments;

import com.majruszsenchantments.config.Config;
import com.majruszlibrary.annotation.Dist;
import com.majruszlibrary.annotation.OnlyIn;
import com.majruszlibrary.item.CustomEnchantment;
import com.majruszlibrary.item.ItemHelper;
import com.majruszlibrary.modhelper.ModHelper;
import com.majruszlibrary.registry.Custom;
import com.majruszlibrary.registry.RegistryGroup;
import com.majruszlibrary.registry.RegistryObject;
import com.majruszsenchantments.curses.*;
import com.majruszsenchantments.data.Config;
import com.majruszsenchantments.enchantments.*;
import com.majruszsenchantments.particles.DodgeParticle;
import com.majruszsenchantments.particles.SmelterParticle;
import com.majruszsenchantments.particles.TelekinesisParticle;
import com.majruszsenchantments.particles.TelekinesisParticleType;
import com.mlib.annotation.Dist;
import com.mlib.annotation.OnlyIn;
import com.mlib.item.CustomEnchantment;
import com.mlib.item.ItemHelper;
import com.mlib.modhelper.ModHelper;
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.particles.SimpleParticleType;
import net.minecraft.core.registries.BuiltInRegistries;
Expand All @@ -28,7 +28,9 @@ public class MajruszsEnchantments {
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< Enchantment > ENCHANTMENTS = HELPER.create( BuiltInRegistries.ENCHANTMENT );
Expand Down
25 changes: 13 additions & 12 deletions common/src/main/java/com/majruszsenchantments/common/Handler.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
package com.majruszsenchantments.common;

import com.majruszsenchantments.config.Config;
import com.mlib.data.Serializable;
import com.mlib.data.Serializables;
import com.mlib.item.CustomEnchantment;
import com.mlib.registry.RegistryObject;
import com.majruszlibrary.data.Reader;
import com.majruszlibrary.data.SerializableObject;
import com.majruszlibrary.data.Serializables;
import com.majruszlibrary.item.CustomEnchantment;
import com.majruszlibrary.registry.RegistryObject;
import com.majruszsenchantments.data.Config;

public class Handler {
protected final RegistryObject< ? extends CustomEnchantment > enchantment;
protected final Serializable< ? > config;
protected final SerializableObject< ? > config;
protected boolean isEnabled = true;

public < Type extends CustomEnchantment > Handler( RegistryObject< Type > enchantment, boolean isCurse ) {
public < Type extends CustomEnchantment > Handler( RegistryObject< Type > enchantment, Class< ? extends Handler > clazz, boolean isCurse ) {
this.enchantment = enchantment;
this.config = new Serializable<>();
this.config.defineBoolean( "is_enabled", s->this.isEnabled, ( s, v )->{
this.config = Serializables.getStatic( clazz );
this.config.define( "is_enabled", Reader.bool(), s->this.isEnabled, ( s, v )->{
this.isEnabled = v;
this.enchantment.ifPresent( y->y.setEnabled( this.isEnabled ) );
} );

Class< ? > clazz = isCurse ? Config.Curses.class : Config.Enchantments.class;
Serializables.get( clazz )
.defineCustom( enchantment.getId(), ()->this.config );
Class< ? > parent = isCurse ? Config.Curses.class : Config.Enchantments.class;
Serializables.getStatic( parent )
.define( enchantment.getId(), clazz );
}
}
20 changes: 0 additions & 20 deletions common/src/main/java/com/majruszsenchantments/config/Config.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.majruszsenchantments.curses;

import com.majruszlibrary.annotation.AutoInstance;
import com.majruszlibrary.data.Reader;
import com.majruszlibrary.events.OnItemDamaged;
import com.majruszlibrary.events.base.Priority;
import com.majruszlibrary.item.CustomEnchantment;
import com.majruszlibrary.item.EnchantmentHelper;
import com.majruszlibrary.item.EquipmentSlots;
import com.majruszlibrary.math.Random;
import com.majruszlibrary.math.Range;
import com.majruszsenchantments.MajruszsEnchantments;
import com.majruszsenchantments.common.Handler;
import com.mlib.annotation.AutoInstance;
import com.mlib.contexts.OnItemDamaged;
import com.mlib.contexts.base.Priority;
import com.mlib.item.CustomEnchantment;
import com.mlib.item.EnchantmentHelper;
import com.mlib.item.EquipmentSlots;
import com.mlib.math.Random;
import com.mlib.math.Range;
import net.minecraft.world.item.enchantment.DigDurabilityEnchantment;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentCategory;
Expand All @@ -31,14 +32,14 @@ public static CustomEnchantment create() {
}

public BreakingCurse() {
super( MajruszsEnchantments.BREAKING, true );
super( MajruszsEnchantments.BREAKING, BreakingCurse.class, true );

OnItemDamaged.listen( this::dealExtraDamage )
.priority( Priority.HIGH )
.addCondition( data->data.player != null )
.addCondition( data->EnchantmentHelper.has( this.enchantment, data.player ) );

this.config.defineFloat( "damage_multiplier_per_level", s->this.damageMultiplier, ( s, v )->{
this.config.define( "damage_multiplier_per_level", Reader.number(), s->this.damageMultiplier, ( s, v )->{
this.damageMultiplier = Range.of( 0.0f, 10.0f ).clamp( v );
} );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.majruszsenchantments.curses;

import com.majruszlibrary.annotation.AutoInstance;
import com.majruszlibrary.data.Reader;
import com.majruszlibrary.events.OnEntityTicked;
import com.majruszlibrary.events.base.Condition;
import com.majruszlibrary.item.CustomEnchantment;
import com.majruszlibrary.item.EnchantmentHelper;
import com.majruszlibrary.item.EquipmentSlots;
import com.majruszlibrary.level.LevelHelper;
import com.majruszlibrary.math.Range;
import com.majruszsenchantments.MajruszsEnchantments;
import com.majruszsenchantments.common.Handler;
import com.mlib.annotation.AutoInstance;
import com.mlib.contexts.OnEntityTicked;
import com.mlib.contexts.base.Condition;
import com.mlib.item.CustomEnchantment;
import com.mlib.item.EnchantmentHelper;
import com.mlib.item.EquipmentSlots;
import com.mlib.level.LevelHelper;
import com.mlib.math.Range;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.Enchantment;
Expand All @@ -31,16 +32,16 @@ public static CustomEnchantment create() {
}

public CorrosionCurse() {
super( MajruszsEnchantments.CORROSION, true );
super( MajruszsEnchantments.CORROSION, CorrosionCurse.class, true );

OnEntityTicked.listen( this::dealDamage )
.addCondition( Condition.isLogicalServer() )
.addCondition( Condition.cooldown( ()->this.cooldown ) )
.addCondition( data->EnchantmentHelper.has( this.enchantment, data.entity ) )
.addCondition( data->LevelHelper.isRainingAt( data.getLevel(), data.entity.blockPosition() ) || data.entity.isInWater() );

this.config.defineFloat( "damage_dealt_per_level", s->this.damage, ( s, v )->this.damage = Range.of( 0.0f, 10.0f ).clamp( v ) );
this.config.defineFloat( "damage_cooldown", s->this.cooldown, ( s, v )->this.cooldown = Range.of( 0.05f, 60.0f ).clamp( v ) );
this.config.define( "damage_dealt_per_level", Reader.number(), s->this.damage, ( s, v )->this.damage = Range.of( 0.0f, 10.0f ).clamp( v ) )
.define( "damage_cooldown", Reader.number(), s->this.cooldown, ( s, v )->this.cooldown = Range.of( 0.05f, 60.0f ).clamp( v ) );
}

private void dealDamage( OnEntityTicked data ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.majruszsenchantments.curses;

import com.majruszlibrary.annotation.AutoInstance;
import com.majruszlibrary.data.Reader;
import com.majruszlibrary.entity.AttributeHandler;
import com.majruszlibrary.events.OnBreakSpeedGet;
import com.majruszlibrary.events.OnItemEquipped;
import com.majruszlibrary.events.OnItemSwingDurationGet;
import com.majruszlibrary.events.OnItemUseTicked;
import com.majruszlibrary.item.CustomEnchantment;
import com.majruszlibrary.item.EnchantmentHelper;
import com.majruszlibrary.item.EquipmentSlots;
import com.majruszlibrary.math.Random;
import com.majruszlibrary.math.Range;
import com.majruszsenchantments.MajruszsEnchantments;
import com.majruszsenchantments.common.Handler;
import com.mlib.annotation.AutoInstance;
import com.mlib.contexts.OnBreakSpeedGet;
import com.mlib.contexts.OnItemEquipped;
import com.mlib.contexts.OnItemSwingDurationGet;
import com.mlib.contexts.OnItemUseTicked;
import com.mlib.entity.AttributeHandler;
import com.mlib.item.CustomEnchantment;
import com.mlib.item.EnchantmentHelper;
import com.mlib.item.EquipmentSlots;
import com.mlib.math.Random;
import com.mlib.math.Range;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
Expand Down Expand Up @@ -44,7 +45,7 @@ public static CustomEnchantment create() {
}

public FatigueCurse() {
super( MajruszsEnchantments.FATIGUE, true );
super( MajruszsEnchantments.FATIGUE, FatigueCurse.class, true );

this.attackSpeed = new AttributeHandler( "%s_attack_speed".formatted( this.enchantment.getId() ), ()->Attributes.ATTACK_SPEED, AttributeModifier.Operation.MULTIPLY_TOTAL );
this.movementSpeed = new AttributeHandler( "%s_movement_speed".formatted( this.enchantment.getId() ), ()->Attributes.MOVEMENT_SPEED, AttributeModifier.Operation.MULTIPLY_TOTAL );
Expand All @@ -64,11 +65,11 @@ public FatigueCurse() {
.addCondition( data->EnchantmentHelper.has( this.enchantment, data.entity ) );

this.config.define( "speed_multiplier_per_level", subconfig->{
subconfig.defineFloat( "mining", s->this.miningMultiplier, ( s, v )->this.miningMultiplier = MULTIPLIER.clamp( v ) );
subconfig.defineFloat( "attacking", s->this.attackMultiplier, ( s, v )->this.attackMultiplier = MULTIPLIER.clamp( v ) );
subconfig.defineFloat( "moving", s->this.movingMultiplier, ( s, v )->this.movingMultiplier = MULTIPLIER.clamp( v ) );
subconfig.defineFloat( "item_using", s->this.usingMultiplier, ( s, v )->this.usingMultiplier = MULTIPLIER.clamp( v ) );
subconfig.defineFloat( "item_swinging", s->this.swingingMultiplier, ( s, v )->this.swingingMultiplier = MULTIPLIER.clamp( v ) );
subconfig.define( "mining", Reader.number(), s->this.miningMultiplier, ( s, v )->this.miningMultiplier = MULTIPLIER.clamp( v ) );
subconfig.define( "attacking", Reader.number(), s->this.attackMultiplier, ( s, v )->this.attackMultiplier = MULTIPLIER.clamp( v ) );
subconfig.define( "moving", Reader.number(), s->this.movingMultiplier, ( s, v )->this.movingMultiplier = MULTIPLIER.clamp( v ) );
subconfig.define( "item_using", Reader.number(), s->this.usingMultiplier, ( s, v )->this.usingMultiplier = MULTIPLIER.clamp( v ) );
subconfig.define( "item_swinging", Reader.number(), s->this.swingingMultiplier, ( s, v )->this.swingingMultiplier = MULTIPLIER.clamp( v ) );
} );
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.majruszsenchantments.curses;

import com.majruszlibrary.annotation.AutoInstance;
import com.majruszlibrary.item.CustomEnchantment;
import com.majruszlibrary.item.EquipmentSlots;
import com.majruszsenchantments.MajruszsEnchantments;
import com.majruszsenchantments.common.Handler;
import com.mlib.annotation.AutoInstance;
import com.mlib.item.CustomEnchantment;
import com.mlib.item.EquipmentSlots;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentCategory;

Expand All @@ -22,6 +22,6 @@ public static CustomEnchantment create() {
}

public IncompatibilityCurse() {
super( MajruszsEnchantments.INCOMPATIBILITY, true );
super( MajruszsEnchantments.INCOMPATIBILITY, IncompatibilityCurse.class, true );
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.majruszsenchantments.curses;

import com.majruszlibrary.annotation.AutoInstance;
import com.majruszlibrary.data.Reader;
import com.majruszlibrary.events.OnEntityTicked;
import com.majruszlibrary.events.base.Condition;
import com.majruszlibrary.item.CustomEnchantment;
import com.majruszlibrary.item.EnchantmentHelper;
import com.majruszlibrary.item.EquipmentSlots;
import com.majruszlibrary.math.Range;
import com.majruszsenchantments.MajruszsEnchantments;
import com.majruszsenchantments.common.Handler;
import com.mlib.annotation.AutoInstance;
import com.mlib.contexts.OnEntityTicked;
import com.mlib.contexts.base.Condition;
import com.mlib.item.CustomEnchantment;
import com.mlib.item.EnchantmentHelper;
import com.mlib.item.EquipmentSlots;
import com.mlib.math.Range;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
Expand All @@ -31,16 +32,16 @@ public static CustomEnchantment create() {
}

public SlipperyCurse() {
super( MajruszsEnchantments.SLIPPERY, true );
super( MajruszsEnchantments.SLIPPERY, SlipperyCurse.class, true );

OnEntityTicked.listen( this::dropItem )
.addCondition( Condition.isLogicalServer() )
.addCondition( Condition.cooldown( ()->this.cooldown ) )
.addCondition( Condition.chance( ()->this.chance ) )
.addCondition( data->EnchantmentHelper.has( this.enchantment, data.entity ) );

this.config.defineFloat( "drop_chance", s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) );
this.config.defineFloat( "drop_cooldown", s->this.cooldown, ( s, v )->this.cooldown = Range.of( 0.05f, 60.0f ).clamp( v ) );
this.config.define( "drop_chance", Reader.number(), s->this.chance, ( s, v )->this.chance = Range.CHANCE.clamp( v ) )
.define( "drop_cooldown", Reader.number(), s->this.cooldown, ( s, v )->this.cooldown = Range.of( 0.05f, 60.0f ).clamp( v ) );
}

private void dropItem( OnEntityTicked data ) {
Expand Down
19 changes: 19 additions & 0 deletions common/src/main/java/com/majruszsenchantments/data/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.majruszsenchantments.data;

import com.majruszlibrary.data.Serializables;

public class Config {
static {
Serializables.getStatic( Config.class )
.define( "enchantments", Enchantments.class )
.define( "curses", Curses.class );

Serializables.getStatic( Enchantments.class );

Serializables.getStatic( Curses.class );
}

public static class Enchantments {}

public static class Curses {}
}
Loading

0 comments on commit 40e8874

Please sign in to comment.