-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
50 additions
and
19 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
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
42 changes: 42 additions & 0 deletions
42
forge/src/main/java/org/popcraft/chunkyborder/packet/BorderPayload.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,42 @@ | ||
package org.popcraft.chunkyborder.packet; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.popcraft.chunky.platform.World; | ||
import org.popcraft.chunky.shape.Shape; | ||
import org.popcraft.chunkyborder.util.ClientBorder; | ||
import org.popcraft.chunkyborder.util.PluginMessage; | ||
|
||
public class BorderPayload implements CustomPacketPayload { | ||
public static final Type<BorderPayload> ID = CustomPacketPayload.createType("chunky:border"); | ||
private World world; | ||
private Shape shape; | ||
private ClientBorder border; | ||
|
||
public BorderPayload(final World world, final Shape shape) { | ||
this.world = world; | ||
this.shape = shape; | ||
} | ||
|
||
public BorderPayload(final FriendlyByteBuf buf) { | ||
final ByteBuf unwrapped = buf.unwrap(); | ||
final byte[] bytes = new byte[unwrapped.readableBytes()]; | ||
unwrapped.readBytes(bytes); | ||
this.border = PluginMessage.readBorder(bytes); | ||
} | ||
|
||
public void write(final FriendlyByteBuf buf) { | ||
buf.writeBytes(PluginMessage.writeBorder(world, shape)); | ||
} | ||
|
||
public ClientBorder getBorder() { | ||
return border; | ||
} | ||
|
||
@Override | ||
public @NotNull Type<BorderPayload> type() { | ||
return ID; | ||
} | ||
} |
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