forked from gnembon/fabric-carpet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix mixin issue, change version format
- Loading branch information
Showing
12 changed files
with
83 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 25 additions & 25 deletions
50
src/main/java/carpet/mixins/CustomPacketPayload_networkStuffMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
package carpet.mixins; | ||
|
||
import carpet.helpers.CarpetTaintedList; | ||
import carpet.network.CarpetClient; | ||
import net.minecraft.network.ConnectionProtocol; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.PacketFlow; | ||
//import carpet.helpers.CarpetTaintedList; | ||
//import carpet.network.CarpetClient; | ||
//import net.minecraft.network.ConnectionProtocol; | ||
//import net.minecraft.network.FriendlyByteBuf; | ||
//import net.minecraft.network.codec.StreamCodec; | ||
//import net.minecraft.network.protocol.PacketFlow; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
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.CallbackInfoReturnable; | ||
//import org.spongepowered.asm.mixin.injection.At; | ||
//import org.spongepowered.asm.mixin.injection.Inject; | ||
//import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
// | ||
//import java.util.List; | ||
|
||
import java.util.List; | ||
|
||
@Mixin(CustomPacketPayload.class) | ||
@Mixin(value = CustomPacketPayload.class, priority = 9999) | ||
public interface CustomPacketPayload_networkStuffMixin | ||
{ | ||
//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) | ||
@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) | ||
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) | ||
{ | ||
// this is stupid hack to make sure carpet payloads are always registered | ||
// that might collide with other mods that do the same thing | ||
// so we may need to adjust this in the future | ||
if (!(list instanceof CarpetTaintedList)) | ||
{ | ||
List<CustomPacketPayload.TypeAndCodec<? super B, ?>> extendedList = new CarpetTaintedList<>(list); | ||
extendedList.add(new CustomPacketPayload.TypeAndCodec<>(CarpetClient.CarpetPayload.TYPE, CarpetClient.CarpetPayload.STREAM_CODEC)); | ||
cir.setReturnValue(CustomPacketPayload.codec(fallbackProvider, extendedList, protocol, packetFlow)); | ||
} | ||
} | ||
// @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) | ||
// 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) | ||
// { | ||
// // this is stupid hack to make sure carpet payloads are always registered | ||
// // that might collide with other mods that do the same thing | ||
// // so we may need to adjust this in the future | ||
// if (!(list instanceof CarpetTaintedList)) | ||
// { | ||
// List<CustomPacketPayload.TypeAndCodec<? super B, ?>> extendedList = new CarpetTaintedList<>(list); | ||
// extendedList.add(new CustomPacketPayload.TypeAndCodec<>(CarpetClient.CarpetPayload.TYPE, CarpetClient.CarpetPayload.STREAM_CODEC)); | ||
// cir.setReturnValue(CustomPacketPayload.codec(fallbackProvider, extendedList, protocol, packetFlow)); | ||
// } | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/org/thinkingstudio/sheet/util/PermissionHooks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.thinkingstudio.sheet.util; | ||
|
||
import net.neoforged.fml.ModList; | ||
import net.neoforged.neoforge.server.ServerLifecycleHooks; | ||
import net.neoforged.neoforge.server.permission.events.PermissionGatherEvent; | ||
import net.neoforged.neoforge.server.permission.nodes.PermissionNode; | ||
import org.thinkingstudio.sheet.SheetModReference; | ||
|
||
import java.util.ArrayList; | ||
|
||
// TODO | ||
public class PermissionHooks { | ||
private static final ArrayList<PermissionNode<?>> PENDING = makeRegisterQueue(); | ||
|
||
private static boolean hasPermissionAPI() { | ||
// in version 1.18, the permission api only available on the service side. | ||
return ServerLifecycleHooks.getCurrentServer() != null; | ||
} | ||
|
||
private static ArrayList<PermissionNode<?>> makeRegisterQueue() { | ||
var modEventBus = ModList.get().getModContainerById(SheetModReference.MODID).orElseThrow().getEventBus(); | ||
modEventBus.addListener(PermissionGatherEvent.Nodes.class, event -> event.addNodes(PENDING)); | ||
return new ArrayList<>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters