Skip to content

Commit

Permalink
Combatify 1.2.3 1.21 Fabric - Adding a common packet type to update b…
Browse files Browse the repository at this point in the history
…ridging
  • Loading branch information
Alexandra-Myers committed Aug 1, 2024
1 parent b5fc3a2 commit 19bc548
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -598,4 +598,9 @@ public ArrowDisableMode arrowDisableMode() {
public ArmourPiercingMode armourPiercingMode() {
return armourPiercingMode.get();
}

public void setBridging(boolean allowBridging) {
bedrockBridging.setValue(allowBridging);
bedrockBridging.serverManaged = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
public class ClientNetworkingHandler {
public static ConnectionState connectionState = ConnectionState.LOGIN;
public static void init() {
ClientPlayNetworking.registerGlobalReceiver(NetworkingHandler.UpdateBridgingStatusPacket.TYPE, (packet, context) -> CONFIG.setBridging(packet.enableBridging()));
ClientPlayNetworking.registerGlobalReceiver(NetworkingHandler.RemainingUseSyncPacket.TYPE, (packet, player) -> {
Entity entity = Minecraft.getInstance().level.getEntity(packet.id());
if (entity instanceof LivingEntityExtensions livingEntity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ConfigurationTask;
Expand All @@ -27,6 +28,7 @@ public NetworkingHandler() {
PayloadTypeRegistry.playC2S().register(ServerboundClientInformationExtensionPacket.TYPE, ServerboundClientInformationExtensionPacket.CODEC);
PayloadTypeRegistry.configurationC2S().register(ServerboundClientInformationExtensionPacket.TYPE, ServerboundClientInformationExtensionPacket.CODEC);
PayloadTypeRegistry.playS2C().register(RemainingUseSyncPacket.TYPE, RemainingUseSyncPacket.CODEC);
PayloadTypeRegistry.playS2C().register(UpdateBridgingStatusPacket.TYPE, UpdateBridgingStatusPacket.CODEC);
PayloadTypeRegistry.configurationS2C().register(ClientboundClientInformationRetrievalPacket.TYPE, ClientboundClientInformationRetrievalPacket.CODEC);
ServerConfigurationConnectionEvents.CONFIGURE.register((handler, server) -> {
if (ServerConfigurationNetworking.canSend(handler, ClientboundClientInformationRetrievalPacket.TYPE))
Expand Down Expand Up @@ -68,6 +70,22 @@ public NetworkingHandler() {
});
ServerLifecycleEvents.SERVER_STARTED.register(modDetectionNetworkChannel, server -> ITEMS = new ItemConfig());
}
public record UpdateBridgingStatusPacket(boolean enableBridging) implements CustomPacketPayload {
public static final Type<UpdateBridgingStatusPacket> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath("c", "update_status"));
public static final StreamCodec<FriendlyByteBuf, UpdateBridgingStatusPacket> CODEC = CustomPacketPayload.codec(UpdateBridgingStatusPacket::write, UpdateBridgingStatusPacket::new);

public UpdateBridgingStatusPacket(FriendlyByteBuf buf) {
this(buf.readBoolean());
}

public void write(FriendlyByteBuf buf) {

}
@Override
public @NotNull Type<?> type() {
return TYPE;
}
}
public record ServerboundMissPacket() implements CustomPacketPayload {
public static final Type<ServerboundMissPacket> TYPE = new Type<>(Combatify.id("miss_attack"));
public static final StreamCodec<FriendlyByteBuf, ServerboundMissPacket> CODEC = CustomPacketPayload.codec(ServerboundMissPacket::write, ServerboundMissPacket::new);
Expand Down

0 comments on commit 19bc548

Please sign in to comment.