From 7560df438cd582503c6c662c00b08949e38058ab Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 20 May 2024 16:02:52 +0100 Subject: [PATCH] Move server-affecting mixins to their own package --- .../mixin/MixinChunkBlockLightProvider.java | 10 ---------- .../{ => server}/MixinPlayerManager.java | 2 +- .../MixinServerPlayNetworkHandler.java | 2 +- .../{ => server}/MixinServerPlayerEntity.java | 2 +- .../mixin/{ => server}/MixinServerWorld.java | 14 +------------ .../mixin/server/MixinSleepManager.java | 20 +++++++++++++++++++ src/main/resources/unicopia.mixin.json | 10 +++++----- 7 files changed, 29 insertions(+), 31 deletions(-) rename src/main/java/com/minelittlepony/unicopia/mixin/{ => server}/MixinPlayerManager.java (97%) rename src/main/java/com/minelittlepony/unicopia/mixin/{ => server}/MixinServerPlayNetworkHandler.java (97%) rename src/main/java/com/minelittlepony/unicopia/mixin/{ => server}/MixinServerPlayerEntity.java (98%) rename src/main/java/com/minelittlepony/unicopia/mixin/{ => server}/MixinServerWorld.java (77%) create mode 100644 src/main/java/com/minelittlepony/unicopia/mixin/server/MixinSleepManager.java diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinChunkBlockLightProvider.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinChunkBlockLightProvider.java index db7ec5cf..e8a40cfb 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinChunkBlockLightProvider.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinChunkBlockLightProvider.java @@ -37,16 +37,6 @@ abstract class MixinChunkBlockLightProvider extends ChunkLightProvider { } } - /* - @Inject(method = "getLightSourceLuminance", at = @At("RETURN"), cancellable = true) - private void onGetLightSourceLuminance(long blockPos, BlockState blockState, CallbackInfoReturnable info) { - int x = ChunkSectionPos.getSectionCoord(BlockPos.unpackLongX(blockPos)); - int z = ChunkSectionPos.getSectionCoord(BlockPos.unpackLongZ(blockPos)); - if (chunkProvider.getChunk(x, z) instanceof WorldChunk chunk) { - info.setReturnValue(Math.max(info.getReturnValue(), LightSources.get(chunk.getWorld()).getLuminance(blockPos))); - } - }*/ - @Inject(method = "method_51529", at = @At("TAIL")) private void onMethod_51529(long blockPos, CallbackInfo info) { long sectionPos = ChunkSectionPos.fromBlockPos(blockPos); diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerManager.java b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinPlayerManager.java similarity index 97% rename from src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerManager.java rename to src/main/java/com/minelittlepony/unicopia/mixin/server/MixinPlayerManager.java index ce8be7b9..0c845c1c 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerManager.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinPlayerManager.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.mixin; +package com.minelittlepony.unicopia.mixin.server; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayNetworkHandler.java b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayNetworkHandler.java similarity index 97% rename from src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayNetworkHandler.java rename to src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayNetworkHandler.java index 9ec1f042..c6580d88 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayNetworkHandler.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayNetworkHandler.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.mixin; +package com.minelittlepony.unicopia.mixin.server; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayerEntity.java similarity index 98% rename from src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerEntity.java rename to src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayerEntity.java index 17bb934d..2ae21fe5 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerPlayerEntity.java @@ -1,4 +1,4 @@ -package com.minelittlepony.unicopia.mixin; +package com.minelittlepony.unicopia.mixin.server; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerWorld.java b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerWorld.java similarity index 77% rename from src/main/java/com/minelittlepony/unicopia/mixin/MixinServerWorld.java rename to src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerWorld.java index 019d5cbd..b24c24ae 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinServerWorld.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinServerWorld.java @@ -1,6 +1,5 @@ -package com.minelittlepony.unicopia.mixin; +package com.minelittlepony.unicopia.mixin.server; -import java.util.List; import java.util.function.BooleanSupplier; import org.spongepowered.asm.mixin.Mixin; @@ -8,16 +7,13 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyConstant; -import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.minelittlepony.unicopia.server.world.BlockDestructionManager; import com.minelittlepony.unicopia.server.world.NocturnalSleepManager; import net.minecraft.block.BlockState; -import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; -import net.minecraft.server.world.SleepManager; import net.minecraft.util.math.BlockPos; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.World; @@ -57,11 +53,3 @@ abstract class MixinServerWorld extends World implements StructureWorldAccess, N getNocturnalSleepManager().skipTime(); } } - -@Mixin(SleepManager.class) -abstract class MixinSleepManager { - @ModifyVariable(method = "update(Ljava/util/List;)Z", at = @At("HEAD")) - public List modifyPlayers(List players) { - return players.size() <= 0 ? players : ((NocturnalSleepManager.Source)players.get(0).getWorld()).getNocturnalSleepManager().filterPlayers(players); - } -} \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinSleepManager.java b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinSleepManager.java new file mode 100644 index 00000000..76c18b65 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/mixin/server/MixinSleepManager.java @@ -0,0 +1,20 @@ +package com.minelittlepony.unicopia.mixin.server; + +import java.util.List; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +import com.minelittlepony.unicopia.server.world.NocturnalSleepManager; + +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.SleepManager; + +@Mixin(SleepManager.class) +abstract class MixinSleepManager { + @ModifyVariable(method = "update(Ljava/util/List;)Z", at = @At("HEAD")) + public List modifyPlayers(List players) { + return players.size() <= 0 ? players : ((NocturnalSleepManager.Source)players.get(0).getWorld()).getNocturnalSleepManager().filterPlayers(players); + } +} diff --git a/src/main/resources/unicopia.mixin.json b/src/main/resources/unicopia.mixin.json index f09a4e9c..5de80517 100644 --- a/src/main/resources/unicopia.mixin.json +++ b/src/main/resources/unicopia.mixin.json @@ -37,15 +37,10 @@ "MixinPersistentProjectileEntity", "MixinPlayerEntity", "MixinPlayerInventory", - "MixinPlayerManager", "MixinPointOfInterestType", "MixinPowderSnowBlock", "MixinProjectileEntity", "MixinPufferfishEntity", - "MixinServerPlayerEntity", - "MixinServerPlayNetworkHandler", - "MixinServerWorld", - "MixinSleepManager", "MixinSheepEntity", "MixinShulkerEntity", "MixinStateManager", @@ -56,6 +51,11 @@ "MixinWardenEntity", "MixinWorld", "PointOfInterestTypesAccessor", + "server.MixinPlayerManager", + "server.MixinServerPlayerEntity", + "server.MixinServerPlayNetworkHandler", + "server.MixinServerWorld", + "server.MixinSleepManager", "gravity.MixinBrain", "gravity.MixinEntity", "gravity.MixinLivingEntity",