Skip to content

Commit

Permalink
Merged 1.9.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Majrusz authored Dec 9, 2023
2 parents 07a4d00 + cabc490 commit a253903
Show file tree
Hide file tree
Showing 12 changed files with 285 additions and 211 deletions.
11 changes: 6 additions & 5 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- changed required Majrusz Library from 7.0.0+ to 7.0.1+
- fixed game crash `java.lang.ClassNotFoundException` (reported by @NanoAi)
- fixed Soul Jar color issue caused by incompatibility with Sodium (reported by @LonelyFear)
- fixed bug with being unable to disable natural Undead Army spawns (reported by @NeuTraLZero)
- fixed bug with Undead Army not changing weather properly
- changed required Majrusz Library version from 7.0.1+ to 7.0.2+
- readded missing Bleeding advancements
- updated Chinese translation (thanks to @UDTakerBean)
- fixed bug with blood particles not being visible on server
- fixed bug with some expert mode and master mode mechanics working on earlier game stages
- fixed bug with Cursed Armor spawns not working properly
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.majruszsdifficulty.effects.Bleeding;
import com.majruszsdifficulty.effects.BleedingImmunity;
import com.majruszsdifficulty.effects.GlassRegeneration;
import com.majruszsdifficulty.effects.bleeding.BleedingParticles;
import com.majruszsdifficulty.entity.*;
import com.majruszsdifficulty.gamestage.GameStageAdvancement;
import com.majruszsdifficulty.items.*;
Expand Down Expand Up @@ -73,6 +74,7 @@ public class MajruszsDifficulty {
public static final RegistryGroup< SoundEvent > SOUND_EVENTS = HELPER.create( BuiltInRegistries.SOUND_EVENT );

// Network
public static final NetworkObject< BleedingParticles.Message > BLEEDING_GUI = HELPER.create( "bleeding_gui", BleedingParticles.Message.class );
public static final NetworkObject< TreasureBag.RightClickAction > TREASURE_BAG_RIGHT_CLICK_NETWORK = HELPER.create( "treasure_bag_right_click", TreasureBag.RightClickAction.class );
public static final NetworkObject< TreasureBagHelper.Progress > TREASURE_BAG_PROGRESS_NETWORK = HELPER.create( "treasure_bag_progress", TreasureBagHelper.Progress.class );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
import com.majruszsdifficulty.effects.Bleeding;
import com.majruszsdifficulty.events.OnBleedingCheck;
import net.minecraft.core.Holder;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.phys.Vec3;

Expand All @@ -38,6 +40,7 @@ public class BleedingDamage {
private static void tryToApply( OnEntityDamaged data ) {
if( Events.dispatch( new OnBleedingCheck( data ) ).isBleedingTriggered() && Bleeding.apply( data.target, data.attacker ) ) {
BleedingDamage.dealDamage( data.target );
BleedingDamage.giveAdvancements( data );
}
}

Expand Down Expand Up @@ -67,4 +70,17 @@ private static void dealDamage( LivingEntity entity ) {
entity.hurt( new DamageSource( damageType ), 1.0f );
}
}

private static void giveAdvancements( OnEntityDamaged data ) {
if( data.target instanceof ServerPlayer player ) {
MajruszsDifficulty.HELPER.triggerAchievement( player, "bleeding_received" );
if( data.source.is( DamageTypes.CACTUS ) ) {
MajruszsDifficulty.HELPER.triggerAchievement( player, "cactus_bleeding" );
}
}

if( data.attacker instanceof ServerPlayer player ) {
MajruszsDifficulty.HELPER.triggerAchievement( player, "bleeding_inflicted" );
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.majruszsdifficulty.effects.bleeding;

import com.majruszlibrary.annotation.Dist;
import com.majruszlibrary.annotation.OnlyIn;
import com.majruszlibrary.data.Reader;
import com.majruszlibrary.data.Serializables;
import com.majruszlibrary.emitter.ParticleEmitter;
import com.majruszlibrary.entity.EffectHelper;
import com.majruszlibrary.entity.EntityHelper;
Expand All @@ -10,8 +14,8 @@
import com.majruszlibrary.events.base.Priority;
import com.majruszlibrary.math.AnyPos;
import com.majruszlibrary.math.Random;
import com.majruszlibrary.platform.Side;
import com.majruszsdifficulty.MajruszsDifficulty;
import net.minecraft.server.level.ServerPlayer;

public class BleedingParticles {
static {
Expand All @@ -26,7 +30,8 @@ public class BleedingParticles {

OnEntityPreDamaged.listen( BleedingParticles::addGuiOverlay )
.priority( Priority.LOWEST )
.addCondition( data->data.source.is( MajruszsDifficulty.BLEEDING_DAMAGE_SOURCE ) );
.addCondition( data->data.source.is( MajruszsDifficulty.BLEEDING_DAMAGE_SOURCE ) )
.addCondition( data->data.target instanceof ServerPlayer );
}

private static void emit( OnEntityTicked data ) {
Expand All @@ -49,10 +54,32 @@ private static void emit( OnEntityDied data ) {
}

private static void addGuiOverlay( OnEntityPreDamaged data ) {
Side.runOnClient( ()->()->{
if( data.target.equals( Side.getLocalPlayer() ) ) {
BleedingGui.addBloodOnScreen( 3 );
}
} );
MajruszsDifficulty.BLEEDING_GUI.sendToClient( ( ServerPlayer )data.target, new Message( 3 ) );
}

public static class Message {
int count;

static {
Serializables.get( Message.class )
.define( "count", Reader.integer(), s->s.count, ( s, v )->s.count = v );
}

public Message( int count ) {
this.count = count;
}

public Message() {}
}

@OnlyIn( Dist.CLIENT )
public static class Client {
static {
MajruszsDifficulty.BLEEDING_GUI.addClientCallback( Client::onMessageReceived );
}

private static void onMessageReceived( Message message ) {
BleedingGui.addBloodOnScreen( message.count );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class GameStage {
private List< ChatFormatting > format = new ArrayList<>();
private Trigger trigger = new Trigger();
private List< Message > messages = new ArrayList<>();
private int ordinal = 0;
int ordinal = 0;

static {
Serializables.get( GameStage.class )
Expand Down Expand Up @@ -46,10 +46,6 @@ public boolean equals( Object object ) {
&& this.id.equals( gameStage.id );
}

public void setOrdinal( int ordinal ) {
this.ordinal = ordinal;
}

public boolean checkDimension( String dimensionId ) {
return this.trigger.dimensions.stream().anyMatch( string->string.matches( dimensionId ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import com.majruszlibrary.data.Reader;
import com.majruszlibrary.data.Serializables;
import com.majruszlibrary.events.OnLevelsLoaded;
import net.minecraft.ChatFormatting;

import java.util.List;

public class GameStageConfig {
public static boolean IS_PER_PLAYER_DIFFICULTY_ENABLED = false;
public static List< GameStage > GAME_STAGES = List.of(
public static List< GameStage > GAME_STAGES = GameStageConfig.updateOrdinals( List.of(
GameStage.named( GameStage.NORMAL_ID )
.format( ChatFormatting.WHITE )
.create(),
Expand All @@ -25,22 +24,14 @@ public class GameStageConfig {
.message( "majruszsdifficulty.stages.master.started", ChatFormatting.DARK_PURPLE, ChatFormatting.BOLD )
.message( "majruszsdifficulty.undead_army.on_master", ChatFormatting.DARK_PURPLE )
.create()
);
) );

static {
OnLevelsLoaded.listen( GameStageConfig::updateOrdinals );

Serializables.getStatic( GameStageConfig.class )
.define( "is_per_player_difficulty_enabled", Reader.bool(), ()->IS_PER_PLAYER_DIFFICULTY_ENABLED, v->IS_PER_PLAYER_DIFFICULTY_ENABLED = v )
.define( "list", Reader.list( Reader.custom( GameStage::new ) ), ()->GAME_STAGES, v->GAME_STAGES = GameStageConfig.validate( v ) );
}

private static void updateOrdinals( OnLevelsLoaded data ) {
for( int idx = 0; idx < GAME_STAGES.size(); ++idx ) {
GAME_STAGES.get( idx ).setOrdinal( idx );
}
}

private static List< GameStage > validate( List< GameStage > gameStages ) {
boolean hasDefaultGameStages = gameStages.stream()
.filter( gameStage->gameStage.is( GameStage.NORMAL_ID ) || gameStage.is( GameStage.EXPERT_ID ) || gameStage.is( GameStage.MASTER_ID ) )
Expand All @@ -49,15 +40,39 @@ private static List< GameStage > validate( List< GameStage > gameStages ) {
throw new IllegalArgumentException( "Default game stages cannot be removed" );
}

int idx = 0;
for( GameStage gameStage : gameStages ) {
gameStage.setOrdinal( idx++ );
long count = gameStages.stream().filter( stage->stage.equals( gameStage ) ).count();
if( count > 1 ) {
throw new IllegalArgumentException( "Found %d game stages with identical id (%s)".formatted( count, gameStage.getId() ) );
}
}

GameStageConfig.keepOldReferencesValid( gameStages, GAME_STAGES );
GameStageConfig.updateOrdinals( gameStages );

return gameStages;
}

private static List< GameStage > keepOldReferencesValid( List< GameStage > newGameStages, List< GameStage > oldGameStages ) {
for( int idx = 0; idx < newGameStages.size(); ++idx ) {
GameStage newGameStage = newGameStages.get( idx );
for( GameStage oldGameStage : oldGameStages ) {
if( oldGameStage.is( newGameStage.getId() ) ) {
newGameStage = oldGameStage; // to keep references valid
break;
}
}
newGameStages.set( idx, newGameStage );
}

return newGameStages;
}

private static List< GameStage > updateOrdinals( List< GameStage > gameStages ) {
for( int idx = 0; idx < gameStages.size(); ++idx ) {
gameStages.get( idx ).ordinal = idx;
}

return gameStages;
}
}
Loading

0 comments on commit a253903

Please sign in to comment.