From 27eec61ee29de977efdb7dfabab58fa84f2641f4 Mon Sep 17 00:00:00 2001 From: i509VCB Date: Wed, 4 Nov 2020 18:35:41 -0600 Subject: [PATCH] Turn off tests and mixins for currently disabled part --- .../event/lifecycle/MinecraftServerMixin.java | 4 ++-- .../event/lifecycle/ServerWorldMixin.java | 4 ++-- .../mixin/event/lifecycle/WorldMixin.java | 15 ++------------- .../client/ClientPlayNetworkHandlerMixin.java | 19 ++++--------------- .../lifecycle/client/ClientWorldMixin.java | 19 ++++--------------- .../ServerBlockEntityLifecycleTests.java | 11 ++--------- .../ClientBlockEntityLifecycleTests.java | 4 ++-- 7 files changed, 18 insertions(+), 58 deletions(-) diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MinecraftServerMixin.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MinecraftServerMixin.java index d5f6e46d8..05b2f435c 100644 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MinecraftServerMixin.java +++ b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/MinecraftServerMixin.java @@ -79,12 +79,12 @@ public abstract class MinecraftServerMixin { /** * When a world is closed, it means the world will be unloaded. */ - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;close()V"), method = "shutdown", locals = LocalCapture.CAPTURE_FAILEXCEPTION) + /*@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;close()V"), method = "shutdown", locals = LocalCapture.CAPTURE_FAILEXCEPTION) private void closeWorld(CallbackInfo ci, Iterator worlds, ServerWorld serverWorld) { for (BlockEntity blockEntity : serverWorld.blockEntities) { ServerBlockEntityEvents.BLOCK_ENTITY_UNLOAD.invoker().onUnload(blockEntity, serverWorld); } - } + }*/ // The locals you have to manage for an inject are insane. And do it twice. A redirect is much cleaner. // Here is what it looks like with an inject: https://gist.github.com/i509VCB/f80077cc536eb4dba62b794eba5611c1 diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/ServerWorldMixin.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/ServerWorldMixin.java index 4c89416b9..8c635a787 100644 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/ServerWorldMixin.java +++ b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/ServerWorldMixin.java @@ -33,7 +33,7 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; @Mixin(ServerWorld.class) public abstract class ServerWorldMixin { - @Shadow + /*@Shadow private boolean inEntityTick; // Call our load event after vanilla has loaded the entity @@ -42,7 +42,7 @@ public abstract class ServerWorldMixin { if (!this.inEntityTick) { // Copy vanilla logic, we cannot load entities while the game is ticking entities ServerEntityEvents.ENTITY_LOAD.invoker().onLoad(entity, (ServerWorld) (Object) this); } - } + }*/ // Make sure "insideBlockTick" is true before we call the start tick, so inject after it is set @Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/server/world/ServerWorld;inBlockTick:Z", opcode = Opcodes.PUTFIELD, ordinal = 0, shift = At.Shift.AFTER)) diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/WorldMixin.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/WorldMixin.java index f4f094142..a69a2d477 100644 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/WorldMixin.java +++ b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/WorldMixin.java @@ -16,27 +16,16 @@ package net.fabricmc.fabric.mixin.event.lifecycle; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.Slice; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import net.minecraft.block.entity.BlockEntity; import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.profiler.Profiler; import net.minecraft.world.World; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerBlockEntityEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; @Mixin(World.class) @@ -47,7 +36,7 @@ public abstract class WorldMixin { @Shadow public abstract Profiler getProfiler(); - @Inject(method = "addBlockEntity", at = @At("TAIL")) + /*@Inject(method = "addBlockEntity", at = @At("TAIL")) protected void onLoadBlockEntity(BlockEntity blockEntity, CallbackInfoReturnable cir) { if (!this.isClient()) { // Only fire this event if we are a server world ServerBlockEntityEvents.BLOCK_ENTITY_LOAD.invoker().onLoad(blockEntity, (ServerWorld) (Object) this); @@ -79,7 +68,7 @@ public abstract class WorldMixin { // Mimic vanilla logic return blockEntityList.removeAll(removals); - } + }*/ @Inject(at = @At("RETURN"), method = "tickBlockEntities") protected void tickWorldAfterBlockEntities(CallbackInfo ci) { diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientPlayNetworkHandlerMixin.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientPlayNetworkHandlerMixin.java index 712e3d367..ce11a2e19 100644 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientPlayNetworkHandlerMixin.java +++ b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientPlayNetworkHandlerMixin.java @@ -17,27 +17,16 @@ package net.fabricmc.fabric.mixin.event.lifecycle.client; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; -import net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientBlockEntityEvents; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents; @Environment(EnvType.CLIENT) @Mixin(ClientPlayNetworkHandler.class) public abstract class ClientPlayNetworkHandlerMixin { - @Shadow + /*@Shadow private ClientWorld world; @Inject(method = "onPlayerRespawn", at = @At(value = "NEW", target = "net/minecraft/client/world/ClientWorld")) @@ -53,7 +42,7 @@ public abstract class ClientPlayNetworkHandlerMixin { // No need to clear the `tickingBlockEntities` list since it will be null in just an instant } } - } + }*/ /** * An explanation why we unload entities during onGameJoin: @@ -61,7 +50,7 @@ public abstract class ClientPlayNetworkHandlerMixin { * Velocity by default will send a Game Join packet when the player changes servers, which will create a new client world. * Also anyone can send another GameJoinPacket at any time, so we need to watch out. */ - @Inject(method = "onGameJoin", at = @At(value = "NEW", target = "net/minecraft/client/world/ClientWorld")) + /*@Inject(method = "onGameJoin", at = @At(value = "NEW", target = "net/minecraft/client/world/ClientWorld")) private void onGameJoin(GameJoinS2CPacket packet, CallbackInfo ci) { // If a world already exists, we need to unload all (block)entities in the world. if (this.world != null) { @@ -90,5 +79,5 @@ public abstract class ClientPlayNetworkHandlerMixin { // No need to clear the `tickingBlockEntities` list since it will be null in just an instant } } - } + }*/ } diff --git a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientWorldMixin.java b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientWorldMixin.java index 6ad6af0ce..5f164c6ff 100644 --- a/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientWorldMixin.java +++ b/fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientWorldMixin.java @@ -16,33 +16,22 @@ package net.fabricmc.fabric.mixin.event.lifecycle.client; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.block.entity.BlockEntity; import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.profiler.Profiler; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientBlockEntityEvents; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.mixin.event.lifecycle.WorldMixin; @Environment(EnvType.CLIENT) @Mixin(ClientWorld.class) public abstract class ClientWorldMixin extends WorldMixin { - // Call our load event after vanilla has loaded the entity + /*// Call our load event after vanilla has loaded the entity @Inject(method = "addEntityPrivate", at = @At("TAIL")) private void onEntityLoad(int id, Entity entity, CallbackInfo ci) { ClientEntityEvents.ENTITY_LOAD.invoker().onLoad(entity, (ClientWorld) (Object) this); @@ -52,10 +41,10 @@ public abstract class ClientWorldMixin extends WorldMixin { @Inject(method = "finishRemovingEntity", at = @At("HEAD")) private void onEntityUnload(Entity entity, CallbackInfo ci) { ClientEntityEvents.ENTITY_UNLOAD.invoker().onUnload(entity, (ClientWorld) (Object) this); - } + }*/ // We override our injection on the clientworld so only the client's block entity invocations will run - @Override + /*@Override protected void onLoadBlockEntity(BlockEntity blockEntity, CallbackInfoReturnable cir) { ClientBlockEntityEvents.BLOCK_ENTITY_LOAD.invoker().onLoad(blockEntity, (ClientWorld) (Object) this); } @@ -78,7 +67,7 @@ public abstract class ClientWorldMixin extends WorldMixin { } return super.onPurgeRemovedBlockEntities(blockEntityList, removals); // Call super - } + }*/ // We override our injection on the clientworld so only the client world's tick invocations will run @Override diff --git a/fabric-lifecycle-events-v1/src/testmod/java/net/fabricmc/fabric/test/event/lifecycle/ServerBlockEntityLifecycleTests.java b/fabric-lifecycle-events-v1/src/testmod/java/net/fabricmc/fabric/test/event/lifecycle/ServerBlockEntityLifecycleTests.java index c3210b597..3da0ba341 100644 --- a/fabric-lifecycle-events-v1/src/testmod/java/net/fabricmc/fabric/test/event/lifecycle/ServerBlockEntityLifecycleTests.java +++ b/fabric-lifecycle-events-v1/src/testmod/java/net/fabricmc/fabric/test/event/lifecycle/ServerBlockEntityLifecycleTests.java @@ -19,16 +19,9 @@ package net.fabricmc.fabric.test.event.lifecycle; import java.util.ArrayList; import java.util.List; -import org.apache.logging.log4j.Logger; - import net.minecraft.block.entity.BlockEntity; -import net.minecraft.server.world.ServerWorld; -import net.minecraft.util.registry.Registry; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerBlockEntityEvents; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; public class ServerBlockEntityLifecycleTests implements ModInitializer { private static boolean PRINT_SERVER_BLOCKENTITY_MESSAGES = System.getProperty("fabric-lifecycle-events-testmod.printServerBlockEntityMessages") != null; @@ -36,7 +29,7 @@ public class ServerBlockEntityLifecycleTests implements ModInitializer { @Override public void onInitialize() { - final Logger logger = ServerLifecycleTests.LOGGER; + /*final Logger logger = ServerLifecycleTests.LOGGER; ServerBlockEntityEvents.BLOCK_ENTITY_LOAD.register((blockEntity, world) -> { this.serverBlockEntities.add(blockEntity); @@ -89,6 +82,6 @@ public class ServerBlockEntityLifecycleTests implements ModInitializer { if (this.serverBlockEntities.size() != 0) { logger.error("[SERVER] Mismatch in tracked blockentities, expected 0"); } - }); + });*/ } } diff --git a/fabric-lifecycle-events-v1/src/testmod/java/net/fabricmc/fabric/test/event/lifecycle/client/ClientBlockEntityLifecycleTests.java b/fabric-lifecycle-events-v1/src/testmod/java/net/fabricmc/fabric/test/event/lifecycle/client/ClientBlockEntityLifecycleTests.java index 94202d6a9..2681d32dd 100644 --- a/fabric-lifecycle-events-v1/src/testmod/java/net/fabricmc/fabric/test/event/lifecycle/client/ClientBlockEntityLifecycleTests.java +++ b/fabric-lifecycle-events-v1/src/testmod/java/net/fabricmc/fabric/test/event/lifecycle/client/ClientBlockEntityLifecycleTests.java @@ -37,7 +37,7 @@ public class ClientBlockEntityLifecycleTests implements ClientModInitializer { @Override public void onInitializeClient() { - final Logger logger = ServerLifecycleTests.LOGGER; + /*final Logger logger = ServerLifecycleTests.LOGGER; ClientBlockEntityEvents.BLOCK_ENTITY_LOAD.register((blockEntity, world) -> { this.clientBlockEntities.add(blockEntity); @@ -80,6 +80,6 @@ public class ClientBlockEntityLifecycleTests implements ClientModInitializer { logger.error("[CLIENT] Mismatch in tracked blockentities, expected 0"); } } - }); + });*/ } }