-
Notifications
You must be signed in to change notification settings - Fork 0
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
15 changed files
with
184 additions
and
154 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
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
49 changes: 0 additions & 49 deletions
49
src/main/java/dev/louis/nebula/networking/SpellCastC2SPacket.java
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
src/main/java/dev/louis/nebula/networking/SyncManaS2CPacket.java
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
src/main/java/dev/louis/nebula/networking/UpdateSpellCastabilityS2CPacket.java
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
src/main/java/dev/louis/nebula/networking/c2s/SpellCastPayload.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,49 @@ | ||
package dev.louis.nebula.networking.c2s; | ||
|
||
import dev.louis.nebula.Nebula; | ||
import dev.louis.nebula.api.spell.SpellType; | ||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; | ||
import net.minecraft.network.RegistryByteBuf; | ||
import net.minecraft.network.codec.PacketCodec; | ||
import net.minecraft.network.codec.PacketCodecs; | ||
import net.minecraft.network.packet.CustomPayload; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class SpellCastPayload implements CustomPayload { | ||
public static final Id<SpellCastPayload> ID = new CustomPayload.Id<>(Identifier.of(Nebula.MOD_ID, "spellcast")); | ||
public static final PacketCodec<RegistryByteBuf, SpellCastPayload> CODEC = PacketCodec.of( | ||
SpellCastPayload::write, | ||
SpellCastPayload::read | ||
); | ||
public final SpellType<?> spellType; | ||
|
||
public SpellCastPayload(SpellType<?> spellType) { | ||
this.spellType = spellType; | ||
} | ||
|
||
public static SpellCastPayload read(RegistryByteBuf buf) { | ||
SpellType<?> spellType = PacketCodecs.registryValue(SpellType.REGISTRY_KEY).decode(buf); | ||
|
||
if (spellType == null) throw new IllegalStateException("Spell type not found in registry"); | ||
return new SpellCastPayload(spellType); | ||
} | ||
|
||
public void write(RegistryByteBuf buf) { | ||
PacketCodecs.registryValue(SpellType.REGISTRY_KEY).encode(buf, this.spellType); | ||
} | ||
|
||
public static void receive(SpellCastPayload packet, ServerPlayNetworking.Context context) { | ||
context.player().server.executeSync(() -> context.player().getSpellManager().cast(packet.spellType)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SpellCastC2SPacket[" + | ||
"spellType=" + spellType + ']'; | ||
} | ||
|
||
@Override | ||
public Id<? extends CustomPayload> getId() { | ||
return ID; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/dev/louis/nebula/networking/s2c/SyncManaPayload.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,25 @@ | ||
package dev.louis.nebula.networking.s2c; | ||
|
||
import dev.louis.nebula.Nebula; | ||
import net.minecraft.network.PacketByteBuf; | ||
import net.minecraft.network.codec.PacketCodec; | ||
import net.minecraft.network.packet.CustomPayload; | ||
import net.minecraft.util.Identifier; | ||
|
||
public record SyncManaPayload(int mana) implements CustomPayload { | ||
public static final Id<SyncManaPayload> ID = new CustomPayload.Id<>(Identifier.of(Nebula.MOD_ID, "synchronizemana")); | ||
public static final PacketCodec<PacketByteBuf, SyncManaPayload> CODEC = PacketCodec.of(SyncManaPayload::write, SyncManaPayload::read); | ||
|
||
public static SyncManaPayload read(PacketByteBuf buf) { | ||
return new SyncManaPayload(buf.readVarInt()); | ||
} | ||
|
||
public void write(PacketByteBuf buf) { | ||
buf.writeVarInt(mana); | ||
} | ||
|
||
@Override | ||
public Id<? extends CustomPayload> getId() { | ||
return ID; | ||
} | ||
} |
Oops, something went wrong.