Skip to content

Commit

Permalink
move client tick event subscription to modloader api's
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Dec 23, 2023
1 parent d7ddd82 commit 8b22fa4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,13 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.waste.of.time.storage.cache.LootableInjectionHandler;
import org.waste.of.time.Events;

@Mixin(MinecraftClient.class)
public class MinecraftClientMixin {
@Shadow
@Nullable
public Screen currentScreen;

@Inject(method = "tick", at = @At("HEAD"))
public void tickHead(final CallbackInfo ci) {
Events.INSTANCE.onClientTickStart();
}

@Inject(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;removed()V", shift = At.Shift.AFTER))
private void onScreenRemove(@Nullable Screen screen, CallbackInfo ci) {
if (currentScreen != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents
import net.fabricmc.fabric.api.event.player.UseBlockCallback
import net.minecraft.util.ActionResult
import org.waste.of.time.Events
import org.waste.of.time.manager.CaptureManager
import org.waste.of.time.WorldTools
import org.waste.of.time.WorldTools.LOG
import org.waste.of.time.manager.CaptureManager

object WorldToolsFabric : ClientModInitializer {
override fun onInitializeClient() {
Expand Down Expand Up @@ -43,6 +44,9 @@ object WorldToolsFabric : ClientModInitializer {
Events.onInteractBlock(world, hitResult)
ActionResult.PASS
})
ClientTickEvents.START_CLIENT_TICK.register(ClientTickEvents.StartTick {
Events.onClientTickStart()
})

LOG.info("WorldTools Fabric initialized")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import net.minecraft.server.command.ServerCommandSource
import net.minecraftforge.client.event.ClientPlayerNetworkEvent
import net.minecraftforge.client.event.RegisterClientCommandsEvent
import net.minecraftforge.client.event.RegisterKeyMappingsEvent
import net.minecraftforge.event.TickEvent
import net.minecraftforge.event.TickEvent.ClientTickEvent
import net.minecraftforge.event.entity.EntityJoinLevelEvent
import net.minecraftforge.event.entity.EntityLeaveLevelEvent
import net.minecraftforge.event.entity.player.PlayerInteractEvent
import net.minecraftforge.fml.common.Mod
import org.waste.of.time.Events
import org.waste.of.time.manager.CaptureManager
import org.waste.of.time.WorldTools
import org.waste.of.time.WorldTools.LOG
import org.waste.of.time.manager.CaptureManager
import thedarkcolour.kotlinforforge.forge.FORGE_BUS

@Mod(WorldTools.MOD_ID)
Expand Down Expand Up @@ -44,6 +46,9 @@ object WorldToolsForge {
FORGE_BUS.addListener<EntityLeaveLevelEvent> {
Events.onEntityUnload(it.entity)
}
FORGE_BUS.addListener<ClientTickEvent> {
if (it.phase == TickEvent.Phase.START) Events.onClientTickStart()
}

LOG.info("WorldTools Forge initialized")
}
Expand Down

0 comments on commit 8b22fa4

Please sign in to comment.