Finished reimplementing the Sigil of Holding
Probably missed a few System.out messages for testing, but ah well.
This commit is contained in:
parent
b7e06f23bf
commit
3d51f61915
23 changed files with 429 additions and 45 deletions
|
@ -19,6 +19,7 @@ public class BloodMagicPacketHandler extends BasePacketHandler
|
|||
registerServerToClient(SetClientHealthPacket.class, SetClientHealthPacket::encode, SetClientHealthPacket::decode, SetClientHealthPacket::handle);
|
||||
|
||||
registerClientToServer(KeyProcessorPacket.class, KeyProcessorPacket::encode, KeyProcessorPacket::decode, KeyProcessorPacket::handle);
|
||||
registerClientToServer(SigilHoldingPacket.class, SigilHoldingPacket::encode, SigilHoldingPacket::decode, SigilHoldingPacket::handle);
|
||||
// INSTANCE.registerMessage(id, messageType, encoder, decoder, messageConsumer);
|
||||
// INSTANCE.registerMessage(ChatUtil.PacketNoSpamChat.Handler.class, ChatUtil.PacketNoSpamChat.class, 0, Side.CLIENT);
|
||||
// INSTANCE.registerMessage(ItemRouterButtonPacketProcessor.class, ItemRouterButtonPacketProcessor.class, 1, Side.SERVER);
|
||||
|
|
|
@ -46,7 +46,6 @@ public class KeyProcessorPacket
|
|||
|
||||
public static void sendKeyToServer(KeyProcessorPacket msg, PlayerEntity playerEntity)
|
||||
{
|
||||
System.out.println("Hoiiiii");
|
||||
if (playerEntity != null)
|
||||
{
|
||||
ItemStack heldStack = playerEntity.getHeldItemMainhand();
|
||||
|
@ -62,10 +61,4 @@ public class KeyProcessorPacket
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @OnlyIn(Dist.CLIENT)
|
||||
// public static void updateClientHolder(DemonWillHolder holder)
|
||||
// {
|
||||
// ClientHandler.currentAura = holder;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package wayoftime.bloodmagic.network;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilHolding;
|
||||
|
||||
public class SigilHoldingPacket
|
||||
{
|
||||
private int slot;
|
||||
private int mode;
|
||||
|
||||
public SigilHoldingPacket()
|
||||
{
|
||||
}
|
||||
|
||||
public SigilHoldingPacket(int slot, int mode)
|
||||
{
|
||||
this.slot = slot;
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public static void encode(SigilHoldingPacket pkt, PacketBuffer buf)
|
||||
{
|
||||
buf.writeInt(pkt.slot);
|
||||
buf.writeInt(pkt.mode);
|
||||
}
|
||||
|
||||
public static SigilHoldingPacket decode(PacketBuffer buf)
|
||||
{
|
||||
SigilHoldingPacket pkt = new SigilHoldingPacket(buf.readInt(), buf.readInt());
|
||||
|
||||
return pkt;
|
||||
}
|
||||
|
||||
public static void handle(SigilHoldingPacket message, Supplier<Context> context)
|
||||
{
|
||||
context.get().enqueueWork(() -> sendKeyToServer(message, context.get().getSender()));
|
||||
context.get().setPacketHandled(true);
|
||||
}
|
||||
|
||||
public static void sendKeyToServer(SigilHoldingPacket msg, PlayerEntity playerEntity)
|
||||
{
|
||||
ItemStack itemStack = ItemStack.EMPTY;
|
||||
|
||||
if (msg.slot > -1 && msg.slot < 9)
|
||||
{
|
||||
itemStack = playerEntity.inventory.getStackInSlot(msg.slot);
|
||||
}
|
||||
|
||||
if (!itemStack.isEmpty())
|
||||
{
|
||||
ItemSigilHolding.cycleToNextSigil(itemStack, msg.mode);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue