Skip to content

Commit

Permalink
Add to queue packet
Browse files Browse the repository at this point in the history
  • Loading branch information
paulyhedral committed Jan 29, 2024
1 parent 50184f1 commit fb41d42
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.sweetrpg.crafttracker.common.network;

import com.sweetrpg.crafttracker.CraftTracker;
import com.sweetrpg.crafttracker.common.network.packet.AddToQueuePacket;
import com.sweetrpg.crafttracker.common.network.packet.data.AddToQueueData;
import net.minecraftforge.network.PacketDistributor;

public final class PacketHandler {

private static int disc = 0;

public static void init() {
// registerPacket(new CatModePacket(), CatModeData.class);
registerPacket(new AddToQueuePacket(), AddToQueueData.class);
// registerPacket(new CatNamePacket(), CatNameData.class);
// registerPacket(new CatObeyPacket(), CatObeyData.class);
// registerPacket(new CatTalentPacket(), CatTalentData.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.sweetrpg.crafttracker.common.network.packet;

import com.sweetrpg.crafttracker.common.network.IPacket;
import com.sweetrpg.crafttracker.common.network.packet.data.AddToQueueData;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraftforge.network.NetworkEvent.Context;

import java.util.function.Supplier;

public class AddToQueuePacket implements IPacket<AddToQueueData> {

@Override
public void encode(AddToQueueData data, FriendlyByteBuf buf) {
buf.writeUtf(data.itemId);
}

@Override
public AddToQueueData decode(FriendlyByteBuf buf) {
String itemId = buf.readUtf();
return new AddToQueueData(itemId);
}

@Override
public final void handle(AddToQueueData data, Supplier<Context> ctx) {
ctx.get().enqueueWork(() -> {
// Entity target = ctx.get().getSender().level.getEntity(data.entityId);
//
// if (!(target instanceof CatEntity)) {
// return;
// }
//
// this.handleCat((CatEntity) target, data, ctx);
});

ctx.get().setPacketHandled(true);
}

// public abstract void handleCat(CatEntity catIn, T data, Supplier<Context> ctx);

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.sweetrpg.crafttracker.common.network.packet.data;

public class AddToQueueData {

public String itemId;

public AddToQueueData(String itemId) {
this.itemId = itemId;
}
}

This file was deleted.

0 comments on commit fb41d42

Please sign in to comment.