Skip to content

Commit a2f0ffb

Browse files
committed
fix mixin issue, change version format
1 parent cda9269 commit a2f0ffb

12 files changed

+83
-41
lines changed

build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sourceCompatibility = JavaVersion.VERSION_21
77
targetCompatibility = JavaVersion.VERSION_21
88

99
archivesBaseName = "$project.archives_base_name-${loom.getPlatform().get().id()}"
10-
version = "$project.minecraft_version-$project.mod_version+v${new Date().format('yyMMdd')}"
10+
version = "$project.mod_main_version.${new Date().format('yyMMdd')}+mc$project.minecraft_version"
1111
group = project.maven_group
1212

1313
loom {
@@ -37,14 +37,15 @@ dependencies {
3737
parchment("org.parchmentmc.data:parchment-${project.minecraft_version}:${project.parchment_mappings}@zip")
3838
}
3939
neoForge "net.neoforged:neoforge:${project.neoforge_version}"
40+
4041
compileOnly "com.google.code.findbugs:jsr305:${project.jsr305_version}"
4142
}
4243

4344
processResources {
44-
inputs.property "version", project.version+'+v'+new Date().format('yyMMdd')
45+
inputs.property "version", project.version
4546

4647
filesMatching("META-INF/neoforge.mods.toml") {
47-
expand "version": project.mod_version+'+v'+new Date().format('yyMMdd')
48+
expand "version": project.version
4849
}
4950
}
5051

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ loom.platform = neoforge
99
parchment_mappings=2024.11.17
1010

1111
# Mod Properties
12-
mod_version = 1.4.147
12+
mod_main_version = 0.1.100
13+
carpet_version = 1.4.147
1314
maven_group = org.thinkingstudio.sheet
1415
archives_base_name = sheet
Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
package carpet.mixins;
22

3-
import carpet.helpers.CarpetTaintedList;
4-
import carpet.network.CarpetClient;
5-
import net.minecraft.network.ConnectionProtocol;
6-
import net.minecraft.network.FriendlyByteBuf;
7-
import net.minecraft.network.codec.StreamCodec;
8-
import net.minecraft.network.protocol.PacketFlow;
3+
//import carpet.helpers.CarpetTaintedList;
4+
//import carpet.network.CarpetClient;
5+
//import net.minecraft.network.ConnectionProtocol;
6+
//import net.minecraft.network.FriendlyByteBuf;
7+
//import net.minecraft.network.codec.StreamCodec;
8+
//import net.minecraft.network.protocol.PacketFlow;
99
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
1010
import org.spongepowered.asm.mixin.Mixin;
11-
import org.spongepowered.asm.mixin.injection.At;
12-
import org.spongepowered.asm.mixin.injection.Inject;
13-
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
11+
//import org.spongepowered.asm.mixin.injection.At;
12+
//import org.spongepowered.asm.mixin.injection.Inject;
13+
//import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
14+
//
15+
//import java.util.List;
1416

