Skip to content

Commit

Permalink
Fix setDifficulty
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Oct 28, 2024
1 parent df7cf37 commit 003282d
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public abstract class MixinPrimaryLevelData implements InjectionPrimaryLevelData

@Shadow private boolean thundering;
@Shadow public LevelSettings settings;
@Shadow public abstract Difficulty getDifficulty();
@Unique
public ServerLevel world;
@Unique
Expand Down Expand Up @@ -90,10 +91,10 @@ public abstract class MixinPrimaryLevelData implements InjectionPrimaryLevelData

@Inject(method = "setDifficulty", at = @At("RETURN"))
private void banner$sendDiffChange(Difficulty newDifficulty, CallbackInfo ci) {
ClientboundChangeDifficultyPacket packet = new ClientboundChangeDifficultyPacket(newDifficulty, this.isDifficultyLocked());
ClientboundChangeDifficultyPacket packet = new ClientboundChangeDifficultyPacket(getDifficulty(), this.isDifficultyLocked());
if (this.world != null) {
for (Player player : this.world.players()) {
((ServerPlayer) player).connection.send(packet);
for (ServerPlayer player : this.world.players()) {
player.connection.send(packet);
}
}
}
Expand All @@ -118,7 +119,12 @@ public void checkName(String name) {
// CraftBukkit start - Add world and pdc
@Override
public void setWorld(ServerLevel world) {
if (this.world != null) {
return;
}
this.world = world;
world.getWorld().readBukkitValues(pdc);
pdc = null;
}
// CraftBukkit end
}

0 comments on commit 003282d

Please sign in to comment.