mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 05:45:03 +00:00
Job Packets
This commit is contained in:
1 parent
7366b11077
commit
0124154380
15 files changed
+166
-117
No files matched your search
@@ -28,6 +28,10 @@ import kamkeel.npcs.network.packets.request.dialog.*;
|
||||
import kamkeel.npcs.network.packets.request.faction.FactionRemovePacket;
|
||||
import kamkeel.npcs.network.packets.request.faction.FactionSavePacket;
|
||||
import kamkeel.npcs.network.packets.request.faction.FactionSetPacket;
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobSavePacket;
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobSpawnerAddPacket;
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobSpawnerRemovePacket;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedAddPacket;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedGetAllPacket;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedRemovePacket;
|
||||
@@ -197,6 +201,12 @@ public class PacketHandler {
|
||||
REQUEST_PACKET.registerPacket(new CustomGuiUnfocusedPacket());
|
||||
REQUEST_PACKET.registerPacket(new CustomScrollClickPacket());
|
||||
|
||||
// Job
|
||||
REQUEST_PACKET.registerPacket(new JobGetPacket());
|
||||
REQUEST_PACKET.registerPacket(new JobSavePacket());
|
||||
REQUEST_PACKET.registerPacket(new JobSpawnerAddPacket());
|
||||
REQUEST_PACKET.registerPacket(new JobSpawnerRemovePacket());
|
||||
|
||||
// Other
|
||||
REQUEST_PACKET.registerPacket(new GuiRequestPacket());
|
||||
REQUEST_PACKET.registerPacket(new DimensionsGetPacket());
|
||||
|
||||
@@ -50,9 +50,15 @@ public final class JobGetPacket extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP)) return;
|
||||
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return;
|
||||
if(npc.jobInterface == null) return;
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player))
|
||||
return;
|
||||
|
||||
if(npc.jobInterface == null)
|
||||
return;
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("JobData", true);
|
||||
npc.jobInterface.writeToNBT(compound);
|
||||
|
||||
@@ -3,10 +3,7 @@ package kamkeel.npcs.network.packets.request.jobs;
|
||||
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.PacketUtil;
|
||||
import kamkeel.npcs.network.*;
|
||||
import kamkeel.npcs.network.enums.EnumItemPacketType;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
@@ -14,6 +11,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.roles.JobInterface;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
@@ -21,8 +19,14 @@ import java.util.Set;
|
||||
public final class JobSavePacket extends AbstractPacket {
|
||||
public static String packetName = "Request|JobSave";
|
||||
|
||||
private NBTTagCompound compound;
|
||||
|
||||
public JobSavePacket() { }
|
||||
|
||||
public JobSavePacket(NBTTagCompound compound) {
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumRequestPacket.JobSave;
|
||||
@@ -45,12 +49,18 @@ public final class JobSavePacket extends AbstractPacket {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException { }
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
ByteBufUtils.writeNBT(out, this.compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP)) return;
|
||||
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return;
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player))
|
||||
return;
|
||||
|
||||
NBTTagCompound original = npc.jobInterface.writeToNBT(new NBTTagCompound());
|
||||
NBTTagCompound compound = ByteBufUtils.readNBT(in);
|
||||
Set<String> names = compound.func_150296_c();
|
||||
@@ -60,4 +70,8 @@ public final class JobSavePacket extends AbstractPacket {
|
||||
npc.jobInterface.readFromNBT(original);
|
||||
npc.updateClient = true;
|
||||
}
|
||||
|
||||
public static void saveJob(JobInterface job){
|
||||
PacketClient.sendClient(new JobSavePacket(job.writeToNBT(new NBTTagCompound())));
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,29 @@ import java.io.IOException;
|
||||
public final class JobSpawnerAddPacket extends AbstractPacket {
|
||||
public static String packetName = "Request|JobSpawnerAdd";
|
||||
|
||||
private boolean isServer;
|
||||
|
||||
private String selected;
|
||||
private int activeTab;
|
||||
private int slot;
|
||||
|
||||
private NBTTagCompound compound;
|
||||
|
||||
public JobSpawnerAddPacket() { }
|
||||
|
||||
public JobSpawnerAddPacket(boolean isServer, String selected, int activeTab, int slot) {
|
||||
this.isServer = isServer;
|
||||
this.selected = selected;
|
||||
this.activeTab = activeTab;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public JobSpawnerAddPacket(boolean isServer, int slot, NBTTagCompound compound) {
|
||||
this.isServer = isServer;
|
||||
this.slot = slot;
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumRequestPacket.JobSpawnerAdd;
|
||||
@@ -48,13 +69,29 @@ public final class JobSpawnerAddPacket extends AbstractPacket {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException { }
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeBoolean(this.isServer);
|
||||
if(this.isServer){
|
||||
ByteBufUtils.writeString(out, selected);
|
||||
out.writeInt(this.activeTab);
|
||||
out.writeInt(this.slot);
|
||||
} else {
|
||||
out.writeInt(this.slot);
|
||||
ByteBufUtils.writeNBT(out, this.compound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP)) return;
|
||||
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return;
|
||||
if(npc.advanced.job != EnumJobType.Spawner) return;
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player))
|
||||
return;
|
||||
|
||||
if(npc.advanced.job != EnumJobType.Spawner)
|
||||
return;
|
||||
|
||||
JobSpawner job = (JobSpawner) npc.jobInterface;
|
||||
boolean useServerClone = in.readBoolean();
|
||||
if(useServerClone){
|
||||
@@ -63,6 +100,7 @@ public final class JobSpawnerAddPacket extends AbstractPacket {
|
||||
} else {
|
||||
job.setJobCompound(in.readInt(), ByteBufUtils.readNBT(in));
|
||||
}
|
||||
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, job.getTitles());
|
||||
}
|
||||
}
|
||||
+19
-5
@@ -21,7 +21,13 @@ import java.io.IOException;
|
||||
public final class JobSpawnerRemovePacket extends AbstractPacket {
|
||||
public static String packetName = "Request|JobSpawnerRemove";
|
||||
|
||||
public JobSpawnerRemovePacket() { }
|
||||
private int slot;
|
||||
|
||||
public JobSpawnerRemovePacket(){}
|
||||
|
||||
public JobSpawnerRemovePacket(int slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
@@ -45,13 +51,21 @@ public final class JobSpawnerRemovePacket extends AbstractPacket {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException { }
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(this.slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP)) return;
|
||||
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player)) return;
|
||||
if(npc.advanced.job != EnumJobType.Spawner) return;
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if (!PacketUtil.verifyItemPacket(EnumItemPacketType.WAND, player))
|
||||
return;
|
||||
|
||||
if(npc.advanced.job != EnumJobType.Spawner)
|
||||
return;
|
||||
|
||||
JobSpawner job = (JobSpawner) npc.jobInterface;
|
||||
job.setJobCompound(in.readInt(), null);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, job.getTitles());
|
||||
|
||||
@@ -456,57 +456,12 @@ public class PacketHandlerServer{
|
||||
NoppesUtilServer.setEditingQuest(player,quest);
|
||||
player.openGui(CustomNpcs.instance, gui , player.worldObj, 0, 0, 0);
|
||||
}
|
||||
else if(type == EnumPacketServer.JobSave){
|
||||
NBTTagCompound original = npc.jobInterface.writeToNBT(new NBTTagCompound());
|
||||
NBTTagCompound compound = ByteBufUtils.readNBT(buffer);
|
||||
Set<String> names = compound.func_150296_c();
|
||||
for(String name : names)
|
||||
original.setTag(name, compound.getTag(name));
|
||||
npc.jobInterface.readFromNBT(original);
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.JobGet){
|
||||
if(npc.jobInterface == null)
|
||||
return;
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("JobData", true);
|
||||
npc.jobInterface.writeToNBT(compound);
|
||||
|
||||
if(npc.advanced.job == EnumJobType.Spawner)
|
||||
((JobSpawner)npc.jobInterface).cleanCompound(compound);
|
||||
|
||||
GuiDataPacket.sendGuiData(player, compound);
|
||||
|
||||
if(npc.advanced.job == EnumJobType.Spawner)
|
||||
GuiDataPacket.sendGuiData(player, ((JobSpawner)npc.jobInterface).getTitles());
|
||||
}
|
||||
else if(type == EnumPacketServer.JobSpawnerAdd){
|
||||
if(npc.advanced.job != EnumJobType.Spawner)
|
||||
return;
|
||||
JobSpawner job = (JobSpawner) npc.jobInterface;
|
||||
if(buffer.readBoolean()){
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(null, ByteBufUtils.readString(buffer), buffer.readInt());
|
||||
|
||||
job.setJobCompound(buffer.readInt(), compound);
|
||||
}
|
||||
else{
|
||||
job.setJobCompound(buffer.readInt(), ByteBufUtils.readNBT(buffer));
|
||||
}
|
||||
GuiDataPacket.sendGuiData(player, job.getTitles());
|
||||
}
|
||||
else if(type == EnumPacketServer.RoleCompanionUpdate){
|
||||
if(npc.advanced.role != EnumRoleType.Companion)
|
||||
return;
|
||||
((RoleCompanion)npc.roleInterface).matureTo(EnumCompanionStage.values()[buffer.readInt()]);
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.JobSpawnerRemove){
|
||||
if(npc.advanced.job != EnumJobType.Spawner)
|
||||
return;
|
||||
JobSpawner job = (JobSpawner) npc.jobInterface;
|
||||
job.setJobCompound(buffer.readInt(), null);
|
||||
GuiDataPacket.sendGuiData(player, job.getTitles());
|
||||
}
|
||||
else if(type == EnumPacketServer.RoleSave){
|
||||
npc.roleInterface.readFromNBT(ByteBufUtils.readNBT(buffer));
|
||||
npc.updateClient = true;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.client.gui.mainmenu;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
@@ -69,7 +70,7 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData
|
||||
}
|
||||
if(button.id == 4){
|
||||
save();
|
||||
Client.sendData(EnumPacketServer.JobGet);
|
||||
PacketClient.sendClient(new JobGetPacket());
|
||||
}
|
||||
if(button.id == 5){
|
||||
hasChanges = true;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package noppes.npcs.client.gui.roles;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
@@ -90,7 +92,7 @@ public class GuiNpcBard extends GuiNPCInterface2 implements ISubGuiListener
|
||||
job.maxRange = job.minRange;
|
||||
|
||||
MusicController.Instance.stopAllSounds();
|
||||
Client.sendData(EnumPacketServer.JobSave, job.writeToNBT(new NBTTagCompound()));
|
||||
JobSavePacket.saveJob(job);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.client.gui.roles;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
@@ -109,7 +110,7 @@ public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldLi
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
Client.sendData(EnumPacketServer.JobSave, job.writeToNBT(new NBTTagCompound()));
|
||||
JobSavePacket.saveJob(job);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.client.gui.roles;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobSavePacket;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
@@ -11,12 +12,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiNpcFollowerJob extends GuiNPCInterface2 implements ICustomScrollListener
|
||||
{
|
||||
{
|
||||
private JobFollower job;
|
||||
private GuiCustomScroll scroll;
|
||||
public GuiNpcFollowerJob(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
super(npc);
|
||||
job = (JobFollower) npc.jobInterface;
|
||||
}
|
||||
|
||||
@@ -32,7 +33,7 @@ public class GuiNpcFollowerJob extends GuiNPCInterface2 implements ICustomScroll
|
||||
scroll.guiLeft = guiLeft + 268;
|
||||
scroll.guiTop = guiTop + 4;
|
||||
this.addScroll(scroll);
|
||||
|
||||
|
||||
List<String> names = new ArrayList<String>();
|
||||
List<EntityNPCInterface> list = npc.worldObj.getEntitiesWithinAABB(EntityNPCInterface.class, npc.boundingBox.expand(40, 40, 40));
|
||||
for(EntityNPCInterface npc : list){
|
||||
@@ -46,7 +47,7 @@ public class GuiNpcFollowerJob extends GuiNPCInterface2 implements ICustomScroll
|
||||
@Override
|
||||
public void save() {
|
||||
job.name = getTextField(1).getText();
|
||||
Client.sendData(EnumPacketServer.JobSave, job.writeToNBT(new NBTTagCompound()));
|
||||
JobSavePacket.saveJob(job);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.client.gui.roles;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -16,13 +17,13 @@ import noppes.npcs.roles.JobGuard;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiNpcGuard extends GuiNPCInterface2{
|
||||
public class GuiNpcGuard extends GuiNPCInterface2{
|
||||
private JobGuard role;
|
||||
private GuiCustomScroll scroll1;
|
||||
private GuiCustomScroll scroll2;
|
||||
|
||||
|
||||
public GuiNpcGuard(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
super(npc);
|
||||
role = (JobGuard) npc.jobInterface;
|
||||
}
|
||||
|
||||
@@ -37,10 +38,10 @@ public class GuiNpcGuard extends GuiNPCInterface2{
|
||||
this.addLabel(new GuiNpcLabel(2, "guard.creepers", guiLeft + 275, guiTop + 9));
|
||||
this.addButton(new GuiNpcButton(2, guiLeft + 360, guiTop + 4, 50, 20, new String[]{"gui.no", "gui.yes"},role.attackCreepers?1:0));
|
||||
getButton(2).enabled = role.attackHostileMobs;
|
||||
|
||||
|
||||
this.addLabel(new GuiNpcLabel(3, "guard.specifictargets", guiLeft + 10, guiTop + 31));
|
||||
this.addButton(new GuiNpcButton(3, guiLeft + 85, guiTop + 26, 50, 20, new String[]{"gui.no", "gui.yes"},role.specific?1:0));
|
||||
|
||||
this.addButton(new GuiNpcButton(3, guiLeft + 85, guiTop + 26, 50, 20, new String[]{"gui.no", "gui.yes"},role.specific?1:0));
|
||||
|
||||
if(role.specific){
|
||||
if(scroll1 == null){
|
||||
scroll1 = new GuiCustomScroll(this,0);
|
||||
@@ -50,7 +51,7 @@ public class GuiNpcGuard extends GuiNPCInterface2{
|
||||
scroll1.guiTop = guiTop + 58;
|
||||
this.addScroll(scroll1);
|
||||
addLabel(new GuiNpcLabel(11, "guard.availableTargets", guiLeft + 4, guiTop + 48));
|
||||
|
||||
|
||||
if(scroll2 == null){
|
||||
scroll2 = new GuiCustomScroll(this,1);
|
||||
scroll2.setSize(175, 154);
|
||||
@@ -59,7 +60,7 @@ public class GuiNpcGuard extends GuiNPCInterface2{
|
||||
scroll2.guiTop = guiTop + 58;
|
||||
this.addScroll(scroll2);
|
||||
addLabel(new GuiNpcLabel(12, "guard.currentTargets", guiLeft + 235, guiTop + 48));
|
||||
|
||||
|
||||
List<String> all = new ArrayList<String>();
|
||||
for(Object entity : EntityList.stringToClassMapping.keySet()){
|
||||
String name = "entity." + entity + ".name";
|
||||
@@ -71,11 +72,11 @@ public class GuiNpcGuard extends GuiNPCInterface2{
|
||||
}
|
||||
scroll1.setList(all);
|
||||
scroll2.setList(role.targets);
|
||||
|
||||
|
||||
|
||||
|
||||
addButton(new GuiNpcButton(11, guiLeft + 180, guiTop + 80, 55, 20, ">"));
|
||||
addButton(new GuiNpcButton(12, guiLeft + 180, guiTop + 102, 55, 20, "<"));
|
||||
|
||||
|
||||
addButton(new GuiNpcButton(13, guiLeft + 180, guiTop + 130, 55, 20, ">>"));
|
||||
addButton(new GuiNpcButton(14, guiLeft + 180, guiTop + 152, 55, 20, "<<"));
|
||||
}
|
||||
@@ -92,11 +93,11 @@ public class GuiNpcGuard extends GuiNPCInterface2{
|
||||
}
|
||||
if(button.id == 2){
|
||||
role.attackCreepers = button.getValue()==1;
|
||||
}
|
||||
}
|
||||
if(button.id == 3){
|
||||
role.specific = button.getValue()==1;
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
if(button.id == 11){
|
||||
if(scroll1.hasSelected()){
|
||||
@@ -104,14 +105,14 @@ public class GuiNpcGuard extends GuiNPCInterface2{
|
||||
scroll1.selected = -1;
|
||||
scroll1.selected = -1;
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(button.id == 12){
|
||||
if(scroll2.hasSelected()){
|
||||
role.targets.remove(scroll2.getSelected());
|
||||
scroll2.selected = -1;
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(button.id == 13){
|
||||
role.targets.clear();
|
||||
@@ -136,7 +137,7 @@ public class GuiNpcGuard extends GuiNPCInterface2{
|
||||
}
|
||||
|
||||
public void save() {
|
||||
Client.sendData(EnumPacketServer.JobSave, role.writeToNBT(new NBTTagCompound()));
|
||||
JobSavePacket.saveJob(role);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.client.gui.roles;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobSavePacket;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
||||
@@ -10,11 +11,11 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobHealer;
|
||||
|
||||
public class GuiNpcHealer extends GuiNPCInterface2
|
||||
{
|
||||
{
|
||||
private JobHealer job;
|
||||
public GuiNpcHealer(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
super(npc);
|
||||
job = (JobHealer) npc.jobInterface;
|
||||
}
|
||||
|
||||
@@ -26,16 +27,16 @@ public class GuiNpcHealer extends GuiNPCInterface2
|
||||
addTextField(new GuiNpcTextField(1,this, this.fontRendererObj, guiLeft+130, guiTop + 105, 40, 20, job.speed + ""));
|
||||
getTextField(1).integersOnly = true;
|
||||
getTextField(1).setMinMaxDefault(1, Integer.MAX_VALUE, 8);
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(2,"Range:", guiLeft + 60, guiTop + 133));
|
||||
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+130, guiTop + 128, 40, 20, job.range + ""));
|
||||
getTextField(2).integersOnly = true;
|
||||
getTextField(2).setMinMaxDefault(2, Integer.MAX_VALUE, 5);
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void elementClicked(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +45,7 @@ public class GuiNpcHealer extends GuiNPCInterface2
|
||||
job.speed = getTextField(1).getInteger();
|
||||
job.range = getTextField(2).getInteger();
|
||||
|
||||
Client.sendData(EnumPacketServer.JobSave, job.writeToNBT(new NBTTagCompound()));
|
||||
JobSavePacket.saveJob(job);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.client.gui.roles;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
@@ -17,11 +18,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiNpcItemGiver extends GuiContainerNPCInterface2
|
||||
{
|
||||
{
|
||||
private JobItemGiver role;
|
||||
public GuiNpcItemGiver(EntityNPCInterface npc, ContainerNpcItemGiver container)
|
||||
{
|
||||
super(npc,container);
|
||||
super(npc,container);
|
||||
ySize = 200;
|
||||
role = (JobItemGiver) npc.jobInterface;
|
||||
setBackground("npcitemgiver.png");
|
||||
@@ -37,7 +38,7 @@ public class GuiNpcItemGiver extends GuiContainerNPCInterface2
|
||||
getTextField(0).integersOnly = true;
|
||||
addLabel(new GuiNpcLabel(0,"Cooldown:", guiLeft + 6, guiTop + 59));
|
||||
addLabel(new GuiNpcLabel(1,"Items to give", guiLeft + 46, guiTop + 79));
|
||||
|
||||
|
||||
getTextField(0).integersOnly = true;
|
||||
|
||||
int i = 0;
|
||||
@@ -71,7 +72,7 @@ public class GuiNpcItemGiver extends GuiContainerNPCInterface2
|
||||
if(button.id == 4){
|
||||
setSubGui(new SubGuiNpcAvailability(role.availability));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void save() {
|
||||
@@ -89,7 +90,7 @@ public class GuiNpcItemGiver extends GuiContainerNPCInterface2
|
||||
|
||||
role.cooldown = cc;
|
||||
|
||||
Client.sendData(EnumPacketServer.JobSave, role.writeToNBT(new NBTTagCompound()));
|
||||
JobSavePacket.saveJob(role);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package noppes.npcs.client.gui.roles;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobSavePacket;
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobSpawnerAddPacket;
|
||||
import kamkeel.npcs.network.packets.request.jobs.JobSpawnerRemovePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
@@ -12,9 +16,9 @@ import noppes.npcs.roles.JobSpawner;
|
||||
|
||||
|
||||
public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListener, IGuiData
|
||||
{
|
||||
{
|
||||
private JobSpawner job;
|
||||
|
||||
|
||||
private int slot = -1;
|
||||
|
||||
public String title1 = "gui.selectnpc";
|
||||
@@ -25,10 +29,10 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene
|
||||
public String title6 = "gui.selectnpc";
|
||||
public String title7 = "gui.selectnpc";
|
||||
public String title8 = "gui.selectnpc";
|
||||
|
||||
|
||||
public GuiNpcSpawner(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
super(npc);
|
||||
job = (JobSpawner) npc.jobInterface;
|
||||
}
|
||||
|
||||
@@ -66,12 +70,12 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene
|
||||
addLabel(new GuiNpcLabel(3, "4:", guiLeft + 4, y + 5));
|
||||
this.addButton(new GuiNpcButton(3, guiLeft + 45, y, 140, 20, title4));
|
||||
|
||||
y += 23;
|
||||
y += 23;
|
||||
this.addButton(new GuiNpcButton(24, guiLeft + 20, y,20,20, "X"));
|
||||
addLabel(new GuiNpcLabel(4, "5:", guiLeft + 4, y + 5));
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 45, y, 140, 20, title5));
|
||||
|
||||
y += 23;
|
||||
y += 23;
|
||||
this.addButton(new GuiNpcButton(25, guiLeft + 20, y,20,20, "X"));
|
||||
addLabel(new GuiNpcLabel(5, "6:", guiLeft + 4, y + 5));
|
||||
this.addButton(new GuiNpcButton(5, guiLeft + 45, y, 140, 20, title6));
|
||||
@@ -90,9 +94,9 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene
|
||||
addLabel(new GuiNpcLabel(9,"Z:", guiLeft + 161 + 190, y + 5));
|
||||
addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 171 + 190, y, 24, 20, job.zOffset + ""));
|
||||
getTextField(9).integersOnly = true;
|
||||
getTextField(9).setMinMaxDefault(-9, 9, 0);
|
||||
|
||||
y += 23;
|
||||
getTextField(9).setMinMaxDefault(-9, 9, 0);
|
||||
|
||||
y += 23;
|
||||
addLabel(new GuiNpcLabel(10, "spawner.type", guiLeft + 4 + 190, y + 5));
|
||||
addButton(new GuiNpcButton(10, guiLeft + 80 + 190, y, 100, 20, new String[]{"spawner.one", "spawner.all", "spawner.random", "spawner.summoner"}, job.spawnType));
|
||||
|
||||
@@ -122,15 +126,15 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton){
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
if(button.id >= 0 && button.id < 6){
|
||||
slot = button.id + 1;
|
||||
setSubGui(new GuiNpcMobSpawnerSelector());
|
||||
}
|
||||
}
|
||||
if(button.id >= 20 && button.id < 26){
|
||||
int removeID = button.id - 19;
|
||||
job.setJobCompound(removeID, null);
|
||||
Client.sendData(EnumPacketServer.JobSpawnerRemove, button.id - 19);
|
||||
PacketClient.sendClient(new JobSpawnerRemovePacket(button.id - 19));
|
||||
}
|
||||
if(button.id == 26){
|
||||
job.doesntDie = button.getValue() == 1;
|
||||
@@ -182,13 +186,13 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene
|
||||
if(selector.isServer){
|
||||
String selected = selector.getSelected();
|
||||
if(selected != null)
|
||||
Client.sendData(EnumPacketServer.JobSpawnerAdd, selector.isServer, selected, selector.activeTab, slot);
|
||||
PacketClient.sendClient(new JobSpawnerAddPacket(selector.isServer, selected, selector.activeTab, slot));
|
||||
}
|
||||
else{
|
||||
NBTTagCompound compound = selector.getCompound();
|
||||
if(compound != null){
|
||||
job.setJobCompound(slot, compound);
|
||||
Client.sendData(EnumPacketServer.JobSpawnerAdd, selector.isServer, slot, compound);
|
||||
job.setJobCompound(slot, compound);
|
||||
PacketClient.sendClient(new JobSpawnerAddPacket(selector.isServer, slot, compound));
|
||||
}
|
||||
}
|
||||
initGui();
|
||||
@@ -198,7 +202,7 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene
|
||||
public void save() {
|
||||
NBTTagCompound compound = job.writeToNBT(new NBTTagCompound());
|
||||
job.cleanCompound(compound);
|
||||
Client.sendData(EnumPacketServer.JobSave, compound);
|
||||
PacketClient.sendClient(new JobSavePacket(compound));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,9 +14,9 @@ public enum EnumPacketServer {
|
||||
TransformSave(CustomNpcsPermissions.NPC_ADVANCED, true), TransformGet(true),
|
||||
TransformLoad(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
TraderMarketSave(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
JobSave(CustomNpcsPermissions.NPC_ADVANCED, true), JobGet(true),
|
||||
RoleSave(CustomNpcsPermissions.NPC_ADVANCED, true), RoleGet(true),
|
||||
JobSpawnerAdd(CustomNpcsPermissions.NPC_ADVANCED, true), JobSpawnerRemove(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
|
||||
RoleSave(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
RoleGet(true),
|
||||
RoleCompanionUpdate(CustomNpcsPermissions.NPC_ADVANCED, true),
|
||||
|
||||
ClonePreSave(CustomNpcsPermissions.NPC_CLONE), CloneSave(CustomNpcsPermissions.NPC_CLONE), CloneRemove(CustomNpcsPermissions.NPC_CLONE), CloneList, CloneTagList, CloneAllTags, CloneAllTagsShort,
|
||||
|
||||
Reference in new issue
Block a user