Skip to content

Commit

Permalink
Merged 1.7.1 release for 1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Majrusz committed Mar 4, 2023
1 parent 4d59823 commit e0fee41
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)*
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/majruszsdifficulty/Registries.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 > {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<>() );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e0fee41

Please sign in to comment.