-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I am currently hopped up on pain meds after my wisdom teeth so this is probably not my best code Signed-off-by: Siuolplex <lmeitrodt@gmail.com>
- Loading branch information
Showing
12 changed files
with
132 additions
and
199 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.violetmoon.zeta.net2; | ||
|
||
public enum NetworkPhase { | ||
PLAY, LOGIN, ANY | ||
} |
36 changes: 0 additions & 36 deletions
36
src/main/java/org/violetmoon/zeta/net2/ZetaClientLoginNetworking.java
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
src/main/java/org/violetmoon/zeta/net2/ZetaServerLoginNetworking.java
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/main/java/org/violetmoon/zeta/net2/event/load/ZRegisterPayloadHandlers.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,13 @@ | ||
package org.violetmoon.zeta.net2.event.load; | ||
|
||
import com.mojang.serialization.Codec; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import org.violetmoon.zeta.event.bus.IZetaLoadEvent; | ||
import org.violetmoon.zeta.net2.NetworkPhase; | ||
|
||
public interface ZRegisterPayloadHandlers extends IZetaLoadEvent { | ||
<T> void registerServerboundPayload(CustomPacketPayload.Type type, StreamCodec codec, T handler, NetworkPhase phase); | ||
<T> void registerClientboundPayload(CustomPacketPayload.Type type, StreamCodec codec, T handler, NetworkPhase phase); | ||
<T> void registerBidirectionalPayload(CustomPacketPayload.Type type, StreamCodec codec, T handler, NetworkPhase phase); | ||
} |
49 changes: 0 additions & 49 deletions
49
src/main/java/org/violetmoon/zeta/net2/packet/ZetaClientboundHandshakePacket.java
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
src/main/java/org/violetmoon/zeta/net2/packet/ZetaServerboundHandshakePacket.java
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
src/main/java/org/violetmoon/zeta/net2/packet/listener/ZetaClientLoginPacketListener.java
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/main/java/org/violetmoon/zeta/net2/packet/listener/ZetaServerLoginPacketListener.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
src/main/java/org/violetmoon/zeta/net2/payload/SyncPayload.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,22 @@ | ||
package org.violetmoon.zeta.net2.payload; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import net.minecraft.network.codec.ByteBufCodecs; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import net.minecraft.resources.ResourceLocation; | ||
import org.violetmoon.zeta.Zeta; | ||
|
||
public record SyncPayload(byte[] flags, int expectedLength, int expectedHash) implements ZetaPacketPayload { | ||
public static final CustomPacketPayload.Type<SyncPayload> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(Zeta.ZETA_ID, "handshake_payload")); | ||
public static final StreamCodec<ByteBuf, SyncPayload> STREAM_CODEC = StreamCodec.composite( | ||
ByteBufCodecs.BYTE_ARRAY, SyncPayload::flags, | ||
ByteBufCodecs.INT, SyncPayload::expectedLength, | ||
ByteBufCodecs.INT, SyncPayload::expectedHash, | ||
SyncPayload::new | ||
); | ||
@Override | ||
public Type<? extends CustomPacketPayload> type() { | ||
return TYPE; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/org/violetmoon/zeta/net2/payload/ZetaPacketPayload.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,7 @@ | ||
package org.violetmoon.zeta.net2.payload; | ||
|
||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
|
||
public interface ZetaPacketPayload extends CustomPacketPayload { | ||
|
||
} |
79 changes: 79 additions & 0 deletions
79
...main/java/org/violetmoon/zetaimplforge/net2/event/load/ForgeZRegisterPayloadHandlers.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,79 @@ | ||
package org.violetmoon.zetaimplforge.net2.event.load; | ||
|
||
import com.mojang.serialization.Codec; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent; | ||
import net.neoforged.neoforge.network.registration.PayloadRegistrar; | ||
import org.violetmoon.zeta.Zeta; | ||
import org.violetmoon.zeta.net2.NetworkPhase; | ||
import org.violetmoon.zeta.net2.event.load.ZRegisterPayloadHandlers; | ||
import org.violetmoon.zetaimplforge.net2.handlers.ZetaPayloadHandler; | ||
|
||
public class ForgeZRegisterPayloadHandlers implements ZRegisterPayloadHandlers { | ||
private final RegisterPayloadHandlersEvent e; | ||
|
||
public ForgeZRegisterPayloadHandlers(RegisterPayloadHandlersEvent event) { | ||
this.e = event; | ||
} | ||
|
||
@Override | ||
public <T> void registerServerboundPayload(CustomPacketPayload.Type type, StreamCodec codec, T handler, NetworkPhase phase) { | ||
if (handler instanceof ZetaPayloadHandler zetaPayloadHandler) { | ||
final PayloadRegistrar registrar = e.registrar("1"); | ||
switch (phase) { | ||
case PLAY: { | ||
registrar.playToServer(type, codec, zetaPayloadHandler); | ||
} | ||
case LOGIN: { | ||
registrar.configurationToServer(type, codec, zetaPayloadHandler); | ||
} | ||
case ANY: { | ||
registrar.commonToServer(type, codec, zetaPayloadHandler); | ||
} | ||
} | ||
} else { | ||
Zeta.GLOBAL_LOG.fatal("THE PACKETS HAVE FAILED, OH GOD. PLEASE REPLACE ME WITH AN ACTUAL ERROR MESSAGE"); //todo: Replace this with an actual error message | ||
} | ||
} | ||
|
||
@Override | ||
public <T> void registerClientboundPayload(CustomPacketPayload.Type type, StreamCodec codec, T handler, NetworkPhase phase) { | ||
if (handler instanceof ZetaPayloadHandler zetaPayloadHandler) { | ||
final PayloadRegistrar registrar = e.registrar("1"); | ||
switch (phase) { | ||
case PLAY: { | ||
registrar.playToClient(type, codec, zetaPayloadHandler); | ||
} | ||
case LOGIN: { | ||
registrar.configurationToClient(type, codec, zetaPayloadHandler); | ||
} | ||
case ANY: { | ||
registrar.commonToClient(type, codec, zetaPayloadHandler); | ||
} | ||
} | ||
} else { | ||
Zeta.GLOBAL_LOG.fatal("THE PACKETS HAVE FAILED, OH GOD. PLEASE REPLACE ME WITH AN ACTUAL ERROR MESSAGE"); //todo: Replace this with an actual error message | ||
} | ||
} | ||
|
||
@Override | ||
public <T> void registerBidirectionalPayload(CustomPacketPayload.Type type, StreamCodec codec, T handler, NetworkPhase phase) { | ||
if (handler instanceof ZetaPayloadHandler zetaPayloadHandler) { | ||
final PayloadRegistrar registrar = e.registrar("1"); | ||
switch (phase) { | ||
case PLAY: { | ||
registrar.playBidirectional(type, codec, zetaPayloadHandler); | ||
} | ||
case LOGIN: { | ||
registrar.configurationBidirectional(type, codec, zetaPayloadHandler); | ||
} | ||
case ANY: { | ||
registrar.commonBidirectional(type, codec, zetaPayloadHandler); | ||
} | ||
} | ||
} else { | ||
Zeta.GLOBAL_LOG.fatal("THE PACKETS HAVE FAILED, OH GOD. PLEASE REPLACE ME WITH AN ACTUAL ERROR MESSAGE"); //todo: Replace this with an actual error message | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/org/violetmoon/zetaimplforge/net2/handlers/ZetaPayloadHandler.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,6 @@ | ||
package org.violetmoon.zetaimplforge.net2.handlers; | ||
|
||
import net.neoforged.neoforge.network.handling.IPayloadHandler; | ||
|
||
//todo: Im putting this in for now, but it will probably go byebye | ||
public interface ZetaPayloadHandler extends IPayloadHandler {} |