Move server-affecting mixins to their own package

This commit is contained in:
Sollace 2024-05-20 16:02:52 +01:00
parent 80b885514f
commit 7560df438c
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
7 changed files with 29 additions and 31 deletions

View file

@ -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<Integer> 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);

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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<ServerPlayerEntity> modifyPlayers(List<ServerPlayerEntity> players) {
return players.size() <= 0 ? players : ((NocturnalSleepManager.Source)players.get(0).getWorld()).getNocturnalSleepManager().filterPlayers(players);
}
}

View file

@ -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<ServerPlayerEntity> modifyPlayers(List<ServerPlayerEntity> players) {
return players.size() <= 0 ? players : ((NocturnalSleepManager.Source)players.get(0).getWorld()).getNocturnalSleepManager().filterPlayers(players);
}
}

View file

@ -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",