Merge branch 'main' into famos-amos

because i'm too clever, who the hell knows what SYN/ACK means
This commit is contained in:
petrak@ 2023-04-27 21:37:06 -05:00
commit 19f35e1205
32 changed files with 134 additions and 131 deletions

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.api.casting
import at.petrak.hexcasting.api.pigment.FrozenPigment
import at.petrak.hexcasting.common.network.MsgCastParticleAck
import at.petrak.hexcasting.common.msgs.MsgCastParticleS2C
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.server.level.ServerLevel
import net.minecraft.world.phys.Vec3
@ -24,6 +24,6 @@ data class ParticleSpray(val pos: Vec3, val vel: Vec3, val fuzziness: Double, va
}
fun sprayParticles(world: ServerLevel, color: FrozenPigment) {
IXplatAbstractions.INSTANCE.sendPacketNear(this.pos, 128.0, world, MsgCastParticleAck(this, color))
IXplatAbstractions.INSTANCE.sendPacketNear(this.pos, 128.0, world, MsgCastParticleS2C(this, color))
}
}

View file

@ -9,8 +9,8 @@ import at.petrak.hexcasting.api.casting.iota.PatternIota;
import at.petrak.hexcasting.api.casting.math.HexCoord;
import at.petrak.hexcasting.api.mod.HexStatistics;
import at.petrak.hexcasting.api.pigment.FrozenPigment;
import at.petrak.hexcasting.common.network.MsgNewSpellPatternAck;
import at.petrak.hexcasting.common.network.MsgNewSpellPatternSyn;
import at.petrak.hexcasting.common.msgs.MsgNewSpellPatternC2S;
import at.petrak.hexcasting.common.msgs.MsgNewSpellPatternS2C;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
@ -67,7 +67,7 @@ public class StaffCastEnv extends PlayerBasedCastEnv {
return HexAPI.instance().getColorizer(this.caster);
}
public static void handleNewPatternOnServer(ServerPlayer sender, MsgNewSpellPatternSyn msg) {
public static void handleNewPatternOnServer(ServerPlayer sender, MsgNewSpellPatternC2S msg) {
boolean cheatedPatternOverlap = false;
List<ResolvedPattern> resolvedPatterns = msg.resolvedPatterns();
@ -109,7 +109,7 @@ public class StaffCastEnv extends PlayerBasedCastEnv {
}
IXplatAbstractions.INSTANCE.sendPacketToPlayer(sender,
new MsgNewSpellPatternAck(clientInfo, resolvedPatterns.size() - 1));
new MsgNewSpellPatternS2C(clientInfo, resolvedPatterns.size() - 1));
if (clientInfo.getResolutionType().getSuccess()) {
// Somehow we lost spraying particles on each new pattern, so do it here

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.client;
import at.petrak.hexcasting.api.mod.HexConfig;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.network.MsgShiftScrollSyn;
import at.petrak.hexcasting.common.msgs.MsgShiftScrollC2S;
import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
@ -46,7 +46,7 @@ public class ShiftScrollListener {
public static void clientTickEnd() {
if (mainHandDelta != 0 || offHandDelta != 0) {
IClientXplatAbstractions.INSTANCE.sendPacketToServer(
new MsgShiftScrollSyn(mainHandDelta, offHandDelta, Screen.hasControlDown(),
new MsgShiftScrollC2S(mainHandDelta, offHandDelta, Screen.hasControlDown(),
HexConfig.client().invertSpellbookScrollDirection(),
HexConfig.client().invertAbacusScrollDirection()));
mainHandDelta = 0;

View file

@ -18,7 +18,7 @@ import at.petrak.hexcasting.client.ktxt.accumulatedScroll
import at.petrak.hexcasting.client.render.*
import at.petrak.hexcasting.client.sound.GridSoundInstance
import at.petrak.hexcasting.common.lib.HexSounds
import at.petrak.hexcasting.common.network.MsgNewSpellPatternSyn
import at.petrak.hexcasting.common.msgs.MsgNewSpellPatternC2S
import at.petrak.hexcasting.xplat.IClientXplatAbstractions
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.PoseStack
@ -248,7 +248,7 @@ class GuiSpellcasting constructor(
this.usedSpots.addAll(pat.positions(start))
IClientXplatAbstractions.INSTANCE.sendPacketToServer(
MsgNewSpellPatternSyn(
MsgNewSpellPatternC2S(
this.handOpenedWith,
pat,
this.patterns

View file

@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.casting.castables.SpellAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.common.network.MsgBeepAck
import at.petrak.hexcasting.common.msgs.MsgBeepS2C
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument
import net.minecraft.world.level.gameevent.GameEvent
@ -34,7 +34,7 @@ object OpBeep : SpellAction {
private data class Spell(val target: Vec3, val note: Int, val instrument: NoteBlockInstrument) : RenderedSpell {
override fun cast(ctx: CastingEnvironment) {
IXplatAbstractions.INSTANCE.sendPacketNear(target, 128.0, ctx.world, MsgBeepAck(target, note, instrument))
IXplatAbstractions.INSTANCE.sendPacketNear(target, 128.0, ctx.world, MsgBeepS2C(target, note, instrument))
ctx.world.gameEvent(null, GameEvent.NOTE_BLOCK_PLAY, target)
}
}

View file

@ -12,7 +12,7 @@ import at.petrak.hexcasting.api.casting.mishaps.MishapImmuneEntity
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.mod.HexConfig
import at.petrak.hexcasting.api.mod.HexTags
import at.petrak.hexcasting.common.network.MsgBlinkAck
import at.petrak.hexcasting.common.msgs.MsgBlinkS2C
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.core.BlockPos
import net.minecraft.server.level.ServerLevel
@ -136,7 +136,7 @@ object OpTeleport : SpellAction {
world.chunkSource.addRegionTicket(TicketType.POST_TELEPORT, chunkPos, 1, player.id)
player.connection.resetPosition()
player.setPos(target)
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player, MsgBlinkAck(delta))
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player, MsgBlinkS2C(delta))
}
}
}

View file

@ -7,8 +7,8 @@ import at.petrak.hexcasting.client.render.RenderLib;
import at.petrak.hexcasting.common.items.storage.ItemScroll;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.lib.HexSounds;
import at.petrak.hexcasting.common.network.MsgNewWallScrollAck;
import at.petrak.hexcasting.common.network.MsgRecalcWallScrollDisplayAck;
import at.petrak.hexcasting.common.msgs.MsgNewWallScrollS2C;
import at.petrak.hexcasting.common.msgs.MsgRecalcWallScrollDisplayS2C;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -137,7 +137,7 @@ public class EntityWallScroll extends HangingEntity {
if (pPlayer.getLevel() instanceof ServerLevel slevel) {
IXplatAbstractions.INSTANCE.sendPacketNear(this.position(), 32.0, slevel,
new MsgRecalcWallScrollDisplayAck(this.getId(), true));
new MsgRecalcWallScrollDisplayS2C(this.getId(), true));
} else {
// Beat the packet roundtrip to the punch to get a quicker visual
this.recalculateDisplay();
@ -155,7 +155,7 @@ public class EntityWallScroll extends HangingEntity {
@Override
public Packet<?> getAddEntityPacket() {
return IXplatAbstractions.INSTANCE.toVanillaClientboundPacket(
new MsgNewWallScrollAck(new ClientboundAddEntityPacket(this),
new MsgNewWallScrollS2C(new ClientboundAddEntityPacket(this),
pos, direction, scroll, getShowsStrokeOrder(), blockSize));
}

View file

@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.items;
import at.petrak.hexcasting.annotations.SoftImplement;
import at.petrak.hexcasting.api.misc.DiscoveryHandlers;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.network.MsgUpdateComparatorVisualsAck;
import at.petrak.hexcasting.common.msgs.MsgUpdateComparatorVisualsS2C;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import com.mojang.datafixers.util.Pair;
import net.minecraft.core.BlockPos;
@ -92,7 +92,8 @@ public class ItemLens extends Item implements Wearable {
if (state.is(Blocks.COMPARATOR)) {
syncComparatorValue(player, pos,
state.getDirectSignal(player.level, pos, state.getValue(BlockStateProperties.HORIZONTAL_FACING)), bee);
state.getDirectSignal(player.level, pos, state.getValue(BlockStateProperties.HORIZONTAL_FACING)),
bee);
} else if (state.hasAnalogOutputSignal()) {
syncComparatorValue(player, pos, state.getAnalogOutputSignal(player.level, pos), bee);
} else {
@ -110,13 +111,14 @@ public class ItemLens extends Item implements Wearable {
if (previousComparator != null || previousBee != null) {
comparatorDataMap.remove(player);
beeDataMap.remove(player);
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player, new MsgUpdateComparatorVisualsAck(null, -1, -1));
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player, new MsgUpdateComparatorVisualsS2C(null, -1, -1));
}
} else if (previousComparator == null || !pos.equals(previousComparator.getFirst()) || comparator != previousComparator.getSecond() ||
previousBee == null || !pos.equals(previousBee.getFirst()) || bee != previousBee.getSecond()) {
comparatorDataMap.put(player, new Pair<>(pos, comparator));
beeDataMap.put(player, new Pair<>(pos, bee));
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player, new MsgUpdateComparatorVisualsAck(pos, comparator, bee));
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player, new MsgUpdateComparatorVisualsS2C(pos, comparator,
bee));
}
}

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.items;
import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.common.lib.HexSounds;
import at.petrak.hexcasting.common.network.MsgOpenSpellGuiAck;
import at.petrak.hexcasting.common.msgs.MsgOpenSpellGuiS2C;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
@ -38,7 +38,7 @@ public class ItemStaff extends Item {
var descs = harness.generateDescs();
IXplatAbstractions.INSTANCE.sendPacketToPlayer(serverPlayer,
new MsgOpenSpellGuiAck(hand, patterns, descs.getFirst(), descs.getSecond(),
new MsgOpenSpellGuiS2C(hand, patterns, descs.getFirst(), descs.getSecond(),
0)); // TODO: Fix!
}

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.common.network;
package at.petrak.hexcasting.common.msgs;
import io.netty.buffer.Unpooled;
import net.minecraft.network.FriendlyByteBuf;

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.common.network;
package at.petrak.hexcasting.common.msgs;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
@ -11,7 +11,7 @@ import net.minecraft.world.phys.Vec3;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
public record MsgBeepAck(Vec3 target, int note, NoteBlockInstrument instrument) implements IMessage {
public record MsgBeepS2C(Vec3 target, int note, NoteBlockInstrument instrument) implements IMessage {
public static final ResourceLocation ID = modLoc("beep");
@Override
@ -19,14 +19,14 @@ public record MsgBeepAck(Vec3 target, int note, NoteBlockInstrument instrument)
return ID;
}
public static MsgBeepAck deserialize(ByteBuf buffer) {
public static MsgBeepS2C deserialize(ByteBuf buffer) {
var buf = new FriendlyByteBuf(buffer);
var x = buf.readDouble();
var y = buf.readDouble();
var z = buf.readDouble();
var note = buf.readInt();
var instrument = buf.readEnum(NoteBlockInstrument.class);
return new MsgBeepAck(new Vec3(x, y, z), note, instrument);
return new MsgBeepS2C(new Vec3(x, y, z), note, instrument);
}
@Override
@ -37,8 +37,8 @@ public record MsgBeepAck(Vec3 target, int note, NoteBlockInstrument instrument)
buf.writeInt(this.note);
buf.writeEnum(instrument);
}
public static void handle(MsgBeepAck msg) {
public static void handle(MsgBeepS2C msg) {
Minecraft.getInstance().execute(new Runnable() {
@Override
public void run() {

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.common.network;
package at.petrak.hexcasting.common.msgs;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
@ -11,7 +11,7 @@ import static at.petrak.hexcasting.api.HexAPI.modLoc;
/**
* Sent server->client to synchronize OpBlink when the target is a player.
*/
public record MsgBlinkAck(Vec3 addedPosition) implements IMessage {
public record MsgBlinkS2C(Vec3 addedPosition) implements IMessage {
public static final ResourceLocation ID = modLoc("blink");
@Override
@ -19,12 +19,12 @@ public record MsgBlinkAck(Vec3 addedPosition) implements IMessage {
return ID;
}
public static MsgBlinkAck deserialize(ByteBuf buffer) {
public static MsgBlinkS2C deserialize(ByteBuf buffer) {
var buf = new FriendlyByteBuf(buffer);
var x = buf.readDouble();
var y = buf.readDouble();
var z = buf.readDouble();
return new MsgBlinkAck(new Vec3(x, y, z));
return new MsgBlinkS2C(new Vec3(x, y, z));
}
@Override
@ -34,7 +34,7 @@ public record MsgBlinkAck(Vec3 addedPosition) implements IMessage {
buf.writeDouble(this.addedPosition.z);
}
public static void handle(MsgBlinkAck self) {
public static void handle(MsgBlinkS2C self) {
Minecraft.getInstance().execute(new Runnable() {
@Override
public void run() {

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.common.network;
package at.petrak.hexcasting.common.msgs;
import at.petrak.hexcasting.api.casting.ParticleSpray;
import at.petrak.hexcasting.api.pigment.FrozenPigment;
@ -18,7 +18,7 @@ import static at.petrak.hexcasting.api.HexAPI.modLoc;
/**
* Sent server->client to spray particles everywhere.
*/
public record MsgCastParticleAck(ParticleSpray spray, FrozenPigment colorizer) implements IMessage {
public record MsgCastParticleS2C(ParticleSpray spray, FrozenPigment colorizer) implements IMessage {
public static final ResourceLocation ID = modLoc("cprtcl");
@Override
@ -26,7 +26,7 @@ public record MsgCastParticleAck(ParticleSpray spray, FrozenPigment colorizer) i
return ID;
}
public static MsgCastParticleAck deserialize(ByteBuf buffer) {
public static MsgCastParticleS2C deserialize(ByteBuf buffer) {
var buf = new FriendlyByteBuf(buffer);
var posX = buf.readDouble();
var posY = buf.readDouble();
@ -39,7 +39,7 @@ public record MsgCastParticleAck(ParticleSpray spray, FrozenPigment colorizer) i
var count = buf.readInt();
var tag = buf.readAnySizeNbt();
var colorizer = FrozenPigment.fromNBT(tag);
return new MsgCastParticleAck(
return new MsgCastParticleS2C(
new ParticleSpray(new Vec3(posX, posY, posZ), new Vec3(velX, velY, velZ), fuzziness, spread, count),
colorizer);
}
@ -68,7 +68,7 @@ public record MsgCastParticleAck(ParticleSpray spray, FrozenPigment colorizer) i
return new Vec3(Math.sqrt(1.0 - z * z) * Math.cos(th), Math.sqrt(1.0 - z * z) * Math.sin(th), z);
}
public static void handle(MsgCastParticleAck msg) {
public static void handle(MsgCastParticleS2C msg) {
Minecraft.getInstance().execute(new Runnable() {
@Override
public void run() {

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.common.network;
package at.petrak.hexcasting.common.msgs;
import at.petrak.hexcasting.api.casting.eval.ResolvedPattern;
import at.petrak.hexcasting.api.casting.eval.env.StaffCastEnv;
@ -17,9 +17,9 @@ import static at.petrak.hexcasting.api.HexAPI.modLoc;
/**
* Sent client->server when the player finishes drawing a pattern.
* Server will send back a {@link MsgNewSpellPatternAck} packet
* Server will send back a {@link MsgNewSpellPatternS2C} packet
*/
public record MsgNewSpellPatternSyn(InteractionHand handUsed, HexPattern pattern,
public record MsgNewSpellPatternC2S(InteractionHand handUsed, HexPattern pattern,
List<ResolvedPattern> resolvedPatterns)
implements IMessage {
public static final ResourceLocation ID = modLoc("pat_cs");
@ -29,7 +29,7 @@ public record MsgNewSpellPatternSyn(InteractionHand handUsed, HexPattern pattern
return ID;
}
public static MsgNewSpellPatternSyn deserialize(ByteBuf buffer) {
public static MsgNewSpellPatternC2S deserialize(ByteBuf buffer) {
var buf = new FriendlyByteBuf(buffer);
var hand = buf.readEnum(InteractionHand.class);
var pattern = HexPattern.fromNBT(buf.readNbt());
@ -39,7 +39,7 @@ public record MsgNewSpellPatternSyn(InteractionHand handUsed, HexPattern pattern
for (int i = 0; i < resolvedPatternsLen; i++) {
resolvedPatterns.add(ResolvedPattern.fromNBT(buf.readNbt()));
}
return new MsgNewSpellPatternSyn(hand, pattern, resolvedPatterns);
return new MsgNewSpellPatternC2S(hand, pattern, resolvedPatterns);
}
@Override

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.common.network;
package at.petrak.hexcasting.common.msgs;
import at.petrak.hexcasting.api.casting.eval.ExecutionClientView;
import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType;
@ -16,7 +16,7 @@ import static at.petrak.hexcasting.api.HexAPI.modLoc;
/**
* Sent server->client when the player finishes casting a spell.
*/
public record MsgNewSpellPatternAck(ExecutionClientView info, int index) implements IMessage {
public record MsgNewSpellPatternS2C(ExecutionClientView info, int index) implements IMessage {
public static final ResourceLocation ID = modLoc("pat_sc");
@Override
@ -24,7 +24,7 @@ public record MsgNewSpellPatternAck(ExecutionClientView info, int index) impleme
return ID;
}
public static MsgNewSpellPatternAck deserialize(ByteBuf buffer) {
public static MsgNewSpellPatternS2C deserialize(ByteBuf buffer) {
var buf = new FriendlyByteBuf(buffer);
var isStackEmpty = buf.readBoolean();
@ -34,7 +34,7 @@ public record MsgNewSpellPatternAck(ExecutionClientView info, int index) impleme
var stack = buf.readList(FriendlyByteBuf::readNbt);
var raven = buf.readOptional(FriendlyByteBuf::readNbt).orElse(null);
return new MsgNewSpellPatternAck(
return new MsgNewSpellPatternS2C(
new ExecutionClientView(isStackEmpty, resolutionType, stack, raven), index
);
}
@ -49,7 +49,7 @@ public record MsgNewSpellPatternAck(ExecutionClientView info, int index) impleme
buf.writeOptional(Optional.ofNullable(this.info.getRavenmind()), FriendlyByteBuf::writeNbt);
}
public static void handle(MsgNewSpellPatternAck self) {
public static void handle(MsgNewSpellPatternS2C self) {
Minecraft.getInstance().execute(() -> {
var mc = Minecraft.getInstance();
if (self.info().isStackClear()) {

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.common.network;
package at.petrak.hexcasting.common.msgs;
import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.entities.EntityWallScroll;
@ -13,7 +13,7 @@ import net.minecraft.world.item.ItemStack;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
// https://github.com/VazkiiMods/Botania/blob/1.18.x/Xplat/src/main/java/vazkii/botania/network/clientbound/PacketSpawnDoppleganger.java
public record MsgNewWallScrollAck(ClientboundAddEntityPacket inner, BlockPos pos, Direction dir, ItemStack scrollItem,
public record MsgNewWallScrollS2C(ClientboundAddEntityPacket inner, BlockPos pos, Direction dir, ItemStack scrollItem,
boolean showsStrokeOrder, int blockSize) implements IMessage {
public static final ResourceLocation ID = modLoc("wallscr");
@ -32,17 +32,17 @@ public record MsgNewWallScrollAck(ClientboundAddEntityPacket inner, BlockPos pos
buf.writeVarInt(blockSize);
}
public static MsgNewWallScrollAck deserialize(FriendlyByteBuf buf) {
public static MsgNewWallScrollS2C deserialize(FriendlyByteBuf buf) {
var inner = new ClientboundAddEntityPacket(buf);
var pos = buf.readBlockPos();
var dir = HexUtils.getSafe(Direction.values(), buf.readByte());
var scroll = buf.readItem();
var strokeOrder = buf.readBoolean();
var blockSize = buf.readVarInt();
return new MsgNewWallScrollAck(inner, pos, dir, scroll, strokeOrder, blockSize);
return new MsgNewWallScrollS2C(inner, pos, dir, scroll, strokeOrder, blockSize);
}
public static void handle(MsgNewWallScrollAck self) {
public static void handle(MsgNewWallScrollS2C self) {
Minecraft.getInstance().execute(new Runnable() {
@Override
public void run() {

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.common.network;
package at.petrak.hexcasting.common.msgs;
import at.petrak.hexcasting.api.casting.eval.ResolvedPattern;
import at.petrak.hexcasting.client.gui.GuiSpellcasting;
@ -16,7 +16,7 @@ import static at.petrak.hexcasting.api.HexAPI.modLoc;
/**
* Sent server->client when the player opens the spell gui to request the server provide the current stack.
*/
public record MsgOpenSpellGuiAck(InteractionHand hand, List<ResolvedPattern> patterns,
public record MsgOpenSpellGuiS2C(InteractionHand hand, List<ResolvedPattern> patterns,
List<CompoundTag> stack,
CompoundTag ravenmind,
int parenCount
@ -29,7 +29,7 @@ public record MsgOpenSpellGuiAck(InteractionHand hand, List<ResolvedPattern> pat
return ID;
}
public static MsgOpenSpellGuiAck deserialize(ByteBuf buffer) {
public static MsgOpenSpellGuiS2C deserialize(ByteBuf buffer) {
var buf = new FriendlyByteBuf(buffer);
var hand = buf.readEnum(InteractionHand.class);
@ -41,7 +41,7 @@ public record MsgOpenSpellGuiAck(InteractionHand hand, List<ResolvedPattern> pat
var parenCount = buf.readVarInt();
return new MsgOpenSpellGuiAck(hand, patterns, stack, raven, parenCount);
return new MsgOpenSpellGuiS2C(hand, patterns, stack, raven, parenCount);
}
public void serialize(FriendlyByteBuf buf) {
@ -55,7 +55,7 @@ public record MsgOpenSpellGuiAck(InteractionHand hand, List<ResolvedPattern> pat
buf.writeVarInt(this.parenCount);
}
public static void handle(MsgOpenSpellGuiAck msg) {
public static void handle(MsgOpenSpellGuiS2C msg) {
Minecraft.getInstance().execute(() -> {
var mc = Minecraft.getInstance();
mc.setScreen(

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.common.network;
package at.petrak.hexcasting.common.msgs;
import at.petrak.hexcasting.common.entities.EntityWallScroll;
import io.netty.buffer.ByteBuf;
@ -11,14 +11,14 @@ import static at.petrak.hexcasting.api.HexAPI.modLoc;
/**
* Sent S->C to have a wall scroll recalculate its pattern, to get readability offset.
*/
public record MsgRecalcWallScrollDisplayAck(int entityId, boolean showStrokeOrder) implements IMessage {
public record MsgRecalcWallScrollDisplayS2C(int entityId, boolean showStrokeOrder) implements IMessage {
public static final ResourceLocation ID = modLoc("redoscroll");
public static MsgRecalcWallScrollDisplayAck deserialize(ByteBuf buffer) {
public static MsgRecalcWallScrollDisplayS2C deserialize(ByteBuf buffer) {
var buf = new FriendlyByteBuf(buffer);
var id = buf.readVarInt();
var showStrokeOrder = buf.readBoolean();
return new MsgRecalcWallScrollDisplayAck(id, showStrokeOrder);
return new MsgRecalcWallScrollDisplayS2C(id, showStrokeOrder);
}
@Override
@ -32,7 +32,7 @@ public record MsgRecalcWallScrollDisplayAck(int entityId, boolean showStrokeOrde
return ID;
}
public static void handle(MsgRecalcWallScrollDisplayAck msg) {
public static void handle(MsgRecalcWallScrollDisplayS2C msg) {
Minecraft.getInstance().execute(new Runnable() {
@Override
public void run() {

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.common.network;
package at.petrak.hexcasting.common.msgs;
import at.petrak.hexcasting.api.casting.iota.IotaType;
import at.petrak.hexcasting.api.utils.NBTHelper;
@ -24,7 +24,7 @@ import static at.petrak.hexcasting.api.HexAPI.modLoc;
* Sent client->server when the client shift+scrolls with a shift-scrollable item
* or scrolls in the spellcasting UI.
*/
public record MsgShiftScrollSyn(double mainHandDelta, double offHandDelta, boolean isCtrl, boolean invertSpellbook,
public record MsgShiftScrollC2S(double mainHandDelta, double offHandDelta, boolean isCtrl, boolean invertSpellbook,
boolean invertAbacus) implements IMessage {
public static final ResourceLocation ID = modLoc("scroll");
@ -33,14 +33,14 @@ public record MsgShiftScrollSyn(double mainHandDelta, double offHandDelta, boole
return ID;
}
public static MsgShiftScrollSyn deserialize(ByteBuf buffer) {
public static MsgShiftScrollC2S deserialize(ByteBuf buffer) {
var buf = new FriendlyByteBuf(buffer);
var mainHandDelta = buf.readDouble();
var offHandDelta = buf.readDouble();
var isCtrl = buf.readBoolean();
var invertSpellbook = buf.readBoolean();
var invertAbacus = buf.readBoolean();
return new MsgShiftScrollSyn(mainHandDelta, offHandDelta, isCtrl, invertSpellbook, invertAbacus);
return new MsgShiftScrollC2S(mainHandDelta, offHandDelta, isCtrl, invertSpellbook, invertAbacus);
}
public void serialize(FriendlyByteBuf buf) {

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.common.network;
package at.petrak.hexcasting.common.msgs;
import at.petrak.hexcasting.api.client.ScryingLensOverlayRegistry;
import io.netty.buffer.ByteBuf;
@ -10,9 +10,10 @@ import net.minecraft.resources.ResourceLocation;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
/**
* Sent server->client when a player is looking at a block through a lens whose comparator value is not the same as what they last saw.
* Sent server->client when a player is looking at a block through a lens whose comparator value is not the same as
* what they last saw.
*/
public record MsgUpdateComparatorVisualsAck(BlockPos pos, int comparator, int bee) implements IMessage {
public record MsgUpdateComparatorVisualsS2C(BlockPos pos, int comparator, int bee) implements IMessage {
public static final ResourceLocation ID = modLoc("cmp");
@Override
@ -20,14 +21,14 @@ public record MsgUpdateComparatorVisualsAck(BlockPos pos, int comparator, int be
return ID;
}
public static MsgUpdateComparatorVisualsAck deserialize(ByteBuf buffer) {
public static MsgUpdateComparatorVisualsS2C deserialize(ByteBuf buffer) {
var buf = new FriendlyByteBuf(buffer);
int comparator = buf.readInt();
int bee = buf.readInt();
BlockPos pos = comparator == -1 && bee == -1 ? null : buf.readBlockPos();
return new MsgUpdateComparatorVisualsAck(pos, comparator, bee);
return new MsgUpdateComparatorVisualsS2C(pos, comparator, bee);
}
public void serialize(FriendlyByteBuf buf) {
@ -38,7 +39,7 @@ public record MsgUpdateComparatorVisualsAck(BlockPos pos, int comparator, int be
}
}
public static void handle(MsgUpdateComparatorVisualsAck msg) {
public static void handle(MsgUpdateComparatorVisualsS2C msg) {
Minecraft.getInstance().execute(new Runnable() {
@Override
public void run() {

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.xplat;
import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.common.msgs.IMessage;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.item.ItemPropertyFunction;

View file

@ -16,7 +16,7 @@ import at.petrak.hexcasting.api.pigment.FrozenPigment;
import at.petrak.hexcasting.api.player.AltioraAbility;
import at.petrak.hexcasting.api.player.FlightAbility;
import at.petrak.hexcasting.api.player.Sentinel;
import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.common.msgs.IMessage;
import at.petrak.hexcasting.interop.pehkui.PehkuiInterop;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.fabric.network;
import at.petrak.hexcasting.common.network.*;
import at.petrak.hexcasting.common.msgs.*;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.network.FriendlyByteBuf;
@ -13,10 +13,10 @@ import java.util.function.Function;
public class FabricPacketHandler {
public static void init() {
ServerPlayNetworking.registerGlobalReceiver(MsgNewSpellPatternSyn.ID,
makeServerBoundHandler(MsgNewSpellPatternSyn::deserialize, MsgNewSpellPatternSyn::handle));
ServerPlayNetworking.registerGlobalReceiver(MsgNewSpellPatternC2S.ID,
makeServerBoundHandler(MsgNewSpellPatternC2S::deserialize, MsgNewSpellPatternC2S::handle));
ServerPlayNetworking.registerGlobalReceiver(
MsgShiftScrollSyn.ID, makeServerBoundHandler(MsgShiftScrollSyn::deserialize, MsgShiftScrollSyn::handle));
MsgShiftScrollC2S.ID, makeServerBoundHandler(MsgShiftScrollC2S::deserialize, MsgShiftScrollC2S::handle));
}
private static <T> ServerPlayNetworking.PlayChannelHandler makeServerBoundHandler(
@ -25,22 +25,22 @@ public class FabricPacketHandler {
}
public static void initClient() {
ClientPlayNetworking.registerGlobalReceiver(MsgNewSpellPatternAck.ID,
makeClientBoundHandler(MsgNewSpellPatternAck::deserialize, MsgNewSpellPatternAck::handle));
ClientPlayNetworking.registerGlobalReceiver(MsgNewSpellPatternS2C.ID,
makeClientBoundHandler(MsgNewSpellPatternS2C::deserialize, MsgNewSpellPatternS2C::handle));
ClientPlayNetworking.registerGlobalReceiver(
MsgBlinkAck.ID, makeClientBoundHandler(MsgBlinkAck::deserialize, MsgBlinkAck::handle));
ClientPlayNetworking.registerGlobalReceiver(MsgCastParticleAck.ID,
makeClientBoundHandler(MsgCastParticleAck::deserialize, MsgCastParticleAck::handle));
ClientPlayNetworking.registerGlobalReceiver(MsgOpenSpellGuiAck.ID,
makeClientBoundHandler(MsgOpenSpellGuiAck::deserialize, MsgOpenSpellGuiAck::handle));
ClientPlayNetworking.registerGlobalReceiver(MsgBeepAck.ID,
makeClientBoundHandler(MsgBeepAck::deserialize, MsgBeepAck::handle));
ClientPlayNetworking.registerGlobalReceiver(MsgUpdateComparatorVisualsAck.ID,
makeClientBoundHandler(MsgUpdateComparatorVisualsAck::deserialize, MsgUpdateComparatorVisualsAck::handle));
ClientPlayNetworking.registerGlobalReceiver(MsgNewWallScrollAck.ID,
makeClientBoundHandler(MsgNewWallScrollAck::deserialize, MsgNewWallScrollAck::handle));
ClientPlayNetworking.registerGlobalReceiver(MsgRecalcWallScrollDisplayAck.ID,
makeClientBoundHandler(MsgRecalcWallScrollDisplayAck::deserialize, MsgRecalcWallScrollDisplayAck::handle));
MsgBlinkS2C.ID, makeClientBoundHandler(MsgBlinkS2C::deserialize, MsgBlinkS2C::handle));
ClientPlayNetworking.registerGlobalReceiver(MsgCastParticleS2C.ID,
makeClientBoundHandler(MsgCastParticleS2C::deserialize, MsgCastParticleS2C::handle));
ClientPlayNetworking.registerGlobalReceiver(MsgOpenSpellGuiS2C.ID,
makeClientBoundHandler(MsgOpenSpellGuiS2C::deserialize, MsgOpenSpellGuiS2C::handle));
ClientPlayNetworking.registerGlobalReceiver(MsgBeepS2C.ID,
makeClientBoundHandler(MsgBeepS2C::deserialize, MsgBeepS2C::handle));
ClientPlayNetworking.registerGlobalReceiver(MsgUpdateComparatorVisualsS2C.ID,
makeClientBoundHandler(MsgUpdateComparatorVisualsS2C::deserialize, MsgUpdateComparatorVisualsS2C::handle));
ClientPlayNetworking.registerGlobalReceiver(MsgNewWallScrollS2C.ID,
makeClientBoundHandler(MsgNewWallScrollS2C::deserialize, MsgNewWallScrollS2C::handle));
ClientPlayNetworking.registerGlobalReceiver(MsgRecalcWallScrollDisplayS2C.ID,
makeClientBoundHandler(MsgRecalcWallScrollDisplayS2C::deserialize, MsgRecalcWallScrollDisplayS2C::handle));
}
private static <T> ClientPlayNetworking.PlayChannelHandler makeClientBoundHandler(

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.fabric.xplat;
import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.common.msgs.IMessage;
import at.petrak.hexcasting.fabric.client.ExtendedTexture;
import at.petrak.hexcasting.fabric.interop.trinkets.TrinketsApiInterop;
import at.petrak.hexcasting.interop.HexInterop;

View file

@ -19,7 +19,7 @@ import at.petrak.hexcasting.api.player.AltioraAbility;
import at.petrak.hexcasting.api.player.FlightAbility;
import at.petrak.hexcasting.api.player.Sentinel;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.common.msgs.IMessage;
import at.petrak.hexcasting.fabric.cc.HexCardinalComponents;
import at.petrak.hexcasting.fabric.interop.gravity.GravityApiInterop;
import at.petrak.hexcasting.fabric.interop.trinkets.TrinketsApiInterop;

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.forge.network;
import at.petrak.hexcasting.common.network.*;
import at.petrak.hexcasting.common.msgs.*;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.network.NetworkEvent;
@ -31,41 +31,41 @@ public class ForgePacketHandler {
int messageIdx = 0;
// Client -> server
NETWORK.registerMessage(messageIdx++, MsgNewSpellPatternSyn.class, MsgNewSpellPatternSyn::serialize,
MsgNewSpellPatternSyn::deserialize, makeServerBoundHandler(MsgNewSpellPatternSyn::handle));
NETWORK.registerMessage(messageIdx++, MsgShiftScrollSyn.class, MsgShiftScrollSyn::serialize,
MsgShiftScrollSyn::deserialize, makeServerBoundHandler(MsgShiftScrollSyn::handle));
NETWORK.registerMessage(messageIdx++, MsgNewSpellPatternC2S.class, MsgNewSpellPatternC2S::serialize,
MsgNewSpellPatternC2S::deserialize, makeServerBoundHandler(MsgNewSpellPatternC2S::handle));
NETWORK.registerMessage(messageIdx++, MsgShiftScrollC2S.class, MsgShiftScrollC2S::serialize,
MsgShiftScrollC2S::deserialize, makeServerBoundHandler(MsgShiftScrollC2S::handle));
// Server -> client
NETWORK.registerMessage(messageIdx++, MsgNewSpellPatternAck.class, MsgNewSpellPatternAck::serialize,
MsgNewSpellPatternAck::deserialize, makeClientBoundHandler(MsgNewSpellPatternAck::handle));
NETWORK.registerMessage(messageIdx++, MsgBlinkAck.class, MsgBlinkAck::serialize,
MsgBlinkAck::deserialize, makeClientBoundHandler(MsgBlinkAck::handle));
NETWORK.registerMessage(messageIdx++, MsgNewSpellPatternS2C.class, MsgNewSpellPatternS2C::serialize,
MsgNewSpellPatternS2C::deserialize, makeClientBoundHandler(MsgNewSpellPatternS2C::handle));
NETWORK.registerMessage(messageIdx++, MsgBlinkS2C.class, MsgBlinkS2C::serialize,
MsgBlinkS2C::deserialize, makeClientBoundHandler(MsgBlinkS2C::handle));
NETWORK.registerMessage(messageIdx++, MsgSentinelStatusUpdateAck.class, MsgSentinelStatusUpdateAck::serialize,
MsgSentinelStatusUpdateAck::deserialize, makeClientBoundHandler(MsgSentinelStatusUpdateAck::handle));
NETWORK.registerMessage(messageIdx++, MsgColorizerUpdateAck.class, MsgColorizerUpdateAck::serialize,
MsgColorizerUpdateAck::deserialize, makeClientBoundHandler(MsgColorizerUpdateAck::handle));
NETWORK.registerMessage(messageIdx++, MsgAltioraUpdateAck.class, MsgAltioraUpdateAck::serialize,
MsgAltioraUpdateAck::deserialize, makeClientBoundHandler(MsgAltioraUpdateAck::handle));
NETWORK.registerMessage(messageIdx++, MsgCastParticleAck.class, MsgCastParticleAck::serialize,
MsgCastParticleAck::deserialize, makeClientBoundHandler(MsgCastParticleAck::handle));
NETWORK.registerMessage(messageIdx++, MsgOpenSpellGuiAck.class, MsgOpenSpellGuiAck::serialize,
MsgOpenSpellGuiAck::deserialize, makeClientBoundHandler(MsgOpenSpellGuiAck::handle));
NETWORK.registerMessage(messageIdx++, MsgBeepAck.class, MsgBeepAck::serialize,
MsgBeepAck::deserialize, makeClientBoundHandler(MsgBeepAck::handle));
NETWORK.registerMessage(messageIdx++, MsgCastParticleS2C.class, MsgCastParticleS2C::serialize,
MsgCastParticleS2C::deserialize, makeClientBoundHandler(MsgCastParticleS2C::handle));
NETWORK.registerMessage(messageIdx++, MsgOpenSpellGuiS2C.class, MsgOpenSpellGuiS2C::serialize,
MsgOpenSpellGuiS2C::deserialize, makeClientBoundHandler(MsgOpenSpellGuiS2C::handle));
NETWORK.registerMessage(messageIdx++, MsgBeepS2C.class, MsgBeepS2C::serialize,
MsgBeepS2C::deserialize, makeClientBoundHandler(MsgBeepS2C::handle));
NETWORK.registerMessage(messageIdx++, MsgBrainsweepAck.class, MsgBrainsweepAck::serialize,
MsgBrainsweepAck::deserialize, makeClientBoundHandler(MsgBrainsweepAck::handle));
NETWORK.registerMessage(messageIdx++, MsgUpdateComparatorVisualsAck.class,
MsgUpdateComparatorVisualsAck::serialize,
MsgUpdateComparatorVisualsAck::deserialize,
makeClientBoundHandler(MsgUpdateComparatorVisualsAck::handle));
NETWORK.registerMessage(messageIdx++, MsgNewWallScrollAck.class,
MsgNewWallScrollAck::serialize,
MsgNewWallScrollAck::deserialize,
makeClientBoundHandler(MsgNewWallScrollAck::handle));
NETWORK.registerMessage(messageIdx++, MsgRecalcWallScrollDisplayAck.class,
MsgRecalcWallScrollDisplayAck::serialize,
MsgRecalcWallScrollDisplayAck::deserialize, makeClientBoundHandler(MsgRecalcWallScrollDisplayAck::handle));
NETWORK.registerMessage(messageIdx++, MsgUpdateComparatorVisualsS2C.class,
MsgUpdateComparatorVisualsS2C::serialize,
MsgUpdateComparatorVisualsS2C::deserialize,
makeClientBoundHandler(MsgUpdateComparatorVisualsS2C::handle));
NETWORK.registerMessage(messageIdx++, MsgNewWallScrollS2C.class,
MsgNewWallScrollS2C::serialize,
MsgNewWallScrollS2C::deserialize,
makeClientBoundHandler(MsgNewWallScrollS2C::handle));
NETWORK.registerMessage(messageIdx++, MsgRecalcWallScrollDisplayS2C.class,
MsgRecalcWallScrollDisplayS2C::serialize,
MsgRecalcWallScrollDisplayS2C::deserialize, makeClientBoundHandler(MsgRecalcWallScrollDisplayS2C::handle));
}
private static <T> BiConsumer<T, Supplier<NetworkEvent.Context>> makeServerBoundHandler(

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.forge.network;
import at.petrak.hexcasting.api.player.AltioraAbility;
import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.common.msgs.IMessage;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.forge.network;
import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.common.msgs.IMessage;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.forge.network;
import at.petrak.hexcasting.api.pigment.FrozenPigment;
import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.common.msgs.IMessage;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.forge.network;
import at.petrak.hexcasting.api.player.Sentinel;
import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.common.msgs.IMessage;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.forge.xplat;
import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.common.msgs.IMessage;
import at.petrak.hexcasting.forge.network.ForgePacketHandler;
import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
import net.minecraft.client.renderer.RenderType;

View file

@ -22,7 +22,7 @@ import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.lib.hex.HexEvalSounds;
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.common.msgs.IMessage;
import at.petrak.hexcasting.forge.cap.CapSyncers;
import at.petrak.hexcasting.forge.cap.HexCapabilities;
import at.petrak.hexcasting.forge.interop.curios.CuriosApiInterop;