Skip to content

Commit

Permalink
Merged 1.9.9 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Majrusz authored Mar 2, 2024
2 parents 6a8bb11 + ce264f2 commit dbab2bb
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 20 deletions.
11 changes: 6 additions & 5 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- added config for mobs that should be immune to Bleeding
- updated Russian translation (thanks to @LolsShow and Faster Than Light team)
- fixed bug with Blood Moons not working after 2nd night (reported by @FireKyleA1205)
- fixed bug that sometimes kicks from the game when opening Treasure Bags (reported by @GenericCherrySwitch)
- fixed bug with Skeleton Horse and Zombie Horse not being immune to Bleeding
- added Undead Army compatibility with RpgZ mod (suggested by @Sazuzaki)
- added Japanese translation (thanks to @もふざとう)
- changed fishing requirements for Angler Treasure Bag from 20/15/10 to 16 on all game stages
- fixed bug with mobs being able to spawn in Mushroom Fields and Deep Dark (reported by @Dagamer2021)
- fixed bug with Undead Army progress bars displaying invalid values after reentering the world
- fixed bug with mob groups being able to spawn recursively
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.majruszsdifficulty.undeadarmy.UndeadArmyHelper;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.*;
import net.minecraft.world.entity.ai.goal.Goal;
Expand Down Expand Up @@ -98,6 +99,7 @@ public class MobGroups {
.addCondition( Condition.isLogicalServer() )
.addCondition( data->!data.isLoadedFromDisk )
.addCondition( data->data.entity instanceof PathfinderMob )
.addCondition( data->!MobGroups.belongsToMobGroup( data.entity ) )
.addCondition( data->!data.getLevel().equals( Side.getServer().overworld() ) || !UndeadArmyHelper.isPartOfUndeadArmy( data.entity ) );

Command.create()
Expand Down Expand Up @@ -151,6 +153,7 @@ private static void tryToSpawnGroup( OnEntitySpawned data ) {
continue;
}

MobGroups.markAsGroupPart( data.entity );
MobGroups.spawn( ( PathfinderMob )data.entity, groupDef );
MobGroups.giveItems( leader, leaderDef.equipment );

Expand All @@ -166,6 +169,7 @@ private static void spawn( PathfinderMob leader, GroupDef groupDef ) {
Entity entity = EntityHelper.createSpawner( ()->sidekickDef.type, level )
.position( MobGroups.getRandomizedPosition( level, leader.position() ) )
.mobSpawnType( MobSpawnType.EVENT )
.beforeEvent( MobGroups::markAsGroupPart )
.spawn();
if( !( entity instanceof PathfinderMob sidekick ) ) {
continue;
Expand Down Expand Up @@ -202,6 +206,16 @@ private static Vec3 getRandomizedPosition( Level level, Vec3 position ) {
return position;
}

private static void markAsGroupPart( Entity entity ) {
Serializables.modify( new Tag(), EntityHelper.getOrCreateExtraTag( entity ), tag->tag.belongsToMobGroup = true );
}

private static boolean belongsToMobGroup( Entity entity ) {
CompoundTag tag = EntityHelper.getExtraTag( entity );

return tag != null && Serializables.read( new Tag(), tag ).belongsToMobGroup;
}

private static int spawn( CommandData data ) throws CommandSyntaxException {
if( !( data.getCaller() instanceof Player player ) ) {
return -1;
Expand Down Expand Up @@ -355,4 +369,13 @@ public SidekickDef( EntityType< ? > type, ResourceLocation equipment ) {

public SidekickDef() {}
}

private static class Tag {
public boolean belongsToMobGroup = false;

static {
Serializables.get( Tag.class )
.define( "belongs_to_mob_group", Reader.bool(), s->s.belongsToMobGroup, ( s, v )->s.belongsToMobGroup = v );
}
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
package com.majruszsdifficulty.treasurebag.listeners;

import com.majruszlibrary.collection.DefaultMap;
import com.majruszlibrary.data.Reader;
import com.majruszlibrary.data.Serializables;
import com.majruszlibrary.entity.EntityHelper;
import com.majruszlibrary.events.OnItemFished;
import com.majruszlibrary.events.base.Condition;
import com.majruszlibrary.item.ItemHelper;
import com.majruszsdifficulty.MajruszsDifficulty;
import com.majruszsdifficulty.gamestage.GameStage;
import com.majruszsdifficulty.gamestage.GameStageHelper;
import com.majruszsdifficulty.gamestage.GameStageValue;
import net.minecraft.world.item.ItemStack;

public class FishingRewarder {
public static GameStageValue< Integer > FISH_REQUIREMENT = GameStageValue.of(
DefaultMap.defaultEntry( 20 ),
DefaultMap.entry( GameStage.EXPERT_ID, 15 ),
DefaultMap.entry( GameStage.MASTER_ID, 10 )
);
public static int FISH_REQUIREMENT = 16;

static {
OnItemFished.listen( FishingRewarder::updateItemsFished )
Expand All @@ -31,7 +23,7 @@ public class FishingRewarder {
private static void updateItemsFished( OnItemFished data ) {
Serializables.modify( new FishingInfo(), EntityHelper.getOrCreateExtraTag( data.player ), fishingInfo->{
if( fishingInfo.fishesLeft <= 0 ) {
fishingInfo.fishesLeft = FISH_REQUIREMENT.get( GameStageHelper.determineGameStage( data.player ) );
fishingInfo.fishesLeft = FISH_REQUIREMENT;
}

--fishingInfo.fishesLeft;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
Expand Down Expand Up @@ -67,6 +68,11 @@ public class UndeadArmy {
.define( "uuid", Reader.optional( Reader.uuid() ), s->s.uuid, ( s, v )->s.uuid = v );
}

public UndeadArmy() {
this.waveInfo.setVisible( false );
this.bossInfo.setVisible( false );
}

public void start( BlockPos position, Direction direction ) {
this.gameStage = GameStageHelper.determineGameStage( this.getLevel(), position.getCenter() );
this.position = position;
Expand Down Expand Up @@ -202,7 +208,16 @@ public MobInfo( UndeadArmyConfig.MobDef def, BlockPos position, boolean isBoss )
public MobInfo() {}

public @Nullable Entity toEntity( ServerLevel level ) {
return this.uuid != null ? level.getEntity( this.uuid ) : null;
if( this.uuid == null ) {
return null;
}

Entity entity = level.getEntity( this.uuid );
if( entity instanceof LivingEntity livingEntity && livingEntity.deathTime >= 20 ) {
return null; // compatibility with RpgZ
}

return entity;
}

public float getHealth( ServerLevel level ) {
Expand Down
Loading

0 comments on commit dbab2bb

Please sign in to comment.