1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-10 09:20:28 +00:00

Small cleanup after testing

- Use TinyRemapper to remap mixins on Fabric. Mixins in the common
   project weren't being remapped correctly.

 - Update to latest NeoForge
   - Switch to the new tick events.
   - Call refreshDimensions() in the fake player constructor.
This commit is contained in:
Jonathan Coates 2024-04-28 22:02:12 +01:00
parent 959bdaeb61
commit 2226df7224
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
9 changed files with 22 additions and 31 deletions

View File

@ -9,7 +9,7 @@
# Remember to update corresponding versions in fabric.mod.json/neoforge.mods.toml # Remember to update corresponding versions in fabric.mod.json/neoforge.mods.toml
fabric-api = "0.97.6+1.20.5" fabric-api = "0.97.6+1.20.5"
fabric-loader = "0.15.10" fabric-loader = "0.15.10"
neoForge = "20.5.0-beta" neoForge = "20.5.20-beta"
neoForgeSpi = "8.0.1" neoForgeSpi = "8.0.1"
mixin = "0.8.5" mixin = "0.8.5"
parchment = "2024.04.14" parchment = "2024.04.14"
@ -67,7 +67,7 @@ ideaExt = "1.1.7"
illuaminate = "0.1.0-71-g378d86e" illuaminate = "0.1.0-71-g378d86e"
lwjgl = "3.3.3" lwjgl = "3.3.3"
minotaur = "2.8.7" minotaur = "2.8.7"
neoGradle = "7.0.107" neoGradle = "7.0.116"
nullAway = "0.10.25" nullAway = "0.10.25"
spotless = "6.23.3" spotless = "6.23.3"
taskTree = "2.1.1" taskTree = "2.1.1"

View File

