diff --git a/README.md b/README.md index c96f60937..9fbce4a6f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ - [Modrinth](https://modrinth.com/mod/majruszs-progressive-difficulty) ## Current Mod Releases (Source Code) -- [v1.6.1 for Minecraft 1.19.3](https://github.com/Majrusz/MajruszsProgressiveDifficultyMod/tree/1.19.X/) +- [v1.7.1 for Minecraft 1.19.3](https://github.com/Majrusz/MajruszsProgressiveDifficultyMod/tree/1.19.X/) - [v1.4.4 for Minecraft 1.18.2](https://github.com/Majrusz/MajruszsProgressiveDifficultyMod/tree/1.18.X/) *(not supported anymore)* - [v1.3.0 for Minecraft 1.17.1](https://github.com/Majrusz/MajruszsProgressiveDifficultyMod/tree/1.17.1/) *(not supported anymore)* - [v1.1.0 for Minecraft 1.16.4](https://github.com/Majrusz/MajruszsProgressiveDifficultyMod/tree/1.16.4/) *(not supported anymore)* diff --git a/build.gradle b/build.gradle index cc73e5692..403d86478 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ apply plugin: 'eclipse' apply plugin: 'maven-publish' apply plugin: 'org.spongepowered.mixin' -version = '1.7.0' +version = '1.7.1' group = 'com.majruszsdifficulty' archivesBaseName = 'majruszs-difficulty-1.18.2' diff --git a/src/main/java/com/majruszsdifficulty/Registries.java b/src/main/java/com/majruszsdifficulty/Registries.java index c6e2fdf35..76cce39c0 100644 --- a/src/main/java/com/majruszsdifficulty/Registries.java +++ b/src/main/java/com/majruszsdifficulty/Registries.java @@ -207,7 +207,7 @@ static RegistryObject< SoundEvent > register( String name ) { public static final AnnotationHandler ANNOTATION_HANDLER = new AnnotationHandler( MajruszsDifficulty.MOD_ID ); public static UndeadArmyManager getUndeadArmyManager() { - return GAME_DATA_SAVER.getUndeadArmyManager(); + return GAME_DATA_SAVER != null ? GAME_DATA_SAVER.getUndeadArmyManager() : UndeadArmyManager.NOT_LOADED; } public static TreasureBagProgressManager getTreasureBagProgressManager() { diff --git a/src/main/java/com/majruszsdifficulty/entities/CerberusEntity.java b/src/main/java/com/majruszsdifficulty/entities/CerberusEntity.java index 3db0126b8..7340d2298 100644 --- a/src/main/java/com/majruszsdifficulty/entities/CerberusEntity.java +++ b/src/main/java/com/majruszsdifficulty/entities/CerberusEntity.java @@ -2,6 +2,7 @@ import com.majruszsdifficulty.PacketHandler; import com.majruszsdifficulty.Registries; +import com.majruszsdifficulty.undeadarmy.UndeadArmyManager; import com.mlib.Random; import com.mlib.Utility; import com.mlib.annotations.AutoInstance; @@ -129,7 +130,7 @@ protected void registerGoals() { this.targetSelector.addGoal( 1, new HurtByTargetGoal( this ) ); this.targetSelector.addGoal( 2, new NearestAttackableTargetGoal<>( this, Player.class, true ) ); - this.targetSelector.addGoal( 3, new NearestAttackableTargetGoal<>( this, Mob.class, 2, true, false, CerberusEntity::isValidTarget ) ); + this.targetSelector.addGoal( 3, new NearestAttackableTargetGoal<>( this, Mob.class, 2, true, false, this::isValidTarget ) ); } @Override @@ -157,9 +158,11 @@ protected void playStepSound( BlockPos blockPos, BlockState blockState ) { this.playSound( SoundEvents.WITHER_SKELETON_STEP, 0.15f, 1.0f ); } - private static boolean isValidTarget( LivingEntity entity ) { - return !Registries.getUndeadArmyManager().isPartOfUndeadArmy( entity ) - && !( entity instanceof CerberusEntity ); + private boolean isValidTarget( LivingEntity entity ) { + UndeadArmyManager undeadArmyManager = Registries.getUndeadArmyManager(); + + return !undeadArmyManager.isPartOfUndeadArmy( this ) + || !undeadArmyManager.isPartOfUndeadArmy( entity ) && undeadArmyManager.findNearestUndeadArmy( entity.blockPosition() ) != null; } public static class Skills extends CustomSkills< SkillType > { diff --git a/src/main/java/com/majruszsdifficulty/gamemodifiers/CustomConditions.java b/src/main/java/com/majruszsdifficulty/gamemodifiers/CustomConditions.java index c06250116..400560776 100644 --- a/src/main/java/com/majruszsdifficulty/gamemodifiers/CustomConditions.java +++ b/src/main/java/com/majruszsdifficulty/gamemodifiers/CustomConditions.java @@ -81,10 +81,6 @@ public boolean check( GameModifier gameModifier, DataType data ) { } public static class IsNotUndeadArmy< DataType extends ContextData > extends Condition< DataType > { - public IsNotUndeadArmy() { - this.apply( params->params.priority( Priority.HIGH ) ); - } - @Override public boolean check( GameModifier gameModifier, DataType data ) { return !Registries.getUndeadArmyManager().isPartOfUndeadArmy( data.entity ); diff --git a/src/main/java/com/majruszsdifficulty/goals/UndeadArmyForgiveTeammateGoal.java b/src/main/java/com/majruszsdifficulty/goals/UndeadArmyForgiveTeammateGoal.java index 3ee0e46f0..1d1001c0e 100644 --- a/src/main/java/com/majruszsdifficulty/goals/UndeadArmyForgiveTeammateGoal.java +++ b/src/main/java/com/majruszsdifficulty/goals/UndeadArmyForgiveTeammateGoal.java @@ -3,21 +3,33 @@ import com.majruszsdifficulty.Registries; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.PathfinderMob; -import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; +import net.minecraft.world.entity.ai.goal.Goal; /** Removes mob's target when both the mob and the target are from the Undead Army. */ -public class UndeadArmyForgiveTeammateGoal extends HurtByTargetGoal { - public UndeadArmyForgiveTeammateGoal( PathfinderMob mob, Class< ? >... ignoredClasses ) { - super( mob, ignoredClasses ); +public class UndeadArmyForgiveTeammateGoal extends Goal { + final PathfinderMob mob; + + public UndeadArmyForgiveTeammateGoal( PathfinderMob mob ) { + this.mob = mob; + } + + @Override + public boolean requiresUpdateEveryTick() { + return true; + } + + @Override + public void tick() { + this.mob.setTarget( null ); } + @Override public boolean canUse() { - return this.mob.getLastHurtByMob() != null - && !this.areFromTheSameTeam( this.mob, this.mob.getLastHurtByMob() ) - && super.canUse(); + return this.mob.getTarget() != null + && this.areFromUndeadArmy( this.mob, this.mob.getTarget() ); } - private boolean areFromTheSameTeam( LivingEntity target, LivingEntity attacker ) { + private boolean areFromUndeadArmy( LivingEntity target, LivingEntity attacker ) { return Registries.getUndeadArmyManager().isPartOfUndeadArmy( target ) && Registries.getUndeadArmyManager().isPartOfUndeadArmy( attacker ); } diff --git a/src/main/java/com/majruszsdifficulty/treasurebags/TreasureBagProgressManager.java b/src/main/java/com/majruszsdifficulty/treasurebags/TreasureBagProgressManager.java index 0f5acbe88..c49884551 100644 --- a/src/main/java/com/majruszsdifficulty/treasurebags/TreasureBagProgressManager.java +++ b/src/main/java/com/majruszsdifficulty/treasurebags/TreasureBagProgressManager.java @@ -119,7 +119,8 @@ public Handler() { new OnPlayerLogged.Context( data->Registries.getTreasureBagProgressManager().onLogged( data ) ) .addCondition( new Condition.IsServer<>() ); - new OnTreasureBagOpened.Context( data->Registries.getTreasureBagProgressManager().updateProgress( data ) ); + new OnTreasureBagOpened.Context( data->Registries.getTreasureBagProgressManager().updateProgress( data ) ) + .addCondition( new Condition.IsServer<>() ); } } } diff --git a/src/main/java/com/majruszsdifficulty/undeadarmy/UndeadArmy.java b/src/main/java/com/majruszsdifficulty/undeadarmy/UndeadArmy.java index 1163885b1..68877b586 100644 --- a/src/main/java/com/majruszsdifficulty/undeadarmy/UndeadArmy.java +++ b/src/main/java/com/majruszsdifficulty/undeadarmy/UndeadArmy.java @@ -61,7 +61,7 @@ public void finish() { public void tick() { if( !this.areEntitiesLoaded ) { - this.areEntitiesLoaded = this.mobsLeft.stream().anyMatch( mobInfo->mobInfo.uuid == null || EntityHelper.isLoaded( this.level, mobInfo.uuid ) ); + this.areEntitiesLoaded = this.mobsLeft.stream().allMatch( mobInfo->mobInfo.uuid == null || EntityHelper.isLoaded( this.level, mobInfo.uuid ) ); if( this.areEntitiesLoaded ) { this.components.dispatch( IComponent::onGameReload ); } else { diff --git a/src/main/java/com/majruszsdifficulty/undeadarmy/UndeadArmyManager.java b/src/main/java/com/majruszsdifficulty/undeadarmy/UndeadArmyManager.java index 43e525712..686c1ced8 100644 --- a/src/main/java/com/majruszsdifficulty/undeadarmy/UndeadArmyManager.java +++ b/src/main/java/com/majruszsdifficulty/undeadarmy/UndeadArmyManager.java @@ -19,6 +19,7 @@ import java.util.Optional; public class UndeadArmyManager extends SerializableStructure { + public static final UndeadArmyManager NOT_LOADED = new UndeadArmyManager(); final List< UndeadArmy > undeadArmies = new ArrayList<>(); final ServerLevel level; final Config config; @@ -30,6 +31,11 @@ public UndeadArmyManager( ServerLevel level, Config config ) { this.define( "undead_armies", ()->this.undeadArmies, this.undeadArmies::addAll, ()->new UndeadArmy( level, config ) ); } + private UndeadArmyManager() { + this.level = null; + this.config = null; + } + public boolean tryToSpawn( Player player ) { return LevelHelper.isEntityOutside( player ) && LevelHelper.isEntityIn( player, Level.OVERWORLD ) diff --git a/src/main/java/com/majruszsdifficulty/undeadarmy/components/MobSpawner.java b/src/main/java/com/majruszsdifficulty/undeadarmy/components/MobSpawner.java index e9b944129..354aca96e 100644 --- a/src/main/java/com/majruszsdifficulty/undeadarmy/components/MobSpawner.java +++ b/src/main/java/com/majruszsdifficulty/undeadarmy/components/MobSpawner.java @@ -131,9 +131,8 @@ private void loadEquipment( PathfinderMob mob, MobInfo mobInfo ) { } private void addGoals( PathfinderMob mob ) { + mob.targetSelector.addGoal( 11, new UndeadArmyForgiveTeammateGoal( mob ) ); mob.goalSelector.addGoal( 4, new UndeadArmyAttackPositionGoal( mob, this.undeadArmy.positionToAttack ) ); - mob.targetSelector.getAvailableGoals().removeIf( wrappedGoal->wrappedGoal.getGoal() instanceof HurtByTargetGoal ); - mob.targetSelector.addGoal( 1, new UndeadArmyForgiveTeammateGoal( mob ) ); } private void makePersistent( PathfinderMob mob ) { diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index d0341756c..aaf955c6d 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -5,7 +5,7 @@ issueTrackerURL = "https://github.com/Majrusz/MajruszsProgressiveDifficultyMod/i [[mods]] modId = "majruszsdifficulty" - version = "1.7.0" + version = "1.7.1" displayName = "Majrusz's Progressive Difficulty" updateJSONURL = "https://raw.githubusercontent.com/Majrusz/MinecraftCommon/main/ProgressiveDifficulty/update.json" displayURL = "https://www.curseforge.com/minecraft/mc-mods/majruszs-progressive-difficulty" diff --git a/src/main/resources/assets/majruszsdifficulty/textures/item/advancement_expert.png b/src/main/resources/assets/majruszsdifficulty/textures/item/advancement_expert.png index e5b188521..6f7008baf 100644 Binary files a/src/main/resources/assets/majruszsdifficulty/textures/item/advancement_expert.png and b/src/main/resources/assets/majruszsdifficulty/textures/item/advancement_expert.png differ diff --git a/src/main/resources/assets/majruszsdifficulty/textures/item/advancement_master.png b/src/main/resources/assets/majruszsdifficulty/textures/item/advancement_master.png index 0685bf075..9c414883d 100644 Binary files a/src/main/resources/assets/majruszsdifficulty/textures/item/advancement_master.png and b/src/main/resources/assets/majruszsdifficulty/textures/item/advancement_master.png differ diff --git a/src/main/resources/assets/majruszsdifficulty/textures/item/advancement_normal.png b/src/main/resources/assets/majruszsdifficulty/textures/item/advancement_normal.png index 63adfa082..5f8cfe7c3 100644 Binary files a/src/main/resources/assets/majruszsdifficulty/textures/item/advancement_normal.png and b/src/main/resources/assets/majruszsdifficulty/textures/item/advancement_normal.png differ