mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 04:57:27 +00:00
Merge branch 'packet' of https://github.com/KAMKEEL/CustomNPC-Plus into packet
This commit is contained in:
commit
b5d294dd20
8 files changed
+87
-22
No files matched your search
@@ -16,6 +16,7 @@ import kamkeel.npcs.network.packets.data.npc.*;
|
||||
import kamkeel.npcs.network.packets.data.script.*;
|
||||
import kamkeel.npcs.network.packets.player.BankPacket;
|
||||
import kamkeel.npcs.network.packets.player.FollowerPacket;
|
||||
import kamkeel.npcs.network.packets.player.TransportPacket;
|
||||
import kamkeel.npcs.network.packets.request.*;
|
||||
import kamkeel.npcs.network.packets.request.animation.*;
|
||||
import kamkeel.npcs.network.packets.request.bank.BankGetPacket;
|
||||
@@ -323,6 +324,8 @@ public class PacketHandler {
|
||||
public void registerPlayerPackets() {
|
||||
PLAYER_PACKET.registerPacket(new FollowerPacket());
|
||||
|
||||
PLAYER_PACKET.registerPacket(new TransportPacket());
|
||||
|
||||
PLAYER_PACKET.registerPacket(new BankPacket());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,21 @@ package kamkeel.npcs.network.enums;
|
||||
|
||||
public enum EnumPlayerPacket {
|
||||
FollowerAction,
|
||||
Transport, // TODO
|
||||
Transport,
|
||||
BankAction,
|
||||
Dialog, // TODO
|
||||
QuestLog, // TODO
|
||||
TrackedQuest, // TODO
|
||||
CheckQuestCompletion, // TODO
|
||||
|
||||
FactionsGet, // TODO
|
||||
MailAction, // TODO: Get, Delete, Send, Read, OpenMail
|
||||
SaveSign, // TODO
|
||||
SaveBook, // TODO
|
||||
Companion, // TODO: OpenInv, TalentExp
|
||||
RoleGet, // TODO
|
||||
KeyPressed, // TODO
|
||||
MouseClicked, // TODO
|
||||
ScreenSize; // TODO
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,16 +10,14 @@ import kamkeel.npcs.network.enums.EnumPlayerPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.BankData;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class BankPacket extends AbstractPacket {
|
||||
public static final String packetName = "Player|Follower";
|
||||
public static final String packetName = "Player|Bank";
|
||||
|
||||
private Action type;
|
||||
private int slotID;
|
||||
@@ -63,8 +61,6 @@ public class BankPacket extends AbstractPacket {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
if (type == null)
|
||||
return;
|
||||
out.writeInt(type.ordinal());
|
||||
|
||||
if (type == Action.OpenSlot) {
|
||||
|
||||
@@ -12,9 +12,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.constants.EnumJobType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package kamkeel.npcs.network.packets.player;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
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.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class TransportPacket extends AbstractPacket {
|
||||
public static final String packetName = "Player|Transport";
|
||||
|
||||
private String destination;
|
||||
|
||||
public TransportPacket() {
|
||||
|
||||
}
|
||||
|
||||
public TransportPacket(String destination) {
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumPlayerPacket.Transport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.PLAYER_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsNPC() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
ByteBufUtils.writeString(out, destination);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (npc.advanced.role != EnumRoleType.Transporter)
|
||||
return;
|
||||
NoppesUtilPlayer.transport((EntityPlayerMP) player, npc, ByteBufUtils.readString(in));
|
||||
}
|
||||
}
|
||||
@@ -152,12 +152,12 @@ public class PacketHandlerPlayer{
|
||||
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)
|
||||
return;
|
||||
NoppesUtilPlayer.transport(player, npc, ByteBufUtils.readString(buffer));
|
||||
}
|
||||
// else if(type == EnumPlayerPacket.Transport){
|
||||
// EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
// if(npc == null || npc.advanced.role != EnumRoleType.Transporter)
|
||||
// return;
|
||||
// NoppesUtilPlayer.transport(player, npc, ByteBufUtils.readString(buffer));
|
||||
// }
|
||||
// else if(type == EnumPlayerPacket.BankUpgrade){
|
||||
// EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
// if(npc == null || npc.advanced.role != EnumRoleType.Bank)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package noppes.npcs.client.gui.player;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.player.TransportPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
@@ -18,9 +20,9 @@ public class GuiTransportSelection extends GuiNPCInterface implements ITopButton
|
||||
protected int xSize;
|
||||
protected int guiLeft;
|
||||
protected int guiTop;
|
||||
|
||||
|
||||
private GuiCustomScroll scroll;
|
||||
|
||||
|
||||
public GuiTransportSelection(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
xSize = 176;
|
||||
@@ -43,7 +45,7 @@ public class GuiTransportSelection extends GuiNPCInterface implements ITopButton
|
||||
scroll.guiTop = guiTop + 20;
|
||||
addScroll(scroll);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawScreen(int i, int j, float f)
|
||||
{
|
||||
@@ -61,7 +63,7 @@ public class GuiTransportSelection extends GuiNPCInterface implements ITopButton
|
||||
String sel = scroll.getSelected();
|
||||
if(button.id == 0 && sel != null){
|
||||
close();
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.Transport,sel);
|
||||
PacketClient.sendClient(new TransportPacket(sel));
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
@@ -82,7 +84,7 @@ public class GuiTransportSelection extends GuiNPCInterface implements ITopButton
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
}
|
||||
@@ -93,7 +95,7 @@ public class GuiTransportSelection extends GuiNPCInterface implements ITopButton
|
||||
@Override
|
||||
public void setSelected(String selected) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@ public enum EnumPlayerPacket {
|
||||
// FollowerHire, // Finished
|
||||
// FollowerExtend,
|
||||
// FollowerState,
|
||||
Transport,
|
||||
// Transport,
|
||||
// BankUnlock,
|
||||
// BankUpgrade,
|
||||
Dialog,
|
||||
|
||||
Reference in new issue
Block a user