-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed title being set by default, and made Positive more data-based
- Loading branch information
1 parent
637514a
commit 25e90ae
Showing
5 changed files
with
62 additions
and
2 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,18 @@ | ||
package rubyboat.ghost; | ||
|
||
import net.fabricmc.api.ModInitializer; | ||
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; | ||
import rubyboat.ghost.server.NetworkHandler; | ||
|
||
public class Main implements ModInitializer { | ||
public static final String MOD_ID = "ghost"; | ||
|
||
@Override | ||
public void onInitialize() { | ||
System.out.println("test"); | ||
ServerPlayConnectionEvents.JOIN.register((handler, sender, client) -> { | ||
System.out.println("sent allow midair blocks"); | ||
NetworkHandler.sendAllowMidAirBlocks(handler.player, true); | ||
}); | ||
} | ||
} |
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
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,28 @@ | ||
package rubyboat.ghost.server; | ||
|
||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; | ||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; | ||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; | ||
import net.minecraft.network.PacketByteBuf; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.util.Identifier; | ||
import rubyboat.ghost.Main; | ||
import rubyboat.ghost.client.GhostClient; | ||
|
||
public class NetworkHandler { | ||
public static final Identifier ALLOW_MIDAIR_BLOCKS = new Identifier(Main.MOD_ID, "allow_midair_blocks"); | ||
|
||
|
||
public static void registerS2CPackets() { | ||
ClientPlayNetworking.registerGlobalReceiver(ALLOW_MIDAIR_BLOCKS, (client, handler, buf, responseSender) -> { | ||
GhostClient.AllowMidAirGhostBlocks = buf.readBoolean(); | ||
System.out.println("allow midair blocks: " + GhostClient.AllowMidAirGhostBlocks); | ||
}); | ||
} | ||
|
||
public static void sendAllowMidAirBlocks(ServerPlayerEntity player, boolean allow) { | ||
PacketByteBuf buf = PacketByteBufs.create(); | ||
buf.writeBoolean(allow); | ||
ServerPlayNetworking.send(player, ALLOW_MIDAIR_BLOCKS, buf); | ||
} | ||
} |