generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hendrix-Shen <[email protected]>
- Loading branch information
1 parent
adf997b
commit 6a1c277
Showing
13 changed files
with
187 additions
and
147 deletions.
There are no files selected for viewing
4 changes: 0 additions & 4 deletions
4
src/main/java/com/plusls/MasaGadget/api/network/packet/PCAPacket.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/com/plusls/MasaGadget/impl/network/NoopCodec.java
This file was deleted.
Oops, something went wrong.
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
12 changes: 0 additions & 12 deletions
12
versions/1.20.6-fabric/src/main/java/com/plusls/MasaGadget/api/network/packet/PCAPacket.java
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
versions/1.20.6-fabric/src/main/java/com/plusls/MasaGadget/impl/network/NoopCodec.java
This file was deleted.
Oops, something went wrong.
24 changes: 7 additions & 17 deletions
24
...va/com/plusls/MasaGadget/impl/network/packet/ClientboundDisablePcaSyncProtocolPacket.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,24 @@ | ||
package com.plusls.MasaGadget.impl.network.packet; | ||
|
||
import com.plusls.MasaGadget.api.network.packet.PCAPacket; | ||
import com.plusls.MasaGadget.impl.network.NoopCodec; | ||
import com.plusls.MasaGadget.util.PcaSyncProtocol; | ||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.function.Function; | ||
|
||
public class ClientboundDisablePcaSyncProtocolPacket extends PCAPacket { | ||
public static final Type<PCAPacket> TYPE = new Type<>(PcaSyncProtocol.DISABLE_PCA_SYNC_PROTOCOL); | ||
public static final StreamCodec<FriendlyByteBuf, PCAPacket> CODEC = NoopCodec.create(ClientboundDisablePcaSyncProtocolPacket.transform()); | ||
public record ClientboundDisablePcaSyncProtocolPacket() implements CustomPacketPayload { | ||
public static final Type<ClientboundDisablePcaSyncProtocolPacket> TYPE = new Type<>(PcaSyncProtocol.DISABLE_PCA_SYNC_PROTOCOL); | ||
public static final StreamCodec<FriendlyByteBuf, ClientboundDisablePcaSyncProtocolPacket> CODEC = CustomPacketPayload.codec(ClientboundDisablePcaSyncProtocolPacket::write, ClientboundDisablePcaSyncProtocolPacket::new); | ||
|
||
public ClientboundDisablePcaSyncProtocolPacket(FriendlyByteBuf byteBuf) { | ||
super(byteBuf); | ||
} | ||
|
||
public static void handle(PCAPacket packet, ClientPlayNetworking.Context context) { | ||
PcaSyncProtocol.disablePcaSyncProtocolHandler(context.client(), context.client().getConnection(), packet.getByteBuf(), context.responseSender()); | ||
} | ||
|
||
private static Function<FriendlyByteBuf, PCAPacket> transform() { | ||
return ClientboundDisablePcaSyncProtocolPacket::new; | ||
this(); | ||
} | ||
|
||
@Override | ||
public @NotNull Type<? extends CustomPacketPayload> type() { | ||
return ClientboundDisablePcaSyncProtocolPacket.TYPE; | ||
} | ||
|
||
private void write(FriendlyByteBuf byteBuf) { | ||
} | ||
} |
24 changes: 7 additions & 17 deletions
24
...ava/com/plusls/MasaGadget/impl/network/packet/ClientboundEnablePcaSyncProtocolPacket.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,24 @@ | ||
package com.plusls.MasaGadget.impl.network.packet; | ||
|
||
import com.plusls.MasaGadget.api.network.packet.PCAPacket; | ||
import com.plusls.MasaGadget.impl.network.NoopCodec; | ||
import com.plusls.MasaGadget.util.PcaSyncProtocol; | ||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.function.Function; | ||
|
||
public class ClientboundEnablePcaSyncProtocolPacket extends PCAPacket { | ||
public static final Type<PCAPacket> TYPE = new Type<>(PcaSyncProtocol.ENABLE_PCA_SYNC_PROTOCOL); | ||
public static final StreamCodec<FriendlyByteBuf, PCAPacket> CODEC = NoopCodec.create(ClientboundEnablePcaSyncProtocolPacket.transform()); | ||
public record ClientboundEnablePcaSyncProtocolPacket() implements CustomPacketPayload { | ||
public static final Type<ClientboundEnablePcaSyncProtocolPacket> TYPE = new Type<>(PcaSyncProtocol.ENABLE_PCA_SYNC_PROTOCOL); | ||
public static final StreamCodec<FriendlyByteBuf, ClientboundEnablePcaSyncProtocolPacket> CODEC = CustomPacketPayload.codec(ClientboundEnablePcaSyncProtocolPacket::write, ClientboundEnablePcaSyncProtocolPacket::new); | ||
|
||
public ClientboundEnablePcaSyncProtocolPacket(FriendlyByteBuf byteBuf) { | ||
super(byteBuf); | ||
} | ||
|
||
public static void handle(PCAPacket packet, ClientPlayNetworking.Context context) { | ||
PcaSyncProtocol.enablePcaSyncProtocolHandler(context.client(), context.client().getConnection(), packet.getByteBuf(), context.responseSender()); | ||
} | ||
|
||
private static Function<FriendlyByteBuf, PCAPacket> transform() { | ||
return ClientboundEnablePcaSyncProtocolPacket::new; | ||
this(); | ||
} | ||
|
||
@Override | ||
public @NotNull Type<? extends CustomPacketPayload> type() { | ||
return ClientboundEnablePcaSyncProtocolPacket.TYPE; | ||
} | ||
|
||
private void write(FriendlyByteBuf byteBuf) { | ||
} | ||
} |
33 changes: 15 additions & 18 deletions
33
...in/java/com/plusls/MasaGadget/impl/network/packet/ClientboundUpdateBlockEntityPacket.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,31 @@ | ||
package com.plusls.MasaGadget.impl.network.packet; | ||
|
||
import com.plusls.MasaGadget.api.network.packet.PCAPacket; | ||
import com.plusls.MasaGadget.impl.network.NoopCodec; | ||
import com.plusls.MasaGadget.util.PcaSyncProtocol; | ||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import net.minecraft.resources.ResourceLocation; | ||
import org.jetbrains.annotations.NotNull; | ||
import top.hendrixshen.magiclib.util.minecraft.NetworkUtil; | ||
|
||
import java.util.function.Function; | ||
public record ClientboundUpdateBlockEntityPacket(ResourceLocation dimension, BlockPos blockPos, CompoundTag tag) implements CustomPacketPayload { | ||
public static final Type<ClientboundUpdateBlockEntityPacket> TYPE = new Type<>(PcaSyncProtocol.UPDATE_BLOCK_ENTITY); | ||
public static final StreamCodec<FriendlyByteBuf, ClientboundUpdateBlockEntityPacket> CODEC = CustomPacketPayload.codec(ClientboundUpdateBlockEntityPacket::write, ClientboundUpdateBlockEntityPacket::new); | ||
|
||
public class ClientboundUpdateBlockEntityPacket extends PCAPacket { | ||
public static final Type<PCAPacket> TYPE = new Type<>(PcaSyncProtocol.UPDATE_BLOCK_ENTITY); | ||
public static final StreamCodec<FriendlyByteBuf, PCAPacket> CODEC = NoopCodec.create(ClientboundUpdateBlockEntityPacket.transform()); | ||
|
||
public ClientboundUpdateBlockEntityPacket(FriendlyByteBuf byteBuf) { | ||
super(byteBuf); | ||
} | ||
|
||
public static void handle(PCAPacket packet, ClientPlayNetworking.Context context) { | ||
PcaSyncProtocol.updateBlockEntityHandler(context.client(), context.client().getConnection(), packet.getByteBuf(), context.responseSender()); | ||
} | ||
|
||
private static Function<FriendlyByteBuf, PCAPacket> transform() { | ||
return ClientboundUpdateBlockEntityPacket::new; | ||
public ClientboundUpdateBlockEntityPacket(@NotNull FriendlyByteBuf byteBuf) { | ||
this(byteBuf.readResourceLocation(), byteBuf.readBlockPos(), NetworkUtil.readNbt(byteBuf)); | ||
} | ||
|
||
@Override | ||
public @NotNull Type<? extends CustomPacketPayload> type() { | ||
return ClientboundUpdateBlockEntityPacket.TYPE; | ||
} | ||
|
||
private void write(@NotNull FriendlyByteBuf byteBuf) { | ||
byteBuf.writeResourceLocation(this.dimension); | ||
byteBuf.writeBlockPos(this.blockPos); | ||
byteBuf.writeNbt(this.tag); | ||
} | ||
} |
Oops, something went wrong.