Skip to content

Commit

Permalink
Less funny mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
Cleptomania committed Dec 18, 2024
1 parent 6d1c740 commit 9836492
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public abstract class MixinWorldServer extends World {
public MixinWorldServer(ISaveHandler p_i45368_1_, String p_i45368_2_, WorldProvider p_i45368_3_,
WorldSettings p_i45368_4_, Profiler p_i45368_5_) {
super(p_i45368_1_, p_i45368_2_, p_i45368_3_, p_i45368_4_, p_i45368_5_);
throw new ArithmeticException("2 + 2 = 5 ???");
throw new RuntimeException(
"Server Utilities player sleeping percentage broke in a huge way. This error should never happen");
}

@Inject(method = "<init>", at = @At("RETURN"))
Expand All @@ -58,7 +59,7 @@ public MixinWorldServer(ISaveHandler p_i45368_1_, String p_i45368_2_, WorldProvi
}

@Inject(method = "updateAllPlayersSleepingFlag", at = @At("HEAD"), cancellable = true)
public void hhheheheheeh(CallbackInfo ci) {
public void serverutilities$handlePlayersSleepingPercentage(CallbackInfo ci) {
percent = Integer.parseInt(this.getGameRules().getGameRuleStringValue("playersSleepingPercentage"));
if (percent > 100) {
this.allPlayersSleeping = false;
Expand Down Expand Up @@ -98,23 +99,23 @@ public void hhheheheheeh(CallbackInfo ci) {
value = "FIELD",
target = "Lnet/minecraft/world/WorldServer;playerEntities:Ljava/util/List;",
opcode = Opcodes.GETFIELD))
public List<EntityPlayer> baited(WorldServer instance) {
public List<EntityPlayer> serverutilities$speedup1(WorldServer instance) {
return sleepingPlayers.isEmpty() ? this.playerEntities : sleepingPlayers;
}

@Inject(
method = "areAllPlayersAsleep",
at = @At(value = "INVOKE", target = "Ljava/util/List;iterator()Ljava/util/Iterator;"),
cancellable = true)
public void turbofast(CallbackInfoReturnable<Boolean> ctx) {
public void serverutilities$speedup2(CallbackInfoReturnable<Boolean> ctx) {
if (percent < 1) ctx.setReturnValue(true);
}

@Inject(
method = "wakeAllPlayers",
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/EntityPlayer;wakeUpPlayer(ZZZ)V"),
locals = LocalCapture.CAPTURE_FAILHARD)
public void broadcast(CallbackInfo ctx, Iterator iterator, EntityPlayer player) {
public void serverutilities$broadcast(CallbackInfo ctx, Iterator iterator, EntityPlayer player) {
if (percent > 0 && percent < 100) {
player.addChatMessage(new ChatComponentTranslation("serverutiltiies.world.skip_night"));
}
Expand All @@ -125,8 +126,7 @@ public List<EntityPlayer> getListWithoutAFK(List<EntityPlayer> list) {
return list.stream()
.filter(
(EntityPlayer entity) -> ServerUtilitiesPlayerData
.get(Universe.get().getPlayer((EntityPlayerMP) entity)).afkTime
>= notificationTimer)
.get(Universe.get().getPlayer((EntityPlayerMP) entity)).afkTime >= notificationTimer)
.collect(Collectors.toList());
}
}

0 comments on commit 9836492

Please sign in to comment.