generated from NeoForgeMDKs/MDK-1.21-ModDevGradle
-
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.
- Loading branch information
Showing
4 changed files
with
69 additions
and
80 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/main/java/org/hiedacamellia/whispergrove/core/event/WGModBusEvent.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,21 @@ | ||
package org.hiedacamellia.whispergrove.core.event; | ||
|
||
import net.neoforged.bus.api.SubscribeEvent; | ||
import net.neoforged.fml.common.EventBusSubscriber; | ||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent; | ||
import net.neoforged.neoforge.network.registration.PayloadRegistrar; | ||
import org.hiedacamellia.whispergrove.WhisperGrove; | ||
import org.hiedacamellia.whispergrove.core.network.PlayerVisceraS2CPacket; | ||
|
||
@EventBusSubscriber(modid = WhisperGrove.MODID, bus = EventBusSubscriber.Bus.MOD) | ||
public class WGModBusEvent { | ||
|
||
@SubscribeEvent | ||
public static void register(final RegisterPayloadHandlersEvent event) { | ||
final PayloadRegistrar registrar = event.registrar("1"); | ||
registrar.playToClient(PlayerVisceraS2CPacket.TYPE, | ||
PlayerVisceraS2CPacket.STREAM_CODEC, | ||
PlayerVisceraS2CPacket::handleData); | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/org/hiedacamellia/whispergrove/core/network/PlayerVisceraS2CPacket.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,38 @@ | ||
package org.hiedacamellia.whispergrove.core.network; | ||
|
||
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 net.neoforged.neoforge.attachment.AttachmentType; | ||
import net.neoforged.neoforge.network.handling.IPayloadContext; | ||
import net.neoforged.neoforge.registries.NeoForgeRegistries; | ||
import org.hiedacamellia.whispergrove.WhisperGrove; | ||
import org.hiedacamellia.whispergrove.content.common.viscera.Viscera; | ||
|
||
public record PlayerVisceraS2CPacket(ResourceLocation name, Double yin, Double yang) implements CustomPacketPayload { | ||
|
||
public static final Type<PlayerVisceraS2CPacket> TYPE = new Type<>(WhisperGrove.prefix("network.viscera")); | ||
public static final StreamCodec<ByteBuf, PlayerVisceraS2CPacket> STREAM_CODEC = StreamCodec.composite( | ||
ResourceLocation.STREAM_CODEC, PlayerVisceraS2CPacket::name, | ||
ByteBufCodecs.DOUBLE, PlayerVisceraS2CPacket::yin, | ||
ByteBufCodecs.DOUBLE, PlayerVisceraS2CPacket::yang, | ||
PlayerVisceraS2CPacket::new); | ||
|
||
@Override | ||
public Type<? extends CustomPacketPayload> type() { | ||
return TYPE; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static void handleData(PlayerVisceraS2CPacket packet, IPayloadContext context) { | ||
context.enqueueWork(() -> { | ||
AttachmentType<Viscera> type = (AttachmentType<Viscera>) NeoForgeRegistries.ATTACHMENT_TYPES.get(packet.name); | ||
if (type != null) { | ||
context.player().setData(type, new Viscera(packet.name, packet.yin, packet.yang)); | ||
} | ||
}); | ||
} | ||
|
||
} |
71 changes: 0 additions & 71 deletions
71
src/main/java/org/hiedacamellia/whispergrove/core/network/WGPayload.java
This file was deleted.
Oops, something went wrong.
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