diff --git a/gradle.properties b/gradle.properties index b6a259162..6fabc847c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,6 @@ versions_minecraft=1.20 versions_minecraft_range=[1.20,1.21) versions_forge=46.0.1 versions_forge_range=[46.0.1,) -versions_mod=1.7.6 -versions_mlib=4.3.0 -versions_mlib_range=[4.3.0,5.0.0) \ No newline at end of file +versions_mod=1.7.7 +versions_mlib=4.3.2 +versions_mlib_range=[4.3.2,5.0.0) \ No newline at end of file diff --git a/libs/majrusz-library-1.20-4.3.0.jar b/libs/majrusz-library-1.20-4.3.2.jar similarity index 85% rename from libs/majrusz-library-1.20-4.3.0.jar rename to libs/majrusz-library-1.20-4.3.2.jar index 886dc0a33..27874ff12 100644 Binary files a/libs/majrusz-library-1.20-4.3.0.jar and b/libs/majrusz-library-1.20-4.3.2.jar differ diff --git a/src/main/java/com/majruszsdifficulty/entities/BlackWidowEntity.java b/src/main/java/com/majruszsdifficulty/entities/BlackWidowEntity.java index 7f89a21a5..572150314 100644 --- a/src/main/java/com/majruszsdifficulty/entities/BlackWidowEntity.java +++ b/src/main/java/com/majruszsdifficulty/entities/BlackWidowEntity.java @@ -17,6 +17,7 @@ import net.minecraft.world.entity.*; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.monster.Monster; import net.minecraft.world.entity.monster.Spider; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; @@ -31,7 +32,7 @@ public static Supplier< EntityType< BlackWidowEntity > > createSupplier() { } public static AttributeSupplier getAttributeMap() { - return Mob.createMobAttributes() + return Monster.createMobAttributes() .add( Attributes.MAX_HEALTH, 12.0 ) .add( Attributes.MOVEMENT_SPEED, 0.3 ) .add( Attributes.ATTACK_DAMAGE, 4.0 ) diff --git a/src/main/java/com/majruszsdifficulty/entities/CerberusEntity.java b/src/main/java/com/majruszsdifficulty/entities/CerberusEntity.java index 70a2ddba0..3d0e3e5c0 100644 --- a/src/main/java/com/majruszsdifficulty/entities/CerberusEntity.java +++ b/src/main/java/com/majruszsdifficulty/entities/CerberusEntity.java @@ -69,7 +69,7 @@ public static Supplier< EntityType< CerberusEntity > > createSupplier() { } public static AttributeSupplier getAttributeMap() { - return Mob.createMobAttributes() + return Monster.createMobAttributes() .add( Attributes.MAX_HEALTH, 240.0 ) .add( Attributes.MOVEMENT_SPEED, 0.28 ) .add( Attributes.ATTACK_DAMAGE, 8.0 ) diff --git a/src/main/java/com/majruszsdifficulty/entities/CreeperlingEntity.java b/src/main/java/com/majruszsdifficulty/entities/CreeperlingEntity.java index 930a83898..1c0520481 100644 --- a/src/main/java/com/majruszsdifficulty/entities/CreeperlingEntity.java +++ b/src/main/java/com/majruszsdifficulty/entities/CreeperlingEntity.java @@ -10,6 +10,7 @@ import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.monster.Creeper; +import net.minecraft.world.entity.monster.Monster; import net.minecraft.world.level.Level; import java.util.function.Supplier; @@ -22,7 +23,7 @@ public static Supplier< EntityType< CreeperlingEntity > > createSupplier() { } public static AttributeSupplier getAttributeMap() { - return Mob.createMobAttributes() + return Monster.createMobAttributes() .add( Attributes.MAX_HEALTH, 6.0 ) .add( Attributes.MOVEMENT_SPEED, 0.35 ) .build(); diff --git a/src/main/java/com/majruszsdifficulty/entities/CursedArmorEntity.java b/src/main/java/com/majruszsdifficulty/entities/CursedArmorEntity.java index c4a5c286d..4b4c3b48c 100644 --- a/src/main/java/com/majruszsdifficulty/entities/CursedArmorEntity.java +++ b/src/main/java/com/majruszsdifficulty/entities/CursedArmorEntity.java @@ -85,7 +85,7 @@ public static Supplier< EntityType< CursedArmorEntity > > createSupplier() { } public static AttributeSupplier getAttributeMap() { - return Mob.createMobAttributes() + return Monster.createMobAttributes() .add( Attributes.MAX_HEALTH, 30.0 ) .add( Attributes.MOVEMENT_SPEED, 0.23 ) .add( Attributes.ATTACK_DAMAGE, 3.0 ) @@ -99,6 +99,11 @@ public CursedArmorEntity( EntityType< ? extends CursedArmorEntity > type, Level super( type, world ); } + @Override + public boolean canBreatheUnderwater() { + return true; + } + @Override public int getExperienceReward() { return Random.nextInt( 7 ); diff --git a/src/main/java/com/majruszsdifficulty/entities/TankEntity.java b/src/main/java/com/majruszsdifficulty/entities/TankEntity.java index 15edb0b6c..1dde81fda 100644 --- a/src/main/java/com/majruszsdifficulty/entities/TankEntity.java +++ b/src/main/java/com/majruszsdifficulty/entities/TankEntity.java @@ -48,7 +48,7 @@ public static Supplier< EntityType< TankEntity > > createSupplier() { } public static AttributeSupplier getAttributeMap() { - return Mob.createMobAttributes() + return Monster.createMobAttributes() .add( Attributes.MAX_HEALTH, 140.0 ) .add( Attributes.MOVEMENT_SPEED, 0.25 ) .add( Attributes.ATTACK_DAMAGE, 6.0 ) diff --git a/src/main/java/com/majruszsdifficulty/gamemodifiers/list/SpawnBlocker.java b/src/main/java/com/majruszsdifficulty/gamemodifiers/list/SpawnBlocker.java index c3b0e4c70..3ad64ab01 100644 --- a/src/main/java/com/majruszsdifficulty/gamemodifiers/list/SpawnBlocker.java +++ b/src/main/java/com/majruszsdifficulty/gamemodifiers/list/SpawnBlocker.java @@ -9,7 +9,6 @@ import com.mlib.gamemodifiers.ModConfigs; import com.mlib.gamemodifiers.contexts.OnCheckSpawn; import net.minecraft.world.entity.Entity; -import net.minecraftforge.eventbus.api.Event; @AutoInstance public class SpawnBlocker { @@ -23,16 +22,12 @@ public SpawnBlocker() { .name( "SpawnBlocker" ) .comment( "Blocks certain mobs from spawning when given game stage is active." ); - OnCheckSpawn.listen( this::blockSpawn ) + OnCheckSpawn.listen( OnCheckSpawn.CANCEL ) .addCondition( Condition.predicate( data->this.isForbidden( data.mob ) ) ) .addConfig( this.forbiddenEntities ) .insertTo( group ); } - private void blockSpawn( OnCheckSpawn.Data data ) { - data.event.setResult( Event.Result.DENY ); - } - private boolean isForbidden( Entity entity ) { return this.forbiddenEntities.getCurrentGameStageValue().contains( Utility.getRegistryString( entity.getType() ) ); } diff --git a/src/main/java/com/majruszsdifficulty/undeadarmy/Config.java b/src/main/java/com/majruszsdifficulty/undeadarmy/Config.java index 9d8db97dd..ba96a7d9d 100644 --- a/src/main/java/com/majruszsdifficulty/undeadarmy/Config.java +++ b/src/main/java/com/majruszsdifficulty/undeadarmy/Config.java @@ -17,6 +17,7 @@ import com.mlib.gamemodifiers.contexts.OnDeath; import com.mlib.gamemodifiers.contexts.OnLoot; import com.mlib.gamemodifiers.contexts.OnServerTick; +import com.mlib.levels.LevelHelper; import com.mlib.loot.LootHelper; import com.mlib.math.Range; import net.minecraft.ChatFormatting; @@ -28,7 +29,7 @@ import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.MobType; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.Level; import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; @@ -74,6 +75,7 @@ public Config() { .addCondition( Condition.predicate( data->data.target.getMobType() == MobType.UNDEAD ) ) .addCondition( Condition.predicate( data->!Registries.getUndeadArmyManager().isPartOfUndeadArmy( data.target ) ) ) .addCondition( Condition.predicate( data->data.attacker instanceof ServerPlayer ) ) + .addCondition( Condition.predicate( data->LevelHelper.isEntityIn( data.attacker, Level.OVERWORLD ) ) ) .insertTo( group ); OnLoot.listen( this::giveExtraLoot ) @@ -138,13 +140,19 @@ public List< WaveDef > getWaves() { .toList(); } - private void updateKilledUndead( OnDeath.Data data ) { - ServerPlayer player = ( ServerPlayer )data.attacker; - CompoundTag tag = player.getPersistentData(); + public UndeadArmyInfo readUndeadArmyInfo( CompoundTag tag ) { UndeadArmyInfo info = new UndeadArmyInfo(); info.killedUndead = this.getInitialKillsCount(); info.read( tag ); + return info; + } + + private void updateKilledUndead( OnDeath.Data data ) { + ServerPlayer player = ( ServerPlayer )data.attacker; + CompoundTag tag = player.getPersistentData(); + UndeadArmyInfo info = this.readUndeadArmyInfo( tag ); + ++info.killedUndead; if( info.killedUndead >= this.getRequiredKills() && Registries.getUndeadArmyManager().tryToSpawn( player ) ) { info.killedUndead = 0; diff --git a/src/main/java/com/majruszsdifficulty/undeadarmy/UndeadArmyManager.java b/src/main/java/com/majruszsdifficulty/undeadarmy/UndeadArmyManager.java index 9323f7748..6f007e01d 100644 --- a/src/main/java/com/majruszsdifficulty/undeadarmy/UndeadArmyManager.java +++ b/src/main/java/com/majruszsdifficulty/undeadarmy/UndeadArmyManager.java @@ -76,6 +76,10 @@ public List< UndeadArmy > getUndeadArmies() { return Collections.unmodifiableList( this.undeadArmies ); } + public Config getConfig() { + return this.config; + } + void tick() { this.undeadArmies.forEach( UndeadArmy::tick ); boolean hasAnyArmyFinished = this.undeadArmies.removeIf( UndeadArmy::hasFinished ); diff --git a/src/main/java/com/majruszsdifficulty/undeadarmy/commands/UndeadArmyPersonalProgressCommand.java b/src/main/java/com/majruszsdifficulty/undeadarmy/commands/UndeadArmyPersonalProgressCommand.java new file mode 100644 index 000000000..d590090a8 --- /dev/null +++ b/src/main/java/com/majruszsdifficulty/undeadarmy/commands/UndeadArmyPersonalProgressCommand.java @@ -0,0 +1,34 @@ +package com.majruszsdifficulty.undeadarmy.commands; + +import com.majruszsdifficulty.Registries; +import com.majruszsdifficulty.undeadarmy.Config; +import com.majruszsdifficulty.undeadarmy.data.UndeadArmyInfo; +import com.mlib.annotations.AutoInstance; +import com.mlib.commands.Command; +import com.mlib.commands.CommandData; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.Entity; + +@AutoInstance +public class UndeadArmyPersonalProgressCommand extends Command { + public UndeadArmyPersonalProgressCommand() { + this.newBuilder() + .literal( "undeadarmy" ) + .literal( "progress" ) + .hasPermission( 4 ) + .execute( this::handle ) + .entity() + .execute( this::handle ); + } + + private int handle( CommandData data ) throws CommandSyntaxException { + Config config = Registries.getUndeadArmyManager().getConfig(); + Entity entity = this.getOptionalEntityOrPlayer( data ); + UndeadArmyInfo info = config.readUndeadArmyInfo( entity.getPersistentData() ); + int killsToStart = Math.max( config.getRequiredKills() - info.killedUndead, 1 ); + + data.source.sendSuccess( ()->Component.translatable( "commands.undeadarmy.progress", entity.getDisplayName(), killsToStart ), true ); + return -1; + } +} diff --git a/src/main/resources/assets/majruszsdifficulty/lang/en_us.json b/src/main/resources/assets/majruszsdifficulty/lang/en_us.json index ac6ce3297..9387b6e53 100644 --- a/src/main/resources/assets/majruszsdifficulty/lang/en_us.json +++ b/src/main/resources/assets/majruszsdifficulty/lang/en_us.json @@ -89,6 +89,7 @@ "commands.undeadarmy.highlighted": "All Undead Army units were highlighted at position: %s", "commands.undeadarmy.list": "List of all Undead Armies in progress:", "commands.undeadarmy.list_empty": "There is no Undead Army in progress!", + "commands.undeadarmy.progress": "%1$s must kill %2$s more undead to start the Undead Army.", "commands.treasurebag.reset": "Progress of all treasure bags has been restarted for %1$s.", "commands.treasurebag.unlockall": "Progress of all treasure bags has been maxed out for %1$s.", "commands.clampedregionaldifficulty": "Clamped regional difficulty at %1$s is %2$s.", diff --git a/src/main/resources/assets/majruszsdifficulty/lang/pl_pl.json b/src/main/resources/assets/majruszsdifficulty/lang/pl_pl.json index ca5c1c99b..4c8b39f3f 100644 --- a/src/main/resources/assets/majruszsdifficulty/lang/pl_pl.json +++ b/src/main/resources/assets/majruszsdifficulty/lang/pl_pl.json @@ -88,6 +88,7 @@ "commands.undeadarmy.highlighted": "Wszystkie jednostki armii nieumarłych zostały podświetlone na pozycji: %s", "commands.undeadarmy.list": "Lista wszystkich trwających najazdów armii nieumarłych:", "commands.undeadarmy.list_empty": "Aktualnie nie trwa żaden najazd armii nieumarłych!", + "commands.undeadarmy.progress": "%1$s musi zabić jeszcze %2$s nieumarłych, żeby rozpocząć najazd armii nieumarłych.", "commands.treasurebag.reset": "Progres wszystkich worków ze skarbami został zresetowany dla %1$s.", "commands.treasurebag.unlockall": "Progres wszystkich worków ze skarbami został ustawiony na maksimum dla %1$s.", "commands.clampedregionaldifficulty": "Poziom regionalnej trudności na %1$s wynosi %2$s.", diff --git a/src/main/resources/data/majruszsdifficulty/forge/biome_modifier/overworld_mobs_modifier.json b/src/main/resources/data/majruszsdifficulty/forge/biome_modifier/overworld_mobs_modifier.json index e573a8094..5f0b944e7 100644 --- a/src/main/resources/data/majruszsdifficulty/forge/biome_modifier/overworld_mobs_modifier.json +++ b/src/main/resources/data/majruszsdifficulty/forge/biome_modifier/overworld_mobs_modifier.json @@ -4,7 +4,7 @@ "spawners": [ { "type": "minecraft:illusioner", - "weight": 20, + "weight": 8, "minCount": 1, "maxCount": 1 },