mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 04:59:05 +00:00
MORE SWAPPING
This commit is contained in:
1 parent
4f5f870e2b
commit
e8c3fc4d0a
14 files changed
+86
-67
No files matched your search
@@ -2,6 +2,8 @@ package kamkeel.npcs.network;
|
||||
|
||||
import kamkeel.npcs.network.packets.client.ChatAlertPacket;
|
||||
import kamkeel.npcs.network.packets.client.AchievementPacket;
|
||||
import kamkeel.npcs.network.packets.client.QuestCompletionPacket;
|
||||
import kamkeel.npcs.network.packets.client.ScrollSelectedPacket;
|
||||
import kamkeel.npcs.network.packets.client.gui.GuiClosePacket;
|
||||
import kamkeel.npcs.network.packets.client.large.LargeGuiDataPacket;
|
||||
import kamkeel.npcs.network.packets.client.gui.GuiErrorPacket;
|
||||
@@ -62,4 +64,14 @@ public class PacketUtil {
|
||||
LargeGuiDataPacket packet = new LargeGuiDataPacket(compound);
|
||||
PacketHandler.Instance.sendToPlayer(packet, playerMP);
|
||||
}
|
||||
|
||||
public static void sendQuestComplete(EntityPlayerMP playerMP, NBTTagCompound compound){
|
||||
QuestCompletionPacket packet = new QuestCompletionPacket(compound);
|
||||
PacketHandler.Instance.sendToPlayer(packet, playerMP);
|
||||
}
|
||||
|
||||
public static void setSelectedList(EntityPlayerMP playerMP, String item){
|
||||
ScrollSelectedPacket packet = new ScrollSelectedPacket(item);
|
||||
PacketHandler.Instance.sendToPlayer(packet, playerMP);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -20,8 +21,16 @@ import java.io.IOException;
|
||||
public final class MarkDataPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|MarkData";
|
||||
|
||||
private int entityID;
|
||||
private NBTTagCompound compound;
|
||||
|
||||
public MarkDataPacket() {}
|
||||
|
||||
public MarkDataPacket(int entityID, NBTTagCompound compound) {
|
||||
this.entityID = entityID;
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.MARK_DATA;
|
||||
@@ -34,7 +43,8 @@ public final class MarkDataPacket extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
out.writeInt(this.entityID);
|
||||
ByteBufUtils.writeNBT(out, this.compound);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -44,7 +54,7 @@ public final class MarkDataPacket extends AbstractPacket {
|
||||
if (!(entity instanceof EntityNPCInterface)) return;
|
||||
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
NBTTagCompound nbt = Server.readNBT(in);
|
||||
NBTTagCompound nbt = ByteBufUtils.readNBT(in);
|
||||
MarkData data = MarkData.get(npc);
|
||||
data.setNBT(nbt);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -20,8 +21,14 @@ import java.io.IOException;
|
||||
public final class OverlayQuestTrackingPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|OverlayQuestTracking";
|
||||
|
||||
private NBTTagCompound compound;
|
||||
|
||||
public OverlayQuestTrackingPacket() {}
|
||||
|
||||
public OverlayQuestTrackingPacket(NBTTagCompound compound) {
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.OVERLAY_QUEST_TRACKING;
|
||||
@@ -34,7 +41,7 @@ public final class OverlayQuestTrackingPacket extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
ByteBufUtils.writeNBT(out, compound);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -7,7 +7,9 @@ import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
@@ -17,8 +19,14 @@ import java.io.IOException;
|
||||
public final class QuestCompletionPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|QuestCompletion";
|
||||
|
||||
private NBTTagCompound compound;
|
||||
|
||||
public QuestCompletionPacket() {}
|
||||
|
||||
public QuestCompletionPacket(NBTTagCompound compound) {
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.QUEST_COMPLETION;
|
||||
@@ -31,12 +39,12 @@ public final class QuestCompletionPacket extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
ByteBufUtils.writeNBT(out, this.compound);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
NoppesUtil.guiQuestCompletion(player, Server.readNBT(in));
|
||||
NoppesUtil.guiQuestCompletion(player, ByteBufUtils.readNBT(in));
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -19,8 +20,14 @@ import java.io.IOException;
|
||||
public final class ScrollSelectedPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|ScrollSelected";
|
||||
|
||||
private String selected;
|
||||
|
||||
public ScrollSelectedPacket() {}
|
||||
|
||||
public ScrollSelectedPacket(String selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.SCROLL_SELECTED;
|
||||
@@ -33,7 +40,7 @@ public final class ScrollSelectedPacket extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
ByteBufUtils.writeString(out, this.selected);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -29,9 +29,7 @@ public final class SwingPlayerArmPacket extends AbstractPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
}
|
||||
public void sendData(ByteBuf out) throws IOException {}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumClientPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
@@ -18,8 +19,14 @@ import java.io.IOException;
|
||||
public final class VillagerListPacket extends AbstractPacket {
|
||||
public static final String packetName = "Client|VillagerList";
|
||||
|
||||
private MerchantRecipeList merchantrecipelist;
|
||||
|
||||
public VillagerListPacket() {}
|
||||
|
||||
public VillagerListPacket(MerchantRecipeList merchantrecipelist) {
|
||||
this.merchantrecipelist = merchantrecipelist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumClientPacket.VILLAGER_LIST;
|
||||
@@ -32,7 +39,7 @@ public final class VillagerListPacket extends AbstractPacket {
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
// TODO: Send Packet
|
||||
ByteBufUtils.fillBuffer(out, merchantrecipelist);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -630,7 +630,7 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
|
||||
playerData.save();
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound()));
|
||||
PacketUtil.sendQuestComplete((EntityPlayerMP)player, data.quest.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(quest.type == EnumQuestType.Item && partyOptions.objectiveRequirement == EnumPartyObjectives.Shared){
|
||||
|
||||
@@ -5,6 +5,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import kamkeel.npcs.controllers.SyncController;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import kamkeel.npcs.network.enums.EnumSoundOperation;
|
||||
import kamkeel.npcs.network.enums.EnumSyncAction;
|
||||
import kamkeel.npcs.network.enums.EnumSyncType;
|
||||
@@ -110,8 +111,8 @@ public class ServerEventsHandler {
|
||||
return;
|
||||
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface)event.target);
|
||||
event.setCanceled(true);
|
||||
Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.GUI, EnumGuiType.Script.ordinal());
|
||||
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
|
||||
PacketUtil.openGUI((EntityPlayerMP)event.entityPlayer, EnumGuiType.Script, 0, 0, 0);
|
||||
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
|
||||
LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "SCRIPTER", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface)(event.target)).display.getName(), (int)(event.target).posX, (int)(event.target).posY, (int)(event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package noppes.npcs.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -25,29 +27,29 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockMailbox extends BlockContainer{
|
||||
|
||||
|
||||
public int renderId = -1;
|
||||
|
||||
public BlockMailbox() {
|
||||
super(Material.iron);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
par3List.add(new ItemStack(par1, 1, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
if(!par1World.isRemote){
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI, EnumGuiType.PlayerMailbox, i, j, k);
|
||||
PacketUtil.openGUI((EntityPlayerMP)player, EnumGuiType.PlayerMailbox, i, j, k);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
|
||||
{
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
@@ -56,40 +58,40 @@ public class BlockMailbox extends BlockContainer{
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int damageDropped(int par1)
|
||||
{
|
||||
return par1 >> 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
l %= 4;
|
||||
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, l | par6ItemStack.getItemDamage() << 2, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isOpaqueCube(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean renderAsNormalBlock(){
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@Override
|
||||
public int getRenderType(){
|
||||
return renderId;
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_)
|
||||
|
||||
@@ -48,37 +48,6 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
MarkData data = MarkData.get((EntityNPCInterface) entity);
|
||||
data.setNBT(Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketClient.QUEST_COMPLETION){
|
||||
NoppesUtil.guiQuestCompletion(player, Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketClient.UPDATE_NPC){
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(compound.getInteger("EntityId"));
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
((EntityNPCInterface)entity).readSpawnData(compound);
|
||||
}
|
||||
else if(type == EnumPacketClient.ROLE){
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(compound.getInteger("EntityId"));
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
((EntityNPCInterface)entity).advanced.setRole(compound.getInteger("Role"));
|
||||
((EntityNPCInterface)entity).roleInterface.readFromNBT(compound);
|
||||
NoppesUtil.setLastNpc((EntityNPCInterface) entity);
|
||||
}
|
||||
else if(type == EnumPacketClient.GUI){
|
||||
EnumGuiType gui = EnumGuiType.values()[buffer.readInt()];
|
||||
CustomNpcs.proxy.openGui(NoppesUtil.getLastNpc(), gui, buffer.readInt(), buffer.readInt(), buffer.readInt());
|
||||
}
|
||||
else if(type == EnumPacketClient.SCROLL_SELECTED){
|
||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
||||
if(gui == null || !(gui instanceof IScrollData))
|
||||
return;
|
||||
String selected = Server.readString(buffer);
|
||||
|
||||
((IScrollData)gui).setSelected(selected);
|
||||
}
|
||||
else if(type == EnumPacketClient.GUI_REDSTONE){
|
||||
NoppesUtil.saveRedstoneBlock(player, Server.readNBT(buffer));
|
||||
}
|
||||
|
||||
@@ -2,11 +2,6 @@ package
|
||||
noppes.npcs.constants;
|
||||
|
||||
public enum EnumPacketClient {
|
||||
QUEST_COMPLETION,
|
||||
UPDATE_NPC,
|
||||
ROLE,
|
||||
GUI,
|
||||
SCROLL_SELECTED,
|
||||
GUI_REDSTONE,
|
||||
GUI_WAYPOINT,
|
||||
GUI_DATA,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -139,7 +140,7 @@ public class Quest implements ICompatibilty, IQuest {
|
||||
|
||||
public boolean instantComplete(EntityPlayer player, QuestData data) {
|
||||
if(completion == EnumQuestCompletion.Instant && NoppesUtilPlayer.questCompletion((EntityPlayerMP) player, data.quest.id)){
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound()));
|
||||
PacketUtil.sendQuestComplete((EntityPlayerMP)player, data.quest.writeToNBT(new NBTTagCompound()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -8,9 +8,11 @@ import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.addon.DBCAddon;
|
||||
import kamkeel.npcs.addon.client.DBCClient;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import kamkeel.npcs.network.enums.EnumSoundOperation;
|
||||
import kamkeel.npcs.network.packets.client.ChatBubblePacket;
|
||||
import kamkeel.npcs.network.packets.client.SoundManagementPacket;
|
||||
import kamkeel.npcs.network.packets.client.npc.UpdateNpcPacket;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -411,8 +413,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
public void updateClient() {
|
||||
NBTTagCompound compound = writeSpawnData();
|
||||
compound.setInteger("EntityId", getEntityId());
|
||||
Server.sendAssociatedData(this, EnumPacketClient.UPDATE_NPC, compound);
|
||||
updateClient = false;
|
||||
PacketHandler.Instance.sendTracking(new UpdateNpcPacket(compound), this);
|
||||
updateClient = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -452,7 +454,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
}
|
||||
else if (data != null){
|
||||
NoppesUtilPlayer.questCompletion((EntityPlayerMP) player, data.quest.id);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound()));
|
||||
PacketUtil.sendQuestComplete((EntityPlayerMP)player, data.quest.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if (dialog != null){
|
||||
NoppesUtilServer.openDialog(player, this, dialog, 0);
|
||||
|
||||
Reference in new issue
Block a user