15-
import java.util.List;
16-
17-
@Mixin(CustomPacketPayload.class)
17+
@Mixin(value = CustomPacketPayload.class, priority = 9999)
1818
public interface CustomPacketPayload_networkStuffMixin
1919
{
2020
//private static <B extends FriendlyByteBuf> void onCodec(final CustomPacketPayload.FallbackProvider<B> fallbackProvider, final List<CustomPacketPayload.TypeAndCodec<? super B, ?>> list, final CallbackInfoReturnable<StreamCodec<B, CustomPacketPayload>> cir)
21-
@Inject(method = "codec(Lnet/minecraft/network/protocol/common/custom/CustomPacketPayload$FallbackProvider;Ljava/util/List;Lnet/minecraft/network/ConnectionProtocol;Lnet/minecraft/network/protocol/PacketFlow;)Lnet/minecraft/network/codec/StreamCodec;", at = @At("HEAD"), cancellable = true)
22-
private static <B extends FriendlyByteBuf> void onCodec(CustomPacketPayload.FallbackProvider<B> fallbackProvider, List<CustomPacketPayload.TypeAndCodec<? super B, ?>> list, ConnectionProtocol protocol, PacketFlow packetFlow, CallbackInfoReturnable<StreamCodec<B, CustomPacketPayload>> cir)
23-
{
24-
// this is stupid hack to make sure carpet payloads are always registered
25-
// that might collide with other mods that do the same thing
26-
// so we may need to adjust this in the future
27-
if (!(list instanceof CarpetTaintedList))
28-
{
29-
List<CustomPacketPayload.TypeAndCodec<? super B, ?>> extendedList = new CarpetTaintedList<>(list);
30-
extendedList.add(new CustomPacketPayload.TypeAndCodec<>(CarpetClient.CarpetPayload.TYPE, CarpetClient.CarpetPayload.STREAM_CODEC));
31-
cir.setReturnValue(CustomPacketPayload.codec(fallbackProvider, extendedList, protocol, packetFlow));
32-
}
33-
}
21+
// @Inject(method = "codec(Lnet/minecraft/network/protocol/common/custom/CustomPacketPayload$FallbackProvider;Ljava/util/List;Lnet/minecraft/network/ConnectionProtocol;Lnet/minecraft/network/protocol/PacketFlow;)Lnet/minecraft/network/codec/StreamCodec;", at = @At("HEAD"), cancellable = true)
22+
// private static <B extends FriendlyByteBuf> void onCodec(CustomPacketPayload.FallbackProvider<B> fallbackProvider, List<CustomPacketPayload.TypeAndCodec<? super B, ?>> list, ConnectionProtocol protocol, PacketFlow packetFlow, CallbackInfoReturnable<StreamCodec<B, CustomPacketPayload>> cir)
23+
// {
24+
// // this is stupid hack to make sure carpet payloads are always registered
25+
// // that might collide with other mods that do the same thing
26+
// // so we may need to adjust this in the future
27+
// if (!(list instanceof CarpetTaintedList))
28+
// {
29+
// List<CustomPacketPayload.TypeAndCodec<? super B, ?>> extendedList = new CarpetTaintedList<>(list);
30+
// extendedList.add(new CustomPacketPayload.TypeAndCodec<>(CarpetClient.CarpetPayload.TYPE, CarpetClient.CarpetPayload.STREAM_CODEC));
31+
// cir.setReturnValue(CustomPacketPayload.codec(fallbackProvider, extendedList, protocol, packetFlow));
32+
// }
33+
// }
3434
}