@ -109,7 +109,7 @@ sourceSets.main { resources.srcDir("src/generated/resources") }
loom { loom {
accessWidenerPath.set(project(":common").file("src/main/resources/computercraft.accesswidener")) accessWidenerPath.set(project(":common").file("src/main/resources/computercraft.accesswidener"))
mixin.defaultRefmapName.set("computercraft.refmap.json") mixin.useLegacyMixinAp = false
mods { mods {
register("computercraft") { register("computercraft") {

View File

@ -12,18 +12,14 @@ import net.minecraft.world.entity.EntityDimensions;
import net.minecraft.world.entity.Pose; import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
public final class FakePlayer extends net.fabricmc.fabric.api.entity.FakePlayer { final class FakePlayer extends net.fabricmc.fabric.api.entity.FakePlayer {
private static final EntityDimensions DIMENSIONS = EntityDimensions.fixed(0, 0); private static final EntityDimensions DIMENSIONS = EntityDimensions.fixed(0, 0);
private FakePlayer(ServerLevel serverLevel, GameProfile gameProfile) { FakePlayer(ServerLevel serverLevel, GameProfile gameProfile) {
super(serverLevel, gameProfile); super(serverLevel, gameProfile);
refreshDimensions(); refreshDimensions();
} }
static FakePlayer create(ServerLevel serverLevel, GameProfile profile) {
return new FakePlayer(serverLevel, profile);
}
@Override @Override
public boolean canHarmPlayer(Player other) { public boolean canHarmPlayer(Player other) {
return true; return true;

View File

@ -236,7 +236,7 @@ public class PlatformHelperImpl implements PlatformHelper {
@Override @Override
public ServerPlayer createFakePlayer(ServerLevel world, GameProfile name) { public ServerPlayer createFakePlayer(ServerLevel world, GameProfile name) {
return FakePlayer.create(world, name); return new FakePlayer(world, name);
} }
@Override @Override

View File

@ -47,7 +47,7 @@
"depends": { "depends": {
"fabricloader": ">=0.15.10", "fabricloader": ">=0.15.10",
"fabric-api": ">=0.97.3", "fabric-api": ">=0.97.3",
"minecraft": "=1.20.5" "minecraft": ">=1.20.5 <1.20.7"
}, },
"accessWidener": "computercraft.accesswidener" "accessWidener": "computercraft.accesswidener"
} }

View File

@ -12,7 +12,6 @@ import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.client.event.*; import net.neoforged.neoforge.client.event.*;
import net.neoforged.neoforge.client.event.sound.PlayStreamingSourceEvent; import net.neoforged.neoforge.client.event.sound.PlayStreamingSourceEvent;
import net.neoforged.neoforge.event.TickEvent;
import net.neoforged.neoforge.event.level.LevelEvent; import net.neoforged.neoforge.event.level.LevelEvent;
/** /**
@ -24,13 +23,13 @@ public final class ForgeClientHooks {
} }
@SubscribeEvent @SubscribeEvent
public static void onTick(TickEvent.ClientTickEvent event) { public static void onTick(ClientTickEvent.Pre event) {
if (event.phase == TickEvent.Phase.START) ClientHooks.onTick(); ClientHooks.onTick();
} }
@SubscribeEvent @SubscribeEvent
public static void onRenderTick(TickEvent.RenderTickEvent event) { public static void onRenderTick(RenderFrameEvent.Pre event) {
if (event.phase == TickEvent.Phase.START) ClientHooks.onRenderTick(); ClientHooks.onRenderTick();
} }
@SubscribeEvent @SubscribeEvent

View File

@ -16,7 +16,6 @@ import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.event.AddReloadListenerEvent; import net.neoforged.neoforge.event.AddReloadListenerEvent;
import net.neoforged.neoforge.event.LootTableLoadEvent; import net.neoforged.neoforge.event.LootTableLoadEvent;
import net.neoforged.neoforge.event.RegisterCommandsEvent; import net.neoforged.neoforge.event.RegisterCommandsEvent;
import net.neoforged.neoforge.event.TickEvent;
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent; import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
import net.neoforged.neoforge.event.entity.living.LivingDropsEvent; import net.neoforged.neoforge.event.entity.living.LivingDropsEvent;
import net.neoforged.neoforge.event.level.ChunkEvent; import net.neoforged.neoforge.event.level.ChunkEvent;
@ -25,6 +24,7 @@ import net.neoforged.neoforge.event.level.ChunkWatchEvent;
import net.neoforged.neoforge.event.server.ServerStartedEvent; import net.neoforged.neoforge.event.server.ServerStartedEvent;
import net.neoforged.neoforge.event.server.ServerStartingEvent; import net.neoforged.neoforge.event.server.ServerStartingEvent;
import net.neoforged.neoforge.event.server.ServerStoppedEvent; import net.neoforged.neoforge.event.server.ServerStoppedEvent;
import net.neoforged.neoforge.event.tick.ServerTickEvent;
/** /**
* Forge-specific dispatch for {@link CommonHooks}. * Forge-specific dispatch for {@link CommonHooks}.
@ -32,11 +32,13 @@ import net.neoforged.neoforge.event.server.ServerStoppedEvent;
@EventBusSubscriber(modid = ComputerCraftAPI.MOD_ID) @EventBusSubscriber(modid = ComputerCraftAPI.MOD_ID)
public class ForgeCommonHooks { public class ForgeCommonHooks {
@SubscribeEvent @SubscribeEvent
public static void onServerTick(TickEvent.ServerTickEvent event) { public static void onServerTick(ServerTickEvent.Pre event) {
switch (event.phase) { CommonHooks.onServerTickStart(event.getServer());
case START -> CommonHooks.onServerTickStart(event.getServer());
case END -> CommonHooks.onServerTickEnd();
} }
@SubscribeEvent
public static void onServerTick(ServerTickEvent.Post event) {
CommonHooks.onServerTickStart(event.getServer());
} }
@SubscribeEvent @SubscribeEvent

View File

@ -22,11 +22,7 @@ class FakePlayerExt extends FakePlayer {
FakePlayerExt(ServerLevel serverLevel, GameProfile profile) { FakePlayerExt(ServerLevel serverLevel, GameProfile profile) {
super(serverLevel, profile); super(serverLevel, profile);
} refreshDimensions();
@Override
public void doTick() {
super.doTick();
} }
@Override @Override

View File

@ -15,8 +15,8 @@ import net.neoforged.neoforge.client.event.ScreenEvent;
import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.RegisterCommandsEvent; import net.neoforged.neoforge.event.RegisterCommandsEvent;
import net.neoforged.neoforge.event.RegisterGameTestsEvent; import net.neoforged.neoforge.event.RegisterGameTestsEvent;
import net.neoforged.neoforge.event.TickEvent;
import net.neoforged.neoforge.event.server.ServerStartedEvent; import net.neoforged.neoforge.event.server.ServerStartedEvent;
import net.neoforged.neoforge.event.tick.ServerTickEvent;
@Mod("cctest") @Mod("cctest")
public class TestMod { public class TestMod {
@ -34,9 +34,7 @@ public class TestMod {
private static void onInitializeClient() { private static void onInitializeClient() {
var bus = NeoForge.EVENT_BUS; var bus = NeoForge.EVENT_BUS;
bus.addListener((TickEvent.ServerTickEvent e) -> { bus.addListener((ServerTickEvent.Pre e) -> ClientTestHooks.onServerTick(e.getServer()));
if (e.phase == TickEvent.Phase.START) ClientTestHooks.onServerTick(e.getServer());
});
bus.addListener((ScreenEvent.Opening e) -> { bus.addListener((ScreenEvent.Opening e) -> {
if (ClientTestHooks.onOpenScreen(e.getScreen())) e.setCanceled(true); if (ClientTestHooks.onOpenScreen(e.getScreen())) e.setCanceled(true);
}); });