Get NPC Role packet

This commit is contained in:
somehussar committed 2025-02-03 04:32:59 +01:00
1 parent a5c3c6768b
commit 10f12ad036
7 files changed
+65 -13

No files matched your search

@@ -357,6 +357,8 @@ public class PacketHandler {
PLAYER_PACKET.registerPacket(new CompanionActionPacket());
PLAYER_PACKET.registerPacket(new GetNPCRole());
PLAYER_PACKET.registerPacket(new InputDevicePacket());
PLAYER_PACKET.registerPacket(new ScreenSizePacket());
@@ -10,8 +10,8 @@ public enum EnumPlayerPacket {
MailSend,
SaveSign, // TODO
SaveBook, // TODO
CompanionAction, // TODO: OpenInv, TalentExp
GetRole, // TODO
CompanionAction,
GetRole,
InputDevice,
ScreenSize
}
@@ -0,0 +1,47 @@
package kamkeel.npcs.network.packets.player;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumPlayerPacket;
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.constants.EnumRoleType;
import java.io.IOException;
public class GetNPCRole extends AbstractPacket {
public static final String packetName = "Player|GetNPCRole";
@Override
public Enum getType() {
return EnumPlayerPacket.GetRole;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.PLAYER_PACKET;
}
@Override
public boolean needsNPC() {
return true;
}
@Override
public void sendData(ByteBuf out) throws IOException {
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if(!(player instanceof EntityPlayerMP))
return;
if (npc.advanced.role == EnumRoleType.None)
return;
GuiDataPacket.sendGuiData((EntityPlayerMP) player, npc.roleInterface.writeToNBT(new NBTTagCompound()));
}
}
@@ -146,12 +146,12 @@ public class PacketHandlerPlayer{
// NoppesUtilPlayer.changeFollowerState(player,npc);
// GuiDataPacket.sendGuiData(player, npc.roleInterface.writeToNBT(new NBTTagCompound()));
// }
if(type == EnumPlayerPacket.RoleGet){
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
if(npc == null || npc.advanced.role == EnumRoleType.None)
return;
GuiDataPacket.sendGuiData(player, npc.roleInterface.writeToNBT(new NBTTagCompound()));
}
// if(type == EnumPlayerPacket.RoleGet){
// EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
// if(npc == null || npc.advanced.role == EnumRoleType.None)
// return;
// GuiDataPacket.sendGuiData(player, npc.roleInterface.writeToNBT(new NBTTagCompound()));
// }
// else if(type == EnumPlayerPacket.Transport){
// EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
// if(npc == null || npc.advanced.role != EnumRoleType.Transporter)
@@ -281,7 +281,7 @@ public class PacketHandlerPlayer{
// }
// }
// }
else if(type == EnumPlayerPacket.SignSave) {
if(type == EnumPlayerPacket.SignSave) {
int x = buffer.readInt(), y = buffer.readInt(), z = buffer.readInt();
if (player.worldObj.blockExists(x, y, z)) {
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
@@ -2,6 +2,7 @@ package noppes.npcs.client.gui.player;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.player.FollowerPacket;
import kamkeel.npcs.network.packets.player.GetNPCRole;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
@@ -31,7 +32,7 @@ public class GuiNpcFollower extends GuiContainerNPCInterface implements IGuiDat
role = (RoleFollower) npc.roleInterface;
closeOnEsc = true;
NoppesUtilPlayer.sendData(EnumPlayerPacket.RoleGet);
PacketClient.sendClient(new GetNPCRole());
}
@Override
public void initGui(){
@@ -1,6 +1,8 @@
package noppes.npcs.client.gui.player.companion;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.player.CompanionActionPacket;
import kamkeel.npcs.network.packets.player.GetNPCRole;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.ItemStack;
@@ -29,7 +31,7 @@ public class GuiNpcCompanionStats extends GuiNPCInterface implements IGuiData {
setBackground("companion.png");
xSize = 171;
ySize = 166;
NoppesUtilPlayer.sendData(EnumPlayerPacket.RoleGet);
PacketClient.sendClient(new GetNPCRole());
}
@Override
@@ -88,7 +90,7 @@ public class GuiNpcCompanionStats extends GuiNPCInterface implements IGuiData {
public void drawScreen(int i, int j, float f) {
super.drawScreen(i, j, f);
if(isEating && !role.isEating()){
NoppesUtilPlayer.sendData(EnumPlayerPacket.RoleGet);
PacketClient.sendClient(new GetNPCRole());
}
isEating = role.isEating();
@@ -21,7 +21,7 @@ public enum EnumPlayerPacket {
SignSave,
SaveBook,
// CompanionOpenInv,
RoleGet,
// RoleGet,
// KeyPressed,
// MouseClicked,
// CompanionTalentExp,