src/main/java/carpet/mixins/ExplosionAccessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public interface ExplosionAccessor {
2424
@Accessor
2525
RandomSource getRandom();
2626

27-
@Accessor
27+
@Accessor(remap = false)
2828
double getX();
2929

30-
@Accessor
30+
@Accessor(remap = false)
3131
double getY();
3232

33-
@Accessor
33+
@Accessor(remap = false)
3434
double getZ();
3535

3636
@Accessor

src/main/java/carpet/mixins/Explosion_optimizedTntMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import net.minecraft.world.level.block.state.BlockState;
2929
import net.minecraft.world.phys.Vec3;
3030

31-
@Mixin(value = Explosion.class)
31+
@Mixin(Explosion.class)
3232
public abstract class Explosion_optimizedTntMixin
3333
{
3434
@Shadow

src/main/java/carpet/mixins/Explosion_scarpetEventMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private void onExplosion(boolean spawnParticles, CallbackInfo ci)
7373
{
7474
if (EXPLOSION_OUTCOME.isNeeded() && !level.isClientSide())
7575
{
76-
EXPLOSION_OUTCOME.onExplosion((ServerLevel) level, source, this::getIndirectSourceEntity, x, y, z, radius, fire, toBlow, affectedEntities, blockInteraction);
76+
EXPLOSION_OUTCOME.onExplosion((ServerLevel) level, source, this::getIndirectSourceEntity, this.x, this.y, this.z, radius, fire, toBlow, affectedEntities, blockInteraction);
7777
}
7878
}
7979
}

src/main/java/carpet/mixins/PerfCommand_permissionMixin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
@Mixin(PerfCommand.class)
1212
public class PerfCommand_permissionMixin
1313
{
14-
@Inject(method = "method_37340", at = @At("HEAD"), cancellable = true, remap = false)
14+
// method_37340 = lambda$register$0
15+
@Inject(method = { "method_37340(Lnet/minecraft/commands/CommandSourceStack;)Z", "lambda$register$0(Lnet/minecraft/commands/CommandSourceStack;)Z" }, at = @At("HEAD"), cancellable = true, remap = false)
1516
private static void canRun(CommandSourceStack source, CallbackInfoReturnable<Boolean> cir)
1617
{
1718
cir.setReturnValue(source.hasPermission(CarpetSettings.perfPermissionLevel));

src/main/java/carpet/mixins/ReloadCommand_reloadAppsMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
@Mixin(ReloadCommand.class)
1313
public class ReloadCommand_reloadAppsMixin {
14-
//method_13530(Lcom/mojang/brigadier/context/CommandContext;)I
14+
// method_13530(Lcom/mojang/brigadier/context/CommandContext;)I = lambda$register$3(Lcom/mojang/brigadier/context/CommandContext;)I
1515
// internal of register.
16-
@Inject(method = "method_13530", at = @At("TAIL"), remap = false)
16+
@Inject(method = { "method_13530(Lcom/mojang/brigadier/context/CommandContext;)I", "lambda$register$3(Lcom/mojang/brigadier/context/CommandContext;)I" }, at = @At("TAIL"), remap = false)
1717
private static void onReload(CommandContext<CommandSourceStack> context, CallbackInfoReturnable<Integer> cir)
1818
{
1919
// can't fetch here the reference to the server

src/main/java/org/thinkingstudio/sheet/SheetModEntrypoint.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22

33
import carpet.CarpetServer;
44
import carpet.utils.CarpetRulePrinter;
5+
import net.neoforged.bus.api.IEventBus;
56
import net.neoforged.fml.common.Mod;
67
import net.neoforged.fml.loading.FMLLoader;
8+
import net.neoforged.neoforge.common.NeoForge;
79

810
@Mod(SheetModEntrypoint.MODID)
911
public class SheetModEntrypoint {
1012
public static final String MODID = "sheet";
1113

12-
public SheetModEntrypoint() {
14+
public SheetModEntrypoint(IEventBus modEventBus) {
1315
CarpetServer.onGameStarted();
1416
if (FMLLoader.getDist().isDedicatedServer()) {
1517
CarpetRulePrinter.onInitializeServer();
1618
}
1719

18-
SheetModEvents.registerEvents();
20+
SheetModEvents.registerEvents(modEventBus, NeoForge.EVENT_BUS);
1921
}
2022
}

src/main/java/org/thinkingstudio/sheet/SheetModEvents.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
package org.thinkingstudio.sheet;
22

33
import carpet.CarpetServer;
4+
import carpet.network.CarpetClient;
45
import net.minecraft.server.level.ServerPlayer;
56
import net.neoforged.bus.api.EventPriority;
7+
import net.neoforged.bus.api.IEventBus;
68
import net.neoforged.neoforge.common.NeoForge;
79
import net.neoforged.neoforge.event.RegisterCommandsEvent;
810
import net.neoforged.neoforge.event.entity.living.LivingSwapItemsEvent;
911
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
12+
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
13+
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
1014

1115
import static carpet.script.CarpetEventServer.Event.PLAYER_SWAPS_HANDS;
1216

1317
public class SheetModEvents {
14-
public static void registerEvents() {
18+
public static void registerEvents(IEventBus modEventBus, IEventBus forgeEventBus) {
1519
NeoForge.EVENT_BUS.addListener(EventPriority.HIGHEST, RegisterCommandsEvent.class, event -> {
1620
CarpetServer.registerCarpetCommands(event.getDispatcher(), event.getCommandSelection(), event.getBuildContext());
1721
});
@@ -23,5 +27,14 @@ public static void registerEvents() {
2327
event.isCanceled();
2428
}
2529
});
30+
31+
modEventBus.addListener(EventPriority.HIGHEST, RegisterPayloadHandlersEvent.class, event -> {
32+
final PayloadRegistrar registrar = event.registrar(SheetModReference.MODID);
33+
34+
registrar.playBidirectional(
35+
CarpetClient.CarpetPayload.TYPE, CarpetClient.CarpetPayload.STREAM_CODEC,
36+
(payload, context) -> context.handle(payload)
37+
);
38+
});
2639
}
2740
}

0 commit comments

Comments
 (0)