mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 00:47:50 +00:00
register packets & needNPC
This commit is contained in:
1 parent
21557ff857
commit
28acfbc8f8
3 files changed
+34
-11
No files matched your search
@@ -14,6 +14,8 @@ import kamkeel.npcs.network.packets.data.gui.IsGuiOpenPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.*;
|
||||
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.request.*;
|
||||
import kamkeel.npcs.network.packets.request.bank.BankGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.bank.BankRemovePacket;
|
||||
@@ -98,6 +100,7 @@ public class PacketHandler {
|
||||
this.registerChannels();
|
||||
this.registerDataPackets();
|
||||
this.registerRequestPackets();
|
||||
this.registerPlayerPackets();
|
||||
}
|
||||
|
||||
public void registerRequestPackets(){
|
||||
@@ -288,6 +291,12 @@ public class PacketHandler {
|
||||
DATA_PACKET.registerPacket(new PartyDataPacket());
|
||||
}
|
||||
|
||||
public void registerPlayerPackets() {
|
||||
PLAYER_PACKET.registerPacket(new FollowerPacket());
|
||||
|
||||
PLAYER_PACKET.registerPacket(new BankPacket());
|
||||
}
|
||||
|
||||
private void registerChannels() {
|
||||
for (PacketChannel channel : packetChannels) {
|
||||
FMLEventChannel eventChannel =
|
||||
|
||||
@@ -21,9 +21,13 @@ import java.io.IOException;
|
||||
public class BankPacket extends AbstractPacket {
|
||||
public static final String packetName = "Player|Follower";
|
||||
|
||||
private final Action type;
|
||||
private final int slotID;
|
||||
private final int bankID;
|
||||
private Action type;
|
||||
private int slotID;
|
||||
private int bankID;
|
||||
|
||||
public BankPacket() {
|
||||
|
||||
}
|
||||
|
||||
private BankPacket(Action action, int bankID, int slotID) {
|
||||
this.type = action;
|
||||
@@ -31,6 +35,11 @@ public class BankPacket extends AbstractPacket {
|
||||
this.slotID = slotID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsNPC() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static BankPacket Open(int bankID, int slotID) {
|
||||
return new BankPacket(Action.OpenSlot, bankID, slotID);
|
||||
}
|
||||
@@ -54,6 +63,8 @@ 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) {
|
||||
@@ -71,9 +82,7 @@ public class BankPacket extends AbstractPacket {
|
||||
|
||||
EntityPlayerMP playerMP = (EntityPlayerMP) player;
|
||||
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(playerMP);
|
||||
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Bank)
|
||||
if(npc.advanced.role != EnumRoleType.Bank)
|
||||
return;
|
||||
|
||||
switch (requestedAction) {
|
||||
|
||||
@@ -21,12 +21,20 @@ import java.io.IOException;
|
||||
public class FollowerPacket extends AbstractPacket {
|
||||
public static final String packetName = "Player|Follower";
|
||||
|
||||
private final Action type;
|
||||
private Action type;
|
||||
|
||||
public FollowerPacket() {
|
||||
}
|
||||
|
||||
public FollowerPacket(Action action) {
|
||||
this.type = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsNPC() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumPlayerPacket.FollowerAction;
|
||||
@@ -51,12 +59,9 @@ public class FollowerPacket extends AbstractPacket {
|
||||
|
||||
EntityPlayerMP playerMP = (EntityPlayerMP) player;
|
||||
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(playerMP);
|
||||
|
||||
if (npc == null || npc.advanced.job != EnumJobType.Follower)
|
||||
if (npc.advanced.job != EnumJobType.Follower)
|
||||
return;
|
||||
|
||||
|
||||
switch (requestedAction) {
|
||||
case Hire:
|
||||
NoppesUtilPlayer.hireFollower(playerMP, npc);
|
||||
|
||||
Reference in new issue
Block a user