mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 14:39:43 +00:00
Merge remote-tracking branch 'refs/remotes/origin/packet' into animation-events-2
# Conflicts: # src/api # src/main/java/noppes/npcs/CommonProxy.java # src/main/java/noppes/npcs/ServerEventsHandler.java # src/main/java/noppes/npcs/client/PacketHandlerClient.java # src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java # src/main/java/noppes/npcs/controllers/data/AnimationData.java
This commit is contained in:
commit
00af353e65
602 files changed
+29702
-6562
No files matched your search
@@ -40,9 +40,6 @@ public class CommonProxy implements IGuiHandler {
|
||||
|
||||
public void load() {
|
||||
this.createAnimationThread();
|
||||
|
||||
CustomNpcs.Channel.register(new PacketHandlerServer());
|
||||
CustomNpcs.ChannelPlayer.register(new PacketHandlerPlayer());
|
||||
}
|
||||
|
||||
protected void createAnimationThread() {
|
||||
@@ -163,9 +160,12 @@ public class CommonProxy implements IGuiHandler {
|
||||
if(gui == EnumGuiType.PlayerTrader)
|
||||
return new ContainerNPCTrader(npc, player);
|
||||
|
||||
if(gui == EnumGuiType.PlayerAnvil)
|
||||
if(gui == EnumGuiType.PlayerCarpentryBench)
|
||||
return new ContainerCarpentryBench(player.inventory, player.worldObj, x, y, z);
|
||||
|
||||
if(gui == EnumGuiType.PlayerAnvil)
|
||||
return new ContainerAnvilRepair(player.inventory, player.worldObj, x, y, z);
|
||||
|
||||
if(gui == EnumGuiType.SetupItemGiver)
|
||||
return new ContainerNpcItemGiver(npc, player);
|
||||
|
||||
@@ -204,16 +204,16 @@ public class CommonProxy implements IGuiHandler {
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void openGui(EntityNPCInterface npc, EnumGuiType gui) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void openGui(EntityNPCInterface npc, EnumGuiType gui, int x, int y, int z) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -222,12 +222,12 @@ public class CommonProxy implements IGuiHandler {
|
||||
}
|
||||
|
||||
public void openGui(EntityPlayer player, Object guiscreen) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void spawnParticle(EntityLivingBase player, String string, Object... ob) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -242,7 +242,7 @@ public class CommonProxy implements IGuiHandler {
|
||||
}
|
||||
|
||||
public void registerItem(Item item) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -255,7 +255,11 @@ public class CommonProxy implements IGuiHandler {
|
||||
|
||||
}
|
||||
|
||||
public String getAchievementDesc(Achievement achievement) {
|
||||
public void generateBigSmokeParticles(World world, int x, int y, int z, boolean signalFire){
|
||||
|
||||
}
|
||||
|
||||
public String getAchievementDesc(Achievement achievement) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +123,11 @@ public class CustomItems {
|
||||
public static Item spellDark;
|
||||
public static Item spellHoly;
|
||||
|
||||
public static Item earthElement;
|
||||
public static Item fireElement;
|
||||
public static Item waterElement;
|
||||
public static Item airElement;
|
||||
|
||||
public static Item staffWood;
|
||||
public static Item staffStone;
|
||||
public static Item staffIron;
|
||||
@@ -743,10 +748,10 @@ public class CustomItems {
|
||||
|
||||
quest = new ItemNpcArmor(26957,ArmorMaterial.IRON,0,"mask").setMaxStackSize(64).setUnlocalizedName("npcBanditMask").setCreativeTab(CustomItems.tabArmor).setTextureName("customnpcs:npcBanditMask");
|
||||
quest = new ItemNpcInterface(26958).setUnlocalizedName("npcBrokenArrow").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBrokenArrow");
|
||||
quest = new ItemNpcInterface(26959).setUnlocalizedName("npcEarthElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcEarthElement");
|
||||
quest = new ItemNpcInterface(26960).setUnlocalizedName("npcWaterElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcWaterElement");
|
||||
quest = new ItemNpcInterface(26961).setUnlocalizedName("npcFireElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcFireElement");
|
||||
quest = new ItemNpcInterface(26962).setUnlocalizedName("npcAirElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAirElement");
|
||||
earthElement = new ItemNpcInterface(26959).setUnlocalizedName("npcEarthElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcEarthElement");
|
||||
waterElement = new ItemNpcInterface(26960).setUnlocalizedName("npcWaterElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcWaterElement");
|
||||
fireElement = new ItemNpcInterface(26961).setUnlocalizedName("npcFireElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcFireElement");
|
||||
airElement = new ItemNpcInterface(26962).setUnlocalizedName("npcAirElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAirElement");
|
||||
|
||||
quest = new ItemNpcInterface(26963).setUnlocalizedName("npcCarKey").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCarKey");
|
||||
quest = new ItemNpcInterface(26964).setUnlocalizedName("npcKey").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcKey");
|
||||
|
||||
@@ -8,10 +8,15 @@ import cpw.mods.fml.common.event.*;
|
||||
import cpw.mods.fml.common.network.FMLEventChannel;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import foxz.command.CommandNoppes;
|
||||
import kamkeel.addon.AddonManager;
|
||||
import kamkeel.command.CommandKamkeel;
|
||||
import kamkeel.developer.Developer;
|
||||
import kamkeel.npcs.addon.AddonManager;
|
||||
import kamkeel.npcs.command.CommandKamkeel;
|
||||
import kamkeel.npcs.command.profile.CommandProfile;
|
||||
import kamkeel.npcs.controllers.ProfileController;
|
||||
import kamkeel.npcs.controllers.data.CNPCData;
|
||||
import kamkeel.npcs.developer.Developer;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockIce;
|
||||
import net.minecraft.block.BlockLeavesBase;
|
||||
@@ -50,9 +55,6 @@ public class CustomNpcs {
|
||||
|
||||
public static boolean FreezeNPCs = false;
|
||||
|
||||
public static FMLEventChannel Channel;
|
||||
public static FMLEventChannel ChannelPlayer;
|
||||
|
||||
public static final MarkovGenerator[] MARKOV_GENERATOR = new MarkovGenerator[10];
|
||||
|
||||
public static boolean InitIgnore = false;
|
||||
@@ -82,8 +84,7 @@ public class CustomNpcs {
|
||||
|
||||
@EventHandler
|
||||
public void load(FMLPreInitializationEvent ev) {
|
||||
Channel = NetworkRegistry.INSTANCE.newEventDrivenChannel("CustomNPCs");
|
||||
ChannelPlayer = NetworkRegistry.INSTANCE.newEventDrivenChannel("CustomNPCsPlayer");
|
||||
PacketHandler.Instance = new PacketHandler();
|
||||
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
String dir = "";
|
||||
@@ -190,6 +191,7 @@ public class CustomNpcs {
|
||||
MARKOV_GENERATOR[8] = new MarkovCustomNPCsClassic(3);
|
||||
MARKOV_GENERATOR[9] = new MarkovSpanish(3);
|
||||
|
||||
PacketHandler.Instance.registerChannels();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -198,6 +200,8 @@ public class CustomNpcs {
|
||||
ChunkController.Instance.clear();
|
||||
FactionController.getInstance().load();
|
||||
// VisibilityController.instance = new VisibilityController();
|
||||
new MagicController();
|
||||
MagicController.getInstance().load();
|
||||
new PlayerDataController();
|
||||
new TagController();
|
||||
new TransportController();
|
||||
@@ -205,6 +209,11 @@ public class CustomNpcs {
|
||||
new SpawnController();
|
||||
new LinkedNpcController();
|
||||
new AnimationController();
|
||||
|
||||
// Profile Controller
|
||||
new ProfileController();
|
||||
ProfileController.registerProfileType(new CNPCData());
|
||||
|
||||
ScriptController.Instance.loadStoredData();
|
||||
ScriptController.Instance.loadForgeScripts();
|
||||
ScriptController.Instance.loadGlobalNPCScripts();
|
||||
@@ -240,6 +249,7 @@ public class CustomNpcs {
|
||||
ServerTagMapController.Instance = new ServerTagMapController();
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void stopped(FMLServerStoppedEvent event){
|
||||
ServerCloneController.Instance = null;
|
||||
@@ -253,6 +263,7 @@ public class CustomNpcs {
|
||||
public void serverstart(FMLServerStartingEvent event) {
|
||||
event.registerServerCommand(new CommandNoppes());
|
||||
event.registerServerCommand(new CommandKamkeel());
|
||||
event.registerServerCommand(new CommandProfile());
|
||||
}
|
||||
|
||||
private void registerNpc(Class<? extends Entity> cl, String name) {
|
||||
@@ -309,4 +320,8 @@ public class CustomNpcs {
|
||||
public static MinecraftServer getServer(){
|
||||
return MinecraftServer.getServer();
|
||||
}
|
||||
|
||||
public static Side side() {
|
||||
return FMLCommonHandler.instance().getEffectiveSide();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package noppes.npcs;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import kamkeel.developer.Developer;
|
||||
import kamkeel.npcs.developer.Developer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
@@ -24,14 +24,14 @@ public class DataInventory implements IInventory {
|
||||
public HashMap<Integer,ItemStack> weapons = new HashMap<Integer, ItemStack>();
|
||||
public HashMap<Integer,ItemStack> prevWeapons = new HashMap<Integer, ItemStack>();
|
||||
public HashMap<Integer,ItemStack> armor = new HashMap<Integer, ItemStack>();
|
||||
|
||||
|
||||
public int minExp = 0;
|
||||
public int maxExp = 0;
|
||||
|
||||
|
||||
public int lootMode = 0;
|
||||
|
||||
|
||||
private EntityNPCInterface npc;
|
||||
|
||||
|
||||
public DataInventory(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public class DataInventory implements IInventory {
|
||||
nbttagcompound.setTag("Weapons", NBTTags.nbtItemStackList(getWeapons()));
|
||||
nbttagcompound.setTag("DoubleDropChance", NBTTags.nbtIntegerDoubleMap(dropchance));
|
||||
nbttagcompound.setInteger("LootMode", lootMode);
|
||||
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
public void readEntityFromNBT(NBTTagCompound nbttagcompound){
|
||||
@@ -187,7 +187,7 @@ public class DataInventory implements IInventory {
|
||||
npc.worldObj.spawnEntityInWorld(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public EntityItem getEntityItem(ItemStack itemstack) {
|
||||
if (itemstack == null) {
|
||||
return null;
|
||||
@@ -205,13 +205,13 @@ public class DataInventory implements IInventory {
|
||||
|
||||
return entityitem;
|
||||
}
|
||||
|
||||
|
||||
public ItemStack armorItemInSlot(int i) {
|
||||
return getArmor().get(i);
|
||||
}
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
return 15;
|
||||
}
|
||||
@Override
|
||||
@@ -243,7 +243,7 @@ public class DataInventory implements IInventory {
|
||||
var3 = getArmor();
|
||||
i = 2;
|
||||
}
|
||||
|
||||
|
||||
ItemStack var4 = null;
|
||||
if (var3.get(par1) != null)
|
||||
{
|
||||
@@ -355,17 +355,17 @@ public class DataInventory implements IInventory {
|
||||
}
|
||||
@Override
|
||||
public void markDirty() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void openInventory() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -81,10 +81,10 @@ public class LogWriter {
|
||||
logger.setLevel(Level.ALL);
|
||||
info(new Date().toString());
|
||||
} catch (SecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -223,4 +223,4 @@ class NPCStamp
|
||||
public Date makeDate = new Date();
|
||||
public Date recentDate = new Date();
|
||||
public int counter = 1;
|
||||
};
|
||||
};
|
||||
@@ -181,8 +181,8 @@ public class NPCSpawning {
|
||||
if(spawnEntity instanceof EntityCustomNpc){
|
||||
EntityCustomNpc npc = (EntityCustomNpc) spawnEntity;
|
||||
npc.stats.spawnCycle = 3;
|
||||
npc.ai.returnToStart = false;
|
||||
npc.ai.startPos = new int[]{x,y, z};
|
||||
npc.ais.returnToStart = false;
|
||||
npc.ais.startPos = new int[]{x,y, z};
|
||||
npc.updateAI = true;
|
||||
npc.updateClient = true;
|
||||
npc.getNavigator().clearPathEntity();
|
||||
|
||||
@@ -3,6 +3,14 @@ package noppes.npcs;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumSoundOperation;
|
||||
import kamkeel.npcs.network.packets.data.*;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiClosePacket;
|
||||
import kamkeel.npcs.network.packets.data.gui.IsGuiOpenPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.PartyDataPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -133,11 +141,11 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
Server.sendData(player, EnumPacketClient.DISABLE_MOUSE_INPUT, time, stringedIds.toString());
|
||||
PacketHandler.Instance.sendToPlayer(new DisableMouseInputPacket(time, stringedIds.toString()), player);
|
||||
}
|
||||
|
||||
public static void swingPlayerArm(EntityPlayerMP player){
|
||||
Server.sendData(player, EnumPacketClient.SWING_PLAYER_ARM);
|
||||
PacketHandler.Instance.sendToPlayer(new SwingPlayerArmPacket(), player);
|
||||
}
|
||||
|
||||
private static void followerBuy(RoleFollower role,IInventory currencyInv,EntityPlayerMP player, EntityNPCInterface npc){
|
||||
@@ -251,16 +259,6 @@ public class NoppesUtilPlayer {
|
||||
|
||||
bankData.openBankGui(player, npc, bank.id, container.slot);
|
||||
}
|
||||
public static void sendData(EnumPlayerPacket enu, Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!Server.fillBuffer(buffer, enu, obs))
|
||||
return;
|
||||
CustomNpcs.ChannelPlayer.sendToServer(new FMLProxyPacket(buffer,"CustomNPCsPlayer"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void dialogSelected(int dialogId, int optionId, EntityPlayerMP player, EntityNPCInterface npc) {
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(dialogId);
|
||||
@@ -286,23 +284,23 @@ public class NoppesUtilPlayer {
|
||||
if(npc.roleInterface != null)
|
||||
npc.roleInterface.interact(player);
|
||||
else
|
||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
||||
GuiClosePacket.closeGUI(player, -1 , new NBTTagCompound());
|
||||
}
|
||||
else if(option.optionType == EnumOptionType.DialogOption){
|
||||
NoppesUtilServer.openDialog(player, npc, option.getDialog(), optionId+1);
|
||||
}
|
||||
else if(option.optionType == EnumOptionType.CommandBlock){
|
||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
||||
GuiClosePacket.closeGUI(player, -1 , new NBTTagCompound());
|
||||
NoppesUtilServer.runCommand(player, npc.getCommandSenderName(), option.command);
|
||||
}
|
||||
else
|
||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
||||
GuiClosePacket.closeGUI(player, -1 , new NBTTagCompound());
|
||||
}
|
||||
|
||||
public static void updateQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
NBTTagCompound compound = ByteBufUtils.readNBT(buffer);
|
||||
HashMap<String,String> questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10));
|
||||
for (Map.Entry<String,String> entry : questAlerts.entrySet()) {
|
||||
Quest quest = getQuestFromStringKey(entry.getKey());
|
||||
@@ -311,7 +309,7 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
String trackedQuestString = Server.readString(buffer);
|
||||
String trackedQuestString = ByteBufUtils.readString(buffer);
|
||||
Quest trackedQuest = getQuestFromStringKey(trackedQuestString);
|
||||
if (trackedQuest != null) {
|
||||
playerData.questData.trackQuest(trackedQuest);
|
||||
@@ -328,7 +326,7 @@ public class NoppesUtilPlayer {
|
||||
|
||||
public static void updatePartyQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
String trackedQuestString = Server.readString(buffer);
|
||||
String trackedQuestString = ByteBufUtils.readString(buffer);
|
||||
Quest trackedQuest = getQuestFromStringKey(trackedQuestString);
|
||||
if (trackedQuest != null) {
|
||||
playerData.questData.trackParty(playerData.getPlayerParty());
|
||||
@@ -384,7 +382,7 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
compound.setTag("ObjectiveList",nbtTagList);
|
||||
|
||||
Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING, compound);
|
||||
PacketHandler.Instance.sendToPlayer(new OverlayQuestTrackingPacket(compound), player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,8 +405,7 @@ public class NoppesUtilPlayer {
|
||||
nbtTagList.appendTag(new NBTTagString(objective.getAdditionalText()));
|
||||
}
|
||||
compound.setTag("ObjectiveList",nbtTagList);
|
||||
|
||||
Server.sendData(player, EnumPacketClient.OVERLAY_QUEST_TRACKING, compound);
|
||||
PacketHandler.Instance.sendToPlayer(new OverlayQuestTrackingPacket(compound), player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,13 +415,14 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
QuestLogData data = new QuestLogData();
|
||||
data.setData(player);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.writeNBT());
|
||||
GuiDataPacket.sendGuiData(player, data.writeNBT());
|
||||
}
|
||||
|
||||
public static void sendTrackedQuest(EntityPlayerMP player) {
|
||||
QuestLogData data = new QuestLogData();
|
||||
data.setTrackedQuestKey(player);
|
||||
Server.sendData(player, EnumPacketClient.PARTY_DATA, data.writeTrackedQuest());
|
||||
|
||||
PartyDataPacket.sendPartyData(player, data.writeTrackedQuest());
|
||||
}
|
||||
|
||||
public static boolean questCompletion(EntityPlayerMP player, int questId) {
|
||||
@@ -626,7 +624,7 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
|
||||
playerData.save();
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound()));
|
||||
QuestCompletionPacket.sendQuestComplete((EntityPlayerMP)player, data.quest.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(quest.type == EnumQuestType.Item && partyOptions.objectiveRequirement == EnumPartyObjectives.Shared){
|
||||
@@ -740,7 +738,7 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
}
|
||||
public static void isGUIOpen(EntityPlayerMP player){
|
||||
Server.sendData(player, EnumPacketClient.ISGUIOPEN);
|
||||
PacketHandler.Instance.sendToPlayer(new IsGuiOpenPacket(), player);
|
||||
}
|
||||
|
||||
public static List<ItemStack> countStacks(IInventory inv, boolean ignoreDamage, boolean ignoreNBT) {
|
||||
@@ -773,30 +771,30 @@ public class NoppesUtilPlayer {
|
||||
public static void playSoundTo(EntityPlayerMP player, int id, ScriptSound sound) {
|
||||
NBTTagCompound compound = sound.writeToNBT();
|
||||
if (sound.sourceEntity == null || player.worldObj.provider.dimensionId == sound.sourceEntity.getDimension()) {
|
||||
Server.sendData(player, EnumPacketClient.PLAY_SOUND_TO, id, compound);
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_SOUND_TO, id, compound), player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void playSoundTo(EntityPlayerMP player, ScriptSound sound) {
|
||||
NBTTagCompound compound = sound.writeToNBT();
|
||||
if (sound.sourceEntity == null || player.worldObj.provider.dimensionId == sound.sourceEntity.getDimension()) {
|
||||
Server.sendData(player, EnumPacketClient.PLAY_SOUND_TO_NO_ID, compound);
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_SOUND_TO_NO_ID, compound), player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopSoundFor(EntityPlayerMP player, int id) {
|
||||
Server.sendData(player, EnumPacketClient.STOP_SOUND_FOR, id);
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.STOP_SOUND_FOR, id), player);
|
||||
}
|
||||
|
||||
public static void pauseSoundsFor(EntityPlayerMP player) {
|
||||
Server.sendData(player, EnumPacketClient.PAUSE_SOUNDS);
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PAUSE_SOUNDS), player);
|
||||
}
|
||||
|
||||
public static void continueSoundsFor(EntityPlayerMP player) {
|
||||
Server.sendData(player, EnumPacketClient.CONTINUE_SOUNDS);
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.CONTINUE_SOUNDS), player);
|
||||
}
|
||||
|
||||
public static void stopSoundsFor(EntityPlayerMP player) {
|
||||
Server.sendData(player, EnumPacketClient.STOP_SOUNDS);
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.STOP_SOUNDS), player);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,22 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.controllers.SyncController;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiClosePacket;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiErrorPacket;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiOpenPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.ScrollDataPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.ScrollListPacket;
|
||||
import kamkeel.npcs.network.packets.data.npc.DialogPacket;
|
||||
import kamkeel.npcs.network.packets.data.ParticlePacket;
|
||||
import kamkeel.npcs.network.packets.data.script.ScriptedParticlePacket;
|
||||
import kamkeel.npcs.network.packets.data.npc.DeleteNpcPacket;
|
||||
import kamkeel.npcs.network.packets.data.npc.EditNpcPacket;
|
||||
import kamkeel.npcs.network.packets.data.npc.RolePacket;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiTeleporterPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.command.server.CommandBlockLogic;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
@@ -13,7 +29,6 @@ import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.MobSpawnerBaseLogic;
|
||||
@@ -27,7 +42,6 @@ import net.minecraft.world.World;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumPlayerData;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.containers.ContainerManageBanks;
|
||||
@@ -41,43 +55,53 @@ import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptSound;
|
||||
import noppes.npcs.scripted.event.DialogEvent;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import static kamkeel.npcs.network.packets.data.large.ScrollDataPacket.sendScrollData;
|
||||
import static kamkeel.npcs.network.packets.data.large.ScrollGroupPacket.sendScrollGroup;
|
||||
|
||||
public class NoppesUtilServer {
|
||||
private static HashMap<String,Quest> editingQuests = new HashMap<String,Quest>();
|
||||
|
||||
public static void setEditingNpc(EntityPlayer player, EntityNPCInterface npc){
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
data.editingNpc = npc;
|
||||
if(npc != null)
|
||||
Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.EDIT_NPC, npc.getEntityId());
|
||||
}
|
||||
public static EntityNPCInterface getEditingNpc(EntityPlayer player){
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
return data.editingNpc;
|
||||
public static IPlayer getIPlayer(EntityPlayer p) {
|
||||
return (IPlayer) NpcAPI.Instance().getIEntity(p);
|
||||
}
|
||||
|
||||
public static UUID getUUID(Entity entity) {
|
||||
return entity instanceof EntityPlayer ? ((EntityPlayer) entity).getGameProfile().getId() : entity.getUniqueID();
|
||||
}
|
||||
|
||||
public static void setEditingNpc(EntityPlayer player, EntityNPCInterface npc){
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
data.editingNpc = npc;
|
||||
if(npc != null)
|
||||
PacketHandler.Instance.sendToPlayer(new EditNpcPacket(npc.getEntityId()), (EntityPlayerMP)player);
|
||||
}
|
||||
|
||||
public static EntityNPCInterface getEditingNpc(EntityPlayer player){
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
return data.editingNpc;
|
||||
}
|
||||
|
||||
public static void setEditingQuest(EntityPlayer player, Quest quest) {
|
||||
editingQuests.put(player.getCommandSenderName(), quest);
|
||||
}
|
||||
|
||||
public static void setEditingQuest(EntityPlayer player, Quest quest) {
|
||||
editingQuests.put(player.getCommandSenderName(), quest);
|
||||
}
|
||||
public static Quest getEditingQuest(EntityPlayer player){
|
||||
return editingQuests.get(player.getCommandSenderName());
|
||||
return editingQuests.get(player.getCommandSenderName());
|
||||
}
|
||||
|
||||
public static void sendRoleData(EntityPlayer player, EntityNPCInterface npc){
|
||||
if(npc.advanced.role == EnumRoleType.None)
|
||||
return;
|
||||
NBTTagCompound comp = new NBTTagCompound();
|
||||
npc.roleInterface.writeToNBT(comp);
|
||||
comp.setInteger("EntityId", npc.getEntityId());
|
||||
comp.setInteger("Role", npc.advanced.role.ordinal());
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.ROLE, comp);
|
||||
if(npc.advanced.role == EnumRoleType.None)
|
||||
return;
|
||||
NBTTagCompound comp = new NBTTagCompound();
|
||||
npc.roleInterface.writeToNBT(comp);
|
||||
comp.setInteger("EntityId", npc.getEntityId());
|
||||
comp.setInteger("Role", npc.advanced.role.ordinal());
|
||||
PacketHandler.Instance.sendToPlayer(new RolePacket(comp), (EntityPlayerMP)player);
|
||||
}
|
||||
|
||||
public static void sendFactionDataAll(EntityPlayerMP player) {
|
||||
@@ -184,11 +208,12 @@ public class NoppesUtilServer {
|
||||
|
||||
if(npc instanceof EntityDialogNpc || dia.id < 0){
|
||||
dialog.hideNPC = true;
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
|
||||
PacketHandler.Instance.sendToPlayer(new DialogPacket(npc.getCommandSenderName(), -1, dialog.writeToNBT(new NBTTagCompound())), (EntityPlayerMP)player);
|
||||
}
|
||||
else
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG, npc.getEntityId(), dialog.writeToNBT(new NBTTagCompound()));
|
||||
dia.factionOptions.addPoints(player);
|
||||
PacketHandler.Instance.sendToPlayer(new DialogPacket("Real", npc.getEntityId(), dialog.writeToNBT(new NBTTagCompound())), (EntityPlayerMP)player);
|
||||
|
||||
dia.factionOptions.addPoints(player);
|
||||
if(dialog.hasQuest())
|
||||
PlayerQuestController.addActiveQuest(new QuestData(dialog.getQuest()),player);
|
||||
if(!dialog.command.isEmpty()){
|
||||
@@ -263,9 +288,6 @@ public class NoppesUtilServer {
|
||||
player.destroyCurrentEquippedItem();
|
||||
}
|
||||
|
||||
public static DataOutputStream getDataOutputStream(ByteArrayOutputStream stream) throws IOException{
|
||||
return new DataOutputStream(new GZIPOutputStream(stream));
|
||||
}
|
||||
public static void sendOpenGui(EntityPlayer player,
|
||||
EnumGuiType gui, EntityNPCInterface npc) {
|
||||
sendOpenGui(player, gui, npc, 0, 0, 0);
|
||||
@@ -289,14 +311,14 @@ public class NoppesUtilServer {
|
||||
return;
|
||||
}
|
||||
else{
|
||||
Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
|
||||
GuiOpenPacket.openGUI((EntityPlayerMP)player, gui, i, j, k);
|
||||
}
|
||||
ArrayList<String> list = getScrollData(player, gui, npc);
|
||||
if(list == null || list.isEmpty())
|
||||
return;
|
||||
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SCROLL_LIST, list);
|
||||
}
|
||||
ScrollListPacket.sendList((EntityPlayerMP)player, list);
|
||||
}
|
||||
|
||||
public static void sendOpenGuiNoDelay(final EntityPlayer player,
|
||||
final EnumGuiType gui, final EntityNPCInterface npc, final int i, final int j, final int k) {
|
||||
@@ -311,13 +333,13 @@ public class NoppesUtilServer {
|
||||
return;
|
||||
}
|
||||
else{
|
||||
Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
|
||||
GuiOpenPacket.openGUI((EntityPlayerMP)player, gui, i, j, k);
|
||||
}
|
||||
ArrayList<String> list = getScrollData(player, gui, npc);
|
||||
if(list == null || list.isEmpty())
|
||||
return;
|
||||
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SCROLL_LIST, list);
|
||||
ScrollListPacket.sendList((EntityPlayerMP)player, list);
|
||||
}
|
||||
|
||||
|
||||
@@ -352,17 +374,12 @@ public class NoppesUtilServer {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static void spawnParticle(Entity entity,String particle,int dimension){
|
||||
Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle);
|
||||
public static void spawnParticle(Entity entity,String particle, int dimension){
|
||||
PacketHandler.Instance.sendTracking(new ParticlePacket(entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle), entity);
|
||||
}
|
||||
|
||||
public static void spawnScriptedParticle(NBTTagCompound compound, int dimensionId){
|
||||
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
for (EntityPlayer player : list) {
|
||||
if (player.worldObj.provider.dimensionId == dimensionId) {
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.SCRIPTED_PARTICLE, compound);
|
||||
}
|
||||
}
|
||||
PacketHandler.Instance.sendToDimension(new ScriptedParticlePacket(compound), dimensionId);
|
||||
}
|
||||
|
||||
public static void playSound(int id, ScriptSound sound) {
|
||||
@@ -408,7 +425,7 @@ public class NoppesUtilServer {
|
||||
}
|
||||
|
||||
public static void deleteNpc(EntityNPCInterface npc,EntityPlayer player) {
|
||||
Server.sendAssociatedData(npc, EnumPacketClient.DELETE_NPC, npc.getEntityId());
|
||||
PacketHandler.Instance.sendTracking(new DeleteNpcPacket(npc.getEntityId()), npc);
|
||||
}
|
||||
|
||||
public static void createMobSpawner(int x, int y, int z, NBTTagCompound comp, EntityPlayer player) {
|
||||
@@ -505,14 +522,14 @@ public class NoppesUtilServer {
|
||||
}
|
||||
}
|
||||
|
||||
NoppesUtilServer.sendScrollData(player, map);
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
|
||||
public static void removePlayerData(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
int id = buffer.readInt();
|
||||
if(EnumPlayerData.values().length <= id)
|
||||
return;
|
||||
String name = Server.readString(buffer);
|
||||
String name = ByteBufUtils.readString(buffer);
|
||||
EnumPlayerData type = EnumPlayerData.values()[id];
|
||||
EntityPlayer pl = MinecraftServer.getServer().getConfigurationManager().func_152612_a(name);
|
||||
PlayerData playerdata = null;
|
||||
@@ -538,7 +555,6 @@ public class NoppesUtilServer {
|
||||
playerdata.setNBT(new NBTTagCompound());
|
||||
sendPlayerData(type, player, name);
|
||||
playerdata.save();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -585,37 +601,18 @@ public class NoppesUtilServer {
|
||||
for(RecipeCarpentry recipe : RecipeController.Instance.globalRecipes.values()){
|
||||
map.put(recipe.name, recipe.id);
|
||||
}
|
||||
}
|
||||
} else if (size == 4){
|
||||
for(RecipeCarpentry recipe : RecipeController.Instance.carpentryRecipes.values()){
|
||||
map.put(recipe.name, recipe.id);
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(RecipeCarpentry recipe : RecipeController.Instance.anvilRecipes.values()){
|
||||
map.put(recipe.name, recipe.id);
|
||||
}
|
||||
for(RecipeAnvil recipe : RecipeController.Instance.anvilRecipes.values()){
|
||||
map.put(recipe.name, recipe.id);
|
||||
}
|
||||
}
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
public static void sendScrollData(EntityPlayerMP player, Map<String,Integer> map){
|
||||
Map<String, Integer> send = new HashMap<String, Integer>();
|
||||
for(String key : map.keySet()){
|
||||
send.put(key, map.get(key));
|
||||
if(send.size() == 100){
|
||||
Server.sendData(player, EnumPacketClient.SCROLL_DATA_PART, send);
|
||||
send = new HashMap<String, Integer>();
|
||||
}
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.SCROLL_DATA, send);
|
||||
}
|
||||
|
||||
public static void sendScrollGroup(EntityPlayerMP player, Map<String,Integer> map){
|
||||
Map<String, Integer> send = new HashMap<String, Integer>();
|
||||
for(String key : map.keySet()){
|
||||
send.put(key, map.get(key));
|
||||
if(send.size() == 100){
|
||||
Server.sendData(player, EnumPacketClient.SCROLL_GROUP_PART, send);
|
||||
send = new HashMap<String, Integer>();
|
||||
}
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.SCROLL_GROUP, send);
|
||||
}
|
||||
|
||||
public static void sendDialogData(EntityPlayerMP player, DialogCategory category) {
|
||||
if(category == null)
|
||||
@@ -659,6 +656,14 @@ public class NoppesUtilServer {
|
||||
sendScrollGroup(player, map);
|
||||
}
|
||||
|
||||
public static void sendCustomEffectDataAll(EntityPlayerMP player) {
|
||||
Map<String, Integer> map = new HashMap<String, Integer>();
|
||||
for (CustomEffect effect : CustomEffectController.getInstance().customEffects.values()) {
|
||||
map.put(effect.name, effect.id);
|
||||
}
|
||||
ScrollDataPacket.sendScrollData(player, map);
|
||||
}
|
||||
|
||||
public static void sendTransportCategoryData(EntityPlayerMP player) {
|
||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||
for(TransportCategory category : TransportController.getInstance().categories.values()){
|
||||
@@ -690,8 +695,7 @@ public class NoppesUtilServer {
|
||||
|
||||
NBTTagCompound compound = option.writeNBT();
|
||||
compound.setInteger("Position", pos);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_DATA, compound);
|
||||
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP)player, compound);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -727,13 +731,13 @@ public class NoppesUtilServer {
|
||||
public static void setClonerGui(EntityPlayerMP player, int x, int y, int z){
|
||||
if(player == null)
|
||||
return;
|
||||
Server.sendData(player, EnumPacketClient.CLONER, x, y, z);
|
||||
GuiOpenPacket.openGUI(player, EnumGuiType.Cloner, x, y, z);
|
||||
}
|
||||
|
||||
public static void setTeleporterGUI(EntityPlayerMP player){
|
||||
if(player == null)
|
||||
return;
|
||||
Server.sendData(player, EnumPacketClient.TELEPORTER);
|
||||
PacketHandler.Instance.sendToPlayer(new GuiTeleporterPacket(), player);
|
||||
}
|
||||
|
||||
public static void setRecipeGui(EntityPlayerMP player, RecipeCarpentry recipe){
|
||||
@@ -744,14 +748,24 @@ public class NoppesUtilServer {
|
||||
|
||||
ContainerManageRecipes container = (ContainerManageRecipes) player.openContainer;
|
||||
container.setRecipe(recipe);
|
||||
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, recipe.writeNBT());
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP)player, recipe.writeNBT());
|
||||
}
|
||||
|
||||
public static void setRecipeAnvilGui(EntityPlayerMP player, RecipeAnvil recipe){
|
||||
if(recipe == null)
|
||||
return;
|
||||
if(!(player.openContainer instanceof ContainerManageRecipes))
|
||||
return;
|
||||
|
||||
ContainerManageRecipes container = (ContainerManageRecipes) player.openContainer;
|
||||
container.setRecipe(recipe);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP)player, recipe.writeNBT());
|
||||
}
|
||||
|
||||
public static void sendBank(EntityPlayerMP player,Bank bank) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
bank.writeEntityToNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP)player, compound);
|
||||
|
||||
if(player.openContainer instanceof ContainerManageBanks){
|
||||
((ContainerManageBanks)player.openContainer).setBank(bank);
|
||||
@@ -777,14 +791,14 @@ public class NoppesUtilServer {
|
||||
}
|
||||
|
||||
public static void sendGuiError(EntityPlayer player, int i) {
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_ERROR, i, new NBTTagCompound());
|
||||
GuiErrorPacket.errorGUI((EntityPlayerMP)player, i, new NBTTagCompound());
|
||||
}
|
||||
|
||||
public static void sendGuiClose(EntityPlayerMP player, int i, NBTTagCompound comp) {
|
||||
if(player.openContainer != player.inventoryContainer){
|
||||
player.openContainer = player.inventoryContainer;
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE, i, comp);
|
||||
GuiClosePacket.closeGUI(player, i, comp);
|
||||
}
|
||||
|
||||
public static Entity spawnCloneWithProtection(NBTTagCompound compound, int x, int y,
|
||||
@@ -798,7 +812,7 @@ public class NoppesUtilServer {
|
||||
entity.setPosition((double) x + 0.5, (double) y, (double) z + 0.5);
|
||||
if(entity instanceof EntityNPCInterface){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
npc.ai.startPos = new int[]{MathHelper.floor_double(npc.posX),MathHelper.floor_double(npc.posY),MathHelper.floor_double(npc.posZ)};
|
||||
npc.ais.startPos = new int[]{MathHelper.floor_double(npc.posX),MathHelper.floor_double(npc.posY),MathHelper.floor_double(npc.posZ)};
|
||||
npc.ticksExisted = 0;
|
||||
npc.totalTicksAlive = 0;
|
||||
}
|
||||
@@ -817,7 +831,7 @@ public class NoppesUtilServer {
|
||||
}
|
||||
if(entity instanceof EntityNPCInterface){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
npc.ai.startPos = new int[]{MathHelper.floor_double(npc.posX),MathHelper.floor_double(npc.posY),MathHelper.floor_double(npc.posZ)};
|
||||
npc.ais.startPos = new int[]{MathHelper.floor_double(npc.posX),MathHelper.floor_double(npc.posY),MathHelper.floor_double(npc.posZ)};
|
||||
npc.ticksExisted = 0;
|
||||
npc.totalTicksAlive = 0;
|
||||
}
|
||||
@@ -826,7 +840,7 @@ public class NoppesUtilServer {
|
||||
|
||||
public static Entity spawnClone(NBTTagCompound compound, int x, int y,
|
||||
int z, World worldObj) {
|
||||
Entity entity = NoppesUtilServer.getEntityFromNBT(compound,x,y,z,worldObj);
|
||||
Entity entity = getEntityFromNBT(compound,x,y,z,worldObj);
|
||||
if(entity == null){
|
||||
return null;
|
||||
}
|
||||
@@ -845,48 +859,6 @@ public class NoppesUtilServer {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
public static void sendPlayerDataCompound(EntityPlayerMP player, NBTTagCompound compound, boolean sync) {
|
||||
try {
|
||||
byte[] bytes = CompressedStreamTools.compress(compound);
|
||||
|
||||
// Split byte array into chunks and send each chunk
|
||||
int chunkSize = 16000;
|
||||
int totalChunks = (int) Math.ceil((double) bytes.length / chunkSize);
|
||||
for (int i = 0; i < totalChunks; i++) {
|
||||
int start = i * chunkSize;
|
||||
int length = Math.min(bytes.length - start, chunkSize);
|
||||
byte[] chunk = new byte[length];
|
||||
System.arraycopy(bytes, start, chunk, 0, length);
|
||||
Server.sendData(player, EnumPacketClient.LARGE_NBT_PART, (Object) chunk);
|
||||
}
|
||||
// Send end packet
|
||||
Server.sendData(player, EnumPacketClient.SYNC_PLAYER, sync);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendDBCCompound(EntityPlayerMP player, NBTTagCompound compound) {
|
||||
try {
|
||||
byte[] bytes = CompressedStreamTools.compress(compound);
|
||||
|
||||
// Split byte array into chunks and send each chunk
|
||||
int chunkSize = 16000;
|
||||
int totalChunks = (int) Math.ceil((double) bytes.length / chunkSize);
|
||||
for (int i = 0; i < totalChunks; i++) {
|
||||
int start = i * chunkSize;
|
||||
int length = Math.min(bytes.length - start, chunkSize);
|
||||
byte[] chunk = new byte[length];
|
||||
System.arraycopy(bytes, start, chunk, 0, length);
|
||||
Server.sendData(player, EnumPacketClient.LARGE_NBT_PART, (Object) chunk);
|
||||
}
|
||||
// Send end packet
|
||||
Server.sendData(player, EnumPacketClient.DBC_FORM);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean isOp(EntityPlayer player) {
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile());
|
||||
|
||||
@@ -1,338 +0,0 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemEditableBook;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemWritableBook;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import noppes.npcs.blocks.tiles.TileBigSign;
|
||||
import noppes.npcs.blocks.tiles.TileBook;
|
||||
import noppes.npcs.constants.*;
|
||||
import noppes.npcs.containers.ContainerMail;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.PlayerQuestController;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleCompanion;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PacketHandlerPlayer{
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerPacket(ServerCustomPacketEvent event) {
|
||||
EntityPlayerMP player = ((NetHandlerPlayServer)event.handler).playerEntity;
|
||||
ByteBuf buffer = event.packet.payload();
|
||||
try {
|
||||
player(buffer, player, EnumPlayerPacket.values()[buffer.readInt()]);
|
||||
} catch (IOException e) {
|
||||
LogWriter.except(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void player(ByteBuf buffer, EntityPlayerMP player, EnumPlayerPacket type) throws IOException {
|
||||
if(type == EnumPlayerPacket.MarkData){
|
||||
String uuid = Server.readString(buffer);
|
||||
if(uuid == null)
|
||||
return;
|
||||
|
||||
Entity entity = NoppesUtilServer.getEntityFromUUID(player.worldObj, UUID.fromString(uuid));
|
||||
if(!(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
MarkData data = MarkData.get((EntityNPCInterface) entity);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.CompanionTalentExp){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Companion || player != npc.getOwner())
|
||||
return;
|
||||
int id = buffer.readInt();
|
||||
int exp = buffer.readInt();
|
||||
RoleCompanion role = (RoleCompanion) npc.roleInterface;
|
||||
if(exp <= 0 || !role.canAddExp(-exp) || id < 0 || id >= EnumCompanionTalent.values().length) //should never happen unless hacking
|
||||
return;
|
||||
EnumCompanionTalent talent = EnumCompanionTalent.values()[id];
|
||||
role.addExp(-exp);
|
||||
role.addTalentExp(talent, exp);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.CompanionOpenInv){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Companion || player != npc.getOwner())
|
||||
return;
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.CompanionInv, npc);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.KeyPressed) {
|
||||
if(ScriptController.Instance.languages.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int button = buffer.readInt();
|
||||
boolean isCtrlPressed = buffer.readBoolean();
|
||||
boolean isShiftPressed = buffer.readBoolean();
|
||||
boolean isAltPressed = buffer.readBoolean();
|
||||
boolean isMetaPressed = buffer.readBoolean();
|
||||
boolean buttonDown = buffer.readBoolean();
|
||||
|
||||
String ints = Server.readString(buffer);
|
||||
String[] split = ints.split(",");
|
||||
int[] keysDown;
|
||||
|
||||
if(ints.length() > 0) {
|
||||
keysDown = new int[split.length];
|
||||
try {
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
keysDown[i] = Integer.parseInt(split[i]);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ignored){
|
||||
}
|
||||
} else {
|
||||
keysDown = new int[0];
|
||||
}
|
||||
|
||||
EventHooks.onPlayerKeyPressed(player, button, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, buttonDown, keysDown);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MouseClicked) {
|
||||
if(ScriptController.Instance.languages.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int button = buffer.readInt();
|
||||
int mouseWheel = buffer.readInt();
|
||||
boolean buttonDown = buffer.readBoolean();
|
||||
|
||||
boolean isCtrlPressed = buffer.readBoolean();
|
||||
boolean isShiftPressed = buffer.readBoolean();
|
||||
boolean isAltPressed = buffer.readBoolean();
|
||||
boolean isMetaPressed = buffer.readBoolean();
|
||||
|
||||
String ints = Server.readString(buffer);
|
||||
String[] split = ints.split(",");
|
||||
int[] keysDown;
|
||||
|
||||
if(ints.length() > 0) {
|
||||
keysDown = new int[split.length];
|
||||
try {
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
keysDown[i] = Integer.parseInt(split[i]);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ignored){
|
||||
}
|
||||
} else {
|
||||
keysDown = new int[0];
|
||||
}
|
||||
|
||||
EventHooks.onPlayerMouseClicked(player, button, mouseWheel, buttonDown, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, keysDown);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.FollowerHire){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
||||
return;
|
||||
NoppesUtilPlayer.hireFollower(player, npc);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.FollowerExtend){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
||||
return;
|
||||
NoppesUtilPlayer.extendFollower(player, npc);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.FollowerState){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
||||
return;
|
||||
NoppesUtilPlayer.changeFollowerState(player,npc);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.RoleGet){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role == EnumRoleType.None)
|
||||
return;
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, 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, Server.readString(buffer));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.BankUpgrade){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Bank)
|
||||
return;
|
||||
NoppesUtilPlayer.bankUpgrade(player, npc);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.BankUnlock){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Bank)
|
||||
return;
|
||||
NoppesUtilPlayer.bankUnlock(player, npc);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.BankSlotOpen){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Bank)
|
||||
return;
|
||||
int slot = buffer.readInt();
|
||||
int bankId = buffer.readInt();
|
||||
BankData data = PlayerDataController.Instance.getBankData(player,bankId).getBankOrDefault(bankId);
|
||||
data.openBankGui(player, npc, bankId, slot);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.Dialog){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null)
|
||||
return;
|
||||
NoppesUtilPlayer.dialogSelected(buffer.readInt(), buffer.readInt(), player, npc);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.CheckQuestCompletion){
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
Party playerParty = playerData.getPlayerParty();
|
||||
if(playerParty != null)
|
||||
PartyController.Instance().checkQuestCompletion(playerParty, null);
|
||||
|
||||
questData.checkQuestCompletion(playerData, null);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.QuestLog){
|
||||
NoppesUtilPlayer.sendQuestLogData(player);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.TrackedQuest){
|
||||
NoppesUtilPlayer.sendTrackedQuest(player);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.FactionsGet){
|
||||
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.getPlayerGuiData());
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailGet){
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.saveNBTData(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailDelete){
|
||||
long time = buffer.readLong();
|
||||
String username = Server.readString(buffer);
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
|
||||
Iterator<PlayerMail> it = data.playermail.iterator();
|
||||
while(it.hasNext()){
|
||||
PlayerMail mail = it.next();
|
||||
if(mail.time == time && mail.sender.equals(username)){
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.saveNBTData(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailSend){
|
||||
if(!(player.openContainer instanceof ContainerMail))
|
||||
return;
|
||||
String username = PlayerDataController.Instance.hasPlayer(Server.readString(buffer));
|
||||
if(username.isEmpty()){
|
||||
NoppesUtilServer.sendGuiError(player, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerMail mail = new PlayerMail();
|
||||
//String s = player.func_145748_c_().getFormattedText();
|
||||
String s = player.getDisplayName();
|
||||
if(!s.equals(player.getCommandSenderName()))
|
||||
s += "(" + player.getCommandSenderName() + ")";
|
||||
mail.readNBT(Server.readNBT(buffer));
|
||||
mail.sender = s;
|
||||
mail.items = ((ContainerMail)player.openContainer).mail.items;
|
||||
|
||||
if(mail.subject.isEmpty()){
|
||||
NoppesUtilServer.sendGuiError(player, 1);
|
||||
return;
|
||||
}
|
||||
PlayerDataController.Instance.addPlayerMessage(username, mail);
|
||||
|
||||
NBTTagCompound comp = new NBTTagCompound();
|
||||
comp.setString("username", username);
|
||||
NoppesUtilServer.sendGuiClose(player, 1,comp);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailboxOpenMail){
|
||||
long time = buffer.readLong();
|
||||
String username = Server.readString(buffer);
|
||||
player.closeContainer();
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
|
||||
Iterator<PlayerMail> it = data.playermail.iterator();
|
||||
while(it.hasNext()){
|
||||
PlayerMail mail = it.next();
|
||||
if(mail.time == time && mail.sender.equals(username)){
|
||||
ContainerMail.staticmail = mail;
|
||||
player.openGui(CustomNpcs.instance, EnumGuiType.PlayerMailman.ordinal(), player.worldObj, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailRead){
|
||||
long time = buffer.readLong();
|
||||
String username = Server.readString(buffer);
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
|
||||
Iterator<PlayerMail> it = data.playermail.iterator();
|
||||
while(it.hasNext()){
|
||||
PlayerMail mail = it.next();
|
||||
if(mail.time == time && mail.sender.equals(username)){
|
||||
mail.beenRead = true;
|
||||
if(mail.hasQuest())
|
||||
PlayerQuestController.addActiveQuest(new QuestData(mail.getQuest()), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
else 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);
|
||||
if(!(tile instanceof TileBigSign))
|
||||
return;
|
||||
TileBigSign sign = (TileBigSign) tile;
|
||||
if (sign.canEdit) {
|
||||
sign.setText(Server.readString(buffer));
|
||||
sign.canEdit = false;
|
||||
player.worldObj.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == EnumPlayerPacket.SaveBook) {
|
||||
int x = buffer.readInt(), y = buffer.readInt(), z = buffer.readInt();
|
||||
if (player.worldObj.blockExists(x, y, z)) {
|
||||
TileEntity tileentity = player.worldObj.getTileEntity(x, y, z);
|
||||
if (!(tileentity instanceof TileBook))
|
||||
return;
|
||||
TileBook tile = (TileBook) tileentity;
|
||||
if (tile.book.getItem() == Items.written_book)
|
||||
return;
|
||||
boolean sign = buffer.readBoolean();
|
||||
ItemStack book = ItemStack.loadItemStackFromNBT(Server.readNBT(buffer));
|
||||
if (book == null)
|
||||
return;
|
||||
if (book.getItem() == Items.writable_book && !sign && ItemWritableBook.func_150930_a(book.getTagCompound())) {
|
||||
tile.book.setTagInfo("pages", book.getTagCompound().getTagList("pages", 8));
|
||||
}
|
||||
if (book.getItem() == Items.written_book && sign && ItemEditableBook.validBookTagContents(book.getTagCompound())) {
|
||||
tile.book.setTagInfo("author", new NBTTagString(player.getCommandSenderName()));
|
||||
tile.book.setTagInfo("title", new NBTTagString(book.getTagCompound().getString("title")));
|
||||
tile.book.setTagInfo("pages", book.getTagCompound().getTagList("pages", 8));
|
||||
tile.book.func_150996_a(Items.written_book);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == EnumPlayerPacket.ScreenSize){
|
||||
int width = buffer.readInt(), height = buffer.readInt();
|
||||
PlayerDataController.Instance.getPlayerData(player).screenSize.setSize(width,height);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -22,6 +22,7 @@ import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.items.ItemScripted;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.event.ItemEvent;
|
||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -60,8 +61,9 @@ public class ScriptItemEventHandler {
|
||||
if(event.player.worldObj instanceof WorldServer) {
|
||||
try {
|
||||
if (event.entityItem.getEntityItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
|
||||
IItemCustom isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem());
|
||||
event.setCanceled(EventHooks.onScriptItemTossed(isw, event.player, event.entityItem));
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityItem.getEntityItem());
|
||||
if(isw instanceof IItemCustom)
|
||||
event.setCanceled(EventHooks.onScriptItemTossed((IItemCustom) isw, event.player, event.entityItem));
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
@@ -75,8 +77,9 @@ public class ScriptItemEventHandler {
|
||||
if(event.player.worldObj instanceof WorldServer) {
|
||||
try {
|
||||
if (event.player.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
|
||||
IItemCustom isw = ItemScripted.GetWrapper(event.player.getHeldItem());
|
||||
EventHooks.onScriptItemPickedUp(isw, event.player);
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.player.getHeldItem());
|
||||
if(isw instanceof IItemCustom)
|
||||
EventHooks.onScriptItemPickedUp((IItemCustom) isw, event.player);
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
@@ -89,8 +92,13 @@ public class ScriptItemEventHandler {
|
||||
ItemStack stack = entity.getEntityItem();
|
||||
|
||||
try {
|
||||
if (stack.stackSize > 0 && stack.getItem() == CustomItems.scripted_item && EventHooks.onScriptItemSpawn(ItemScripted.GetWrapper(stack), entity)) {
|
||||
event.setCanceled(true);
|
||||
if (stack.stackSize > 0 && stack.getItem() == CustomItems.scripted_item) {
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(stack);
|
||||
if(isw instanceof IItemCustom){
|
||||
if(EventHooks.onScriptItemSpawn((IItemCustom) isw, entity)){
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
@@ -104,12 +112,14 @@ public class ScriptItemEventHandler {
|
||||
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
|
||||
try {
|
||||
if (event.entityPlayer.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
|
||||
IItemCustom isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem());
|
||||
ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent(isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIEntity(event.target));
|
||||
event.setCanceled(EventHooks.onScriptItemInteract(isw, eve));
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityPlayer.getHeldItem());
|
||||
if(isw instanceof IItemCustom){
|
||||
ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent((IItemCustom) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIEntity(event.target));
|
||||
event.setCanceled(EventHooks.onScriptItemInteract((IItemCustom) isw, eve));
|
||||
|
||||
ItemEvent.RightClickEvent rightClickEvent = new ItemEvent.RightClickEvent(isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 1, NpcAPI.Instance().getIEntity(event.target));
|
||||
event.setCanceled(EventHooks.onScriptItemRightClick(isw, rightClickEvent));
|
||||
ItemEvent.RightClickEvent rightClickEvent = new ItemEvent.RightClickEvent((IItemCustom) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 1, NpcAPI.Instance().getIEntity(event.target));
|
||||
event.setCanceled(EventHooks.onScriptItemRightClick((IItemCustom) isw, rightClickEvent));
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
@@ -135,9 +145,11 @@ public class ScriptItemEventHandler {
|
||||
}
|
||||
try {
|
||||
if (event.entityPlayer.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
|
||||
IItemCustom isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem());
|
||||
ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent(isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 0, null);
|
||||
event.setCanceled(EventHooks.onScriptItemRightClick(isw, eve));
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityPlayer.getHeldItem());
|
||||
if(isw instanceof IItemCustom){
|
||||
ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent((IItemCustom) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 0, null);
|
||||
event.setCanceled(EventHooks.onScriptItemRightClick((IItemCustom) isw, eve));
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
@@ -149,9 +161,11 @@ public class ScriptItemEventHandler {
|
||||
handler.hadInteract = true;
|
||||
try {
|
||||
if (event.entityPlayer.getHeldItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
|
||||
IItemCustom isw = ItemScripted.GetWrapper(event.entityPlayer.getHeldItem());
|
||||
ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent(isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock((IWorld) NpcAPI.Instance().getIWorld(event.world), event.x, event.y, event.z));
|
||||
event.setCanceled(EventHooks.onScriptItemRightClick(isw, eve));
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityPlayer.getHeldItem());
|
||||
if(isw instanceof IItemCustom){
|
||||
ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent((IItemCustom) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock((IWorld) NpcAPI.Instance().getIWorld(event.world), event.x, event.y, event.z));
|
||||
event.setCanceled(EventHooks.onScriptItemRightClick((IItemCustom) isw, eve));
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
@@ -164,9 +178,12 @@ public class ScriptItemEventHandler {
|
||||
return;
|
||||
|
||||
if(event.entityPlayer.worldObj instanceof WorldServer) {
|
||||
IItemCustom handler = ItemScripted.GetWrapper(event.item);
|
||||
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
|
||||
event.setCanceled(EventHooks.onStartUsingCustomItem(handler, IPlayer, event.duration));
|
||||
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.item);
|
||||
if(isw instanceof IItemCustom){
|
||||
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
|
||||
event.setCanceled(EventHooks.onStartUsingCustomItem((IItemCustom) isw, IPlayer, event.duration));
|
||||
}
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
@@ -175,9 +192,12 @@ public class ScriptItemEventHandler {
|
||||
return;
|
||||
|
||||
if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) {
|
||||
IItemCustom handler = ItemScripted.GetWrapper(event.item);
|
||||
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
|
||||
event.setCanceled(EventHooks.onUsingCustomItem(handler, IPlayer, event.duration));
|
||||
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.item);
|
||||
if(isw instanceof IItemCustom){
|
||||
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
|
||||
event.setCanceled(EventHooks.onUsingCustomItem((IItemCustom) isw, IPlayer, event.duration));
|
||||
}
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
@@ -186,9 +206,11 @@ public class ScriptItemEventHandler {
|
||||
return;
|
||||
|
||||
if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) {
|
||||
IItemCustom handler = ItemScripted.GetWrapper(event.item);
|
||||
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
|
||||
event.setCanceled(EventHooks.onStopUsingCustomItem(handler, IPlayer, event.duration));
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.item);
|
||||
if(isw instanceof IItemCustom){
|
||||
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
|
||||
event.setCanceled(EventHooks.onStopUsingCustomItem((IItemCustom) isw, IPlayer, event.duration));
|
||||
}
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
@@ -197,9 +219,11 @@ public class ScriptItemEventHandler {
|
||||
return;
|
||||
|
||||
if(event.entityPlayer.worldObj instanceof WorldServer && event.item.getItem() == CustomItems.scripted_item) {
|
||||
IItemCustom handler = ItemScripted.GetWrapper(event.item);
|
||||
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
|
||||
EventHooks.onFinishUsingCustomItem(handler, IPlayer, event.duration);
|
||||
IItemStack isw = NpcAPI.Instance().getIItemStack(event.item);
|
||||
if(isw instanceof IItemCustom){
|
||||
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
|
||||
EventHooks.onFinishUsingCustomItem((IItemCustom) isw, IPlayer, event.duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import kamkeel.npcs.controllers.SyncController;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -21,9 +22,8 @@ import net.minecraftforge.event.entity.living.*;
|
||||
import net.minecraftforge.event.entity.player.*;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.constants.SyncType;
|
||||
import noppes.npcs.controllers.CustomEffectController;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
@@ -64,7 +64,7 @@ public class ScriptPlayerEventHandler {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
|
||||
if(playerData.updateClient) {
|
||||
NoppesUtilServer.sendPlayerDataCompound((EntityPlayerMP)player, playerData.getSyncNBT(), true);
|
||||
SyncController.syncPlayerData((EntityPlayerMP)player, true);
|
||||
playerData.updateClient = false;
|
||||
}
|
||||
|
||||
@@ -72,6 +72,16 @@ public class ScriptPlayerEventHandler {
|
||||
playerData.timers.update();
|
||||
}
|
||||
|
||||
if(player.ticksExisted % 10 == 0)
|
||||
SyncController.syncEffects((EntityPlayerMP) player);
|
||||
|
||||
// TODO: Fix Config
|
||||
// player.ticksExisted % ConfigDBCGameplay.CheckEffectsTick == 0
|
||||
if (player.ticksExisted % 10 == 0)
|
||||
CustomEffectController.Instance.runEffects(player);
|
||||
|
||||
if (player.ticksExisted % 20 == 0)
|
||||
CustomEffectController.Instance.decrementEffects(player);
|
||||
|
||||
Party party = playerData.getPlayerParty();
|
||||
boolean trackingPartyQuest = playerData.questData.getTrackedQuest() != null && party != null && party.getQuest() != null && party.getQuest().getId() == playerData.questData.getTrackedQuest().getId();
|
||||
@@ -423,6 +433,8 @@ public class ScriptPlayerEventHandler {
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
if(event.entityLiving instanceof EntityPlayer) {
|
||||
try {
|
||||
CustomEffectController.getInstance().killEffects((EntityPlayer) event.entityLiving);
|
||||
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving);
|
||||
EventHooks.onPlayerDeath(handler,scriptPlayer, event.source, source);
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTSizeTracker;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@@ -20,47 +12,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Server {
|
||||
|
||||
public static void sendData(final EntityPlayerMP player, final EnumPacketClient enu, final Object... obs) {
|
||||
sendDataChecked(player, enu, obs);
|
||||
}
|
||||
|
||||
public static boolean sendDataChecked(EntityPlayerMP player, EnumPacketClient type, Object... obs) {
|
||||
PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
|
||||
try {
|
||||
if(!fillBuffer(buffer, type, obs))
|
||||
return false;
|
||||
CustomNpcs.Channel.sendTo(new FMLProxyPacket(buffer, "CustomNPCs"), player);
|
||||
} catch (IOException e) {
|
||||
LogWriter.error(type + " Errored", e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void sendAssociatedData(final Entity entity, final EnumPacketClient enu, final Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!fillBuffer(buffer, enu, obs))
|
||||
return;
|
||||
TargetPoint point = new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 60);
|
||||
CustomNpcs.Channel.sendToAllAround(new FMLProxyPacket(buffer,"CustomNPCs"), point);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LogWriter.error(enu + " Errored", e);
|
||||
}
|
||||
}
|
||||
public static void sendToAll(EnumPacketClient enu, Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!fillBuffer(buffer, enu, obs))
|
||||
return;
|
||||
CustomNpcs.Channel.sendToAll(new FMLProxyPacket(buffer,"CustomNPCs"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LogWriter.error(enu + " Errored", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean fillBuffer(ByteBuf buffer, Enum enu, Object... obs) throws IOException{
|
||||
buffer.writeInt(enu.ordinal());
|
||||
for(Object ob : obs){
|
||||
@@ -73,7 +24,7 @@ public class Server {
|
||||
for(String key : map.keySet()){
|
||||
int value = map.get(key);
|
||||
buffer.writeInt(value);
|
||||
writeString(buffer, key);
|
||||
ByteBufUtils.writeString(buffer, key);
|
||||
}
|
||||
}
|
||||
else if(ob instanceof MerchantRecipeList)
|
||||
@@ -82,7 +33,7 @@ public class Server {
|
||||
List<String> list = (List<String>) ob;
|
||||
buffer.writeInt(list.size());
|
||||
for(String s : list)
|
||||
writeString(buffer, s);
|
||||
ByteBufUtils.writeString(buffer, s);
|
||||
}
|
||||
else if(ob instanceof Enum)
|
||||
buffer.writeInt(((Enum<?>) ob).ordinal());
|
||||
@@ -91,7 +42,7 @@ public class Server {
|
||||
else if(ob instanceof Boolean)
|
||||
buffer.writeBoolean((Boolean) ob);
|
||||
else if(ob instanceof String)
|
||||
writeString(buffer, (String) ob);
|
||||
ByteBufUtils.writeString(buffer, (String) ob);
|
||||
else if(ob instanceof Float)
|
||||
buffer.writeFloat((Float) ob);
|
||||
else if(ob instanceof Long)
|
||||
@@ -105,7 +56,7 @@ public class Server {
|
||||
buffer.writeBytes(byteArray);
|
||||
}
|
||||
else if(ob instanceof NBTTagCompound)
|
||||
writeNBT(buffer, (NBTTagCompound) ob);
|
||||
ByteBufUtils.writeNBT(buffer, (NBTTagCompound) ob);
|
||||
}
|
||||
if(buffer.array().length >= 32767){
|
||||
LogWriter.error("Packet " + enu + " was too big to be send");
|
||||
@@ -114,34 +65,4 @@ public class Server {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void writeNBT(ByteBuf buffer, NBTTagCompound compound) throws IOException {
|
||||
byte[] bytes = CompressedStreamTools.compress(compound);
|
||||
buffer.writeShort((short)bytes.length);
|
||||
buffer.writeBytes(bytes);
|
||||
}
|
||||
|
||||
public static NBTTagCompound readNBT(ByteBuf buffer) throws IOException {
|
||||
byte[] bytes = new byte[buffer.readShort()];
|
||||
buffer.readBytes(bytes);
|
||||
return CompressedStreamTools.func_152457_a(bytes, new NBTSizeTracker(2097152L));
|
||||
}
|
||||
|
||||
public static void writeString(ByteBuf buffer, String s){
|
||||
byte[] bytes = s.getBytes(Charsets.UTF_8);
|
||||
buffer.writeShort((short)bytes.length);
|
||||
buffer.writeBytes(bytes);
|
||||
}
|
||||
|
||||
public static String readString(ByteBuf buffer){
|
||||
try{
|
||||
byte[] bytes = new byte[buffer.readShort()];
|
||||
buffer.readBytes(bytes);
|
||||
return new String(bytes, Charsets.UTF_8);
|
||||
}
|
||||
catch(IndexOutOfBoundsException ex){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,17 @@ package noppes.npcs;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
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.enums.EnumSoundOperation;
|
||||
import kamkeel.npcs.network.enums.EnumSyncAction;
|
||||
import kamkeel.npcs.network.enums.EnumSyncType;
|
||||
import kamkeel.npcs.network.packets.data.MarkDataPacket;
|
||||
import kamkeel.npcs.network.packets.data.SoundManagementPacket;
|
||||
import kamkeel.npcs.network.packets.data.VillagerListPacket;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiOpenPacket;
|
||||
import kamkeel.npcs.network.packets.data.ClonerPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.SyncPacket;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
@@ -11,22 +22,19 @@ import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
||||
@@ -37,14 +45,12 @@ import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.*;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.RecipeController;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.items.ItemExcalibur;
|
||||
import noppes.npcs.items.ItemShield;
|
||||
import noppes.npcs.items.ItemSoulstoneEmpty;
|
||||
import noppes.npcs.quests.QuestItem;
|
||||
import noppes.npcs.quests.QuestKill;
|
||||
import noppes.npcs.roles.RoleFollower;
|
||||
|
||||
@@ -94,8 +100,7 @@ public class ServerEventsHandler {
|
||||
return;
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
|
||||
ServerCloneController.Instance.cleanTags(compound);
|
||||
if(!Server.sendDataChecked((EntityPlayerMP)event.entityPlayer, EnumPacketClient.CLONE, compound))
|
||||
event.entityPlayer.addChatMessage(new ChatComponentText("Entity too big to clone"));
|
||||
PacketHandler.Instance.sendToPlayer(new ClonerPacket(compound), (EntityPlayerMP)event.entityPlayer);
|
||||
data.cloned = compound;
|
||||
if (event.target instanceof EntityNPCInterface) {
|
||||
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface) event.target);
|
||||
@@ -107,8 +112,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){
|
||||
GuiOpenPacket.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()));
|
||||
}
|
||||
}
|
||||
@@ -133,7 +138,7 @@ public class ServerEventsHandler {
|
||||
|
||||
if (merchantrecipelist != null)
|
||||
{
|
||||
Server.sendData(player, EnumPacketClient.VILLAGER_LIST, merchantrecipelist);
|
||||
PacketHandler.Instance.sendToPlayer(new VillagerListPacket(merchantrecipelist), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,48 +198,20 @@ public class ServerEventsHandler {
|
||||
}
|
||||
|
||||
if(block == Blocks.crafting_table && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
|
||||
RecipeController controller = RecipeController.Instance;
|
||||
NBTTagList list = new NBTTagList();
|
||||
int i = 0;
|
||||
for(RecipeCarpentry recipe : controller.globalRecipes.values()){
|
||||
list.appendTag(recipe.writeNBT());
|
||||
i++;
|
||||
if(i % 10 == 0){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("recipes", list);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||
list = new NBTTagList();
|
||||
}
|
||||
}
|
||||
|
||||
if(i % 10 != 0){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("recipes", list);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||
}
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_WORKBENCH);
|
||||
PacketHandler.Instance.sendToPlayer(new SyncPacket(
|
||||
EnumSyncType.WORKBENCH_RECIPES,
|
||||
EnumSyncAction.RELOAD,
|
||||
-1,
|
||||
SyncController.workbenchNBT()
|
||||
), (EntityPlayerMP) player);
|
||||
}
|
||||
if(block == CustomItems.carpentyBench && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
|
||||
RecipeController controller = RecipeController.Instance;
|
||||
NBTTagList list = new NBTTagList();
|
||||
int i = 0;
|
||||
for(RecipeCarpentry recipe : controller.anvilRecipes.values()){
|
||||
list.appendTag(recipe.writeNBT());
|
||||
i++;
|
||||
if(i % 10 == 0){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("recipes", list);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||
list = new NBTTagList();
|
||||
}
|
||||
}
|
||||
|
||||
if(i % 10 != 0){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("recipes", list);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||
}
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_CARPENTRYBENCH);
|
||||
PacketHandler.Instance.sendToPlayer(new SyncPacket(
|
||||
EnumSyncType.CARPENTRY_RECIPES,
|
||||
EnumSyncAction.RELOAD,
|
||||
-1,
|
||||
SyncController.carpentryNBT()
|
||||
), (EntityPlayerMP) player);
|
||||
}
|
||||
if((block == CustomItems.banner || block == CustomItems.wallBanner || block == CustomItems.sign) && event.action == Action.RIGHT_CLICK_BLOCK){
|
||||
ItemStack item = player.inventory.getCurrentItem();
|
||||
@@ -255,11 +232,23 @@ public class ServerEventsHandler {
|
||||
}
|
||||
|
||||
if(!player.worldObj.isRemote){
|
||||
if(block == CustomItems.banner || block == CustomItems.wallBanner){
|
||||
// If sneaking and using shear
|
||||
if(player.isSneaking() && item.getItem() == Items.shears){
|
||||
int currentVariantIndex = tile.variant.ordinal();
|
||||
int nextVariantIndex = (currentVariantIndex + 1) % EnumBannerVariant.values().length;
|
||||
tile.variant = EnumBannerVariant.values()[nextVariantIndex];
|
||||
|
||||
player.worldObj.markBlockForUpdate(event.x, y, event.z);
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tile.icon = item.copy();
|
||||
player.worldObj.markBlockForUpdate(event.x, y, event.z);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +303,7 @@ public class ServerEventsHandler {
|
||||
ItemStack item = player.getCurrentEquippedItem();
|
||||
if(item == null || item.getItem() != CustomItems.excalibur)
|
||||
return;
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.PLAY_MUSIC, "customnpcs:songs.excalibur");
|
||||
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_MUSIC, "customnpcs:songs.excalibur"), (EntityPlayerMP)player);
|
||||
player.addChatMessage(new ChatComponentTranslation("<" + StatCollector.translateToLocal(item.getItem().getUnlocalizedName() + ".name") + "> " + ItemExcalibur.quotes[player.getRNG().nextInt(ItemExcalibur.quotes.length)]));
|
||||
}
|
||||
|
||||
@@ -512,7 +501,7 @@ public class ServerEventsHandler {
|
||||
MarkData data = MarkData.get((EntityNPCInterface) event.target);
|
||||
if (data.marks.isEmpty())
|
||||
return;
|
||||
Server.sendData((EntityPlayerMP) event.entityPlayer, EnumPacketClient.MARK_DATA, event.target.getEntityId(), data.getNBT());
|
||||
PacketHandler.Instance.sendToPlayer(new MarkDataPacket(event.target.getEntityId(), data.getNBT()), (EntityPlayerMP)event.entityPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,13 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import kamkeel.npcs.controllers.ProfileController;
|
||||
import kamkeel.npcs.controllers.SyncController;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.client.AnalyticsTracking;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.SyncController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
|
||||
import java.net.InetAddress;
|
||||
@@ -52,6 +53,8 @@ public class ServerTickHandler {
|
||||
}
|
||||
|
||||
SyncController.syncPlayer(player);
|
||||
SyncController.syncEffects(player);
|
||||
ProfileController.login(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -46,7 +46,7 @@ public class VersionCompatibility {
|
||||
}
|
||||
if(npc.npcVersion < 12){
|
||||
CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||
CompatabilityFix(compound, npc.ai.writeToNBT(new NBTTagCompound()));
|
||||
CompatabilityFix(compound, npc.ais.writeToNBT(new NBTTagCompound()));
|
||||
CompatabilityFix(compound, npc.stats.writeToNBT(new NBTTagCompound()));
|
||||
CompatabilityFix(compound, npc.display.writeToNBT(new NBTTagCompound()));
|
||||
CompatabilityFix(compound, npc.inventory.writeEntityToNBT(new NBTTagCompound()));
|
||||
@@ -101,7 +101,7 @@ public class VersionCompatibility {
|
||||
int z = ((NBTTagInt) list.removeTag(2)).func_150287_d();
|
||||
int y = ((NBTTagInt) list.removeTag(1)).func_150287_d();
|
||||
int x = ((NBTTagInt) list.removeTag(0)).func_150287_d();
|
||||
|
||||
|
||||
compound.setIntArray("StartPosNew", new int[]{x,y,z});
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class VersionCompatibility {
|
||||
bo = comp.getBoolean("HealthRegen");
|
||||
comp.setInteger("HealthRegen", bo?1:0);
|
||||
compound.setTag("TransformStats", comp);
|
||||
|
||||
|
||||
}
|
||||
npc.npcVersion = ModRev;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ public class VersionCompatibility {
|
||||
if(compatibilty.getVersion() == ModRev)
|
||||
return;
|
||||
CompatabilityFix(compound, compatibilty.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
|
||||
compatibilty.setVersion(ModRev);
|
||||
}
|
||||
private static void CompatabilityFix(NBTTagCompound compound,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import kamkeel.npcs.addon.DBCAddon;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@@ -80,7 +80,7 @@ public class EntityAIAmbushTarget extends EntityAIBase
|
||||
{
|
||||
boolean shouldHide = this.targetEntity.getDistanceSqToEntity(this.theEntity) > this.distance;
|
||||
boolean isSeen = this.theEntity.canSee(targetEntity);
|
||||
return (!this.theEntity.getNavigator().noPath() && shouldHide) || (!isSeen && (shouldHide || this.theEntity.ai.directLOS));
|
||||
return (!this.theEntity.getNavigator().noPath() && shouldHide) || (!isSeen && (shouldHide || this.theEntity.ais.directLOS));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ public class EntityAIAmbushTarget extends EntityAIBase
|
||||
{
|
||||
this.theEntity.getNavigator().tryMoveToXYZ(this.shelterX, this.shelterY, this.shelterZ, this.movementSpeed);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
@@ -114,9 +114,9 @@ public class EntityAIAmbushTarget extends EntityAIBase
|
||||
{
|
||||
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
|
||||
}
|
||||
|
||||
|
||||
private Vec3 findHidingSpot()
|
||||
{
|
||||
{
|
||||
Random random = this.theEntity.getRNG();
|
||||
Vec3 idealPos = null;
|
||||
|
||||
@@ -131,7 +131,7 @@ public class EntityAIAmbushTarget extends EntityAIBase
|
||||
double j = MathHelper.floor_double(this.theEntity.posX + x) + 0.5D;
|
||||
double k = MathHelper.floor_double(this.theEntity.boundingBox.minY + y);
|
||||
double l = MathHelper.floor_double(this.theEntity.posZ + z) + 0.5D;
|
||||
|
||||
|
||||
if (this.theWorld.getBlock((int)j, (int)k, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 1, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 2, (int)l).isOpaqueCube())
|
||||
{
|
||||
Vec3 vec1 = Vec3.createVectorHelper(this.targetEntity.posX, this.targetEntity.posY + (double)this.targetEntity.getEyeHeight(), this.targetEntity.posZ);
|
||||
@@ -148,7 +148,7 @@ public class EntityAIAmbushTarget extends EntityAIBase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (idealPos != null)
|
||||
{
|
||||
return idealPos;
|
||||
|
||||
@@ -24,21 +24,21 @@ public class EntityAIAnimation extends EntityAIBase
|
||||
isDead = !npc.isEntityAlive();
|
||||
if(isDead)
|
||||
return npc.currentAnimation != EnumAnimation.LYING;
|
||||
|
||||
|
||||
if(npc.stats.aimWhileShooting && npc.isAttacking())
|
||||
return npc.currentAnimation != EnumAnimation.AIMING;
|
||||
if(npc.ai.animationType == EnumAnimation.NONE)
|
||||
if(npc.ais.animationType == EnumAnimation.NONE)
|
||||
return npc.currentAnimation != EnumAnimation.NONE;
|
||||
isAttacking = npc.isAttacking();
|
||||
if(npc.ai.returnToStart)
|
||||
if(npc.ais.returnToStart)
|
||||
isAtStartpoint = npc.isVeryNearAssignedPlace();
|
||||
hasPath = !npc.getNavigator().noPath();
|
||||
|
||||
if(npc.ai.movingType == EnumMovingType.Standing && hasNavigation() && npc.currentAnimation.getWalkingAnimation() == 0){
|
||||
|
||||
if(npc.ais.movingType == EnumMovingType.Standing && hasNavigation() && npc.currentAnimation.getWalkingAnimation() == 0){
|
||||
return npc.currentAnimation != EnumAnimation.NONE;
|
||||
}
|
||||
|
||||
return npc.currentAnimation != npc.ai.animationType;
|
||||
|
||||
return npc.currentAnimation != npc.ais.animationType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,21 +47,21 @@ public class EntityAIAnimation extends EntityAIBase
|
||||
setAnimation(EnumAnimation.AIMING);
|
||||
return;
|
||||
}
|
||||
EnumAnimation type = npc.ai.animationType;
|
||||
EnumAnimation type = npc.ais.animationType;
|
||||
if(isDead)
|
||||
type = EnumAnimation.LYING;
|
||||
else if(npc.ai.movingType == EnumMovingType.Standing && npc.ai.animationType.getWalkingAnimation() == 0 && hasNavigation())
|
||||
else if(npc.ais.movingType == EnumMovingType.Standing && npc.ais.animationType.getWalkingAnimation() == 0 && hasNavigation())
|
||||
type = EnumAnimation.NONE;
|
||||
setAnimation(type);
|
||||
}
|
||||
|
||||
|
||||
private void setAnimation(EnumAnimation animation){
|
||||
npc.setCurrentAnimation(animation);
|
||||
npc.updateHitbox();
|
||||
npc.setPosition(npc.posX, npc.posY, npc.posZ);
|
||||
}
|
||||
|
||||
|
||||
private boolean hasNavigation() {
|
||||
return (isAttacking || npc.ai.returnToStart && !isAtStartpoint && !npc.isFollower() || hasPath);
|
||||
return (isAttacking || npc.ais.returnToStart && !isAtStartpoint && !npc.isFollower() || hasPath);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import kamkeel.npcs.addon.DBCAddon;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
@@ -47,14 +47,14 @@ public class EntityAIAttackTarget extends EntityAIBase
|
||||
else if (!entitylivingbase.isEntityAlive()){
|
||||
return false;
|
||||
}
|
||||
else if (this.npc.inventory.getProjectile() != null && this.npc.ai.useRangeMelee == 0){
|
||||
else if (this.npc.inventory.getProjectile() != null && this.npc.ais.useRangeMelee == 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
double var2 = this.npc.getDistanceSq(entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ);
|
||||
double var3 = this.npc.ai.distanceToMelee * this.npc.ai.distanceToMelee;
|
||||
double var3 = this.npc.ais.distanceToMelee * this.npc.ais.distanceToMelee;
|
||||
|
||||
if (this.npc.ai.useRangeMelee == 1 && var2 > var3){
|
||||
if (this.npc.ais.useRangeMelee == 1 && var2 > var3){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
@@ -81,7 +81,7 @@ public class EntityAIAttackTarget extends EntityAIBase
|
||||
|
||||
if(npc.getDistanceToEntity(entityTarget) > npc.stats.aggroRange)
|
||||
return false;
|
||||
if (this.npc.ai.useRangeMelee == 1 && npc.getDistanceSqToEntity(entityTarget) > (this.npc.ai.distanceToMelee * this.npc.ai.distanceToMelee))
|
||||
if (this.npc.ais.useRangeMelee == 1 && npc.getDistanceSqToEntity(entityTarget) > (this.npc.ais.distanceToMelee * this.npc.ais.distanceToMelee))
|
||||
return false;
|
||||
|
||||
return this.npc.isWithinHomeDistance(MathHelper.floor_double(entityTarget.posX), MathHelper.floor_double(entityTarget.posY), MathHelper.floor_double(entityTarget.posZ));
|
||||
@@ -94,7 +94,7 @@ public class EntityAIAttackTarget extends EntityAIBase
|
||||
if(!navOverride)
|
||||
this.npc.getNavigator().setPath(this.entityPathEntity, 1.3D);
|
||||
this.field_75445_i = 0;
|
||||
if (this.npc.getRangedTask() != null && this.npc.ai.useRangeMelee == 2)
|
||||
if (this.npc.getRangedTask() != null && this.npc.ais.useRangeMelee == 2)
|
||||
{
|
||||
this.npc.getRangedTask().navOverride(true);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class EntityAIAttackTarget extends EntityAIBase
|
||||
this.entityTarget = null;
|
||||
this.npc.setAttackTarget(null);
|
||||
this.npc.getNavigator().clearPathEntity();
|
||||
if (this.npc.getRangedTask() != null && this.npc.ai.useRangeMelee == 2)
|
||||
if (this.npc.getRangedTask() != null && this.npc.ais.useRangeMelee == 2)
|
||||
{
|
||||
this.npc.getRangedTask().navOverride(false);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class EntityAIAvoidTarget extends EntityAIBase
|
||||
private EntityNPCInterface theEntity;
|
||||
private Entity closestLivingEntity;
|
||||
private float distanceFromEntity;
|
||||
|
||||
|
||||
private float health;
|
||||
|
||||
/** The PathEntity of our entity */
|
||||
@@ -27,7 +27,7 @@ public class EntityAIAvoidTarget extends EntityAIBase
|
||||
|
||||
/** The PathNavigate of our entity */
|
||||
private PathNavigate entityPathNavigate;
|
||||
|
||||
|
||||
/** The class of the entity we should avoid */
|
||||
private Class targetEntityClass;
|
||||
|
||||
@@ -46,14 +46,14 @@ public class EntityAIAvoidTarget extends EntityAIBase
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
EntityLivingBase target = this.theEntity.getAttackTarget();
|
||||
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
targetEntityClass = target.getClass();
|
||||
|
||||
|
||||
if (this.targetEntityClass == EntityPlayer.class)
|
||||
{
|
||||
this.closestLivingEntity = this.theEntity.worldObj.getClosestPlayerToEntity(this.theEntity, (double)this.distanceFromEntity);
|
||||
@@ -75,7 +75,7 @@ public class EntityAIAvoidTarget extends EntityAIBase
|
||||
this.closestLivingEntity = (Entity)var1.get(0);
|
||||
}
|
||||
|
||||
if (!this.theEntity.getEntitySenses().canSee(this.closestLivingEntity) && this.theEntity.ai.directLOS)
|
||||
if (!this.theEntity.getEntitySenses().canSee(this.closestLivingEntity) && this.theEntity.ais.directLOS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -83,10 +83,10 @@ public class EntityAIAvoidTarget extends EntityAIBase
|
||||
{
|
||||
Vec3 var2 = RandomPositionGeneratorAlt.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, Vec3.createVectorHelper(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ));
|
||||
|
||||
boolean var3 = this.theEntity.inventory.getProjectile() == null || this.theEntity.ai.useRangeMelee == 2;
|
||||
|
||||
boolean var3 = this.theEntity.inventory.getProjectile() == null || this.theEntity.ais.useRangeMelee == 2;
|
||||
|
||||
boolean var4 = var3 ? this.health == this.theEntity.getHealth() : this.theEntity.getRangedTask() != null && !this.theEntity.getRangedTask().hasFired();
|
||||
|
||||
|
||||
if (var2 == null)
|
||||
{
|
||||
return false;
|
||||
@@ -95,7 +95,7 @@ public class EntityAIAvoidTarget extends EntityAIBase
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.theEntity.ai.tacticalVariant == EnumNavType.HitNRun && var4)
|
||||
else if (this.theEntity.ais.tacticalVariant == EnumNavType.HitNRun && var4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -145,13 +145,13 @@ public class EntityAIAvoidTarget extends EntityAIBase
|
||||
{
|
||||
this.theEntity.getNavigator().setSpeed(1.0D);
|
||||
}
|
||||
if (this.theEntity.ai.tacticalVariant == EnumNavType.HitNRun)
|
||||
if (this.theEntity.ais.tacticalVariant == EnumNavType.HitNRun)
|
||||
{
|
||||
float dist = this.theEntity.getDistanceToEntity(this.closestLivingEntity);
|
||||
if (dist > this.distanceFromEntity || dist < this.theEntity.ai.tacticalRadius)
|
||||
if (dist > this.distanceFromEntity || dist < this.theEntity.ais.tacticalRadius)
|
||||
{
|
||||
this.health = this.theEntity.getHealth();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,9 +26,9 @@ public class EntityAIFollow extends EntityAIBase
|
||||
return false;
|
||||
return distance > npc.followRange();
|
||||
}
|
||||
|
||||
|
||||
public boolean excute(){
|
||||
if(!npc.isEntityAlive() || !npc.isFollower() || npc.isAttacking() || (owner = npc.getOwner()) == null || npc.ai.animationType == EnumAnimation.SITTING)
|
||||
if(!npc.isEntityAlive() || !npc.isFollower() || npc.isAttacking() || (owner = npc.getOwner()) == null || npc.ais.animationType == EnumAnimation.SITTING)
|
||||
return false;
|
||||
distance = npc.getDistanceSqToEntity(owner);
|
||||
return true;
|
||||
@@ -62,7 +62,7 @@ public class EntityAIFollow extends EntityAIBase
|
||||
speed = 3;
|
||||
if (this.npc.getNavigator().tryMoveToEntityLiving(owner, speed) || distance < 225.0D)
|
||||
return;
|
||||
|
||||
|
||||
int i = MathHelper.floor_double(this.owner.posX) - 2;
|
||||
int j = MathHelper.floor_double(this.owner.posZ) - 2;
|
||||
int k = MathHelper.floor_double(this.owner.boundingBox.minY);
|
||||
|
||||
@@ -28,15 +28,15 @@ public class EntityAILook extends EntityAIBase{
|
||||
public boolean shouldExecute(){
|
||||
return !npc.isAttacking() && npc.getNavigator().noPath() && !npc.isPlayerSleeping() && npc.isEntityAlive();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
@Override
|
||||
public void startExecuting(){
|
||||
rotatebody = npc.ai.standingType == EnumStandingType.RotateBody || npc.ai.standingType == EnumStandingType.HeadRotation;
|
||||
rotatebody = npc.ais.standingType == EnumStandingType.RotateBody || npc.ais.standingType == EnumStandingType.HeadRotation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
@@ -44,13 +44,13 @@ public class EntityAILook extends EntityAIBase{
|
||||
public void resetTask(){
|
||||
rotatebody = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
@Override
|
||||
public void updateTask(){
|
||||
if(npc.ai.standingType == EnumStandingType.Stalking){
|
||||
public void updateTask(){
|
||||
if(npc.ais.standingType == EnumStandingType.Stalking){
|
||||
EntityPlayer player = npc.worldObj.getClosestPlayerToEntity(npc, 16);
|
||||
if(player == null)
|
||||
rotatebody = true;
|
||||
@@ -75,14 +75,14 @@ public class EntityAILook extends EntityAIBase{
|
||||
npc.getLookHelper().setLookPositionWithEntity(closest, 10F, npc.getVerticalFaceSpeed());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(rotatebody){
|
||||
if(idle == 0 && npc.getRNG().nextFloat() < 0.02F){
|
||||
double var1 = (Math.PI * 2D) * this.npc.getRNG().nextDouble();
|
||||
if(npc.ai.standingType == EnumStandingType.HeadRotation)
|
||||
var1 = Math.PI / 180 * npc.ai.orientation + Math.PI * 0.2 + Math.PI * 0.6 * this.npc.getRNG().nextDouble();
|
||||
if(npc.ais.standingType == EnumStandingType.HeadRotation)
|
||||
var1 = Math.PI / 180 * npc.ais.orientation + Math.PI * 0.2 + Math.PI * 0.6 * this.npc.getRNG().nextDouble();
|
||||
this.lookX = Math.cos(var1);
|
||||
this.lookZ = Math.sin(var1);
|
||||
this.idle = 20 + this.npc.getRNG().nextInt(20);
|
||||
@@ -92,9 +92,9 @@ public class EntityAILook extends EntityAIBase{
|
||||
npc.getLookHelper().setLookPosition(npc.posX + lookX, npc.posY + npc.getEyeHeight(), npc.posZ + lookZ, 10F, npc.getVerticalFaceSpeed());
|
||||
}
|
||||
}
|
||||
|
||||
if(npc.ai.standingType == EnumStandingType.NoRotation){
|
||||
npc.rotationYawHead = npc.rotationYaw = npc.renderYawOffset = npc.ai.orientation;
|
||||
|
||||
if(npc.ais.standingType == EnumStandingType.NoRotation){
|
||||
npc.rotationYawHead = npc.rotationYaw = npc.renderYawOffset = npc.ais.orientation;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,16 +21,16 @@ public class EntityAIMovingPath extends EntityAIBase
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldExecute(){
|
||||
if (npc.isAttacking() || npc.isInteracting() || npc.getRNG().nextInt(40) != 0 && npc.ai.movingPause || !npc.getNavigator().noPath() || npc.isInteracting())
|
||||
if (npc.isAttacking() || npc.isInteracting() || npc.getRNG().nextInt(40) != 0 && npc.ais.movingPause || !npc.getNavigator().noPath() || npc.isInteracting())
|
||||
return false;
|
||||
|
||||
List<int[]> list = npc.ai.getMovingPath();
|
||||
|
||||
List<int[]> list = npc.ais.getMovingPath();
|
||||
if(list.size() < 2)
|
||||
return false;
|
||||
|
||||
npc.ai.incrementMovingPath();
|
||||
pos = npc.ai.getCurrentMovingPath();
|
||||
|
||||
|
||||
npc.ais.incrementMovingPath();
|
||||
pos = npc.ais.getCurrentMovingPath();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class EntityAIMovingPath extends EntityAIBase
|
||||
@Override
|
||||
public boolean continueExecuting(){
|
||||
if(npc.isAttacking() || npc.isInteracting()){
|
||||
npc.ai.decreaseMovingPath();
|
||||
npc.ais.decreaseMovingPath();
|
||||
return false;
|
||||
}
|
||||
return !this.npc.getNavigator().noPath();
|
||||
|
||||
@@ -54,16 +54,16 @@ public class EntityAIRangedAttack extends EntityAIBase
|
||||
EntityLivingBase var1 = this.entityHost.getAttackTarget();
|
||||
|
||||
if (var1 == null || !var1.isEntityAlive()) return false;
|
||||
|
||||
|
||||
if(entityHost.getDistanceToEntity(var1) > entityHost.stats.aggroRange) return false;
|
||||
|
||||
|
||||
if (this.entityHost.inventory.getProjectile() == null) return false;
|
||||
|
||||
|
||||
double var2 = this.entityHost.getDistanceSq(var1.posX, var1.boundingBox.minY, var1.posZ);
|
||||
double var3 = this.entityHost.ai.distanceToMelee * this.entityHost.ai.distanceToMelee;
|
||||
|
||||
if (this.entityHost.ai.useRangeMelee >= 1 && var2 <= var3) return false;
|
||||
|
||||
double var3 = this.entityHost.ais.distanceToMelee * this.entityHost.ais.distanceToMelee;
|
||||
|
||||
if (this.entityHost.ais.useRangeMelee >= 1 && var2 <= var3) return false;
|
||||
|
||||
else
|
||||
{
|
||||
this.attackTarget = var1;
|
||||
@@ -91,7 +91,7 @@ public class EntityAIRangedAttack extends EntityAIBase
|
||||
this.hasFired = false;
|
||||
this.rangedAttackTime = this.entityHost.stats.minDelay / 2;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
@@ -101,7 +101,7 @@ public class EntityAIRangedAttack extends EntityAIBase
|
||||
double var1 = this.entityHost.getDistanceSq(this.attackTarget.posX, this.attackTarget.boundingBox.minY, this.attackTarget.posZ);
|
||||
float field_82642_h = this.entityHost.stats.rangedRange * this.entityHost.stats.rangedRange;
|
||||
|
||||
if (!navOverride && this.entityHost.ai.directLOS)
|
||||
if (!navOverride && this.entityHost.ais.directLOS)
|
||||
{
|
||||
if (this.entityHost.getEntitySenses().canSee(this.attackTarget))
|
||||
{
|
||||
@@ -111,7 +111,7 @@ public class EntityAIRangedAttack extends EntityAIBase
|
||||
{
|
||||
this.field_75318_f = 0;
|
||||
}
|
||||
int v = this.entityHost.ai.tacticalVariant == EnumNavType.Default ? 20 : 5;
|
||||
int v = this.entityHost.ais.tacticalVariant == EnumNavType.Default ? 20 : 5;
|
||||
if (var1 <= (double)field_82642_h && this.field_75318_f >= v)
|
||||
{
|
||||
this.entityHost.getNavigator().clearPathEntity();
|
||||
@@ -123,10 +123,10 @@ public class EntityAIRangedAttack extends EntityAIBase
|
||||
}
|
||||
|
||||
this.rangedAttackTime = Math.max(this.rangedAttackTime - 1, 0);
|
||||
|
||||
|
||||
if (this.rangedAttackTime <= 0)
|
||||
{
|
||||
if (var1 <= (double)field_82642_h && (this.entityHost.getEntitySenses().canSee(this.attackTarget) || this.entityHost.ai.canFireIndirect == 2))
|
||||
if (var1 <= (double)field_82642_h && (this.entityHost.getEntitySenses().canSee(this.attackTarget) || this.entityHost.ais.canFireIndirect == 2))
|
||||
{
|
||||
if (this.field_70846_g++ <= this.entityHost.stats.burstCount)
|
||||
{
|
||||
@@ -138,34 +138,34 @@ public class EntityAIRangedAttack extends EntityAIBase
|
||||
this.hasFired = true;
|
||||
this.rangedAttackTime = (this.entityHost.stats.maxDelay - MathHelper.floor_float(this.entityHost.getRNG().nextFloat() * (this.entityHost.stats.maxDelay - this.entityHost.stats.minDelay)));
|
||||
}
|
||||
|
||||
|
||||
if (this.field_70846_g > 1)
|
||||
{
|
||||
boolean indirect = false;
|
||||
|
||||
switch(this.entityHost.ai.canFireIndirect)
|
||||
|
||||
switch(this.entityHost.ais.canFireIndirect)
|
||||
{
|
||||
case 1 : indirect = var1 > (double)field_82642_h / 2; break;
|
||||
case 2 : indirect = !this.entityHost.getEntitySenses().canSee(this.attackTarget);
|
||||
}
|
||||
|
||||
|
||||
this.rangedAttackEntityHost.attackEntityWithRangedAttack(this.attackTarget, indirect ? 1 : 0);
|
||||
if (this.entityHost.currentAnimation != EnumAnimation.AIMING)
|
||||
{
|
||||
this.entityHost.swingItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean hasFired()
|
||||
{
|
||||
return this.hasFired;
|
||||
}
|
||||
|
||||
|
||||
public void navOverride(boolean nav){
|
||||
this.navOverride = nav;
|
||||
this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,25 +29,25 @@ public class EntityAIReturn extends EntityAIBase
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute() {
|
||||
if (!npc.ai.returnToStart){
|
||||
if (!npc.ais.returnToStart){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(npc.hasOwner() || npc.isKilled() || npc.isInteracting()){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (npc.ai.findShelter == 0 && (!npc.worldObj.isDaytime() || npc.worldObj.isRaining()) && !npc.worldObj.provider.hasNoSky){
|
||||
|
||||
if (npc.ais.findShelter == 0 && (!npc.worldObj.isDaytime() || npc.worldObj.isRaining()) && !npc.worldObj.provider.hasNoSky){
|
||||
if (npc.worldObj.canBlockSeeTheSky((int)npc.getStartXPos(), (int)npc.getStartYPos(), (int)npc.getStartZPos()) || npc.worldObj.getFullBlockLightValue((int)npc.getStartXPos(), (int)npc.getStartYPos(), (int)npc.getStartZPos()) <= 8){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (npc.ai.findShelter == 1 && npc.worldObj.isDaytime()){
|
||||
else if (npc.ais.findShelter == 1 && npc.worldObj.isDaytime()){
|
||||
if (npc.worldObj.canBlockSeeTheSky((int)npc.getStartXPos(), (int)npc.getStartYPos(), (int)npc.getStartZPos())){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(npc.isAttacking()){
|
||||
if(!wasAttacked){
|
||||
wasAttacked = true;
|
||||
@@ -56,33 +56,33 @@ public class EntityAIReturn extends EntityAIBase
|
||||
return false;
|
||||
}
|
||||
|
||||
if(npc.ai.movingType == EnumMovingType.MovingPath && npc.ai.getDistanceSqToPathPoint() < ConfigMain.NpcNavRange * ConfigMain.NpcNavRange)
|
||||
if(npc.ais.movingType == EnumMovingType.MovingPath && npc.ais.getDistanceSqToPathPoint() < ConfigMain.NpcNavRange * ConfigMain.NpcNavRange)
|
||||
return false;
|
||||
|
||||
if (npc.getNavigator().noPath() || (!npc.isAttacking() && wasAttacked)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(npc.ai.movingType == EnumMovingType.Wandering)
|
||||
return this.npc.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos()) > npc.ai.walkingRange * npc.ai.walkingRange;
|
||||
if(npc.ais.movingType == EnumMovingType.Wandering)
|
||||
return this.npc.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos()) > npc.ais.walkingRange * npc.ais.walkingRange;
|
||||
|
||||
if(npc.ai.movingType == EnumMovingType.Standing)
|
||||
if(npc.ais.movingType == EnumMovingType.Standing)
|
||||
return !this.npc.isVeryNearAssignedPlace();
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
public boolean continueExecuting(){
|
||||
return !npc.isFollower() && !npc.isKilled() && !npc.isAttacking() && !npc.isVeryNearAssignedPlace() && totalTicks <= MaxTotalTicks && !npc.isInteracting();
|
||||
}
|
||||
|
||||
|
||||
public void updateTask(){
|
||||
totalTicks++;
|
||||
if(totalTicks > MaxTotalTicks){
|
||||
npc.setPosition(endPosX, endPosY, endPosZ);
|
||||
npc.getNavigator().clearPathEntity();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(stuckTicks > 0){
|
||||
stuckTicks--;
|
||||
}
|
||||
@@ -95,19 +95,19 @@ public class EntityAIReturn extends EntityAIBase
|
||||
}
|
||||
else
|
||||
navigate(stuckCount % 2 == 1);
|
||||
}
|
||||
}
|
||||
else{
|
||||
stuckCount = 0;
|
||||
}
|
||||
}
|
||||
private boolean isTooFar(){
|
||||
int allowedDistance = npc.stats.aggroRange * 2;
|
||||
if(npc.ai.movingType == EnumMovingType.Wandering)
|
||||
allowedDistance += npc.ai.walkingRange;
|
||||
if(npc.ais.movingType == EnumMovingType.Wandering)
|
||||
allowedDistance += npc.ais.walkingRange;
|
||||
return npc.getDistanceSq(endPosX, endPosY, endPosZ) > allowedDistance * allowedDistance;
|
||||
}
|
||||
|
||||
public void startExecuting()
|
||||
|
||||
public void startExecuting()
|
||||
{
|
||||
stuckTicks = 0;
|
||||
totalTicks = 0;
|
||||
@@ -133,7 +133,7 @@ public class EntityAIReturn extends EntityAIBase
|
||||
int distance = (int) range;
|
||||
if(distance > ConfigMain.NpcNavRange)
|
||||
distance = ConfigMain.NpcNavRange / 2;
|
||||
else
|
||||
else
|
||||
distance /= 2;
|
||||
if(distance > 2){
|
||||
Vec3 start = Vec3.createVectorHelper(posX, posY, posZ);
|
||||
|
||||
@@ -22,7 +22,7 @@ public class EntityAISprintToTarget extends EntityAIBase
|
||||
return false;
|
||||
}
|
||||
|
||||
switch(this.npc.ai.onAttack){
|
||||
switch(this.npc.ais.onAttack){
|
||||
case 0 : return !this.npc.isInRange(runTarget, 8)? (!this.npc.onGround ? false : true) : false;
|
||||
case 2 : return this.npc.isInRange(runTarget, 7)? (!this.npc.onGround ? false : true) : false;
|
||||
default : return false;
|
||||
|
||||
@@ -33,9 +33,9 @@ public class EntityAIWander extends EntityAIBase
|
||||
if (this.entity.getAge() >= 100 || !entity.getNavigator().noPath() || entity.isInteracting() || this.entity.getRNG().nextInt(80) != 0){
|
||||
return false;
|
||||
}
|
||||
if(entity.ai.npcInteracting && entity.getRNG().nextInt(4) == 1)
|
||||
if(entity.ais.npcInteracting && entity.getRNG().nextInt(4) == 1)
|
||||
nearbyNPC = getNearbyNPC();
|
||||
|
||||
|
||||
if(nearbyNPC != null){
|
||||
this.xPosition = MathHelper.floor_double(nearbyNPC.posX);
|
||||
this.yPosition = MathHelper.floor_double(nearbyNPC.posY);
|
||||
@@ -52,7 +52,7 @@ public class EntityAIWander extends EntityAIBase
|
||||
this.yPosition = vec.yCoord;
|
||||
|
||||
if(entity.canFly())
|
||||
this.yPosition = entity.getStartYPos() + entity.getRNG().nextFloat() * 0.75 * entity.ai.walkingRange;
|
||||
this.yPosition = entity.getStartYPos() + entity.getRNG().nextFloat() * 0.75 * entity.ais.walkingRange;
|
||||
this.zPosition = vec.zCoord;
|
||||
}
|
||||
}
|
||||
@@ -66,28 +66,28 @@ public class EntityAIWander extends EntityAIBase
|
||||
}
|
||||
}
|
||||
private EntityNPCInterface getNearbyNPC() {
|
||||
List<EntityNPCInterface> list = entity.worldObj.getEntitiesWithinAABBExcludingEntity(entity, entity.boundingBox.expand(entity.ai.walkingRange, entity.ai.walkingRange > 7?7:entity.ai.walkingRange, entity.ai.walkingRange), selector);
|
||||
List<EntityNPCInterface> list = entity.worldObj.getEntitiesWithinAABBExcludingEntity(entity, entity.boundingBox.expand(entity.ais.walkingRange, entity.ais.walkingRange > 7?7:entity.ais.walkingRange, entity.ais.walkingRange), selector);
|
||||
Iterator<EntityNPCInterface> ita = list.iterator();
|
||||
while(ita.hasNext()){
|
||||
EntityNPCInterface npc = ita.next();
|
||||
if(!npc.ai.stopAndInteract || npc.isAttacking() || !npc.isEntityAlive() || entity.faction.isAggressiveToNpc(npc))
|
||||
if(!npc.ais.stopAndInteract || npc.isAttacking() || !npc.isEntityAlive() || entity.faction.isAggressiveToNpc(npc))
|
||||
ita.remove();
|
||||
}
|
||||
|
||||
|
||||
if(list.isEmpty())
|
||||
return null;
|
||||
|
||||
|
||||
return list.get(entity.getRNG().nextInt(list.size()));
|
||||
}
|
||||
|
||||
private Vec3 getVec(){
|
||||
if(entity.ai.walkingRange > 0){
|
||||
if(entity.ais.walkingRange > 0){
|
||||
double distance = this.entity.getDistanceSq(this.entity.getStartXPos(), this.entity.getStartYPos(), this.entity.getStartZPos());
|
||||
int range = (int) MathHelper.sqrt_double(this.entity.ai.walkingRange * this.entity.ai.walkingRange - distance);
|
||||
int range = (int) MathHelper.sqrt_double(this.entity.ais.walkingRange * this.entity.ais.walkingRange - distance);
|
||||
if(range > ConfigMain.NpcNavRange)
|
||||
range = ConfigMain.NpcNavRange;
|
||||
if(range < 3){
|
||||
range = this.entity.ai.walkingRange;
|
||||
range = this.entity.ais.walkingRange;
|
||||
if(range > ConfigMain.NpcNavRange)
|
||||
range = ConfigMain.NpcNavRange;
|
||||
Vec3 start = Vec3.createVectorHelper(this.entity.getStartXPos(), this.entity.getStartYPos(), this.entity.getStartZPos());
|
||||
@@ -121,7 +121,7 @@ public class EntityAIWander extends EntityAIBase
|
||||
entity.saySurrounding(line);
|
||||
else
|
||||
nearbyNPC.saySurrounding(line);
|
||||
|
||||
|
||||
entity.addInteract(nearbyNPC);
|
||||
nearbyNPC.addInteract(entity);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class EntityAIWaterNav extends EntityAIBase
|
||||
{
|
||||
if (this.theEntity.isInWater() || this.theEntity.handleLavaMovement())
|
||||
{
|
||||
if (this.theEntity.ai.canSwim)
|
||||
if (this.theEntity.ais.canSwim)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class EntityAIWaterNav extends EntityAIBase
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class FlyPathFinder extends PathFinder
|
||||
{
|
||||
int i;
|
||||
|
||||
if (((EntityNPCInterface)theEntity).ai.canSwim && this.theEntity.isInWater())
|
||||
if (((EntityNPCInterface)theEntity).ais.canSwim && this.theEntity.isInWater())
|
||||
{
|
||||
i = (int)this.theEntity.boundingBox.minY;
|
||||
BlockPos.MutableBlockPos muteBlock = new BlockPos.MutableBlockPos(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ));
|
||||
@@ -132,7 +132,7 @@ public class FlyPathFinder extends PathFinder
|
||||
|
||||
return openPoint(blockpos1.getX(), i, blockpos1.getZ());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public NPCPathPoint getPathPointToCoords(Entity entityIn, double x, double y, double z)
|
||||
{
|
||||
@@ -661,7 +661,7 @@ public class FlyPathFinder extends PathFinder
|
||||
int entitySizeX = MathHelper.floor_double(this.theEntity.width + 1.0F);
|
||||
int entitySizeY = MathHelper.floor_double(this.theEntity.height + 1.0F);
|
||||
int entitySizeZ = MathHelper.floor_double(this.theEntity.width + 1.0F);
|
||||
return this.getPathNodeType(this.worldMap, p_192558_2_, p_192558_3_, p_192558_4_, p_192558_1_, entitySizeX, entitySizeY, entitySizeZ, ((EntityCustomNpc)this.theEntity).ai.doorInteract == 0, ((EntityCustomNpc)this.theEntity).ai.doorInteract == 1);
|
||||
return this.getPathNodeType(this.worldMap, p_192558_2_, p_192558_3_, p_192558_4_, p_192558_1_, entitySizeX, entitySizeY, entitySizeZ, ((EntityCustomNpc)this.theEntity).ais.doorInteract == 0, ((EntityCustomNpc)this.theEntity).ais.doorInteract == 1);
|
||||
}
|
||||
|
||||
public PathNodeType checkNeighborBlocks(IBlockAccess worldmap, int x, int y, int z, PathNodeType type)
|
||||
@@ -735,7 +735,7 @@ public class FlyPathFinder extends PathFinder
|
||||
{
|
||||
if (material == Material.water)
|
||||
{
|
||||
return ((EntityNPCInterface)this.theEntity).ai.canSwim ? PathNodeType.OPEN : PathNodeType.WATER;
|
||||
return ((EntityNPCInterface)this.theEntity).ais.canSwim ? PathNodeType.OPEN : PathNodeType.WATER;
|
||||
}
|
||||
else if (material == Material.lava)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ public class FlyingMoveHelper extends EntityMoveHelper{
|
||||
this.update = false;
|
||||
|
||||
double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
|
||||
double verticalSpeed = this.speed * this.entity.ai.flySpeed/8.0D;
|
||||
double verticalSpeed = this.speed * this.entity.ais.flySpeed/8.0D;
|
||||
this.entity.setAIMoveSpeed((float)speed);
|
||||
|
||||
double d0 = this.posX - this.entity.posX;
|
||||
@@ -45,7 +45,7 @@ public class FlyingMoveHelper extends EntityMoveHelper{
|
||||
this.entity.motionX += (speed * (d0 / d5) - this.entity.motionX) * speed;
|
||||
this.entity.motionZ += (speed * (d2 / d5) - this.entity.motionZ) * speed;
|
||||
|
||||
if (((EntityNPCFlying)this.entity).flyLimitAllow || !this.entity.ai.hasFlyLimit) {
|
||||
if (((EntityNPCFlying)this.entity).flyLimitAllow || !this.entity.ais.hasFlyLimit) {
|
||||
this.entity.motionY = verticalSpeed * (d1 / d5);
|
||||
if (this.entity.motionY > 0) {
|
||||
this.entity.motionY += 0.1D;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package noppes.npcs.ai.selector;
|
||||
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import kamkeel.npcs.addon.DBCAddon;
|
||||
import net.minecraft.command.IEntitySelector;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -31,20 +31,20 @@ public class NPCAttackSelector implements IEntitySelector
|
||||
public boolean isEntityApplicable(Entity entity){
|
||||
if(!entity.isEntityAlive() || entity == npc || npc.getDistanceToEntity(entity) > npc.stats.aggroRange || !(entity instanceof EntityLivingBase) || ((EntityLivingBase)entity).getHealth() < 1)
|
||||
return false;
|
||||
if (this.npc.ai.directLOS && !this.npc.getEntitySenses().canSee(entity))
|
||||
if (this.npc.ais.directLOS && !this.npc.getEntitySenses().canSee(entity))
|
||||
return false;
|
||||
|
||||
if(!npc.stats.attackInvisible &&((EntityLivingBase)entity).isPotionActive(Potion.invisibility) && npc.getDistanceSqToEntity(entity) < 9)
|
||||
return false;
|
||||
|
||||
//prevent the npc from going on an endless killing spree
|
||||
if(!npc.isFollower() && npc.ai.returnToStart){
|
||||
if(!npc.isFollower() && npc.ais.returnToStart){
|
||||
int allowedDistance = npc.stats.aggroRange * 2;
|
||||
if(npc.ai.movingType == EnumMovingType.Wandering)
|
||||
allowedDistance += npc.ai.walkingRange;
|
||||
if(npc.ais.movingType == EnumMovingType.Wandering)
|
||||
allowedDistance += npc.ais.walkingRange;
|
||||
double distance = entity.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos());
|
||||
if(npc.ai.movingType == EnumMovingType.MovingPath){
|
||||
int[] arr = npc.ai.getCurrentMovingPath();
|
||||
if(npc.ais.movingType == EnumMovingType.MovingPath){
|
||||
int[] arr = npc.ais.getCurrentMovingPath();
|
||||
distance = entity.getDistanceSq(arr[0], arr[1], arr[2]);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public class NPCInteractSelector implements IEntitySelector {
|
||||
if(entity == npc || !(entity instanceof EntityNPCInterface) || !npc.isEntityAlive())
|
||||
return false;
|
||||
EntityNPCInterface selected = (EntityNPCInterface) entity;
|
||||
if(selected.isAttacking() || npc.getFaction().isAggressiveToNpc(selected) || !npc.ai.stopAndInteract)
|
||||
if(selected.isAttacking() || npc.getFaction().isAggressiveToNpc(selected) || !npc.ais.stopAndInteract)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiOpenBookPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -10,9 +12,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.blocks.tiles.TileBook;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
|
||||
public class BlockBook extends BlockRotated{
|
||||
|
||||
@@ -32,8 +32,8 @@ public class BlockBook extends BlockRotated{
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BOOK)) {
|
||||
((TileBook)tile).book.func_150996_a(Items.writable_book);
|
||||
}
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.OPEN_BOOK, i, j, k, ((TileBook)tile).book.writeToNBT(new NBTTagCompound()));
|
||||
return true;
|
||||
PacketHandler.Instance.sendToPlayer(new GuiOpenBookPacket(i, j, k, ((TileBook)tile).book.writeToNBT(new NBTTagCompound())), (EntityPlayerMP) player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,6 +14,7 @@ import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.blocks.tiles.TileCampfire;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Random;
|
||||
@@ -31,17 +32,16 @@ public class BlockCampfire extends BlockLightable{
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileCampfire();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
ItemStack item = player.inventory.getCurrentItem();
|
||||
if(item == null)
|
||||
return true;
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
|
||||
if((item.getItem() == Items.flint || item.getItem() == Items.flint_and_steel) && unlitBlock() == this){
|
||||
if(world.rand.nextInt(3) == 0 && !world.isRemote)
|
||||
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
|
||||
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
|
||||
CustomNpcs.proxy.spawnParticle("largesmoke", x + 0.5f, y + 0.5f, z + 0.5f, 0.0D, 0.0D, 0.0D, 2);
|
||||
if(item.getItem() == Items.flint)
|
||||
NoppesUtilServer.consumeItemStack(1, player);
|
||||
@@ -49,11 +49,11 @@ public class BlockCampfire extends BlockLightable{
|
||||
item.damageItem(1, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if(item.getItem() == Item.getItemFromBlock(Blocks.sand) && litBlock() == this){
|
||||
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -68,24 +68,28 @@ public class BlockCampfire extends BlockLightable{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(meta == 1)
|
||||
return;
|
||||
|
||||
|
||||
if(random.nextInt(36) == 0){
|
||||
world.playSound(x + 0.5F, y + 0.5F, z + 0.5F, "fire.fire", 1.0F + random.nextFloat(), 0.3F + random.nextFloat() * 0.7f , false);
|
||||
}
|
||||
|
||||
|
||||
TileCampfire tile = (TileCampfire) world.getTileEntity(x, y, z);
|
||||
|
||||
|
||||
float xOffset = 0.5f, yOffset = 0.7f, zOffset = 0.5f;
|
||||
|
||||
double d0 = (double)((float)x + xOffset);
|
||||
double d1 = (double)((float)y + yOffset);
|
||||
double d2 = (double)((float)z + zOffset);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
CustomNpcs.proxy.spawnParticle("largesmoke", d0, d1, d2, 0.0D, 0.0D, 0.0D, 2);
|
||||
CustomNpcs.proxy.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D, 4);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
if(ConfigClient.LegacyCampfire){
|
||||
CustomNpcs.proxy.spawnParticle("largesmoke", d0, d1, d2, 0.0D, 0.0D, 0.0D, 2);
|
||||
CustomNpcs.proxy.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D, 4);
|
||||
}
|
||||
else {
|
||||
tile.updateEntity();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ package noppes.npcs.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -32,9 +32,14 @@ public class BlockCarpentryBench extends BlockContainer
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{//onBlockActivated
|
||||
{
|
||||
if(!par1World.isRemote){
|
||||
player.openGui(CustomNpcs.instance, EnumGuiType.PlayerAnvil.ordinal(), par1World, i, j, k);
|
||||
int meta = par1World.getBlockMetadata(i, j, k);
|
||||
if(meta >= 4){
|
||||
player.openGui(CustomNpcs.instance, EnumGuiType.PlayerAnvil.ordinal(), par1World, i, j, k);
|
||||
} else {
|
||||
player.openGui(CustomNpcs.instance, EnumGuiType.PlayerCarpentryBench.ordinal(), par1World, i, j, k);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -6,33 +6,49 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class BlockLightable extends BlockRotated{
|
||||
public abstract class BlockLightable extends BlockRotated {
|
||||
|
||||
protected BlockLightable(Block block, boolean lit) {
|
||||
super(block);
|
||||
|
||||
|
||||
if (lit)
|
||||
this.setLightLevel(1.0F);
|
||||
}
|
||||
|
||||
public abstract Block unlitBlock();
|
||||
public abstract Block litBlock();
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(litBlock() == this)
|
||||
world.setBlock(x, y, z, unlitBlock(), world.getBlockMetadata(x, y, z), 2);
|
||||
else
|
||||
world.setBlock(x, y, z, litBlock(), world.getBlockMetadata(x, y, z), 2);
|
||||
tile.validate();
|
||||
world.setTileEntity(x, y, z, tile);
|
||||
// Get the current tile entity and store its NBT
|
||||
TileEntity oldTile = world.getTileEntity(x, y, z);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
oldTile.writeToNBT(compound);
|
||||
|
||||
// Determine which block to set (lit/unlit) based on the current one
|
||||
Block newBlock = (litBlock() == this ? unlitBlock() : litBlock());
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
// Change the block; this creates a new tile entity instance
|
||||
world.setBlock(x, y, z, newBlock, meta, 2);
|
||||
|
||||
// Get the new tile and load the stored NBT
|
||||
TileEntity newTile = world.getTileEntity(x, y, z);
|
||||
if(newTile != null){
|
||||
newTile.readFromNBT(compound);
|
||||
newTile.markDirty();
|
||||
}
|
||||
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
world.notifyBlockOfNeighborChange(x, y, z, newBlock);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiOpenPacket;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -16,38 +17,36 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.blocks.tiles.TileMailbox;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
|
||||
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);
|
||||
GuiOpenPacket.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 +55,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_)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiRedstonePacket;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -13,10 +15,8 @@ import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.blocks.tiles.TileRedstoneBlock;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
|
||||
public class BlockNpcRedstone extends BlockContainer{
|
||||
public BlockNpcRedstone(){
|
||||
@@ -32,8 +32,8 @@ public class BlockNpcRedstone extends BlockContainer{
|
||||
TileEntity tile = par1World.getTileEntity(i, j, k);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_REDSTONE, compound);
|
||||
return true;
|
||||
PacketHandler.Instance.sendToPlayer(new GuiRedstonePacket(compound), (EntityPlayerMP)player);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.packets.data.gui.GuiWaypointPacket;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -12,10 +14,8 @@ import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.blocks.tiles.TileWaypoint;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
|
||||
public class BlockWaypoint extends BlockContainer{
|
||||
|
||||
@@ -34,7 +34,7 @@ public class BlockWaypoint extends BlockContainer{
|
||||
TileEntity tile = par1World.getTileEntity(i, j, k);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_WAYPOINT, compound);
|
||||
PacketHandler.Instance.sendToPlayer(new GuiWaypointPacket(compound), (EntityPlayerMP)player);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -3,29 +3,39 @@ package noppes.npcs.blocks.tiles;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import noppes.npcs.constants.EnumBannerVariant;
|
||||
|
||||
public class TileBanner extends TileColorable {
|
||||
|
||||
|
||||
public ItemStack icon;
|
||||
public EnumBannerVariant variant = EnumBannerVariant.Normal;
|
||||
public long time = 0;
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
super.readFromNBT(compound);
|
||||
icon = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("BannerIcon"));
|
||||
|
||||
int variantIndex = compound.getInteger("BannerVariant");
|
||||
if (variantIndex >= 0 && variantIndex < EnumBannerVariant.values().length) {
|
||||
variant = EnumBannerVariant.values()[variantIndex];
|
||||
} else {
|
||||
variant = EnumBannerVariant.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound compound){
|
||||
super.writeToNBT(compound);
|
||||
if(icon != null)
|
||||
compound.setTag("BannerIcon", icon.writeToNBT(new NBTTagCompound()));
|
||||
compound.setInteger("BannerVariant", variant.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox(){
|
||||
return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 2, zCoord + 1);
|
||||
}
|
||||
|
||||
|
||||
public boolean canEdit(){
|
||||
return System.currentTimeMillis() - time < 10000;
|
||||
return System.currentTimeMillis() - time < 20000;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,62 @@
|
||||
package noppes.npcs.blocks.tiles;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class TileCampfire extends TileColorable {
|
||||
|
||||
|
||||
public static final Random RAND = new Random();
|
||||
private boolean rainAndSky = false;
|
||||
private boolean previousTickLit = false;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (getWorldObj().isRemote)
|
||||
{
|
||||
if (isLit())
|
||||
{
|
||||
if (!previousTickLit || distributedInterval(50L))
|
||||
rainAndSky = isBeingRainedOn();
|
||||
|
||||
addParticles();
|
||||
}
|
||||
|
||||
previousTickLit = isLit();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean distributedInterval(long interval)
|
||||
{
|
||||
if (hasWorldObj())
|
||||
return (getWorldObj().getTotalWorldTime() + (long) (xCoord + yCoord + zCoord)) % interval == 0L;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void addParticles()
|
||||
{
|
||||
CustomNpcs.proxy.generateBigSmokeParticles(getWorldObj(), xCoord, yCoord, zCoord, false);
|
||||
if (rainAndSky)
|
||||
{
|
||||
for (int i = 0; i < RAND.nextInt(3); ++i)
|
||||
getWorldObj().spawnParticle("smoke", xCoord + RAND.nextDouble(), yCoord + 0.9, zCoord + RAND.nextDouble(), 0.0, 0.0, 0.0);
|
||||
}
|
||||
}
|
||||
public boolean isBeingRainedOn()
|
||||
{
|
||||
return getWorldObj().isRaining() && getWorldObj().getPrecipitationHeight(xCoord, zCoord) <= yCoord + 1
|
||||
&& getWorldObj().getBiomeGenForCoords(xCoord, zCoord).canSpawnLightningBolt();
|
||||
}
|
||||
|
||||
public boolean isLit()
|
||||
{
|
||||
Block block = this.getBlockType();
|
||||
return block == CustomItems.campfire;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package noppes.npcs.client;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Client {
|
||||
|
||||
public static void sendData(final EnumPacketServer enu, final Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!Server.fillBuffer(buffer, enu, obs))
|
||||
return;
|
||||
CustomNpcs.Channel.sendToServer(new FMLProxyPacket(buffer, "CustomNPCs"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import kamkeel.addon.client.DBCClient;
|
||||
import kamkeel.npcs.addon.client.DBCClient;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
@@ -32,6 +32,7 @@ import noppes.npcs.*;
|
||||
import noppes.npcs.api.IWorld;
|
||||
import noppes.npcs.blocks.tiles.*;
|
||||
import noppes.npcs.client.controllers.*;
|
||||
import noppes.npcs.client.fx.EntityBigSmokeFX;
|
||||
import noppes.npcs.client.fx.EntityElementalStaffFX;
|
||||
import noppes.npcs.client.fx.EntityEnderFX;
|
||||
import noppes.npcs.client.fx.EntityRainbowFX;
|
||||
@@ -76,7 +77,7 @@ import java.util.Random;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
public static KeyBinding NPCButton;
|
||||
|
||||
public static final Random RAND = new Random();
|
||||
public static FontContainer Font;
|
||||
|
||||
public void load() {
|
||||
@@ -84,8 +85,6 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
Font = new FontContainer(ConfigClient.FontType, ConfigClient.FontSize);
|
||||
createFolders();
|
||||
CustomNpcs.Channel.register(new PacketHandlerClient());
|
||||
CustomNpcs.ChannelPlayer.register(new PacketHandlerPlayer());
|
||||
new MusicController();
|
||||
new ScriptSoundController();
|
||||
|
||||
@@ -246,7 +245,8 @@ public class ClientProxy extends CommonProxy {
|
||||
return new GuiNpcPather(npc);
|
||||
|
||||
else if (gui == EnumGuiType.ManageFactions)
|
||||
return new GuiNPCManageFactions(npc);
|
||||
return new GuiNPCManageMagic(npc);
|
||||
// return new GuiNPCManageFactions(npc);
|
||||
|
||||
else if (gui == EnumGuiType.ManageCustomForms)
|
||||
return DBCClient.Instance.manageCustomForms(npc);
|
||||
@@ -274,7 +274,7 @@ public class ClientProxy extends CommonProxy {
|
||||
return new GuiNPCManageAnimations(animNpc, save);
|
||||
}
|
||||
else if (gui == EnumGuiType.ManageLinked)
|
||||
return new GuiNPCManageLinkedNpc(npc);
|
||||
return new GuiNPCManageLinked(npc);
|
||||
|
||||
else if (gui == EnumGuiType.ManageTransport)
|
||||
return new GuiNPCManageTransporters(npc);
|
||||
@@ -291,6 +291,9 @@ public class ClientProxy extends CommonProxy {
|
||||
else if (gui == EnumGuiType.ManageBanks)
|
||||
return new GuiNPCManageBanks(npc, (ContainerManageBanks) container);
|
||||
|
||||
else if (gui == EnumGuiType.ManageEffects)
|
||||
return new GuiNPCManageEffects(npc);
|
||||
|
||||
else if (gui == EnumGuiType.MainMenuGlobal)
|
||||
return new GuiNPCGlobalMainMenu(npc);
|
||||
|
||||
@@ -318,9 +321,12 @@ public class ClientProxy extends CommonProxy {
|
||||
else if (gui == EnumGuiType.ScriptItem)
|
||||
return new GuiScriptItem();
|
||||
|
||||
else if (gui == EnumGuiType.PlayerAnvil)
|
||||
else if (gui == EnumGuiType.PlayerCarpentryBench)
|
||||
return new GuiNpcCarpentryBench((ContainerCarpentryBench) container);
|
||||
|
||||
else if (gui == EnumGuiType.PlayerAnvil)
|
||||
return new GuiNpcAnvil((ContainerAnvilRepair) container);
|
||||
|
||||
else if (gui == EnumGuiType.SetupFollower)
|
||||
return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container);
|
||||
|
||||
@@ -366,7 +372,7 @@ public class ClientProxy extends CommonProxy {
|
||||
else if (gui == EnumGuiType.RedstoneBlock)
|
||||
return new GuiNpcRedstoneBlock(x, y, z);
|
||||
|
||||
else if(gui == EnumGuiType.MobSpawner)
|
||||
else if(gui == EnumGuiType.Cloner)
|
||||
return new GuiNpcMobSpawner(x, y, z);
|
||||
|
||||
else if(gui == EnumGuiType.MobSpawnerMounter)
|
||||
@@ -543,6 +549,17 @@ public class ClientProxy extends CommonProxy {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateBigSmokeParticles(World world, int x, int y, int z, boolean signalFire)
|
||||
{
|
||||
if (RAND.nextFloat() < 0.11F)
|
||||
{
|
||||
float[] colours = new float[0];
|
||||
for (int i = 0; i < RAND.nextInt(2) + 1; ++i)
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(new EntityBigSmokeFX(world, x, y, z, signalFire, colours));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAchievementDesc(Achievement achievement) {
|
||||
return achievement.getDescription();
|
||||
|
||||
@@ -5,11 +5,12 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import kamkeel.addon.client.DBCClient;
|
||||
import kamkeel.npcs.addon.client.DBCClient;
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
|
||||
import kamkeel.npcs.network.packets.player.InputDevicePacket;
|
||||
import kamkeel.npcs.network.packets.player.ScreenSizePacket;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import net.minecraft.client.audio.SoundManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.inventory.ContainerPlayer;
|
||||
import net.minecraft.world.World;
|
||||
@@ -49,7 +50,7 @@ public class ClientTickHandler{
|
||||
}
|
||||
if(mc.thePlayer != null && mc.thePlayer.openContainer instanceof ContainerPlayer){
|
||||
if(otherContainer){
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.CheckQuestCompletion);
|
||||
PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.CheckQuestCompletion));
|
||||
otherContainer = false;
|
||||
}
|
||||
}
|
||||
@@ -74,7 +75,7 @@ public class ClientTickHandler{
|
||||
if(Minecraft.getMinecraft().thePlayer!=null && (prevWidth!=mc.displayWidth || prevHeight!=mc.displayHeight)){
|
||||
prevWidth = mc.displayWidth;
|
||||
prevHeight = mc.displayHeight;
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.ScreenSize,mc.displayWidth,mc.displayHeight);
|
||||
PacketClient.sendClient(new ScreenSizePacket(mc.displayWidth,mc.displayHeight));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,22 +84,7 @@ public class ClientTickHandler{
|
||||
if(Mouse.getEventButton() == -1 && Mouse.getEventDWheel() == 0)
|
||||
return;
|
||||
|
||||
boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29);
|
||||
boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42);
|
||||
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
|
||||
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
|
||||
|
||||
StringBuilder keysDownString = new StringBuilder();
|
||||
for (int i = 0; i < Keyboard.getKeyCount(); i++) {//Creates a comma separated string of the integer IDs of held keys
|
||||
if (Keyboard.isKeyDown(i)) {
|
||||
keysDownString.append(Integer.valueOf(i)).append(",");
|
||||
}
|
||||
}
|
||||
if (keysDownString.length() > 0) {//Removes last comma for later parsing
|
||||
keysDownString.deleteCharAt(keysDownString.length() - 1);
|
||||
}
|
||||
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.MouseClicked, Mouse.getEventButton(),Mouse.getEventDWheel(),Mouse.isButtonDown(Mouse.getEventButton()), isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, keysDownString.toString());
|
||||
InputDevicePacket.sendMouse(Mouse.getEventButton(),Mouse.getEventDWheel(),Mouse.isButtonDown(Mouse.getEventButton()));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -130,23 +116,9 @@ public class ClientTickHandler{
|
||||
|
||||
if(!Keyboard.isRepeatEvent()) {
|
||||
int key = Keyboard.getEventKey();
|
||||
boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29);
|
||||
boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42);
|
||||
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
|
||||
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
|
||||
boolean keyDown = Keyboard.isKeyDown(key);
|
||||
|
||||
StringBuilder keysDownString = new StringBuilder();
|
||||
for (int i = 0; i < Keyboard.getKeyCount(); i++) {//Creates a comma separated string of the integer IDs of held keys
|
||||
if (Keyboard.isKeyDown(i)) {
|
||||
keysDownString.append(Integer.valueOf(i)).append(",");
|
||||
}
|
||||
}
|
||||
if (keysDownString.length() > 0) {//Removes last comma for later parsing
|
||||
keysDownString.deleteCharAt(keysDownString.length() - 1);
|
||||
}
|
||||
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, key, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, keyDown, keysDownString.toString());
|
||||
InputDevicePacket.sendKeyboard(key, keyDown);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package noppes.npcs.client;
|
||||
|
||||
import kamkeel.addon.DBCAddon;
|
||||
import kamkeel.addon.GeckoAddon;
|
||||
import kamkeel.npcs.addon.DBCAddon;
|
||||
import kamkeel.npcs.addon.GeckoAddon;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.passive.EntityChicken;
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
package noppes.npcs.client;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.GuiRequestPacket;
|
||||
import kamkeel.npcs.network.packets.request.IsGuiOpenInform;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTSizeTracker;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.fx.CustomFX;
|
||||
import noppes.npcs.client.gui.player.GuiDialogInteract;
|
||||
import noppes.npcs.client.gui.player.GuiQuestCompletion;
|
||||
import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
|
||||
@@ -24,20 +22,16 @@ import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.IScrollData;
|
||||
import noppes.npcs.client.gui.util.IScrollGroup;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.ScriptParticle;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
|
||||
public class NoppesUtil {
|
||||
@@ -47,31 +41,10 @@ public class NoppesUtil {
|
||||
}
|
||||
|
||||
public static void requestOpenGUI(EnumGuiType gui, int i, int j, int k) {
|
||||
Client.sendData(EnumPacketServer.Gui, gui.ordinal(), i, j, k);
|
||||
PacketClient.sendClient(new GuiRequestPacket(gui.ordinal(), i, j, k));
|
||||
}
|
||||
|
||||
public static void spawnParticle(ByteBuf buffer) throws IOException{
|
||||
double posX = buffer.readDouble();
|
||||
double posY = buffer.readDouble();
|
||||
double posZ = buffer.readDouble();
|
||||
float height = buffer.readFloat();
|
||||
float width = buffer.readFloat();
|
||||
float yOffset = buffer.readFloat();
|
||||
|
||||
String particle = Server.readString(buffer);
|
||||
World worldObj = Minecraft.getMinecraft().theWorld;
|
||||
|
||||
Random rand = worldObj.rand;
|
||||
if(particle.equals("heal")){
|
||||
for (int k = 0; k < 6; k++)
|
||||
{
|
||||
worldObj.spawnParticle("instantSpell", posX + (rand.nextDouble() - 0.5D) * (double)width, (posY + rand.nextDouble() * (double)height) - (double)yOffset, posZ + (rand.nextDouble() - 0.5D) * (double)width, 0, 0, 0);
|
||||
worldObj.spawnParticle("spell", posX + (rand.nextDouble() - 0.5D) * (double)width, (posY + rand.nextDouble() * (double)height) - (double)yOffset, posZ + (rand.nextDouble() - 0.5D) * (double)width, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateSkinOverlayData(EntityPlayer player, NBTTagCompound compound) {
|
||||
public static void updateSkinOverlayData(EntityPlayer player, NBTTagCompound compound) {
|
||||
HashMap<Integer, SkinOverlay> skinOverlays = new HashMap<>();
|
||||
HashMap<Integer, SkinOverlay> oldOverlays = new HashMap<>();
|
||||
NBTTagList skinOverlayList = compound.getTagList("SkinOverlayData",10);
|
||||
@@ -90,39 +63,7 @@ public class NoppesUtil {
|
||||
ClientCacheHandler.skinOverlays.put(player.getUniqueID(), skinOverlays);
|
||||
}
|
||||
|
||||
public static void spawnScriptedParticle(EntityPlayer player, ByteBuf buffer){
|
||||
Minecraft minecraft = Minecraft.getMinecraft();
|
||||
|
||||
NBTTagCompound compound;
|
||||
ScriptParticle particle;
|
||||
try {
|
||||
compound = Server.readNBT(buffer);
|
||||
particle = ScriptParticle.fromNBT(compound);
|
||||
} catch (IOException ignored) {
|
||||
return;
|
||||
}
|
||||
|
||||
World worldObj = player.worldObj;
|
||||
if (worldObj == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = null;
|
||||
if (compound.hasKey("EntityID")) {
|
||||
entity = worldObj.getEntityByID(compound.getInteger("EntityID"));
|
||||
if (entity != null)
|
||||
worldObj = entity.worldObj;
|
||||
else return;
|
||||
}
|
||||
|
||||
CustomFX fx = CustomFX.fromScriptedParticle(particle, worldObj, entity);
|
||||
|
||||
for(int i = 0; i < particle.amount; i++){
|
||||
minecraft.effectRenderer.addEffect(fx);
|
||||
}
|
||||
}
|
||||
|
||||
public static void clickSound() {
|
||||
public static void clickSound() {
|
||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
}
|
||||
|
||||
@@ -202,7 +143,7 @@ public class NoppesUtil {
|
||||
try {
|
||||
int size = buffer.readInt();
|
||||
for(int i = 0; i < size; i++){
|
||||
data.add(Server.readString(buffer));
|
||||
data.add(ByteBufUtils.readString(buffer));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -219,7 +160,7 @@ public class NoppesUtil {
|
||||
int size = buffer.readInt();
|
||||
for(int i = 0; i < size; i++){
|
||||
int id = buffer.readInt();
|
||||
String name = Server.readString(buffer);
|
||||
String name = ByteBufUtils.readString(buffer);
|
||||
group.put(name, id);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
@@ -234,7 +175,7 @@ public class NoppesUtil {
|
||||
int size = buffer.readInt();
|
||||
for(int i = 0; i < size; i++){
|
||||
int id = buffer.readInt();
|
||||
String name = Server.readString(buffer);
|
||||
String name = ByteBufUtils.readString(buffer);
|
||||
group.put(name, id);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
@@ -250,18 +191,6 @@ public class NoppesUtil {
|
||||
group = new HashMap<String,Integer>();
|
||||
}
|
||||
|
||||
public static void addScrollData(ByteBuf buffer) {
|
||||
try {
|
||||
int size = buffer.readInt();
|
||||
for(int i = 0; i < size; i++){
|
||||
int id = buffer.readInt();
|
||||
String name = Server.readString(buffer);
|
||||
data.put(name, id);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setScrollData(ByteBuf buffer) {
|
||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
||||
if(gui == null)
|
||||
@@ -270,7 +199,7 @@ public class NoppesUtil {
|
||||
int size = buffer.readInt();
|
||||
for(int i = 0; i < size; i++){
|
||||
int id = buffer.readInt();
|
||||
String name = Server.readString(buffer);
|
||||
String name = ByteBufUtils.readString(buffer);
|
||||
data.put(name, id);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -327,53 +256,6 @@ public class NoppesUtil {
|
||||
}
|
||||
|
||||
public static void isGUIOpen(boolean isGUIOpen) {
|
||||
Client.sendData(EnumPacketServer.IsGuiOpen, isGUIOpen);
|
||||
PacketClient.sendClient(new IsGuiOpenInform(isGUIOpen));
|
||||
}
|
||||
|
||||
|
||||
private static byte[] accumulatedData = new byte[0];
|
||||
public static void handleLargeData(byte[] chunk) {
|
||||
// Append the chunk to the accumulated data
|
||||
accumulatedData = concatByteArrays(accumulatedData, chunk);
|
||||
}
|
||||
|
||||
public static void handlePlayerDataEnd(boolean sync) {
|
||||
NBTTagCompound compound;
|
||||
try {
|
||||
compound = CompressedStreamTools.func_152457_a(accumulatedData, new NBTSizeTracker(2097152L));
|
||||
if(sync){
|
||||
ClientCacheHandler.playerData.setSyncNBT(compound);
|
||||
}
|
||||
else {
|
||||
ClientCacheHandler.playerData.setSyncNBTFull(compound);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
} finally {
|
||||
// Reset the accumulated data after processing
|
||||
accumulatedData = new byte[0];
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleFormEnd() {
|
||||
NBTTagCompound compound;
|
||||
try {
|
||||
compound = CompressedStreamTools.func_152457_a(accumulatedData, new NBTSizeTracker(2097152L));
|
||||
ClientCacheHandler.playerData.setDBCSync(compound);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
} finally {
|
||||
accumulatedData = new byte[0];
|
||||
}
|
||||
}
|
||||
|
||||
// Utility method to concatenate two byte arrays
|
||||
private static byte[] concatByteArrays(byte[] a, byte[] b) {
|
||||
byte[] result = new byte[a.length + b.length];
|
||||
System.arraycopy(a, 0, result, 0, a.length);
|
||||
System.arraycopy(b, 0, result, a.length, b.length);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,448 +0,0 @@
|
||||
package noppes.npcs.client;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.achievement.GuiAchievement;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import noppes.npcs.*;
|
||||
import noppes.npcs.client.ClientProxy.FontContainer;
|
||||
import noppes.npcs.client.controllers.MusicController;
|
||||
import noppes.npcs.client.controllers.ScriptClientSound;
|
||||
import noppes.npcs.client.controllers.ScriptSoundController;
|
||||
import noppes.npcs.client.gui.GuiNpcMobSpawnerAdd;
|
||||
import noppes.npcs.client.gui.OverlayQuestTracking;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import noppes.npcs.client.gui.player.GuiBook;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.RecipeController;
|
||||
import noppes.npcs.controllers.SyncController;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.controllers.data.MarkData;
|
||||
import noppes.npcs.controllers.data.RecipeCarpentry;
|
||||
import noppes.npcs.entity.EntityDialogNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PacketHandlerClient extends PacketHandlerServer{
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPacketData(ClientCustomPacketEvent event) {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
ByteBuf buffer = event.packet.payload();
|
||||
try {
|
||||
client(buffer,(EntityPlayer) player,EnumPacketClient.values()[buffer.readInt()]);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void client(ByteBuf buffer, final EntityPlayer player, EnumPacketClient type) throws IOException{
|
||||
if(type == EnumPacketClient.CHATBUBBLE){
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
if(npc.messages == null)
|
||||
npc.messages = new RenderChatMessages();
|
||||
String text = NoppesStringUtils.formatText(Server.readString(buffer), player, npc);
|
||||
npc.messages.addMessage(text, npc);
|
||||
|
||||
if(buffer.readBoolean())
|
||||
player.addChatMessage(new ChatComponentTranslation(npc.getCommandSenderName() + ": " + text));
|
||||
}
|
||||
else if(type == EnumPacketClient.CHAT){
|
||||
if(!ConfigClient.ChatAlerts)
|
||||
return;
|
||||
|
||||
String message = "";
|
||||
String str;
|
||||
while((str = Server.readString(buffer)) != null && !str.isEmpty())
|
||||
message += StatCollector.translateToLocal(str);
|
||||
|
||||
player.addChatMessage(new ChatComponentTranslation(message));
|
||||
}
|
||||
else if(type == EnumPacketClient.MESSAGE || type == EnumPacketClient.PARTY_MESSAGE){
|
||||
if(!ConfigClient.BannerAlerts)
|
||||
return;
|
||||
|
||||
String description = StatCollector.translateToLocal(Server.readString(buffer));
|
||||
String message = Server.readString(buffer);
|
||||
Achievement ach = type == EnumPacketClient.MESSAGE ? new MessageAchievement(message, description) : new MessageAchievement(CustomItems.bag == null ? Items.paper : CustomItems.bag, message, description);
|
||||
Minecraft.getMinecraft().guiAchievement.func_146256_a(ach);
|
||||
ObfuscationReflectionHelper.setPrivateValue(GuiAchievement.class, Minecraft.getMinecraft().guiAchievement, ach.getDescription(), 4);
|
||||
}
|
||||
else if(type == EnumPacketClient.SYNCRECIPES_ADD){
|
||||
NBTTagList list = Server.readNBT(buffer).getTagList("recipes", 10);
|
||||
if(list == null)
|
||||
return;
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
RecipeCarpentry recipe = RecipeCarpentry.read(list.getCompoundTagAt(i));
|
||||
RecipeController.syncRecipes.put(recipe.id,recipe);
|
||||
}
|
||||
|
||||
}
|
||||
else if(type == EnumPacketClient.SYNCRECIPES_WORKBENCH){
|
||||
RecipeController.reloadGlobalRecipes(RecipeController.syncRecipes);
|
||||
RecipeController.syncRecipes = new HashMap<Integer, RecipeCarpentry>();
|
||||
}
|
||||
else if(type == EnumPacketClient.SYNCRECIPES_CARPENTRYBENCH){
|
||||
RecipeController.Instance.anvilRecipes = RecipeController.syncRecipes;
|
||||
RecipeController.syncRecipes = new HashMap<Integer, RecipeCarpentry>();
|
||||
}
|
||||
else if(type == EnumPacketClient.LARGE_NBT_PART){
|
||||
byte[] chunk = new byte[buffer.readShort()];
|
||||
buffer.readBytes(chunk);
|
||||
NoppesUtil.handleLargeData(chunk);
|
||||
}
|
||||
else if(type == EnumPacketClient.SYNC_PLAYER){
|
||||
boolean sync = buffer.readBoolean();
|
||||
NoppesUtil.handlePlayerDataEnd(sync);
|
||||
}
|
||||
else if(type == EnumPacketClient.SYNC_ADD || type == EnumPacketClient.SYNC_END){
|
||||
int synctype = buffer.readInt();
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
SyncController.clientSync(synctype, compound, type == EnumPacketClient.SYNC_END);
|
||||
}
|
||||
else if(type == EnumPacketClient.SYNC_UPDATE){
|
||||
int synctype = buffer.readInt();
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
SyncController.clientSyncUpdate(synctype, compound, buffer);
|
||||
}
|
||||
else if(type == EnumPacketClient.SYNC_REMOVE){
|
||||
int synctype = buffer.readInt();
|
||||
int id = buffer.readInt();
|
||||
|
||||
SyncController.clientSyncRemove(synctype, id);
|
||||
}
|
||||
else if(type == EnumPacketClient.MARK_DATA){
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt());
|
||||
if(!(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
MarkData data = MarkData.get((EntityNPCInterface) entity);
|
||||
data.setNBT(Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketClient.DIALOG){
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
NoppesUtil.openDialog(Server.readNBT(buffer), (EntityNPCInterface) entity, player);
|
||||
}
|
||||
else if(type == EnumPacketClient.DIALOG_DUMMY){
|
||||
EntityDialogNpc npc = new EntityDialogNpc(player.worldObj);
|
||||
npc.display.name = Server.readString(buffer);
|
||||
EntityUtil.Copy(player, npc);
|
||||
NoppesUtil.openDialog(Server.readNBT(buffer), npc, player);
|
||||
}
|
||||
else if(type == EnumPacketClient.QUEST_COMPLETION){
|
||||
NoppesUtil.guiQuestCompletion(player, Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketClient.EDIT_NPC){
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
NoppesUtil.setLastNpc((EntityNPCInterface) entity);
|
||||
}
|
||||
else if(type == EnumPacketClient.PLAY_MUSIC){
|
||||
MusicController.Instance.playMusicBackground(Server.readString(buffer), player, Integer.MAX_VALUE);
|
||||
}
|
||||
else if(type == EnumPacketClient.PLAY_SOUND){
|
||||
MusicController.Instance.playSound(Server.readString(buffer),buffer.readFloat(),buffer.readFloat(),buffer.readFloat());
|
||||
}
|
||||
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.SCRIPTED_PARTICLE){
|
||||
NoppesUtil.spawnScriptedParticle(player, buffer);
|
||||
}
|
||||
else if(type == EnumPacketClient.PARTICLE){
|
||||
NoppesUtil.spawnParticle(buffer);
|
||||
}
|
||||
else if(type == EnumPacketClient.DELETE_NPC){
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
((EntityNPCInterface)entity).delete();
|
||||
}
|
||||
else if(type == EnumPacketClient.SCROLL_LIST){
|
||||
NoppesUtil.setScrollList(buffer);
|
||||
}
|
||||
else if(type == EnumPacketClient.SCROLL_DATA){
|
||||
NoppesUtil.setScrollData(buffer);
|
||||
}
|
||||
else if(type == EnumPacketClient.SCROLL_DATA_PART){
|
||||
NoppesUtil.addScrollData(buffer);
|
||||
}
|
||||
else if(type == EnumPacketClient.SCROLL_GROUP){
|
||||
NoppesUtil.setScrollGroup(buffer);
|
||||
}
|
||||
else if(type == EnumPacketClient.SCROLL_GROUP_PART){
|
||||
NoppesUtil.addScrollGroup(buffer);
|
||||
}
|
||||
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));
|
||||
}
|
||||
else if(type == EnumPacketClient.GUI_WAYPOINT){
|
||||
NoppesUtil.saveWayPointBlock(player, Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketClient.CLONE){
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
NoppesUtil.openGUI(player, new GuiNpcMobSpawnerAdd(compound));
|
||||
}
|
||||
else if(type == EnumPacketClient.CLONER){
|
||||
int x = buffer.readInt();
|
||||
int y = buffer.readInt();
|
||||
int z = buffer.readInt();
|
||||
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.MobSpawner, player);
|
||||
}
|
||||
else if(type == EnumPacketClient.TELEPORTER){
|
||||
CustomNpcs.proxy.openGui((EntityNPCInterface)null,EnumGuiType.NpcDimensions);
|
||||
}
|
||||
else if(type == EnumPacketClient.GUI_DATA){
|
||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
||||
if(gui == null)
|
||||
return;
|
||||
|
||||
if(gui instanceof GuiNPCInterface && ((GuiNPCInterface)gui).hasSubGui()){
|
||||
gui = (GuiScreen) ((GuiNPCInterface)gui).getSubGui();
|
||||
}
|
||||
else if(gui instanceof GuiContainerNPCInterface && ((GuiContainerNPCInterface)gui).hasSubGui()){
|
||||
gui = (GuiScreen) ((GuiContainerNPCInterface)gui).getSubGui();
|
||||
}
|
||||
if(gui instanceof IGuiData)
|
||||
((IGuiData)gui).setGuiData(Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketClient.GUI_ERROR){
|
||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
||||
if(gui == null || !(gui instanceof IGuiError))
|
||||
return;
|
||||
|
||||
int i = buffer.readInt();
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
|
||||
((IGuiError)gui).setError(i, compound);
|
||||
}
|
||||
else if(type == EnumPacketClient.GUI_CLOSE){
|
||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
||||
if(gui == null)
|
||||
return;
|
||||
|
||||
if(gui instanceof IGuiClose){
|
||||
int i = buffer.readInt();
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
((IGuiClose)gui).setClose(i, compound);
|
||||
}
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.displayGuiScreen(null);
|
||||
mc.setIngameFocus();
|
||||
}
|
||||
else if(type == EnumPacketClient.VILLAGER_LIST){
|
||||
MerchantRecipeList merchantrecipelist = MerchantRecipeList.func_151390_b(new PacketBuffer(buffer));
|
||||
ServerEventsHandler.Merchant.setRecipes(merchantrecipelist);
|
||||
}
|
||||
else if(type == EnumPacketClient.OPEN_BOOK){
|
||||
int x = buffer.readInt(), y = buffer.readInt(), z = buffer.readInt();
|
||||
|
||||
NoppesUtil.openGUI(player, new GuiBook(player, ItemStack.loadItemStackFromNBT(Server.readNBT(buffer)), x, y, z));
|
||||
}
|
||||
else if(type == EnumPacketClient.CONFIG){
|
||||
int config = buffer.readInt();
|
||||
if(config == 0){//Font
|
||||
String font = Server.readString(buffer);
|
||||
int size = buffer.readInt();
|
||||
if(!font.isEmpty()){
|
||||
ConfigClient.FontType = font;
|
||||
ConfigClient.FontSize = size;
|
||||
ClientProxy.Font = new FontContainer(ConfigClient.FontType, ConfigClient.FontSize);
|
||||
|
||||
ConfigClient.FontTypeProperty.set(ConfigClient.FontType);
|
||||
ConfigClient.FontSizeProperty.set(ConfigClient.FontSize);
|
||||
if(ConfigClient.config.hasChanged()){
|
||||
ConfigClient.config.save();
|
||||
}
|
||||
|
||||
player.addChatMessage(new ChatComponentTranslation("Font set to %s", ClientProxy.Font.getName()));
|
||||
}
|
||||
else
|
||||
player.addChatMessage(new ChatComponentTranslation("Current font is %s", ClientProxy.Font.getName()));
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketClient.ISGUIOPEN){
|
||||
boolean isGUIOpen = Minecraft.getMinecraft().currentScreen != null;
|
||||
|
||||
NoppesUtil.isGUIOpen(isGUIOpen);
|
||||
}
|
||||
else if(type == EnumPacketClient.SCRIPT_OVERLAY_DATA){
|
||||
OverlayCustom overlayCustom = new OverlayCustom(Minecraft.getMinecraft());
|
||||
overlayCustom.setOverlayData(Server.readNBT(buffer));
|
||||
|
||||
ClientCacheHandler.customOverlays.put(overlayCustom.overlay.getID(),overlayCustom);
|
||||
}
|
||||
else if(type == EnumPacketClient.SCRIPT_OVERLAY_CLOSE){
|
||||
int id = buffer.readInt();
|
||||
ClientCacheHandler.customOverlays.remove(id);
|
||||
}
|
||||
else if(type == EnumPacketClient.OVERLAY_QUEST_TRACKING){
|
||||
try {
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
ClientCacheHandler.questTrackingOverlay = new OverlayQuestTracking(Minecraft.getMinecraft());
|
||||
ClientCacheHandler.questTrackingOverlay.setOverlayData(compound);
|
||||
} catch (IOException e) {
|
||||
ClientCacheHandler.questTrackingOverlay = null;
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketClient.SWING_PLAYER_ARM){
|
||||
Minecraft.getMinecraft().thePlayer.swingItem();
|
||||
}
|
||||
else if(type == EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS) {
|
||||
EntityPlayer sendingPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(Server.readString(buffer));
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
if (sendingPlayer != null) {
|
||||
NoppesUtil.updateSkinOverlayData(sendingPlayer, compound);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketClient.UPDATE_ANIMATIONS) {
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
AnimationData animationData = null;
|
||||
if (compound.hasKey("EntityId")) {
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(compound.getInteger("EntityId"));
|
||||
if (entity instanceof EntityNPCInterface) {
|
||||
animationData = ((EntityNPCInterface) entity).display.animationData;
|
||||
}
|
||||
} else {
|
||||
EntityPlayer sendingPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(Server.readString(buffer));
|
||||
if (sendingPlayer != null) {
|
||||
if (!ClientCacheHandler.playerAnimations.containsKey(sendingPlayer.getUniqueID())) {
|
||||
ClientCacheHandler.playerAnimations.put(sendingPlayer.getUniqueID(), new AnimationData(sendingPlayer));
|
||||
}
|
||||
animationData = ClientCacheHandler.playerAnimations.get(sendingPlayer.getUniqueID());
|
||||
animationData.parent = sendingPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
if (animationData != null) {
|
||||
if (compound.hasKey("Animation")) {
|
||||
Animation animation = new Animation();
|
||||
animation.readFromNBT(compound.getCompoundTag("Animation"));
|
||||
animationData.setAnimation(animation);
|
||||
} else {
|
||||
animationData.setAnimation(null);
|
||||
}
|
||||
animationData.readFromNBT(compound);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketClient.DISABLE_MOUSE_INPUT) {
|
||||
long length = buffer.readLong();
|
||||
try {
|
||||
String parsedButtons = Server.readString(buffer);
|
||||
if (parsedButtons == null || parsedButtons.isEmpty()) {
|
||||
ClientEventHandler.disabledButtonTimes.put(-1, length);
|
||||
return;
|
||||
}
|
||||
|
||||
String[] splitIds = parsedButtons.split(";");
|
||||
for (String s : splitIds) {
|
||||
ClientEventHandler.disabledButtonTimes.put(Integer.parseInt(s), length);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
else if(type == EnumPacketClient.PLAY_SOUND_TO) {
|
||||
int id = buffer.readInt();
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
ScriptClientSound sound = ScriptClientSound.fromScriptSound(compound, player.worldObj);
|
||||
|
||||
ScriptSoundController.Instance.playSound(id,sound);
|
||||
}
|
||||
else if(type == EnumPacketClient.PLAY_SOUND_TO_NO_ID) {
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
ScriptClientSound sound = ScriptClientSound.fromScriptSound(compound, player.worldObj);
|
||||
ScriptSoundController.Instance.playSound(sound);
|
||||
}
|
||||
else if(type == EnumPacketClient.STOP_SOUND_FOR) {
|
||||
int id = buffer.readInt();
|
||||
ScriptSoundController.Instance.stopSound(id);
|
||||
}
|
||||
else if(type == EnumPacketClient.PAUSE_SOUNDS) {
|
||||
ScriptSoundController.Instance.pauseAllSounds();
|
||||
}
|
||||
else if(type == EnumPacketClient.CONTINUE_SOUNDS) {
|
||||
ScriptSoundController.Instance.continueAllSounds();
|
||||
}
|
||||
else if(type == EnumPacketClient.STOP_SOUNDS) {
|
||||
ScriptSoundController.Instance.stopAllSounds();
|
||||
}
|
||||
else if(type == EnumPacketClient.SYNC_WEAPON) {
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt());
|
||||
if(!(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
int weaponSlotIndex = buffer.readInt();
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(Server.readNBT(buffer));
|
||||
npc.inventory.weapons.put(weaponSlotIndex,stack);
|
||||
}
|
||||
else if(type == EnumPacketClient.PARTY_DATA){
|
||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
||||
if(gui == null)
|
||||
return;
|
||||
|
||||
if(gui instanceof GuiNPCInterface && ((GuiNPCInterface)gui).hasSubGui()){
|
||||
gui = (GuiScreen) ((GuiNPCInterface)gui).getSubGui();
|
||||
}
|
||||
else if(gui instanceof GuiContainerNPCInterface && ((GuiContainerNPCInterface)gui).hasSubGui()){
|
||||
gui = (GuiScreen) ((GuiContainerNPCInterface)gui).getSubGui();
|
||||
}
|
||||
if(gui instanceof IPartyData)
|
||||
((IPartyData)gui).setPartyData(Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketClient.DBC_FORM){
|
||||
NoppesUtil.handleFormEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class TranslateUtil {
|
||||
private static final String AudioUrl = "http://translate.google.com/translate_tts?q=%s&tl=%s";
|
||||
|
||||
public static String Translate(String text){
|
||||
|
||||
|
||||
try {
|
||||
String urlStr = String.format(TranslateUrl, URLEncoder.encode(text,"utf8"), "auto", "nl");
|
||||
URL url = new URL(urlStr);
|
||||
@@ -45,10 +45,10 @@ public class TranslateUtil {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
// public static void PlayAudio(String text){
|
||||
// try {
|
||||
// String urlStr = String.format(AudioUrl, URLEncoder.encode(text,"utf8"), "en");
|
||||
@@ -59,12 +59,12 @@ public class TranslateUtil {
|
||||
// //connection.setDoOutput(true);
|
||||
// connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)");
|
||||
// connection.setRequestProperty("X-HTTP-Method-Override", "GET");
|
||||
//
|
||||
//
|
||||
// InputStream audioSrc = new BufferedInputStream(connection.getInputStream());
|
||||
// //DataInputStream read = new DataInputStream(audioSrc);
|
||||
// AudioInputStream audioIn = AudioSystem.getAudioInputStream(audioSrc);
|
||||
// Clip clip = AudioSystem.getClip();
|
||||
//
|
||||
//
|
||||
// } catch (UnsupportedEncodingException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (MalformedURLException e) {
|
||||
@@ -72,10 +72,10 @@ public class TranslateUtil {
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (UnsupportedAudioFileException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
//
|
||||
// e.printStackTrace();
|
||||
// } catch (LineUnavailableException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
//
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
package noppes.npcs.client.fx;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
|
||||
|
||||
public class EntityBigSmokeFX extends EntityFX
|
||||
{
|
||||
|
||||
/** there are 12 smoke textures. */
|
||||
public static final int TEXTURE_COUNT = 12;
|
||||
public static final ResourceLocation[] TEXTURES = new ResourceLocation[TEXTURE_COUNT];
|
||||
static
|
||||
{
|
||||
for (int i = 0; i < TEXTURE_COUNT; i++)
|
||||
TEXTURES[i] = new ResourceLocation("customnpcs" + ":" + "textures/particle/big_smoke_" + i + ".png");
|
||||
}
|
||||
|
||||
protected final int texIndex;
|
||||
protected boolean alphaFading = false;
|
||||
protected float alphaFadePerTick = -0.015F;
|
||||
protected boolean localizedCombustion = true;
|
||||
protected boolean isColored = false;
|
||||
|
||||
/**
|
||||
* Posts a {@link EntityBigSmokeFXConstructingEvent}.
|
||||
*/
|
||||
public EntityBigSmokeFX(World world, int x, int y, int z, boolean signalFire, float[] colours) {
|
||||
super(world, x, y, z);
|
||||
|
||||
// Position: Centered above the spawn point with slight randomness
|
||||
this.setPosition(
|
||||
x + 0.5 + (rand.nextDouble() / 10.0 * (rand.nextBoolean() ? 1 : -1)), // Small horizontal offset
|
||||
y + 0.1 + (rand.nextDouble() * 0.1), // Start slightly above y
|
||||
z + 0.5 + (rand.nextDouble() / 10.0 * (rand.nextBoolean() ? 1 : -1))
|
||||
);
|
||||
|
||||
// Scale: Smoke size
|
||||
this.particleScale = 4.0F * (rand.nextFloat() * 0.5F + 0.5F); // Smaller size
|
||||
this.setSize(0.25F, 0.25F);
|
||||
|
||||
// Gravity: Slows upward motion gradually
|
||||
this.particleGravity = 0.005F;
|
||||
|
||||
// Upward motion: Slow, with slight randomness
|
||||
this.motionX = 0; // No horizontal motion
|
||||
this.motionY = 0.02F + rand.nextFloat() * 0.01F;
|
||||
this.motionZ = 0; // No horizontal motion
|
||||
|
||||
this.particleMaxAge = rand.nextInt(50) + 100; // Shorter lifetime for normal smoke
|
||||
this.particleAlpha = 0.8F;
|
||||
|
||||
if (colours.length == 3) {
|
||||
this.setRBGColorF(colours[0], colours[1], colours[2]);
|
||||
}
|
||||
|
||||
// Smoke appearance
|
||||
this.texIndex = rand.nextInt(TEXTURE_COUNT);
|
||||
this.isColored = this.particleRed != 1.0F || this.particleGreen != 1.0F || this.particleBlue != 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tess, float partialTicks, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY)
|
||||
{
|
||||
rotX = ActiveRenderInfo.rotationX;
|
||||
rotXZ = ActiveRenderInfo.rotationXZ;
|
||||
rotZ = ActiveRenderInfo.rotationZ;
|
||||
rotYZ = ActiveRenderInfo.rotationYZ;
|
||||
rotXY = ActiveRenderInfo.rotationXY;
|
||||
|
||||
EntityLivingBase view = Minecraft.getMinecraft().renderViewEntity;
|
||||
double interpX = view.lastTickPosX + (view.posX - view.lastTickPosX) * partialTicks;
|
||||
double interpY = view.lastTickPosY + (view.posY - view.lastTickPosY) * partialTicks;
|
||||
double interpZ = view.lastTickPosZ + (view.posZ - view.lastTickPosZ) * partialTicks;
|
||||
|
||||
float partialPosX = (float) (prevPosX + (posX - prevPosX) * partialTicks - interpX);
|
||||
float partialPosY = (float) (prevPosY + (posY - prevPosY) * partialTicks - interpY);
|
||||
float partialPosZ = (float) (prevPosZ + (posZ - prevPosZ) * partialTicks - interpZ);
|
||||
|
||||
float scale = 0.1F * particleScale;
|
||||
|
||||
double minU = this.particleTextureIndexX * 0.25;
|
||||
double maxU = minU + 0.25;
|
||||
double minV = this.particleTextureIndexY * 0.125;
|
||||
double maxV = minV + 0.125;
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURES[this.texIndex % TEXTURES.length]);
|
||||
|
||||
tess.startDrawingQuads();
|
||||
|
||||
tess.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
|
||||
tess.setBrightness(15 << 20 | 14 << 4); // slightly less than MiscUtil.MAX_LIGHT_BRIGHTNESS so that smoke doesn't glow super bright with shaders
|
||||
|
||||
tess.addVertexWithUV(partialPosX - rotX * scale - rotYZ * scale, partialPosY - rotXZ * scale, partialPosZ - rotZ * scale - rotXY * scale, 1, 1);
|
||||
tess.addVertexWithUV(partialPosX - rotX * scale + rotYZ * scale, partialPosY + rotXZ * scale, partialPosZ - rotZ * scale + rotXY * scale, 1, 0);
|
||||
tess.addVertexWithUV(partialPosX + rotX * scale + rotYZ * scale, partialPosY + rotXZ * scale, partialPosZ + rotZ * scale + rotXY * scale, 0, 0);
|
||||
tess.addVertexWithUV(partialPosX + rotX * scale - rotYZ * scale, partialPosY - rotXZ * scale, partialPosZ + rotZ * scale - rotXY * scale, 0, 1);
|
||||
|
||||
tess.draw();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
|
||||
// Age-based behavior: Fade out near the end of lifetime
|
||||
if (this.particleAge++ >= this.particleMaxAge - 40) {
|
||||
this.alphaFading = true;
|
||||
}
|
||||
|
||||
if (this.particleAge < this.particleMaxAge && this.particleAlpha > 0.0F) {
|
||||
// Minimal horizontal drift for slight randomness
|
||||
float horizontalMotionScale = 0.001F; // Very small horizontal movement
|
||||
this.motionX += this.rand.nextFloat() * horizontalMotionScale * (this.rand.nextBoolean() ? 1 : -1);
|
||||
this.motionZ += this.rand.nextFloat() * horizontalMotionScale * (this.rand.nextBoolean() ? 1 : -1);
|
||||
|
||||
// Move the particle
|
||||
this.moveEntity(this.motionX, this.motionY, this.motionZ);
|
||||
|
||||
// Fade out alpha if needed
|
||||
if (this.alphaFading) {
|
||||
this.particleAlpha = MathHelper.clamp_float(this.particleAlpha + this.alphaFadePerTick, 0.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
// Kill the particle if it has faded out or reached max age
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Allows you to change various aspects of campfire smoke particles:<br>
|
||||
* - {@link #particleRed}, {@link #particleGreen}, and {@link #particleBlue} are the float r, g, b values of the smoke. <br>
|
||||
* - {@link #motionX}, {@link #motionY}, and {@link #motionZ} are the x, y, z motion of the smoke.<br>
|
||||
* - {@link #particleGravity} is the amount the smoke's y motion changes per tick. <br>
|
||||
* - {@link #particleAlpha} is the smoke's initial alpha. <br>
|
||||
* - {@link #alphaFading} is whether the smoke's alpha should currently be changing (fading in or out). <br>
|
||||
* - {@link #alphaFadePerTick} is the amount the smoke's alpha changes per tick if {@link #alphaFading} is true. Negative values make it fade out, positive values make it fade
|
||||
* back in. <br>
|
||||
* - {@link #particleMaxAge} is the maximum number of ticks the particle will live for. <br>
|
||||
* <br>
|
||||
* You're also given {@link #campfirePosition}, which is the x, y, z position of the campfire tile entity where the smoke was created. <br>
|
||||
* <br>
|
||||
* Also, {@link EntityBigSmokeFX} are only created on the client side, so you should mark your subscribe event with {@link Side#CLIENT}. <br>
|
||||
* <br>
|
||||
* This event is posted from {@link EntityBigSmokeFX#EntityBigSmokeFX} on the {@link MinecraftForge#EVENT_BUS}.<br>
|
||||
* This event is {@link Cancelable}. If canceled, the entity will be removed.<br>
|
||||
*/
|
||||
@Cancelable
|
||||
public static class EntityBigSmokeFXConstructingEvent extends EntityConstructing
|
||||
{
|
||||
public final int[] campfirePosition;
|
||||
|
||||
public float particleRed;
|
||||
public float particleGreen;
|
||||
public float particleBlue;
|
||||
public double motionX;
|
||||
public double motionY;
|
||||
public double motionZ;
|
||||
public float particleGravity;
|
||||
public float particleAlpha;
|
||||
public boolean alphaFading;
|
||||
public float alphaFadePerTick;
|
||||
public int particleMaxAge;
|
||||
|
||||
public EntityBigSmokeFXConstructingEvent(EntityBigSmokeFX entity, int x, int y, int z)
|
||||
{
|
||||
super(entity);
|
||||
|
||||
campfirePosition = new int[] { x, y, z };
|
||||
|
||||
particleRed = entity.particleRed;
|
||||
particleGreen = entity.particleGreen;
|
||||
particleBlue = entity.particleBlue;
|
||||
motionX = entity.motionX;
|
||||
motionY = entity.motionY;
|
||||
motionZ = entity.motionZ;
|
||||
particleGravity = entity.particleGravity;
|
||||
particleAlpha = entity.particleAlpha;
|
||||
alphaFading = entity.alphaFading;
|
||||
alphaFadePerTick = entity.alphaFadePerTick;
|
||||
particleMaxAge = entity.particleMaxAge;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +1,38 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.TileEntityGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.TileEntitySavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.blocks.tiles.TileBorder;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
public class GuiBorderBlock extends GuiNPCInterface implements IGuiData{
|
||||
|
||||
private TileBorder tile;
|
||||
|
||||
|
||||
public GuiBorderBlock(int x, int y, int z) {
|
||||
super();
|
||||
tile = (TileBorder) player.worldObj.getTileEntity(x, y, z);
|
||||
|
||||
Client.sendData(EnumPacketServer.GetTileEntity, x, y, z);
|
||||
|
||||
PacketClient.sendClient(new TileEntityGetPacket(x, y, z));
|
||||
}
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 40, guiTop + 40, 120, 20, "Availability Options"));
|
||||
|
||||
addLabel(new GuiNpcLabel(0,"Height", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||
|
||||
addLabel(new GuiNpcLabel(0,"Height", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 60, guiTop + 71,40,20, tile.height + ""));
|
||||
getTextField(0).integersOnly = true;
|
||||
getTextField(0).setMinMaxDefault(0, 500, 6);
|
||||
getTextField(0).setMinMaxDefault(0, 500, 6);
|
||||
|
||||
addLabel(new GuiNpcLabel(1,"Message", guiLeft+ 1, guiTop + 100, 0xffffff));
|
||||
addLabel(new GuiNpcLabel(1,"Message", guiLeft+ 1, guiTop + 100, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 60, guiTop + 95,200,20, tile.message));
|
||||
|
||||
|
||||
addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done"));
|
||||
}
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
@@ -48,10 +50,10 @@ public class GuiBorderBlock extends GuiNPCInterface implements IGuiData{
|
||||
return;
|
||||
tile.height = getTextField(0).getInteger();
|
||||
tile.message = getTextField(1).getText();
|
||||
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
Client.sendData(EnumPacketServer.SaveTileEntity, compound);
|
||||
PacketClient.sendClient(new TileEntitySavePacket(compound));
|
||||
}
|
||||
@Override
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import noppes.npcs.client.gui.util.GuiDiagram;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.controllers.MagicController;
|
||||
import noppes.npcs.controllers.data.Magic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiMagicMap extends GuiDiagram {
|
||||
|
||||
private List<Magic> magics;
|
||||
|
||||
// Single RenderItem instance for efficiency.
|
||||
private RenderItem renderItem = new RenderItem();
|
||||
|
||||
public GuiMagicMap(GuiNPCInterface parent, int x, int y, int width, int height) {
|
||||
super(parent, x, y, width, height);
|
||||
magics = new ArrayList<>();
|
||||
|
||||
// Cache all magics from the MagicController.
|
||||
for (Magic magic : MagicController.getInstance().magics.values()) {
|
||||
magics.add(magic);
|
||||
}
|
||||
setLayout(DiagramLayout.CHART);
|
||||
this.setCurvedArrows(true);
|
||||
this.setCurveAngle(-20);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<DiagramIcon> createIcons() {
|
||||
List<DiagramIcon> icons = new ArrayList<>();
|
||||
for (Magic magic : magics) {
|
||||
MagicIcon icon = new MagicIcon(magic);
|
||||
// Set your desired flags (for example, enabled and pressable).
|
||||
icon.enabled = true;
|
||||
icon.pressable = true;
|
||||
icons.add(icon);
|
||||
}
|
||||
return icons;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<DiagramConnection> createConnections() {
|
||||
List<DiagramConnection> conns = new ArrayList<>();
|
||||
// For each Magic, generate connections from each weakness (attacker) to this magic.
|
||||
for (Magic magic : magics) {
|
||||
if (magic.weaknesses == null)
|
||||
continue;
|
||||
for (Map.Entry<Integer, Float> entry : magic.weaknesses.entrySet()) {
|
||||
int attackerId = entry.getKey();
|
||||
float percent = entry.getValue();
|
||||
String hover = "+" + (int) (percent * 100) + "%";
|
||||
conns.add(new DiagramConnection(attackerId, magic.id, percent, hover));
|
||||
}
|
||||
}
|
||||
return conns;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderIcon(DiagramIcon icon, int posX, int posY, IconRenderState state) {
|
||||
Magic magic = ((MagicIcon) icon).magic;
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
FontRenderer fontRenderer = mc.fontRenderer;
|
||||
int size = this.iconSize;
|
||||
int iconX = posX - size / 2;
|
||||
int iconY = posY - size / 2;
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
if (magic.iconItem != null) {
|
||||
renderItem.renderItemAndEffectIntoGUI(fontRenderer, mc.getTextureManager(), magic.iconItem, iconX, iconY);
|
||||
} else if (magic.iconTexture != null && !magic.iconTexture.isEmpty()) {
|
||||
mc.getTextureManager().bindTexture(new ResourceLocation(magic.iconTexture));
|
||||
this.drawTexturedModalRect(iconX, iconY, 0, 0, size, size);
|
||||
} else {
|
||||
ItemStack sword = new ItemStack(Items.iron_sword);
|
||||
renderItem.renderItemAndEffectIntoGUI(fontRenderer, mc.getTextureManager(), sword, iconX, iconY);
|
||||
}
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
// If the icon is not highlighted, draw a translucent overlay.
|
||||
if (state == IconRenderState.NOT_HIGHLIGHTED) {
|
||||
drawRect(iconX, iconY, iconX + size, iconY + size, 0x80202020);
|
||||
}
|
||||
|
||||
// Reset color.
|
||||
GL11.glColor4f(1f, 1f, 1f, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getIconTooltip(DiagramIcon icon) {
|
||||
Magic magic = ((MagicIcon) icon).magic;
|
||||
List<String> tooltip = new ArrayList<>();
|
||||
tooltip.add(magic.getName());
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawHoveringText(List<String> text, int mouseX, int mouseY, FontRenderer fontRenderer) {
|
||||
parent.renderHoveringText(text, mouseX, mouseY, fontRenderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override getIconName so that connection tooltips can show Magic names.
|
||||
*/
|
||||
@Override
|
||||
protected String getIconName(DiagramIcon icon) {
|
||||
Magic magic = ((MagicIcon) icon).magic;
|
||||
return magic.getName();
|
||||
}
|
||||
|
||||
// Wrap a Magic object as a DiagramIcon.
|
||||
private class MagicIcon extends DiagramIcon {
|
||||
public Magic magic;
|
||||
public MagicIcon(Magic magic) {
|
||||
super(magic.id, magic.index, magic.priority);
|
||||
this.magic = magic;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.MerchantUpdatePacket;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
@@ -16,10 +18,10 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.village.MerchantRecipe;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import noppes.npcs.ServerEventsHandler;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.CustomNpcResourceListener;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.containers.ContainerMerchantAdd;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
@@ -109,7 +111,7 @@ public class GuiMerchantAdd extends GuiContainer
|
||||
merchantrecipelist.remove(currentRecipeIndex);
|
||||
if(currentRecipeIndex > 0)
|
||||
currentRecipeIndex--;
|
||||
Client.sendData(EnumPacketServer.MerchantUpdate, ServerEventsHandler.Merchant.getEntityId(), merchantrecipelist);
|
||||
PacketClient.sendClient(new MerchantUpdatePacket(ServerEventsHandler.Merchant.getEntityId(), merchantrecipelist));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +134,7 @@ public class GuiMerchantAdd extends GuiContainer
|
||||
|
||||
MerchantRecipeList merchantrecipelist = this.theIMerchant.getRecipes(mc.thePlayer);
|
||||
merchantrecipelist.add(recipe);
|
||||
Client.sendData(EnumPacketServer.MerchantUpdate, ServerEventsHandler.Merchant.getEntityId(), merchantrecipelist);
|
||||
PacketClient.sendClient(new MerchantUpdatePacket(ServerEventsHandler.Merchant.getEntityId(), merchantrecipelist));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.faction.FactionsGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
@@ -28,7 +30,7 @@ public class GuiNPCFactionSelection extends GuiNPCInterface implements IScrollDa
|
||||
this.parent = parent;
|
||||
this.factionId = dialog;
|
||||
|
||||
Client.sendData(EnumPacketServer.FactionsGet);
|
||||
PacketClient.sendClient(new FactionsGetPacket());
|
||||
|
||||
if(parent instanceof GuiSelectionListener){
|
||||
listener = (GuiSelectionListener) parent;
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.Line;
|
||||
import noppes.npcs.controllers.data.Lines;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
@@ -22,7 +25,8 @@ public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData, ISubG
|
||||
{
|
||||
super(npc);
|
||||
this.lines = lines;
|
||||
Client.sendData(EnumPacketServer.MainmenuAdvancedGet);
|
||||
|
||||
PacketClient.sendClient(new MainmenuAdvancedGetPacket());
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
@@ -73,7 +77,8 @@ public class GuiNPCLinesEdit extends GuiNPCInterface2 implements IGuiData, ISubG
|
||||
|
||||
public void save() {
|
||||
saveLines();
|
||||
Client.sendData(EnumPacketServer.MainmenuAdvancedSave, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
PacketClient.sendClient(new MainmenuAdvancedSavePacket(npc.advanced.writeToNBT(new NBTTagCompound())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.transport.TransportCategoriesGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.transport.TransportCategorySavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class GuiNPCTransportCategoryEdit extends GuiNPCInterface
|
||||
@@ -30,7 +33,7 @@ public class GuiNPCTransportCategoryEdit extends GuiNPCInterface
|
||||
super.initGui();
|
||||
this.addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, width / 2 - 40, 100, 140, 20, name));
|
||||
addLabel(new GuiNpcLabel(1,"Title:", width / 2 - 100+4, 105, 0xffffff));
|
||||
|
||||
|
||||
this.addButton(new GuiNpcButton(2, width / 2 - 100, 210,98, 20, "gui.back"));
|
||||
this.addButton(new GuiNpcButton(3, width / 2 +2, 210,98, 20, "Save"));
|
||||
}
|
||||
@@ -47,25 +50,20 @@ public class GuiNPCTransportCategoryEdit extends GuiNPCInterface
|
||||
if(id == 2)
|
||||
{
|
||||
NoppesUtil.openGUI(player, parent);
|
||||
Client.sendData(EnumPacketServer.TransportCategoriesGet);
|
||||
PacketClient.sendClient(new TransportCategoriesGetPacket());
|
||||
}
|
||||
if(id == 3)
|
||||
{
|
||||
save();
|
||||
NoppesUtil.openGUI(player, parent);
|
||||
Client.sendData(EnumPacketServer.TransportCategoriesGet);
|
||||
PacketClient.sendClient(new TransportCategoriesGetPacket());
|
||||
}
|
||||
}
|
||||
public void save() {
|
||||
String name = getTextField(1).getText();
|
||||
if(name.trim().isEmpty())
|
||||
return;
|
||||
Client.sendData(EnumPacketServer.TransportCategorySave,name,id);
|
||||
}
|
||||
// @Override
|
||||
// public void drawDefaultBackground()
|
||||
// {
|
||||
// drawBackground(0);
|
||||
// }
|
||||
|
||||
PacketClient.sendClient(new TransportCategorySavePacket(name, id));
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,28 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.DimensionsGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.feather.DimensionTeleportPacket;
|
||||
import kamkeel.npcs.network.packets.request.npc.RemoteDeletePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
|
||||
public class GuiNpcDimension extends GuiNPCInterface implements IScrollData{
|
||||
|
||||
|
||||
private GuiCustomScroll scroll;
|
||||
private HashMap<String, Integer> data = new HashMap<String, Integer>();
|
||||
public GuiNpcDimension() {
|
||||
super();
|
||||
xSize = 256;
|
||||
setBackground("menubg.png");
|
||||
Client.sendData(EnumPacketServer.DimensionsGet);
|
||||
PacketClient.sendClient(new DimensionsGetPacket());
|
||||
}
|
||||
public void initGui()
|
||||
{
|
||||
@@ -30,10 +34,10 @@ public class GuiNpcDimension extends GuiNPCInterface implements IScrollData{
|
||||
scroll.guiLeft = guiLeft + 4;
|
||||
scroll.guiTop = guiTop + 4;
|
||||
addScroll(scroll);
|
||||
|
||||
|
||||
String title = StatCollector.translateToLocal("Dimensions");
|
||||
int x = (xSize - this.fontRendererObj.getStringWidth(title)) / 2;
|
||||
|
||||
|
||||
this.addLabel(new GuiNpcLabel(0, title, guiLeft + x, guiTop - 8));
|
||||
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 170, guiTop + 72,82,20, "remote.tp"));
|
||||
@@ -43,23 +47,23 @@ public class GuiNpcDimension extends GuiNPCInterface implements IScrollData{
|
||||
public void confirmClicked(boolean flag, int i)
|
||||
{
|
||||
if(flag){
|
||||
Client.sendData(EnumPacketServer.RemoteDelete,data.get(scroll.getSelected()));
|
||||
PacketClient.sendClient(new RemoteDeletePacket(data.get(scroll.getSelected())));
|
||||
}
|
||||
NoppesUtil.openGUI(player, this);
|
||||
}
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
int id = guibutton.id;
|
||||
|
||||
|
||||
if(!data.containsKey(scroll.getSelected()))
|
||||
return;
|
||||
|
||||
|
||||
if(id == 4){
|
||||
Client.sendData(EnumPacketServer.DimensionTeleport, data.get(scroll.getSelected()));
|
||||
PacketClient.sendClient(new DimensionTeleportPacket(data.get(scroll.getSelected())));
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int i, int j, int k)
|
||||
{
|
||||
@@ -76,8 +80,8 @@ public class GuiNpcDimension extends GuiNPCInterface implements IScrollData{
|
||||
}
|
||||
@Override
|
||||
public void save() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void setData(Vector<String> list, HashMap<String, Integer> data) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.clone.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -9,11 +11,11 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.controllers.ClientCloneController;
|
||||
import noppes.npcs.client.controllers.ClientTagMapController;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.Tag;
|
||||
import noppes.npcs.controllers.data.TagMap;
|
||||
|
||||
@@ -62,7 +64,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
this.closeOnEsc = true;
|
||||
|
||||
setBackground("menubg.png");
|
||||
Client.sendData(EnumPacketServer.CloneAllTags, activeTab);
|
||||
PacketClient.sendClient(new CloneAllTagsPacket());
|
||||
}
|
||||
public void initGui()
|
||||
{
|
||||
@@ -187,8 +189,8 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
private void showClones() {
|
||||
if(showingClones == 2){
|
||||
Client.sendData(EnumPacketServer.CloneTagList, activeTab);
|
||||
Client.sendData(EnumPacketServer.CloneList, activeTab);
|
||||
PacketClient.sendClient(new CloneTagListPacket(activeTab));
|
||||
PacketClient.sendClient(new CloneListPacket(activeTab));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -377,14 +379,14 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
String sel = scroll.getSelected();
|
||||
if(sel == null)
|
||||
return;
|
||||
Client.sendData(EnumPacketServer.SpawnMob, true, posX, posY, posZ, sel, activeTab);
|
||||
SpawnMobPacket.Server(posX, posY, posZ, sel, activeTab);
|
||||
close();
|
||||
}
|
||||
else{
|
||||
NBTTagCompound compound = getCompound();
|
||||
if(compound == null)
|
||||
return;
|
||||
Client.sendData(EnumPacketServer.SpawnMob, false, posX, posY, posZ, compound);
|
||||
SpawnMobPacket.Client(posX, posY, posZ, compound);
|
||||
close();
|
||||
}
|
||||
}
|
||||
@@ -393,14 +395,14 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
String sel = scroll.getSelected();
|
||||
if(sel == null)
|
||||
return;
|
||||
Client.sendData(EnumPacketServer.MobSpawner, true, posX, posY, posZ, sel, activeTab);
|
||||
MobSpawnerPacket.Server(posX, posY, posZ, sel, activeTab);
|
||||
close();
|
||||
}
|
||||
else{
|
||||
NBTTagCompound compound = getCompound();
|
||||
if(compound == null)
|
||||
return;
|
||||
Client.sendData(EnumPacketServer.MobSpawner, false, posX, posY, posZ, compound);
|
||||
MobSpawnerPacket.Client(posX, posY, posZ, compound);
|
||||
close();
|
||||
|
||||
}
|
||||
@@ -427,7 +429,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
if(id == 6){
|
||||
if(scroll.getSelected() != null){
|
||||
if(showingClones == 2){
|
||||
Client.sendData(EnumPacketServer.CloneRemove, activeTab, scroll.getSelected());
|
||||
PacketClient.sendClient(new CloneRemovePacket(activeTab, scroll.getSelected()));
|
||||
return;
|
||||
}
|
||||
ClientCloneController.Instance.removeClone(scroll.getSelected(), activeTab);
|
||||
@@ -464,7 +466,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -534,4 +536,4 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneAllTagsShortPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.ClonePreSavePacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneSavePacket;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
@@ -9,10 +14,10 @@ import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.controllers.ClientCloneController;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.TagController;
|
||||
import noppes.npcs.controllers.data.Tag;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
@@ -58,7 +63,7 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall
|
||||
addTagUUIDs = new HashSet<>();
|
||||
}
|
||||
if(isNPC){
|
||||
Client.sendData(EnumPacketServer.CloneAllTagsShort);
|
||||
PacketClient.sendClient(new CloneAllTagsShortPacket());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +107,7 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall
|
||||
confirmClicked(true, 0);
|
||||
}
|
||||
else
|
||||
Client.sendData(EnumPacketServer.ClonePreSave, name, tab);
|
||||
PacketClient.sendClient(new ClonePreSavePacket(name, tab));
|
||||
}
|
||||
if(id == 1){
|
||||
close();
|
||||
@@ -145,7 +150,7 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall
|
||||
if(isNPC){
|
||||
compounder.setTag("TagUUIDs", tagsCompound);
|
||||
}
|
||||
Client.sendData(EnumPacketServer.CloneSave, name, tab, extraTags, compounder);
|
||||
PacketClient.sendClient(new CloneSavePacket(name, tab, extraTags, compounder));
|
||||
}
|
||||
|
||||
close();
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.MountPacket;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneListPacket;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -9,10 +12,10 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagDouble;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.controllers.ClientCloneController;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
@@ -20,19 +23,19 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData{
|
||||
|
||||
|
||||
private GuiCustomScroll scroll;
|
||||
|
||||
|
||||
private int posX,posY,posZ;
|
||||
|
||||
|
||||
private List<String> list;
|
||||
|
||||
|
||||
private static int showingClones = 0;
|
||||
|
||||
private static String search = "";
|
||||
|
||||
|
||||
private int activeTab = 1;
|
||||
|
||||
|
||||
public GuiNpcMobSpawnerMounter(int i, int j, int k) {
|
||||
super();
|
||||
xSize = 256;
|
||||
@@ -40,16 +43,16 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData
|
||||
posX = i;
|
||||
posY = j;
|
||||
posZ = k;
|
||||
|
||||
|
||||
this.closeOnEsc = true;
|
||||
|
||||
|
||||
setBackground("menubg.png");
|
||||
}
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
guiTop += 10;
|
||||
|
||||
|
||||
if(scroll == null){
|
||||
scroll = new GuiCustomScroll(this,0);
|
||||
scroll.setSize(165, 188);
|
||||
@@ -59,7 +62,7 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData
|
||||
scroll.guiLeft = guiLeft + 4;
|
||||
scroll.guiTop = guiTop + 26;
|
||||
addScroll(scroll);
|
||||
|
||||
|
||||
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 4, 165, 20, search));
|
||||
|
||||
GuiMenuTopButton button;
|
||||
@@ -90,7 +93,7 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData
|
||||
addSideButton(new GuiMenuSideButton(33,guiLeft - 90, this.guiTop + 170, 45,22, "13"));
|
||||
addSideButton(new GuiMenuSideButton(34,guiLeft - 45, this.guiTop + 191, 45,22, "14"));
|
||||
addSideButton(new GuiMenuSideButton(35,guiLeft - 90, this.guiTop + 191, 45,22, "15"));
|
||||
|
||||
|
||||
getSideButton(20 + activeTab).active = true;
|
||||
showClones();
|
||||
}
|
||||
@@ -109,17 +112,17 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.list = list;
|
||||
scroll.setList(getSearchList());
|
||||
}
|
||||
private void showClones() {
|
||||
|
||||
if(showingClones == 2){
|
||||
Client.sendData(EnumPacketServer.CloneList, activeTab);
|
||||
PacketClient.sendClient(new CloneListPacket(activeTab));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
this.list = ClientCloneController.Instance.getClones(activeTab);
|
||||
scroll.setList(getSearchList());
|
||||
@@ -127,7 +130,7 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData
|
||||
public void keyTyped(char c, int i)
|
||||
{
|
||||
super.keyTyped(c, i);
|
||||
|
||||
|
||||
if(search.equals(getTextField(1).getText()))
|
||||
return;
|
||||
search = getTextField(1).getText().toLowerCase();
|
||||
@@ -147,7 +150,7 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData
|
||||
String sel = scroll.getSelected();
|
||||
if(sel == null)
|
||||
return null;
|
||||
|
||||
|
||||
if(showingClones == 0){
|
||||
return ClientCloneController.Instance.getCloneData(player, sel, activeTab);
|
||||
}
|
||||
@@ -159,9 +162,9 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData
|
||||
entity.writeToNBTOptional(compound);
|
||||
return compound;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
int id = guibutton.id;
|
||||
@@ -172,12 +175,12 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData
|
||||
NBTTagCompound compound = getCompound();
|
||||
if(compound != null){
|
||||
compound.setTag("Pos", this.newDoubleNBTList(new double[] {this.posX + 0.5, this.posY + 1, this.posZ + 0.5}));
|
||||
Client.sendData(EnumPacketServer.SpawnRider, compound);
|
||||
MountPacket.Spawn(compound);
|
||||
close();
|
||||
}
|
||||
}
|
||||
if(id == 2){
|
||||
Client.sendData(EnumPacketServer.PlayerRider);
|
||||
MountPacket.Player();
|
||||
close();
|
||||
}
|
||||
if(id == 3){
|
||||
@@ -211,11 +214,11 @@ public class GuiNpcMobSpawnerMounter extends GuiNPCInterface implements IGuiData
|
||||
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
|
||||
@@ -1,36 +1,38 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.clone.CloneListPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagDouble;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.controllers.ClientCloneController;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiNpcMobSpawnerSelector extends SubGuiInterface implements IGuiData{
|
||||
|
||||
|
||||
private GuiCustomScroll scroll;
|
||||
private List<String> list;
|
||||
|
||||
|
||||
private static String search = "";
|
||||
public int activeTab = 1;
|
||||
public boolean isServer = false;
|
||||
|
||||
|
||||
public GuiNpcMobSpawnerSelector() {
|
||||
super();
|
||||
xSize = 256;
|
||||
this.closeOnEsc = true;
|
||||
setBackground("menubg.png");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
super.initGui();
|
||||
if(scroll == null){
|
||||
scroll = new GuiCustomScroll(this,0);
|
||||
scroll.setSize(165, 188);
|
||||
@@ -40,7 +42,7 @@ public class GuiNpcMobSpawnerSelector extends SubGuiInterface implements IGuiDat
|
||||
scroll.guiLeft = guiLeft + 4;
|
||||
scroll.guiTop = guiTop + 26;
|
||||
addScroll(scroll);
|
||||
|
||||
|
||||
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 4, 165, 20, search));
|
||||
|
||||
addButton(new GuiNpcButton(0, guiLeft + 171, guiTop + 80, 80, 20, "gui.done"));
|
||||
@@ -61,30 +63,30 @@ public class GuiNpcMobSpawnerSelector extends SubGuiInterface implements IGuiDat
|
||||
addSideButton(new GuiMenuSideButton(33,guiLeft - 90, this.guiTop + 170, 45,22, "13"));
|
||||
addSideButton(new GuiMenuSideButton(34,guiLeft - 45, this.guiTop + 191, 45,22, "14"));
|
||||
addSideButton(new GuiMenuSideButton(35,guiLeft - 90, this.guiTop + 191, 45,22, "15"));
|
||||
|
||||
|
||||
getSideButton(20 + activeTab).active = true;
|
||||
showClones();
|
||||
}
|
||||
|
||||
|
||||
public String getSelected(){
|
||||
return scroll.getSelected();
|
||||
}
|
||||
private void showClones() {
|
||||
|
||||
if(isServer){
|
||||
Client.sendData(EnumPacketServer.CloneList, activeTab);
|
||||
PacketClient.sendClient(new CloneListPacket(activeTab));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
|
||||
|
||||
this.list = new ArrayList<String>(ClientCloneController.Instance.getClones(activeTab));
|
||||
scroll.setList(getSearchList());
|
||||
}
|
||||
public void keyTyped(char c, int i)
|
||||
{
|
||||
super.keyTyped(c, i);
|
||||
|
||||
|
||||
if(search.equals(getTextField(1).getText()))
|
||||
return;
|
||||
search = getTextField(1).getText().toLowerCase();
|
||||
@@ -109,7 +111,7 @@ public class GuiNpcMobSpawnerSelector extends SubGuiInterface implements IGuiDat
|
||||
compound.setString("ClonedName", sel);
|
||||
return compound;
|
||||
}
|
||||
|
||||
|
||||
public void buttonEvent(GuiButton guibutton)
|
||||
{
|
||||
int id = guibutton.id;
|
||||
@@ -139,11 +141,11 @@ public class GuiNpcMobSpawnerSelector extends SubGuiInterface implements IGuiDat
|
||||
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.pather.MovingPathGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.pather.MovingPathSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.DataAI;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.IGuiData;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -17,19 +20,19 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiNpcPather extends GuiNPCInterface implements IGuiData{
|
||||
|
||||
|
||||
private GuiCustomScroll scroll;
|
||||
private HashMap<String, Integer> data = new HashMap<String, Integer>();
|
||||
private DataAI ai;
|
||||
|
||||
|
||||
public GuiNpcPather(EntityNPCInterface npc) {
|
||||
super();
|
||||
drawDefaultBackground = false;
|
||||
xSize = 176;
|
||||
title = "Npc Pather";
|
||||
setBackground("smallbg.png");
|
||||
ai = npc.ai;
|
||||
Client.sendData(EnumPacketServer.MovingPathGet);
|
||||
ai = npc.ais;
|
||||
PacketClient.sendClient(new MovingPathGetPacket());
|
||||
}
|
||||
@Override
|
||||
public void initGui()
|
||||
@@ -44,7 +47,7 @@ public class GuiNpcPather extends GuiNPCInterface implements IGuiData{
|
||||
scroll.setUnsortedList(list);
|
||||
scroll.guiLeft = guiLeft + 7;
|
||||
scroll.guiTop = guiTop + 12;
|
||||
|
||||
|
||||
addScroll(scroll);
|
||||
this.addButton(new GuiNpcButton(0, guiLeft + 6, guiTop + 178,52,20, "gui.down"));
|
||||
this.addButton(new GuiNpcButton(1, guiLeft + 62, guiTop + 178,52,20, "gui.up"));
|
||||
@@ -55,7 +58,7 @@ public class GuiNpcPather extends GuiNPCInterface implements IGuiData{
|
||||
{
|
||||
if(scroll.selected < 0)
|
||||
return;
|
||||
|
||||
|
||||
int id = guibutton.id;
|
||||
if(id == 0){
|
||||
List<int[]> list = ai.getMovingPath();
|
||||
@@ -109,12 +112,12 @@ public class GuiNpcPather extends GuiNPCInterface implements IGuiData{
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(ai.getMovingPath()));
|
||||
Client.sendData(EnumPacketServer.MovingPathSave, compound);
|
||||
PacketClient.sendClient(new MovingPathSavePacket(compound));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,71 +1,73 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.TileEntitySavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.blocks.tiles.TileRedstoneBlock;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
|
||||
public class GuiNpcRedstoneBlock extends GuiNPCInterface{
|
||||
|
||||
private TileRedstoneBlock tile;
|
||||
|
||||
|
||||
public GuiNpcRedstoneBlock(int x, int y, int z) {
|
||||
super();
|
||||
tile = (TileRedstoneBlock) player.worldObj.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 40, guiTop + 20, 120, 20, "availability.options"));
|
||||
|
||||
addLabel(new GuiNpcLabel(11,"gui.detailed", guiLeft+ 40, guiTop + 47, 0xffffff));
|
||||
addLabel(new GuiNpcLabel(11,"gui.detailed", guiLeft+ 40, guiTop + 47, 0xffffff));
|
||||
this.addButton(new GuiNpcButton(1, guiLeft + 110, guiTop + 42, 50, 20, new String[]{"gui.no", "gui.yes"},tile.isDetailed?1:0));
|
||||
|
||||
|
||||
if(tile.isDetailed){
|
||||
addLabel(new GuiNpcLabel(0,StatCollector.translateToLocal("bard.ondistance") + " X:", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||
addLabel(new GuiNpcLabel(0,StatCollector.translateToLocal("bard.ondistance") + " X:", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRangeX + ""));
|
||||
getTextField(0).integersOnly = true;
|
||||
getTextField(0).setMinMaxDefault(0, 50, 6);
|
||||
addLabel(new GuiNpcLabel(1,"Y:", guiLeft+ 113, guiTop + 76, 0xffffff));
|
||||
getTextField(0).setMinMaxDefault(0, 50, 6);
|
||||
addLabel(new GuiNpcLabel(1,"Y:", guiLeft+ 113, guiTop + 76, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 122, guiTop + 71,30,20, tile.onRangeY + ""));
|
||||
getTextField(1).integersOnly = true;
|
||||
getTextField(1).setMinMaxDefault(0, 50, 6);
|
||||
addLabel(new GuiNpcLabel(2,"Z:", guiLeft+ 155, guiTop + 76, 0xffffff));
|
||||
getTextField(1).setMinMaxDefault(0, 50, 6);
|
||||
addLabel(new GuiNpcLabel(2,"Z:", guiLeft+ 155, guiTop + 76, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft+ 164, guiTop + 71,30,20, tile.onRangeZ + ""));
|
||||
getTextField(2).integersOnly = true;
|
||||
getTextField(2).setMinMaxDefault(0, 50, 6);
|
||||
|
||||
addLabel(new GuiNpcLabel(3,StatCollector.translateToLocal("bard.offdistance") + " X:", guiLeft - 3, guiTop + 99, 0xffffff));
|
||||
|
||||
addLabel(new GuiNpcLabel(3,StatCollector.translateToLocal("bard.offdistance") + " X:", guiLeft - 3, guiTop + 99, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRangeX + ""));
|
||||
getTextField(3).integersOnly = true;
|
||||
getTextField(3).setMinMaxDefault(0, 50, 10);
|
||||
addLabel(new GuiNpcLabel(4,"Y:", guiLeft+ 113, guiTop + 99, 0xffffff));
|
||||
getTextField(3).setMinMaxDefault(0, 50, 10);
|
||||
addLabel(new GuiNpcLabel(4,"Y:", guiLeft+ 113, guiTop + 99, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft+ 122, guiTop + 94,30,20, tile.offRangeY + ""));
|
||||
getTextField(4).integersOnly = true;
|
||||
getTextField(4).setMinMaxDefault(0, 50, 10);
|
||||
addLabel(new GuiNpcLabel(5,"Z:", guiLeft+ 155, guiTop + 99, 0xffffff));
|
||||
getTextField(4).setMinMaxDefault(0, 50, 10);
|
||||
addLabel(new GuiNpcLabel(5,"Z:", guiLeft+ 155, guiTop + 99, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft+ 164, guiTop + 94,30,20, tile.offRangeZ + ""));
|
||||
getTextField(5).integersOnly = true;
|
||||
getTextField(5).setMinMaxDefault(0, 50, 10);
|
||||
}
|
||||
else{
|
||||
addLabel(new GuiNpcLabel(0,"bard.ondistance", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||
addLabel(new GuiNpcLabel(0,"bard.ondistance", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRange + ""));
|
||||
getTextField(0).integersOnly = true;
|
||||
getTextField(0).setMinMaxDefault(0, 50, 6);
|
||||
|
||||
addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft - 3, guiTop + 99, 0xffffff));
|
||||
getTextField(0).setMinMaxDefault(0, 50, 6);
|
||||
|
||||
addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft - 3, guiTop + 99, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRange + ""));
|
||||
getTextField(3).integersOnly = true;
|
||||
getTextField(3).setMinMaxDefault(0, 50, 10);
|
||||
getTextField(3).setMinMaxDefault(0, 50, 10);
|
||||
}
|
||||
addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done"));
|
||||
}
|
||||
@@ -96,7 +98,7 @@ public class GuiNpcRedstoneBlock extends GuiNPCInterface{
|
||||
tile.offRangeX = getTextField(3).getInteger();
|
||||
tile.offRangeY = getTextField(4).getInteger();
|
||||
tile.offRangeZ = getTextField(5).getInteger();
|
||||
|
||||
|
||||
if(tile.onRangeX > tile.offRangeX)
|
||||
tile.offRangeX = tile.onRangeX;
|
||||
if(tile.onRangeY > tile.offRangeY)
|
||||
@@ -111,10 +113,10 @@ public class GuiNpcRedstoneBlock extends GuiNPCInterface{
|
||||
tile.offRange = tile.onRange;
|
||||
}
|
||||
tile.isActivated = false;
|
||||
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
Client.sendData(EnumPacketServer.SaveTileEntity, compound);
|
||||
PacketClient.sendClient(new TileEntitySavePacket(compound));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +1,42 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.npc.*;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData, GuiYesNoCallback{
|
||||
|
||||
private GuiCustomScroll scroll;
|
||||
private HashMap<String, Integer> data = new HashMap<String, Integer>();
|
||||
private String search = "";
|
||||
|
||||
public GuiNpcRemoteEditor() {
|
||||
super();
|
||||
xSize = 256;
|
||||
setBackground("menubg.png");
|
||||
Client.sendData(EnumPacketServer.RemoteNpcsGet);
|
||||
Client.sendData(EnumPacketServer.RemoteFreezeGet);
|
||||
PacketClient.sendClient(new RemoteNpcsGetPacket());
|
||||
PacketClient.sendClient(new RemoteFreezeGetPacket());
|
||||
}
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
if(scroll == null){
|
||||
scroll = new GuiCustomScroll(this,0, 0);
|
||||
scroll.setSize(165, 208);
|
||||
scroll.setSize(165, 188);
|
||||
}
|
||||
scroll.guiLeft = guiLeft + 4;
|
||||
scroll.guiTop = guiTop + 4;
|
||||
@@ -39,6 +45,8 @@ public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData,
|
||||
String title = StatCollector.translateToLocal("remote.title");
|
||||
int x = (xSize - this.fontRendererObj.getStringWidth(title)) / 2;
|
||||
|
||||
addTextField(new GuiNpcTextField(66, this, fontRendererObj, guiLeft + 4, guiTop + 5 + scroll.ySize, scroll.xSize, 20, search));
|
||||
|
||||
this.addLabel(new GuiNpcLabel(0, title, guiLeft + x, guiTop - 8));
|
||||
|
||||
this.addButton(new GuiNpcButton(0, guiLeft + 170, guiTop + 6,82,20, "selectServer.edit"));
|
||||
@@ -53,7 +61,7 @@ public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData,
|
||||
@Override
|
||||
public void confirmClicked(boolean flag, int i){
|
||||
if(flag){
|
||||
Client.sendData(EnumPacketServer.RemoteDelete,data.get(scroll.getSelected()));
|
||||
PacketClient.sendClient(new RemoteDeletePacket(data.get(scroll.getSelected())));
|
||||
}
|
||||
NoppesUtil.openGUI(player, this);
|
||||
}
|
||||
@@ -61,11 +69,11 @@ public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData,
|
||||
{
|
||||
int id = guibutton.id;
|
||||
if(id == 3){
|
||||
Client.sendData(EnumPacketServer.RemoteFreeze);
|
||||
PacketClient.sendClient(new RemoteFreezePacket());
|
||||
}
|
||||
if(id == 5){
|
||||
for(int ids : data.values()){
|
||||
Client.sendData(EnumPacketServer.RemoteReset, ids);
|
||||
PacketClient.sendClient(new RemoteResetPacket(ids));
|
||||
Entity entity = player.worldObj.getEntityByID(ids);
|
||||
if(entity != null && entity instanceof EntityNPCInterface)
|
||||
((EntityNPCInterface)entity).reset();
|
||||
@@ -73,27 +81,28 @@ public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData,
|
||||
}
|
||||
if(id == 6){
|
||||
NoppesUtil.setLastNpc(null);
|
||||
Client.sendData(EnumPacketServer.RemoteGlobalMenu);
|
||||
PacketClient.sendClient(new RemoteGlobalMenuPacket());
|
||||
}
|
||||
|
||||
if(!data.containsKey(scroll.getSelected()))
|
||||
return;
|
||||
|
||||
if(id == 0){
|
||||
Client.sendData(EnumPacketServer.RemoteMainMenu,data.get(scroll.getSelected()));
|
||||
PacketClient.sendClient(new RemoteMainMenuPacket(data.get(scroll.getSelected())));
|
||||
}
|
||||
if(id == 1){
|
||||
GuiYesNo guiyesno = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("gui.delete"), 0);
|
||||
displayGuiScreen(guiyesno);
|
||||
}
|
||||
if(id == 2){
|
||||
Client.sendData(EnumPacketServer.RemoteReset,data.get(scroll.getSelected()));
|
||||
Entity entity = player.worldObj.getEntityByID(data.get(scroll.getSelected()));
|
||||
int selected = data.get(scroll.getSelected());
|
||||
PacketClient.sendClient(new RemoteResetPacket(selected));
|
||||
Entity entity = player.worldObj.getEntityByID(selected);
|
||||
if(entity != null && entity instanceof EntityNPCInterface)
|
||||
((EntityNPCInterface)entity).reset();
|
||||
}
|
||||
if(id == 4){
|
||||
Client.sendData(EnumPacketServer.RemoteTpToNpc,data.get(scroll.getSelected()));
|
||||
PacketClient.sendClient(new RemoteTpToNpcPacket(data.get(scroll.getSelected())));
|
||||
close();
|
||||
}
|
||||
}
|
||||
@@ -107,20 +116,47 @@ public class GuiNpcRemoteEditor extends GuiNPCInterface implements IScrollData,
|
||||
@Override
|
||||
public void keyTyped(char c, int i)
|
||||
{
|
||||
if (i == 1 || isInventoryKey(i))
|
||||
super.keyTyped(c, i);
|
||||
if(getTextField(66) != null){
|
||||
if(getTextField(66).isFocused()){
|
||||
if (i == 1)
|
||||
{
|
||||
close();
|
||||
return;
|
||||
}
|
||||
if(search.equals(getTextField(66).getText()))
|
||||
return;
|
||||
search = getTextField(66).getText().toLowerCase();
|
||||
scroll.resetScroll();
|
||||
scroll.setList(getNPCSearch());
|
||||
}
|
||||
}
|
||||
if (i == 1)
|
||||
{
|
||||
close();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void save() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
private List<String> getNPCSearch(){
|
||||
if(search.isEmpty()){
|
||||
return new ArrayList<String>(this.data.keySet());
|
||||
}
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(String name : this.data.keySet()){
|
||||
if(name.toLowerCase().contains(search))
|
||||
list.add(name);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {}
|
||||
|
||||
@Override
|
||||
public void setData(Vector<String> list, HashMap<String, Integer> data) {
|
||||
scroll.setList(list);
|
||||
this.data = data;
|
||||
this.data = data;
|
||||
scroll.resetScroll();
|
||||
scroll.setList(getNPCSearch());
|
||||
}
|
||||
@Override
|
||||
public void setSelected(String selected) {
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.TileEntitySavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.blocks.tiles.TileWaypoint;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
|
||||
public class GuiNpcWaypoint extends GuiNPCInterface{
|
||||
|
||||
private TileWaypoint tile;
|
||||
|
||||
|
||||
public GuiNpcWaypoint(int x, int y, int z) {
|
||||
super();
|
||||
tile = (TileWaypoint) player.worldObj.getTileEntity(x, y, z);
|
||||
@@ -23,11 +25,11 @@ public class GuiNpcWaypoint extends GuiNPCInterface{
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
|
||||
addLabel(new GuiNpcLabel(0,"gui.name", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||
|
||||
addLabel(new GuiNpcLabel(0,"gui.name", guiLeft+ 1, guiTop + 76, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 60, guiTop + 71,200,20, tile.name));
|
||||
|
||||
addLabel(new GuiNpcLabel(1,"gui.range", guiLeft+ 1, guiTop + 97, 0xffffff));
|
||||
|
||||
addLabel(new GuiNpcLabel(1,"gui.range", guiLeft+ 1, guiTop + 97, 0xffffff));
|
||||
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 60, guiTop + 92,200,20, tile.range + ""));
|
||||
getTextField(1).integersOnly = true;
|
||||
getTextField(1).setMinMaxDefault(2, 60, 10);
|
||||
@@ -43,10 +45,10 @@ public class GuiNpcWaypoint extends GuiNPCInterface{
|
||||
public void save() {
|
||||
tile.name = getTextField(0).getText();
|
||||
tile.range = getTextField(1).getInteger();
|
||||
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
Client.sendData(EnumPacketServer.SaveTileEntity, compound);
|
||||
PacketClient.sendClient(new TileEntitySavePacket(compound));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.script.NPCScriptPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiConfirmOpenLink;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
@@ -9,11 +10,11 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.NoppesStringUtils;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.script.GuiNPCEventScripts;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.data.DataScript;
|
||||
@@ -38,7 +39,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
||||
xSize = 420;
|
||||
|
||||
setBackground("menubg.png");
|
||||
Client.sendData(EnumPacketServer.ScriptDataGet);
|
||||
NPCScriptPacket.Get();
|
||||
}
|
||||
|
||||
public void initGui() {
|
||||
@@ -267,7 +268,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
||||
@Override
|
||||
public void save() {
|
||||
setScript();
|
||||
Client.sendData(EnumPacketServer.ScriptDataSave, script.writeToNBT(new NBTTagCompound()));
|
||||
NPCScriptPacket.Save(script.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagsGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagsNpcGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagSetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.TagController;
|
||||
import noppes.npcs.controllers.data.Tag;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -31,8 +30,8 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
|
||||
{
|
||||
this.parent = guiNpcMobSpawnerAdd;
|
||||
this.mobSpawnerAdd = guiNpcMobSpawnerAdd;
|
||||
Client.sendData(EnumPacketServer.TagsGet);
|
||||
Client.sendData(EnumPacketServer.NpcTagsGet);
|
||||
PacketClient.sendClient(new TagsGetPacket());
|
||||
PacketClient.sendClient(new TagsNpcGetPacket());
|
||||
setBackground("menubg.png");
|
||||
xSize = 305;
|
||||
ySize = 220;
|
||||
@@ -146,7 +145,7 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
|
||||
|
||||
GuiNpcMobSpawnerAdd.tagsCompound = UUIDTagList;
|
||||
tagCompound.setTag("TagNames",tagList);
|
||||
Client.sendData(EnumPacketServer.TagSet, tagCompound);
|
||||
PacketClient.sendClient(new TagSetPacket(tagCompound));
|
||||
}
|
||||
|
||||
public void keyTyped(char c, int i)
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.effects.EffectSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.gui.global.GuiNPCManageEffects;
|
||||
import noppes.npcs.client.gui.script.GuiScriptEffect;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.client.renderer.ImageData;
|
||||
import noppes.npcs.controllers.data.CustomEffect;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SubGuiEffectGeneral extends SubGuiInterface implements ITextfieldListener {
|
||||
private final GuiNPCManageEffects parent;
|
||||
public CustomEffect effect;
|
||||
private final String originalName;
|
||||
|
||||
private List<GuiMenuTopButton> topButtons = new ArrayList<>();
|
||||
|
||||
public SubGuiEffectGeneral(GuiNPCManageEffects parent, CustomEffect effect) {
|
||||
this.effect = effect;
|
||||
this.parent = parent;
|
||||
this.originalName = effect.name;
|
||||
this.closeOnEsc = true;
|
||||
|
||||
setBackground("menubg.png");
|
||||
xSize = 360;
|
||||
ySize = 216;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
GuiMenuTopButton close = new GuiMenuTopButton(-5, guiLeft + xSize - 22, guiTop - 10, "X");
|
||||
|
||||
GuiMenuTopButton general = new GuiMenuTopButton(-1, guiLeft + 4, guiTop - 10, "display.general");
|
||||
GuiMenuTopButton scripts = new GuiMenuTopButton(-2, general.xPosition + general.getWidth(), guiTop - 10, "script.scripts");
|
||||
|
||||
close.active = false;
|
||||
general.active = true;
|
||||
scripts.active = false;
|
||||
|
||||
addTopButton(close);
|
||||
addTopButton(general);
|
||||
addTopButton(scripts);
|
||||
|
||||
guiTop += 7;
|
||||
int y = guiTop + 7;
|
||||
int x = guiLeft + 4 + 4;
|
||||
addTextField(new GuiNpcTextField(1, this, this.fontRendererObj, x + 36, y, 280, 20, effect.name));
|
||||
getTextField(1).setMaxStringLength(40);
|
||||
addLabel(new GuiNpcLabel(1, "gui.name", x, y + 5));
|
||||
|
||||
addLabel(new GuiNpcLabel(-1, "ID", x + 320, y + 1));
|
||||
addLabel(new GuiNpcLabel(-2, effect.id + "", x + 320, y + 11));
|
||||
|
||||
y += 23;
|
||||
|
||||
addTextField(new GuiNpcTextField(2, this, x + 70, y, 246, 20, effect.menuName.replaceAll("§", "&")));
|
||||
getTextField(2).setMaxStringLength(40);
|
||||
addLabel(new GuiNpcLabel(2, "general.menuName", x, y + 5));
|
||||
|
||||
y += 23;
|
||||
|
||||
addTextField(setIntegerOnly(
|
||||
new GuiNpcTextField(3, this, x + 70, y, 83, 20, ""+effect.everyXTick),
|
||||
10,
|
||||
1200,
|
||||
effect.everyXTick
|
||||
));
|
||||
getTextField(3).setMaxStringLength(6);
|
||||
getTextField(3).integersOnly = true;
|
||||
addLabel(new GuiNpcLabel(3, "effect.editor.runsEveryX", x, y + 5));
|
||||
|
||||
int oldX = x;
|
||||
int xEnd = guiLeft+xSize-10;
|
||||
x = getTextField(3).xPosition + getTextField(3).width;
|
||||
addButton(new GuiNpcButtonYesNo(10, (x+xEnd - 83) / 2, y + 23, 83, 20, effect.lossOnDeath));
|
||||
GuiNpcLabel label = new GuiNpcLabel(10, "effect.editor.lossOnDeath", x, y + 5);
|
||||
label.x = (x+xEnd - fontRendererObj.getStringWidth(label.label))/2;
|
||||
addLabel(label);
|
||||
x = oldX;
|
||||
y += 23;
|
||||
|
||||
addTextField(setIntegerOnly(
|
||||
new GuiNpcTextField(4, this, x + 70, y, 83, 20, ""+effect.length),
|
||||
-100,
|
||||
86400,
|
||||
effect.length
|
||||
));
|
||||
|
||||
addLabel(new GuiNpcLabel(4, "effect.editor.defaultLength", x, y + 5));
|
||||
|
||||
x = oldX - 4;
|
||||
y += 23;
|
||||
GuiScrollWindow scrollWindow = new GuiScrollWindow(this, x + 5, y, xSize - 20, ySize - 10 - (y - guiTop), 0) {
|
||||
@Override
|
||||
public void drawComponents(int mouseX, int mouseY, float partialTicks) {
|
||||
super.drawComponents(mouseX, mouseY, partialTicks);
|
||||
|
||||
int iconRenderSize = 96;
|
||||
|
||||
int x = 10, y = (clipHeight - 96) / 2;
|
||||
|
||||
TextureManager textureManager = mc.getTextureManager();
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
ImageData data = ClientCacheHandler.getImageData(effect.icon);
|
||||
if (data.imageLoaded()) {
|
||||
data.bindTexture();
|
||||
int iconX = effect.iconX;
|
||||
int iconY = effect.iconY;
|
||||
int iconWidth = effect.getWidth();
|
||||
int iconHeight = effect.getHeight();
|
||||
int width = data.getTotalWidth();
|
||||
int height = data.getTotalWidth();
|
||||
|
||||
|
||||
func_152125_a(x, y, iconX, iconY, iconWidth, iconHeight, iconRenderSize, iconRenderSize, width, height);
|
||||
|
||||
} else {
|
||||
textureManager.bindTexture(new ResourceLocation("customnpcs", "textures/marks/question.png"));
|
||||
func_152125_a(x, y, 0, 0, 1, 1, iconRenderSize, iconRenderSize, 1, 1);
|
||||
}
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
// TODO: FIX TEXTURE
|
||||
// textureManager.bindTexture(new ResourceLocation(CustomNpcPlusDBC.ID + ":textures/gui/icons.png"));
|
||||
func_152125_a(x, y, 0, 240, 16, 16, iconRenderSize, iconRenderSize, 256, 256);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
};
|
||||
addScrollableGui(0, scrollWindow);
|
||||
|
||||
y = (scrollWindow.clipHeight - 96) / 2 + 5;
|
||||
x = 116;
|
||||
scrollWindow.addLabel(new GuiNpcLabel(5, "display.texture", x, y, 0xFFFFFF));
|
||||
y += 12;
|
||||
scrollWindow.addTextField(new GuiNpcTextField(5, this, x, y, scrollWindow.clipWidth-x-10, 20, effect.icon));
|
||||
scrollWindow.getTextField(5).setMaxStringLength(100);
|
||||
|
||||
y += 25;
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(6, "effect.editor.xPos", x, y + 6, 0xFFFFFF));
|
||||
scrollWindow.addTextField(setIntegerOnly(
|
||||
new GuiNpcTextField(6, this, x + 43, y, 60, 20, ""+effect.iconX),
|
||||
0,
|
||||
10240,
|
||||
effect.iconX
|
||||
));
|
||||
scrollWindow.addTextField(setIntegerOnly(
|
||||
new GuiNpcTextField(7, this, scrollWindow.clipWidth - 60 - 10, y, 60, 20, ""+effect.iconY),
|
||||
0,
|
||||
10240,
|
||||
effect.iconY
|
||||
));
|
||||
scrollWindow.addLabel(new GuiNpcLabel(7, "effect.editor.yPos", scrollWindow.getTextField(7).xPosition - 43, y + 6, 0xFFFFFF));
|
||||
y += 23;
|
||||
|
||||
scrollWindow.addLabel(new GuiNpcLabel(8, "effect.editor.width", x, y + 6, 0xFFFFFF));
|
||||
scrollWindow.addTextField(setIntegerOnly(
|
||||
new GuiNpcTextField(8, this, x + 43, y, 60, 20, ""+effect.width),
|
||||
0,
|
||||
10240,
|
||||
effect.width
|
||||
));
|
||||
scrollWindow.addTextField(setIntegerOnly(
|
||||
new GuiNpcTextField(9, this, scrollWindow.clipWidth - 60 - 10, y, 60, 20, ""+effect.height),
|
||||
0,
|
||||
10240,
|
||||
effect.height
|
||||
));
|
||||
scrollWindow.addLabel(new GuiNpcLabel(9, "effect.editor.height", scrollWindow.getTextField(9).xPosition - 43, y + 6, 0xFFFFFF));
|
||||
|
||||
}
|
||||
|
||||
private GuiNpcTextField setIntegerOnly(GuiNpcTextField field, int min, int max, int def) {
|
||||
field.integersOnly = true;
|
||||
field.setMinMaxDefault(min, max, def);
|
||||
field.setMaxStringLength(6);
|
||||
return field;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
int id = guibutton.id;
|
||||
|
||||
if (id == -5) {
|
||||
close();
|
||||
return;
|
||||
}
|
||||
if (id == -2) {
|
||||
PacketClient.sendClient(new EffectSavePacket(effect.writeToNBT(false), originalName));
|
||||
GuiScriptEffect scriptGUI = new GuiScriptEffect(parent, effect);
|
||||
scriptGUI.setWorldAndResolution(mc, width, height);
|
||||
scriptGUI.initGui();
|
||||
mc.currentScreen = scriptGUI;
|
||||
}
|
||||
if (id == 10) {
|
||||
GuiNpcButtonYesNo button = (GuiNpcButtonYesNo) guibutton;
|
||||
effect.lossOnDeath = button.getBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField guiNpcTextField) {
|
||||
int id = guiNpcTextField.id;
|
||||
|
||||
switch (id) {
|
||||
case 1:
|
||||
effect.setName(guiNpcTextField.getText());
|
||||
break;
|
||||
case 2:
|
||||
effect.setMenuName(guiNpcTextField.getText());
|
||||
break;
|
||||
case 3:
|
||||
effect.setEveryXTick(guiNpcTextField.getInteger());
|
||||
guiNpcTextField.setText(effect.everyXTick+"");
|
||||
break;
|
||||
case 4:
|
||||
int length = guiNpcTextField.getInteger();
|
||||
if (length < 0)
|
||||
length = -100;
|
||||
guiNpcTextField.setText(length+"");
|
||||
effect.length = length;
|
||||
break;
|
||||
case 5:
|
||||
effect.icon = guiNpcTextField.getText();
|
||||
break;
|
||||
case 6:
|
||||
effect.iconX = guiNpcTextField.getInteger();
|
||||
break;
|
||||
case 7:
|
||||
effect.iconY = guiNpcTextField.getInteger();
|
||||
break;
|
||||
case 8:
|
||||
effect.width = guiNpcTextField.getInteger();
|
||||
break;
|
||||
case 9:
|
||||
effect.height = guiNpcTextField.getInteger();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
super.close();
|
||||
PacketClient.sendClient(new EffectSavePacket(effect.writeToNBT(false), originalName));
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.MailOpenSetupPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.player.GuiMailmanWrite;
|
||||
import noppes.npcs.client.gui.select.GuiQuestSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.containers.ContainerMail;
|
||||
import noppes.npcs.controllers.data.PlayerMail;
|
||||
|
||||
@@ -63,7 +65,7 @@ public class SubGuiMailmanSendSetup extends SubGuiInterface implements ITextfiel
|
||||
GuiMailmanWrite.parent = getParent();
|
||||
GuiMailmanWrite.mail = mail;
|
||||
|
||||
Client.sendData(EnumPacketServer.MailOpenSetup, mail.writeNBT());
|
||||
PacketClient.sendClient(new MailOpenSetupPacket(mail.writeNBT()));
|
||||
}
|
||||
if(id == 3){
|
||||
setSubGui(new GuiQuestSelection(mail.questId));
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.faction.FactionGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumAvailabilityFactionType;
|
||||
import noppes.npcs.constants.EnumDayTime;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.Availability;
|
||||
import noppes.npcs.controllers.data.Faction;
|
||||
|
||||
public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener, IGuiData
|
||||
public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener, IGuiData
|
||||
{
|
||||
private Availability availabitily;
|
||||
private int slot = 0;
|
||||
|
||||
|
||||
public SubGuiNpcAvailability(Availability availabitily)
|
||||
{
|
||||
this.availabitily = availabitily;
|
||||
@@ -34,14 +35,14 @@ public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfield
|
||||
this.addButton(new GuiNpcButton(0, guiLeft + 34, guiTop + 12, 180, 20, "availability.selectdialog"));
|
||||
this.addButton(new GuiNpcButton(1, guiLeft + 34, guiTop + 35, 180, 20, "availability.selectquest"));
|
||||
|
||||
|
||||
|
||||
this.addButton(new GuiNpcButton(20, guiLeft + 4, guiTop + 104, 50, 20, new String[]{"availability.always","availability.is","availability.isnot"},availabitily.factionAvailable.ordinal()));
|
||||
this.addButton(new GuiNpcButton(22, guiLeft + 56, guiTop + 104, 60, 20, new String[]{"faction.friendly","faction.neutral","faction.unfriendly"},availabitily.factionStance.ordinal()));
|
||||
this.addButton(new GuiNpcButton(21, guiLeft + 118, guiTop + 104, 110, 20, "availability.selectfaction"));
|
||||
getButton(21).setEnabled(availabitily.factionAvailable != EnumAvailabilityFactionType.Always);
|
||||
getButton(22).setEnabled(availabitily.factionAvailable != EnumAvailabilityFactionType.Always);
|
||||
this.addButton(new GuiNpcButton(23, guiLeft + 230, guiTop + 104,20, 20, "X"));
|
||||
|
||||
|
||||
this.addButton(new GuiNpcButton(24, guiLeft + 4, guiTop + 126, 50, 20, new String[]{"availability.always","availability.is","availability.isnot"},availabitily.faction2Available.ordinal()));
|
||||
this.addButton(new GuiNpcButton(27, guiLeft + 56, guiTop + 126, 60, 20, new String[]{"faction.friendly","faction.neutral","faction.unfriendly"},availabitily.faction2Stance.ordinal()));
|
||||
this.addButton(new GuiNpcButton(25, guiLeft + 118, guiTop + 126, 110, 20, "availability.selectfaction"));
|
||||
@@ -56,19 +57,19 @@ public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfield
|
||||
this.addTextField(new GuiNpcTextField(51, this, fontRendererObj, guiLeft + 50, guiTop + 170,90, 20, availabitily.minPlayerLevel + ""));
|
||||
this.getTextField(51).integersOnly = true;
|
||||
this.getTextField(51).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
||||
|
||||
|
||||
this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done"));
|
||||
|
||||
|
||||
updateGuiButtons();
|
||||
}
|
||||
|
||||
|
||||
private void updateGuiButtons() {
|
||||
if(availabitily.factionId >= 0){
|
||||
Client.sendData(EnumPacketServer.FactionGet, availabitily.factionId);
|
||||
FactionGetPacket.getFaction(availabitily.factionId);
|
||||
}
|
||||
if(availabitily.faction2Id >= 0){
|
||||
Client.sendData(EnumPacketServer.FactionGet, availabitily.faction2Id);
|
||||
FactionGetPacket.getFaction(availabitily.faction2Id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.dialog.DialogGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.select.GuiDialogSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumAvailabilityDialog;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.Availability;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
|
||||
@@ -66,16 +67,16 @@ public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiS
|
||||
getButton(13).setDisplayText("availability.selectdialog");
|
||||
|
||||
if(availabitily.dialogId >= 0){
|
||||
Client.sendData(EnumPacketServer.DialogGet, availabitily.dialogId);
|
||||
DialogGetPacket.getDialog(availabitily.dialogId);
|
||||
}
|
||||
if(availabitily.dialog2Id >= 0){
|
||||
Client.sendData(EnumPacketServer.DialogGet, availabitily.dialog2Id);
|
||||
DialogGetPacket.getDialog(availabitily.dialog2Id);
|
||||
}
|
||||
if(availabitily.dialog3Id >= 0){
|
||||
Client.sendData(EnumPacketServer.DialogGet, availabitily.dialog3Id);
|
||||
DialogGetPacket.getDialog(availabitily.dialog3Id);
|
||||
}
|
||||
if(availabitily.dialog4Id >= 0){
|
||||
Client.sendData(EnumPacketServer.DialogGet, availabitily.dialog4Id);
|
||||
DialogGetPacket.getDialog(availabitily.dialog4Id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.quest.QuestGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.select.GuiQuestSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumAvailabilityQuest;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.Availability;
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
|
||||
@@ -66,16 +67,16 @@ public class SubGuiNpcAvailabilityQuest extends SubGuiInterface implements GuiSe
|
||||
getButton(13).setDisplayText("availability.selectquest");
|
||||
|
||||
if(availabitily.questId >= 0){
|
||||
Client.sendData(EnumPacketServer.QuestGet, availabitily.questId);
|
||||
QuestGetPacket.getQuest(availabitily.questId);
|
||||
}
|
||||
if(availabitily.quest2Id >= 0){
|
||||
Client.sendData(EnumPacketServer.QuestGet, availabitily.quest2Id);
|
||||
QuestGetPacket.getQuest(availabitily.quest2Id);
|
||||
}
|
||||
if(availabitily.quest3Id >= 0){
|
||||
Client.sendData(EnumPacketServer.QuestGet, availabitily.quest3Id);
|
||||
QuestGetPacket.getQuest(availabitily.quest3Id);
|
||||
}
|
||||
if(availabitily.quest4Id >= 0){
|
||||
Client.sendData(EnumPacketServer.QuestGet, availabitily.quest4Id);
|
||||
QuestGetPacket.getQuest(availabitily.quest4Id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.dialog.DialogSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.EntityUtil;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.global.GuiNPCManageDialogs;
|
||||
@@ -10,7 +12,7 @@ import noppes.npcs.client.gui.player.GuiDialogInteract;
|
||||
import noppes.npcs.client.gui.select.GuiQuestSelection;
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
import noppes.npcs.controllers.data.PlayerMail;
|
||||
import noppes.npcs.entity.EntityDialogNpc;
|
||||
@@ -196,10 +198,10 @@ public class SubGuiNpcDialog extends SubGuiInterface implements ISubGuiListener,
|
||||
dialog.quest = ob;
|
||||
parent.dialogQuestName = name;
|
||||
initGui();
|
||||
Client.sendData(EnumPacketServer.DialogSave, this.dialogCategoryID, dialog.writeToNBT(new NBTTagCompound()));
|
||||
PacketClient.sendClient(new DialogSavePacket(this.dialogCategoryID, dialog.writeToNBT(new NBTTagCompound()), false));
|
||||
}
|
||||
|
||||
public void save(){
|
||||
Client.sendData(EnumPacketServer.DialogSave, this.dialogCategoryID, dialog.writeToNBT(new NBTTagCompound()));
|
||||
PacketClient.sendClient(new DialogSavePacket(this.dialogCategoryID, dialog.writeToNBT(new NBTTagCompound()), false));
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.dialog.DialogGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.select.GuiDialogSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumOptionType;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
import noppes.npcs.controllers.data.DialogOption;
|
||||
|
||||
@@ -44,7 +45,7 @@ public class SubGuiNpcDialogOption extends SubGuiInterface implements IGuiData,
|
||||
if(option.optionType == EnumOptionType.DialogOption){
|
||||
this.addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 84, "availability.selectdialog"));
|
||||
if(option.dialogId >= 0)
|
||||
Client.sendData(EnumPacketServer.DialogGet, option.dialogId);
|
||||
DialogGetPacket.getDialog(option.dialogId);
|
||||
}
|
||||
if(option.optionType == EnumOptionType.CommandBlock){
|
||||
this.addTextField(new GuiNpcTextField(4, this, this.fontRendererObj, guiLeft + 4, guiTop + 84, 248, 20, option.command));
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.dialog.DialogSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
import noppes.npcs.controllers.data.DialogImage;
|
||||
|
||||
@@ -419,7 +421,7 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis
|
||||
public void save() {
|
||||
GuiNpcTextField.unfocus();
|
||||
if(dialog.id >= 0)
|
||||
Client.sendData(EnumPacketServer.DialogSave, ((SubGuiNpcDialog)parent).dialogCategoryID, dialog.writeToNBT(new NBTTagCompound()));
|
||||
PacketClient.sendClient(new DialogSavePacket(((SubGuiNpcDialog)parent).dialogCategoryID, dialog.writeToNBT(new NBTTagCompound()), false));
|
||||
}
|
||||
|
||||
private DialogImage getSelectedImage() {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.DimensionsGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.SpawnData;
|
||||
|
||||
import java.util.*;
|
||||
@@ -14,14 +16,14 @@ public class SubGuiNpcDimensions extends SubGuiInterface implements IScrollData
|
||||
private GuiCustomScroll allDimensions;
|
||||
private HashMap<String, Integer> dimensionMap = new HashMap<>();
|
||||
private GuiCustomScroll dataDimensions;
|
||||
|
||||
|
||||
public SubGuiNpcDimensions(SpawnData data){
|
||||
this.data = data;
|
||||
setBackground("menubg.png");
|
||||
xSize = 346;
|
||||
ySize = 216;
|
||||
closeOnEsc = true;
|
||||
Client.sendData(EnumPacketServer.DimensionsGet);
|
||||
PacketClient.sendClient(new DimensionsGetPacket());
|
||||
}
|
||||
|
||||
public void initGui(){
|
||||
@@ -34,7 +36,7 @@ public class SubGuiNpcDimensions extends SubGuiInterface implements IScrollData
|
||||
allDimensions.guiTop = guiTop + 14;
|
||||
this.addScroll(allDimensions);
|
||||
addLabel(new GuiNpcLabel(1, "spawning.availableDimensions", guiLeft + 4, guiTop + 4));
|
||||
|
||||
|
||||
if(dataDimensions == null){
|
||||
dataDimensions = new GuiCustomScroll(this,1);
|
||||
dataDimensions.setSize(140, 180);
|
||||
@@ -58,8 +60,8 @@ public class SubGuiNpcDimensions extends SubGuiInterface implements IScrollData
|
||||
|
||||
addButton(new GuiNpcButton(3, guiLeft + 145, guiTop + 90, 55, 20, ">>"));
|
||||
addButton(new GuiNpcButton(4, guiLeft + 145, guiTop + 112, 55, 20, "<<"));
|
||||
|
||||
|
||||
|
||||
|
||||
addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done"));
|
||||
}
|
||||
|
||||
@@ -70,14 +72,14 @@ public class SubGuiNpcDimensions extends SubGuiInterface implements IScrollData
|
||||
data.dimensions.add(dimensionMap.get(allDimensions.getSelected()));
|
||||
allDimensions.selected = -1;
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(button.id == 2){
|
||||
if(dataDimensions.hasSelected()){
|
||||
data.dimensions.remove(dimensionMap.get(dataDimensions.getSelected()));
|
||||
dataDimensions.selected = -1;
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(button.id == 3){
|
||||
data.dimensions.clear();
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.faction.FactionsGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.FactionOptions;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -15,9 +17,9 @@ public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollD
|
||||
private FactionOptions options;
|
||||
private HashMap<String,Integer> data = new HashMap<String,Integer>();
|
||||
private GuiCustomScroll scrollFactions;
|
||||
|
||||
|
||||
private int selected = -1;
|
||||
|
||||
|
||||
public SubGuiNpcFactionOptions(FactionOptions options)
|
||||
{
|
||||
this.options = options;
|
||||
@@ -25,7 +27,7 @@ public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollD
|
||||
xSize = 256;
|
||||
ySize = 216;
|
||||
closeOnEsc = true;
|
||||
Client.sendData(EnumPacketServer.FactionsGet);
|
||||
PacketClient.sendClient(new FactionsGetPacket());
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
@@ -42,7 +44,7 @@ public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollD
|
||||
addLabel(new GuiNpcLabel(0, "1: ", guiLeft + 4, guiTop + 12));
|
||||
if(data.containsValue(options.factionId)){
|
||||
addLabel(new GuiNpcLabel(1, getFactionName(options.factionId), guiLeft + 12, guiTop + 8));
|
||||
|
||||
|
||||
String label = "";
|
||||
if(options.decreaseFactionPoints)
|
||||
label += StatCollector.translateToLocal("gui.decrease");
|
||||
@@ -69,14 +71,14 @@ public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollD
|
||||
addButton(new GuiNpcButton(1, guiLeft + 110, guiTop + 35, 20, 20, "X"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(selected >= 0 && (!data.containsValue(options.faction2Id) || !data.containsValue(options.factionId)) && !options.hasFaction(selected)){
|
||||
addButton(new GuiNpcButton(2, guiLeft + 4, guiTop + 60, 90, 20, new String[]{"gui.increase","gui.decrease"},0));
|
||||
|
||||
|
||||
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 82, 110, 20, "10"));
|
||||
getTextField(1).integersOnly = true;
|
||||
getTextField(1).setMinMaxDefault(1, 100000, 10);
|
||||
|
||||
|
||||
addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 104, 60, 20, "gui.add"));
|
||||
}
|
||||
|
||||
@@ -88,7 +90,7 @@ public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollD
|
||||
return s;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton)
|
||||
{
|
||||
int id = guibutton.id;
|
||||
@@ -135,16 +137,16 @@ public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollD
|
||||
String name = scroll.getSelected();
|
||||
this.data = data;
|
||||
scroll.setList(list);
|
||||
|
||||
|
||||
if(name != null)
|
||||
scroll.setSelected(name);
|
||||
|
||||
|
||||
initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(String selected) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.quest.QuestOpenGuiPacket;
|
||||
import kamkeel.npcs.network.packets.request.quest.QuestSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.global.GuiNPCManageQuest;
|
||||
import noppes.npcs.client.gui.questtypes.GuiNpcQuestTypeDialog;
|
||||
import noppes.npcs.client.gui.questtypes.GuiNpcQuestTypeKill;
|
||||
@@ -101,7 +104,7 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
|
||||
setSubGui(new SubGuiNpcTextArea(quest.logText));
|
||||
}
|
||||
if(button.id == 5 && quest.id >= 0){
|
||||
Client.sendData(EnumPacketServer.QuestOpenGui, EnumGuiType.QuestReward, quest.writeToNBT(new NBTTagCompound()));
|
||||
PacketClient.sendClient(new QuestOpenGuiPacket(EnumGuiType.QuestReward, quest.writeToNBT(new NBTTagCompound())));
|
||||
}
|
||||
if(button.id == 6 && quest.id >= 0){
|
||||
quest.setType(EnumQuestType.values()[button.getValue()]);
|
||||
@@ -109,7 +112,7 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
|
||||
if(button.id == 7)
|
||||
{
|
||||
if(quest.type == EnumQuestType.Item)
|
||||
Client.sendData(EnumPacketServer.QuestOpenGui, EnumGuiType.QuestItem, quest.writeToNBT(new NBTTagCompound()));
|
||||
PacketClient.sendClient(new QuestOpenGuiPacket(EnumGuiType.QuestItem, quest.writeToNBT(new NBTTagCompound())));
|
||||
|
||||
if(quest.type == EnumQuestType.Dialog)
|
||||
setSubGui(new GuiNpcQuestTypeDialog(npc, quest, this));
|
||||
@@ -218,10 +221,10 @@ public class SubGuiNpcQuest extends SubGuiInterface implements ISubGuiListener,
|
||||
quest.nextQuestTitle = name;
|
||||
parent.nextQuestName = name;
|
||||
initGui();
|
||||
Client.sendData(EnumPacketServer.QuestSave, this.questCategoryID, quest.writeToNBT(new NBTTagCompound()));
|
||||
PacketClient.sendClient(new QuestSavePacket(this.questCategoryID, quest.writeToNBT(new NBTTagCompound()), false));
|
||||
}
|
||||
|
||||
public void save(){
|
||||
Client.sendData(EnumPacketServer.QuestSave, this.questCategoryID, quest.writeToNBT(new NBTTagCompound()));
|
||||
PacketClient.sendClient(new QuestSavePacket(this.questCategoryID, quest.writeToNBT(new NBTTagCompound()), false));
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class SubGuiNpcResistanceProperties extends SubGuiInterface implements IS
|
||||
|
||||
@Override
|
||||
public void mousePressed(GuiNpcSlider slider) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedGetAllPacket;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedSetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -15,21 +18,21 @@ import java.util.Vector;
|
||||
public class GuiNPCAdvancedLinkedNpc extends GuiNPCInterface2 implements IScrollData, ICustomScrollListener{
|
||||
private GuiCustomScroll scroll;
|
||||
private List<String> data = new ArrayList<String>();
|
||||
|
||||
|
||||
public static GuiScreen Instance;
|
||||
|
||||
|
||||
public GuiNPCAdvancedLinkedNpc(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
Instance = this;
|
||||
Client.sendData(EnumPacketServer.LinkedGetAll);
|
||||
PacketClient.sendClient(new LinkedGetAllPacket());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
|
||||
|
||||
this.addButton(new GuiNpcButton(1,guiLeft + 358, guiTop + 38, 58, 20, "gui.clear"));
|
||||
|
||||
|
||||
if(scroll == null){
|
||||
scroll = new GuiCustomScroll(this,0);
|
||||
scroll.setSize(143, 208);
|
||||
@@ -44,9 +47,9 @@ public class GuiNPCAdvancedLinkedNpc extends GuiNPCInterface2 implements IScroll
|
||||
@Override
|
||||
public void buttonEvent(GuiButton button){
|
||||
if(button.id == 1){
|
||||
Client.sendData(EnumPacketServer.LinkedSet, "");
|
||||
PacketClient.sendClient(new LinkedSetPacket(""));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,13 +65,13 @@ public class GuiNPCAdvancedLinkedNpc extends GuiNPCInterface2 implements IScroll
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k,
|
||||
GuiCustomScroll guiCustomScroll) {
|
||||
Client.sendData(EnumPacketServer.LinkedSet, guiCustomScroll.getSelected());
|
||||
PacketClient.sendClient(new LinkedSetPacket(guiCustomScroll.getSelected()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.dialog.DialogNpcGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.dialog.DialogNpcRemovePacket;
|
||||
import kamkeel.npcs.network.packets.request.dialog.DialogNpcSetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.select.GuiDialogSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.DialogOption;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
@@ -21,7 +25,7 @@ public class GuiNPCDialogNpcOptions extends GuiNPCInterface2 implements GuiSelec
|
||||
super(npc);
|
||||
this.parent = parent;
|
||||
this.drawDefaultBackground = true;
|
||||
Client.sendData(EnumPacketServer.DialogNpcGet);
|
||||
PacketClient.sendClient(new DialogNpcGetPacket());
|
||||
}
|
||||
|
||||
public void initGui() {
|
||||
@@ -55,7 +59,7 @@ public class GuiNPCDialogNpcOptions extends GuiNPCInterface2 implements GuiSelec
|
||||
if (id >= 20 && id < 40) {
|
||||
int slot = id - 20;
|
||||
data.remove(slot);
|
||||
Client.sendData(EnumPacketServer.DialogNpcRemove,slot);
|
||||
PacketClient.sendClient(new DialogNpcRemovePacket(slot));
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
@@ -66,7 +70,7 @@ public class GuiNPCDialogNpcOptions extends GuiNPCInterface2 implements GuiSelec
|
||||
|
||||
@Override
|
||||
public void selected(int id, String name) {
|
||||
Client.sendData(EnumPacketServer.DialogNpcSet, selectedSlot, id);
|
||||
PacketClient.sendClient(new DialogNpcSetPacket(selectedSlot, id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.faction.FactionSetPacket;
|
||||
import kamkeel.npcs.network.packets.request.faction.FactionsGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.SubGuiNpcFactionOptions;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -15,11 +19,11 @@ public class GuiNPCFactionSetup extends GuiNPCInterface2 implements IScrollData,
|
||||
{
|
||||
private GuiCustomScroll scrollFactions;
|
||||
private HashMap<String,Integer> data = new HashMap<String,Integer>();
|
||||
|
||||
|
||||
public GuiNPCFactionSetup(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
Client.sendData(EnumPacketServer.FactionsGet);
|
||||
PacketClient.sendClient(new FactionsGetPacket());
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
@@ -34,7 +38,7 @@ public class GuiNPCFactionSetup extends GuiNPCInterface2 implements IScrollData,
|
||||
|
||||
this.addLabel(new GuiNpcLabel(12, "faction.ondeath", guiLeft + 4, guiTop + 69));
|
||||
addButton(new GuiNpcButton(12, guiLeft + 90, guiTop + 64, 80, 20, "faction.points"));
|
||||
|
||||
|
||||
if(scrollFactions == null){
|
||||
scrollFactions = new GuiCustomScroll(this,0,0);
|
||||
scrollFactions.setSize(180, 200);
|
||||
@@ -59,41 +63,41 @@ public class GuiNPCFactionSetup extends GuiNPCInterface2 implements IScrollData,
|
||||
if(button.id == 12)
|
||||
setSubGui(new SubGuiNpcFactionOptions(npc.advanced.factions));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setData(Vector<String> list, HashMap<String, Integer> data)
|
||||
public void setData(Vector<String> list, HashMap<String, Integer> data)
|
||||
{
|
||||
String name = npc.getFaction().name;
|
||||
this.data = data;
|
||||
scrollFactions.setList(list);
|
||||
|
||||
|
||||
if(name != null)
|
||||
setSelected(name);
|
||||
}
|
||||
|
||||
|
||||
public void mouseClicked(int i, int j, int k)
|
||||
{
|
||||
super.mouseClicked(i, j, k);
|
||||
if(k == 0 && scrollFactions != null)
|
||||
scrollFactions.mouseClicked(i, j, k);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSelected(String selected) {
|
||||
scrollFactions.setSelected(selected);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
if(guiCustomScroll.id == 0)
|
||||
{
|
||||
Client.sendData(EnumPacketServer.FactionSet, data.get(scrollFactions.getSelected()));
|
||||
PacketClient.sendClient(new FactionSetPacket(data.get(scrollFactions.getSelected())));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void save() {
|
||||
Client.sendData(EnumPacketServer.MainmenuAdvancedSave, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
PacketClient.sendClient(new MainmenuAdvancedSavePacket(npc.advanced.writeToNBT(new NBTTagCompound())));
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,21 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.GuiNPCLinesEdit;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButtonYesNo;
|
||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class GuiNPCLinesMenu extends GuiNPCInterface2 {
|
||||
|
||||
|
||||
public GuiNPCLinesMenu(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
}
|
||||
@@ -54,10 +56,10 @@ public class GuiNPCLinesMenu extends GuiNPCInterface2 {
|
||||
npc.advanced.orderedLines = !((GuiNpcButtonYesNo)guibutton).getBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
Client.sendData(EnumPacketServer.MainmenuAdvancedSave, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||
PacketClient.sendClient(new MainmenuAdvancedSavePacket(npc.advanced.writeToNBT(new NBTTagCompound())));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedMarkDataPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.SubGuiColorSelector;
|
||||
import noppes.npcs.client.gui.SubGuiNpcAvailability;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.constants.MarkType;
|
||||
import noppes.npcs.controllers.data.MarkData;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
@@ -78,7 +81,7 @@ public class GuiNPCMarks extends GuiNPCInterface2 implements ISubGuiListener {
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
Client.sendData(EnumPacketServer.MainmenuAdvancedMarkData, data.getNBT());
|
||||
PacketClient.sendClient(new MainmenuAdvancedMarkDataPacket(data.getNBT()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +1,29 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.transform.TransformGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.transform.TransformLoadPacket;
|
||||
import kamkeel.npcs.network.packets.request.transform.TransformSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||
import noppes.npcs.client.gui.util.IGuiData;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.DataTransform;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class GuiNPCNightSetup extends GuiNPCInterface2 implements IGuiData
|
||||
{
|
||||
private DataTransform data;
|
||||
|
||||
|
||||
public GuiNPCNightSetup(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
data = npc.transform;
|
||||
Client.sendData(EnumPacketServer.TransformGet);
|
||||
PacketClient.sendClient(new TransformGetPacket());
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
@@ -40,16 +44,16 @@ public class GuiNPCNightSetup extends GuiNPCInterface2 implements IGuiData
|
||||
|
||||
this.addLabel(new GuiNpcLabel(4, "menu.advanced", guiLeft + 4, guiTop + 113));
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 104, guiTop + 108, 50, 20, new String[]{"gui.no","gui.yes"}, data.hasAdvanced?1:0));
|
||||
|
||||
|
||||
this.addLabel(new GuiNpcLabel(5, "role.name", guiLeft + 4, guiTop + 135));
|
||||
this.addButton(new GuiNpcButton(5, guiLeft + 104, guiTop + 130, 50, 20, new String[]{"gui.no","gui.yes"}, data.hasRole?1:0));
|
||||
|
||||
|
||||
this.addLabel(new GuiNpcLabel(6, "job.name", guiLeft + 4, guiTop + 157));
|
||||
this.addButton(new GuiNpcButton(6, guiLeft + 104, guiTop + 152, 50, 20, new String[]{"gui.no","gui.yes"}, data.hasJob?1:0));
|
||||
|
||||
|
||||
this.addLabel(new GuiNpcLabel(10, "advanced.editingmode", guiLeft + 170, guiTop + 9));
|
||||
this.addButton(new GuiNpcButton(10, guiLeft + 244, guiTop + 4, 50, 20, new String[]{"gui.no","gui.yes"}, data.editingModus?1:0));
|
||||
|
||||
|
||||
if(data.editingModus){
|
||||
this.addButton(new GuiNpcButton(11, guiLeft + 170, guiTop + 34, "advanced.loadday"));
|
||||
this.addButton(new GuiNpcButton(12, guiLeft + 170, guiTop + 56, "advanced.loadnight"));
|
||||
@@ -80,16 +84,16 @@ public class GuiNPCNightSetup extends GuiNPCInterface2 implements IGuiData
|
||||
initGui();
|
||||
}
|
||||
if(button.id == 11){
|
||||
Client.sendData(EnumPacketServer.TransformLoad, false);
|
||||
PacketClient.sendClient(new TransformLoadPacket(false));
|
||||
}
|
||||
if(button.id == 12){
|
||||
Client.sendData(EnumPacketServer.TransformLoad, true);
|
||||
PacketClient.sendClient(new TransformLoadPacket(true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void save() {
|
||||
Client.sendData(EnumPacketServer.TransformSave, data.writeOptions(new NBTTagCompound()));
|
||||
PacketClient.sendClient(new TransformSavePacket(data.writeOptions(new NBTTagCompound())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.mainmenu.MainmenuAdvancedSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.select.GuiSoundSelection;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldListener, ISubGuiListener
|
||||
@@ -77,7 +79,7 @@ public class GuiNPCSoundsMenu extends GuiNPCInterface2 implements ITextfieldLis
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
Client.sendData(EnumPacketServer.MainmenuAdvancedSave, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||
PacketClient.sendClient(new MainmenuAdvancedSavePacket(npc.advanced.writeToNBT(new NBTTagCompound())));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagsGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagsNpcGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagSetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -26,8 +28,8 @@ public class GuiNPCTagSetup extends GuiNPCInterface2 implements IScrollData,ICus
|
||||
public GuiNPCTagSetup(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
Client.sendData(EnumPacketServer.TagsGet);
|
||||
Client.sendData(EnumPacketServer.NpcTagsGet);
|
||||
PacketClient.sendClient(new TagsGetPacket());
|
||||
PacketClient.sendClient(new TagsNpcGetPacket());
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
@@ -120,7 +122,7 @@ public class GuiNPCTagSetup extends GuiNPCInterface2 implements IScrollData,ICus
|
||||
tagList.appendTag(new NBTTagString(string));
|
||||
}
|
||||
tagCompound.setTag("TagNames",tagList);
|
||||
Client.sendData(EnumPacketServer.TagSet, tagCompound);
|
||||
PacketClient.sendClient(new TagSetPacket(tagCompound));
|
||||
}
|
||||
|
||||
public void keyTyped(char c, int i)
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package noppes.npcs.client.gui.custom;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.customgui.CustomGuiButtonPacket;
|
||||
import kamkeel.npcs.network.packets.request.customgui.CustomGuiClosePacket;
|
||||
import kamkeel.npcs.network.packets.request.customgui.CustomGuiUnfocusedPacket;
|
||||
import kamkeel.npcs.network.packets.request.customgui.CustomScrollClickPacket;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
@@ -20,7 +25,7 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.api.gui.ICustomGuiComponent;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.custom.components.*;
|
||||
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
|
||||
import noppes.npcs.client.gui.custom.interfaces.IDataHolder;
|
||||
@@ -28,7 +33,7 @@ import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
|
||||
import noppes.npcs.client.gui.util.GuiCustomScroll;
|
||||
import noppes.npcs.client.gui.util.ICustomScrollListener;
|
||||
import noppes.npcs.client.gui.util.IGuiData;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.containers.ContainerCustomGui;
|
||||
import noppes.npcs.scripted.gui.*;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -449,25 +454,25 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
super.actionPerformed(button);
|
||||
Client.sendData(EnumPacketServer.CustomGuiButton, new Object[]{this.updateGui().toNBT(), button.id});
|
||||
PacketClient.sendClient(new CustomGuiButtonPacket(button.id, this.updateGui().toNBT()));
|
||||
}
|
||||
|
||||
public void buttonClick(CustomGuiButton button) {
|
||||
Client.sendData(EnumPacketServer.CustomGuiButton, new Object[]{this.updateGui().toNBT(), button.id});
|
||||
PacketClient.sendClient(new CustomGuiButtonPacket(button.id, this.updateGui().toNBT()));
|
||||
}
|
||||
|
||||
public String prevScrollClicked = null;
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) {
|
||||
Client.sendData(EnumPacketServer.CustomGuiScrollClick, new Object[]{this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), false});
|
||||
PacketClient.sendClient(new CustomScrollClickPacket(this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), false));
|
||||
if(Integer.toString(scroll.selected).equals(prevScrollClicked)){
|
||||
Client.sendData(EnumPacketServer.CustomGuiScrollClick, new Object[]{this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), true});
|
||||
PacketClient.sendClient(new CustomScrollClickPacket(this.updateGui().toNBT(), scroll.id, scroll.selected, this.getScrollSelection((CustomGuiScrollComponent)scroll), true));
|
||||
}
|
||||
prevScrollClicked = Integer.toString(scroll.selected);
|
||||
}
|
||||
|
||||
public void onGuiClosed() {
|
||||
if (this.gui != null) {
|
||||
Client.sendData(EnumPacketServer.CustomGuiClose, new Object[]{this.updateGui().toNBT()});
|
||||
PacketClient.sendClient(new CustomGuiClosePacket(this.updateGui().toNBT()));
|
||||
}
|
||||
|
||||
if (this.mc.thePlayer != null)
|
||||
@@ -477,10 +482,10 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
}
|
||||
|
||||
public void onTextFieldUnfocused(CustomGuiTextField textField){
|
||||
Client.sendData(EnumPacketServer.CustomGuiUnfocused, new Object[]{this.updateGui().toNBT(), textField.getID()});
|
||||
PacketClient.sendClient(new CustomGuiUnfocusedPacket(textField.getID(), this.updateGui().toNBT()));
|
||||
}
|
||||
|
||||
ScriptGui updateGui() {
|
||||
public ScriptGui updateGui() {
|
||||
Iterator var1 = this.dataHolders.iterator();
|
||||
|
||||
while(var1.hasNext()) {
|
||||
@@ -491,7 +496,7 @@ public class GuiCustom extends GuiScreen implements ICustomScrollListener, IGuiD
|
||||
return this.gui;
|
||||
}
|
||||
|
||||
NBTTagCompound getScrollSelection(CustomGuiScrollComponent scroll) {
|
||||
public NBTTagCompound getScrollSelection(CustomGuiScrollComponent scroll) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
if (scroll.multiSelect) {
|
||||
Iterator var3 = scroll.getSelectedList().iterator();
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.animation.AnimationSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.SubGuiAnimationFrame;
|
||||
import noppes.npcs.client.gui.SubGuiAnimationOptions;
|
||||
import noppes.npcs.client.gui.SubGuiColorSelector;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumAnimationPart;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.controllers.data.Frame;
|
||||
@@ -591,7 +593,7 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield
|
||||
public void close() {
|
||||
if (!this.hasSubGui()) {
|
||||
if (animation != null) {
|
||||
Client.sendData(EnumPacketServer.AnimationSave, animation.writeToNBT());
|
||||
PacketClient.sendClient(new AnimationSavePacket(animation.writeToNBT()));
|
||||
}
|
||||
displayGuiScreen(parent);
|
||||
} else {
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.animation.AnimationGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.animation.AnimationRemovePacket;
|
||||
import kamkeel.npcs.network.packets.request.animation.AnimationSavePacket;
|
||||
import kamkeel.npcs.network.packets.request.animation.AnimationsGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
@@ -33,7 +38,7 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol
|
||||
this.setSave(save);
|
||||
this.xOffset = -148 + 70;
|
||||
this.yOffset = -170 + 137;
|
||||
Client.sendData(EnumPacketServer.AnimationsGet);
|
||||
PacketClient.sendClient(new AnimationsGetPacket());
|
||||
|
||||
AnimationData data = npc.display.animationData;
|
||||
data.setEnabled(true);
|
||||
@@ -155,12 +160,12 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
|
||||
if(button.id == 0){
|
||||
save();
|
||||
String name = "New";
|
||||
while(data.containsKey(name))
|
||||
name += "_";
|
||||
Animation animation = new Animation(-1, name);
|
||||
Client.sendData(EnumPacketServer.AnimationSave, animation.writeToNBT());
|
||||
save();
|
||||
String name = "New";
|
||||
while(data.containsKey(name))
|
||||
name += "_";
|
||||
Animation animation = new Animation(-1, name);
|
||||
PacketClient.sendClient(new AnimationSavePacket(animation.writeToNBT()));
|
||||
}
|
||||
if(button.id == 1){
|
||||
if(data.containsKey(scrollAnimations.getSelected())) {
|
||||
@@ -225,20 +230,20 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol
|
||||
scrollAnimations.setSelected(selected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
if(guiCustomScroll.id == 0)
|
||||
{
|
||||
selected = scrollAnimations.getSelected();
|
||||
Client.sendData(EnumPacketServer.AnimationGet, data.get(selected));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
if(guiCustomScroll.id == 0)
|
||||
{
|
||||
selected = scrollAnimations.getSelected();
|
||||
PacketClient.sendClient(new AnimationGetPacket(data.get(selected)));
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if(selected != null && data.containsKey(selected) && animation != null){
|
||||
Client.sendData(EnumPacketServer.AnimationSave, animation.writeToNBT());
|
||||
}
|
||||
}
|
||||
public void save() {
|
||||
if(selected != null && data.containsKey(selected) && animation != null){
|
||||
PacketClient.sendClient(new AnimationSavePacket(animation.writeToNBT()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unFocused(GuiNpcTextField guiNpcTextField) {
|
||||
@@ -268,7 +273,7 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol
|
||||
return;
|
||||
if(id == 1) {
|
||||
if(data.containsKey(scrollAnimations.getSelected())) {
|
||||
Client.sendData(EnumPacketServer.AnimationRemove, data.get(selected));
|
||||
PacketClient.sendClient(new AnimationRemovePacket(data.get(selected)));
|
||||
scrollAnimations.clear();
|
||||
animation = new Animation();
|
||||
initGui();
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.bank.BankGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.bank.BankRemovePacket;
|
||||
import kamkeel.npcs.network.packets.request.bank.BankSavePacket;
|
||||
import kamkeel.npcs.network.packets.request.bank.BanksGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.CustomNpcResourceListener;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.containers.ContainerManageBanks;
|
||||
import noppes.npcs.controllers.data.Bank;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
@@ -23,13 +28,13 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
|
||||
private Bank bank = new Bank();
|
||||
private String selected = null;
|
||||
private String search = "";
|
||||
|
||||
|
||||
public GuiNPCManageBanks(EntityNPCInterface npc,ContainerManageBanks container)
|
||||
{
|
||||
super(npc,container);
|
||||
this.container = container;
|
||||
drawDefaultBackground = false;
|
||||
Client.sendData(EnumPacketServer.BanksGet);
|
||||
PacketClient.sendClient(new BanksGetPacket());
|
||||
setBackground("npcbanksetup.png");
|
||||
ySize = 200;
|
||||
}
|
||||
@@ -37,7 +42,7 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
|
||||
this.addButton(new GuiNpcButton(6,guiLeft + 340, guiTop + 10, 45, 20, "gui.add"));
|
||||
this.addButton(new GuiNpcButton(7,guiLeft + 340, guiTop + 32, 45, 20, "gui.remove"));
|
||||
if(scroll == null)
|
||||
@@ -46,21 +51,21 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
|
||||
scroll.guiLeft = guiLeft + 174;
|
||||
scroll.guiTop = guiTop + 8;
|
||||
addScroll(scroll);
|
||||
|
||||
|
||||
for(int i = 0; i < 6; i++){
|
||||
int x = guiLeft + 6;
|
||||
int y = (guiTop + 36) + (i * 22);
|
||||
addButton(new GuiNpcButton(i, x + 50, y,80, 20, new String[]{"Can Upgrade","Can't Upgrade","Upgraded"},0));
|
||||
getButton(i).setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
addTextField(new GuiNpcTextField(0,this, this.fontRendererObj, guiLeft+8, guiTop + 8, 160, 16, ""));
|
||||
getTextField(0).setMaxStringLength(20);
|
||||
|
||||
|
||||
addTextField(new GuiNpcTextField(1,this, this.fontRendererObj, guiLeft+10, guiTop + 80, 16, 16, ""));
|
||||
getTextField(1).integersOnly = true;
|
||||
getTextField(1).setMaxStringLength(1);
|
||||
|
||||
|
||||
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+10, guiTop + 110, 16, 16, ""));
|
||||
getTextField(2).integersOnly = true;
|
||||
getTextField(2).setMaxStringLength(1);
|
||||
@@ -85,15 +90,15 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
|
||||
name += "_";
|
||||
Bank bank = new Bank();
|
||||
bank.name = name;
|
||||
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
bank.writeEntityToNBT(compound);
|
||||
Client.sendData(EnumPacketServer.BankSave, compound);
|
||||
PacketClient.sendClient(new BankSavePacket(compound));
|
||||
}
|
||||
else if(button.id == 7)
|
||||
{
|
||||
if(data.containsKey(scroll.getSelected()))
|
||||
Client.sendData(EnumPacketServer.BankRemove, data.get(selected));
|
||||
PacketClient.sendClient(new BankRemovePacket(data.get(selected)));
|
||||
}
|
||||
else if(button.id >= 0 && button.id < 6)
|
||||
{
|
||||
@@ -103,7 +108,7 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
{
|
||||
fontRendererObj.drawString("Tab Cost", 23, 28, CustomNpcResourceListener.DefaultTextColor);
|
||||
fontRendererObj.drawString("Upg. Cost", 123, 28, CustomNpcResourceListener.DefaultTextColor);
|
||||
fontRendererObj.drawString("Start", 6, 70, CustomNpcResourceListener.DefaultTextColor);
|
||||
@@ -115,28 +120,28 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
|
||||
Bank bank = new Bank();
|
||||
bank.readEntityFromNBT(compound);
|
||||
this.bank = bank;
|
||||
|
||||
|
||||
if (bank.id == -1) {
|
||||
getTextField(0).setText("");
|
||||
getTextField(1).setText("");
|
||||
getTextField(2).setText("");
|
||||
|
||||
getTextField(2).setText("");
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
getButton(i).setDisplay(0);
|
||||
getButton(i).setDisplay(0);
|
||||
getButton(i).setEnabled(false);
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
getTextField(0).setText(bank.name);
|
||||
getTextField(1).setText(Integer.toString(bank.startSlots));
|
||||
getTextField(2).setText(Integer.toString(bank.maxSlots));
|
||||
|
||||
getTextField(2).setText(Integer.toString(bank.maxSlots));
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
int type = 0;
|
||||
if(bank.slotTypes.containsKey(i))
|
||||
type = bank.slotTypes.get(i);
|
||||
getButton(i).setDisplay(type);
|
||||
getButton(i).setDisplay(type);
|
||||
getButton(i).setEnabled(true);
|
||||
}
|
||||
}
|
||||
@@ -173,27 +178,27 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
|
||||
String name = scroll.getSelected();
|
||||
this.data = data;
|
||||
scroll.setList(getSearchList());
|
||||
|
||||
|
||||
if(name != null)
|
||||
scroll.setSelected(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSelected(String selected) {
|
||||
this.selected = selected;
|
||||
scroll.setSelected(selected);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
if(guiCustomScroll.id == 0)
|
||||
{
|
||||
save();
|
||||
selected = scroll.getSelected();
|
||||
Client.sendData(EnumPacketServer.BankGet, data.get(selected));
|
||||
PacketClient.sendClient(new BankGetPacket(data.get(selected)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
if(selected != null && data.containsKey(selected) && bank != null){
|
||||
@@ -201,7 +206,7 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
|
||||
bank.currencyInventory = container.bank.currencyInventory;
|
||||
bank.upgradeInventory = container.bank.upgradeInventory;
|
||||
bank.writeEntityToNBT(compound);
|
||||
Client.sendData(EnumPacketServer.BankSave, compound);
|
||||
PacketClient.sendClient(new BankSavePacket(compound));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,27 +225,27 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
|
||||
}
|
||||
} else if(guiNpcTextField.id == 1 || guiNpcTextField.id == 2) {
|
||||
int num = 1;
|
||||
|
||||
|
||||
if(!guiNpcTextField.isEmpty())
|
||||
num = guiNpcTextField.getInteger();
|
||||
|
||||
|
||||
if(num > 6)
|
||||
num = 6;
|
||||
|
||||
|
||||
if(num < 0)
|
||||
num = 0;
|
||||
|
||||
|
||||
if(guiNpcTextField.id == 1) {
|
||||
bank.startSlots = num;
|
||||
} else if(guiNpcTextField.id == 2) {
|
||||
bank.maxSlots = num;
|
||||
}
|
||||
|
||||
|
||||
if(bank.startSlots > bank.maxSlots)
|
||||
bank.maxSlots = bank.startSlots;
|
||||
|
||||
|
||||
guiNpcTextField.setText(Integer.toString(num));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.dialog.*;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.SubGuiEditText;
|
||||
import noppes.npcs.client.gui.SubGuiNpcDialog;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
import noppes.npcs.controllers.data.DialogCategory;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
@@ -38,42 +40,61 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
private String catSearch = "";
|
||||
private String diagSearch = "";
|
||||
|
||||
private boolean isResizing = false;
|
||||
private int initialDragX = 0;
|
||||
private int dividerOffset = 143;
|
||||
|
||||
private final int dividerWidth = 5;
|
||||
private final int minScrollWidth = 50;
|
||||
|
||||
private int dividerLineHeight = 20;
|
||||
private int dividerLineYOffset = 0;
|
||||
|
||||
public GuiNPCManageDialogs(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
Client.sendData(EnumPacketServer.DialogCategoriesGet);
|
||||
PacketClient.sendClient(new DialogCategoriesGetPacket());
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
if(catScroll == null){
|
||||
catScroll = new GuiCustomScroll(this,0, 0);
|
||||
catScroll.setSize(143, 185);
|
||||
}
|
||||
catScroll.guiLeft = guiLeft + 64;
|
||||
catScroll.guiTop = guiTop + 4;
|
||||
this.addScroll(catScroll);
|
||||
// Define overall horizontal region.
|
||||
int regionLeft = guiLeft + 64;
|
||||
int regionRight = guiLeft + 355;
|
||||
|
||||
if(dialogScroll == null){
|
||||
dialogScroll = new GuiCustomScroll(this,1, 0);
|
||||
dialogScroll.setSize(143, 185);
|
||||
}
|
||||
dialogScroll.guiLeft = guiLeft + 212;
|
||||
dialogScroll.guiTop = guiTop + 4;
|
||||
this.addScroll(dialogScroll);
|
||||
// Recalculate dividerX using the stored offset:
|
||||
int dividerX = regionLeft + dividerOffset;
|
||||
|
||||
addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 64, guiTop + 4 + 3 + 185, 143, 20, catSearch));
|
||||
// Left scroll (catScroll)
|
||||
if (catScroll == null) {
|
||||
catScroll = new GuiCustomScroll(this, 0, 0);
|
||||
}
|
||||
catScroll.guiLeft = regionLeft;
|
||||
catScroll.guiTop = guiTop + 4;
|
||||
catScroll.setSize(dividerX - regionLeft, 185);
|
||||
this.addScroll(catScroll);
|
||||
|
||||
this.addButton(new GuiNpcButton(44,guiLeft + 3, guiTop + 8, 58, 20, "gui.categories"));
|
||||
// Right scroll (dialogScroll)
|
||||
if (dialogScroll == null) {
|
||||
dialogScroll = new GuiCustomScroll(this, 1, 0);
|
||||
}
|
||||
dialogScroll.guiLeft = dividerX + dividerWidth;
|
||||
dialogScroll.guiTop = guiTop + 4;
|
||||
dialogScroll.setSize(regionRight - (dividerX + dividerWidth), 185);
|
||||
this.addScroll(dialogScroll);
|
||||
|
||||
// Adjust text fields:
|
||||
addTextField(new GuiNpcTextField(55, this, fontRendererObj, regionLeft, guiTop + 4 + 3 + 185, dividerX - regionLeft, 20, catSearch));
|
||||
addTextField(new GuiNpcTextField(66, this, fontRendererObj, dividerX + dividerWidth, guiTop + 4 + 3 + 185, regionRight - (dividerX + dividerWidth), 20, diagSearch));
|
||||
|
||||
this.addButton(new GuiNpcButton(44,guiLeft + 3, guiTop + 8, 58, 20, "gui.categories"));
|
||||
getButton(44).setEnabled(false);
|
||||
this.addButton(new GuiNpcButton(4,guiLeft + 3, guiTop + 38, 58, 20, "gui.add"));
|
||||
this.addButton(new GuiNpcButton(5,guiLeft + 3, guiTop + 61, 58, 20, "gui.remove"));
|
||||
this.addButton(new GuiNpcButton(6,guiLeft + 3, guiTop + 94, 58, 20, "gui.edit"));
|
||||
|
||||
addTextField(new GuiNpcTextField(66, this, fontRendererObj, guiLeft + 212, guiTop + 4 + 3 + 185, 143, 20, diagSearch));
|
||||
|
||||
this.addButton(new GuiNpcButton(33,guiLeft + 358, guiTop + 8, 58, 20, "dialog.dialogs"));
|
||||
getButton(33).setEnabled(false);
|
||||
this.addButton(new GuiNpcButton(0,guiLeft + 358, guiTop + 94, 58, 20, "gui.edit"));
|
||||
@@ -91,6 +112,86 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
if(!hasSubGui()){
|
||||
int regionLeft = guiLeft + 64;
|
||||
int dividerX = regionLeft + dividerOffset; // dividerOffset remains your left-scroll width
|
||||
int regionTop = guiTop + 4;
|
||||
int regionHeight = 185;
|
||||
// Calculate the vertical position for the handle (centered by default)
|
||||
int handleTop = regionTop + (regionHeight - dividerLineHeight) / 2 + dividerLineYOffset;
|
||||
drawRect(dividerX + 1, handleTop, dividerX + dividerWidth - 1, handleTop + dividerLineHeight, 0xFF707070);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
if(!hasSubGui()){
|
||||
int regionLeft = guiLeft + 64;
|
||||
int dividerX = regionLeft + dividerOffset;
|
||||
int regionTop = guiTop + 4;
|
||||
int regionHeight = 185;
|
||||
int handleTop = regionTop + (regionHeight - dividerLineHeight) / 2 + dividerLineYOffset;
|
||||
int handleBottom = handleTop + dividerLineHeight;
|
||||
if (mouseX >= dividerX && mouseX <= dividerX + dividerWidth &&
|
||||
mouseY >= handleTop && mouseY <= handleBottom) {
|
||||
isResizing = true;
|
||||
resizingActive = true;
|
||||
initialDragX = mouseX;
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
|
||||
if (isResizing) {
|
||||
int dx = mouseX - initialDragX;
|
||||
initialDragX = mouseX;
|
||||
dividerOffset += dx;
|
||||
int regionLeft = guiLeft + 64;
|
||||
int regionRight = guiLeft + 355;
|
||||
// Clamp dividerOffset so each scroll remains at least minScrollWidth:
|
||||
int minOffset = minScrollWidth;
|
||||
int maxOffset = (regionRight - regionLeft) - dividerWidth - minScrollWidth;
|
||||
if (dividerOffset < minOffset) {
|
||||
dividerOffset = minOffset;
|
||||
}
|
||||
if (dividerOffset > maxOffset) {
|
||||
dividerOffset = maxOffset;
|
||||
}
|
||||
int dividerX = regionLeft + dividerOffset;
|
||||
// Update left scroll:
|
||||
catScroll.setSize(dividerX - regionLeft, 185);
|
||||
// Update right scroll:
|
||||
dialogScroll.guiLeft = dividerX + dividerWidth;
|
||||
dialogScroll.setSize(regionRight - (dividerX + dividerWidth), 185);
|
||||
// Update text fields:
|
||||
if (getTextField(55) != null) {
|
||||
getTextField(55).width = dividerX - regionLeft;
|
||||
}
|
||||
if (getTextField(66) != null) {
|
||||
getTextField(66).width = regionRight - (dividerX + dividerWidth);
|
||||
getTextField(66).xPosition = dividerX + dividerWidth;
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseMovedOrUp(int mouseX, int mouseY, int state) {
|
||||
if (isResizing) {
|
||||
isResizing = false;
|
||||
resizingActive = false;
|
||||
return;
|
||||
}
|
||||
super.mouseMovedOrUp(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int i)
|
||||
{
|
||||
@@ -181,7 +282,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
}
|
||||
DialogCategory category = new DialogCategory();
|
||||
category.title = name;
|
||||
Client.sendData(EnumPacketServer.DialogCategorySave, category.writeNBT(new NBTTagCompound()));
|
||||
PacketClient.sendClient(new DialogCategorySavePacket(category.writeNBT(new NBTTagCompound())));
|
||||
}
|
||||
// Remove Cat
|
||||
if(id == 5){
|
||||
@@ -202,7 +303,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
}
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.title = name;
|
||||
Client.sendData(EnumPacketServer.DialogSave, category.id, dialog.writeToNBT(new NBTTagCompound()), true);
|
||||
PacketClient.sendClient(new DialogSavePacket(category.id, dialog.writeToNBT(new NBTTagCompound()), true));
|
||||
}
|
||||
// Remove Dialog
|
||||
if(id == 2) {
|
||||
@@ -231,7 +332,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.readNBTPartial(this.dialog.writeToNBT(new NBTTagCompound()));
|
||||
dialog.title = name;
|
||||
Client.sendData(EnumPacketServer.DialogSave, category.id, dialog.writeToNBT(new NBTTagCompound()), true);
|
||||
PacketClient.sendClient(new DialogSavePacket(category.id, dialog.writeToNBT(new NBTTagCompound()), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,7 +377,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
else {
|
||||
category.readNBT(compound);
|
||||
setPrevCatName(category.title);
|
||||
Client.sendData(EnumPacketServer.DialogsGet, category.id, true);
|
||||
PacketClient.sendClient(new DialogsGetPacket(category.id, true));
|
||||
resetDiagList();
|
||||
}
|
||||
initGui();
|
||||
@@ -341,7 +442,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
dialog = null;
|
||||
getTextField(66).setText("");
|
||||
|
||||
Client.sendData(EnumPacketServer.DialogCategoryGet, catData.get(selected));
|
||||
PacketClient.sendClient(new DialogCategoryGetPacket(catData.get(selected)));
|
||||
setPrevCatName(selected);
|
||||
}
|
||||
}
|
||||
@@ -352,7 +453,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
String selected = dialogScroll.getSelected();
|
||||
if(!selected.equals(prevDialogName) || override){
|
||||
dialog = new Dialog();
|
||||
Client.sendData(EnumPacketServer.DialogGet, dialogData.get(selected));
|
||||
DialogGetPacket.getDialog(dialogData.get(selected));
|
||||
setPrevDialogName(selected);
|
||||
}
|
||||
}
|
||||
@@ -371,13 +472,13 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
if(saveDiag){
|
||||
if(dialogScroll.selected != -1 && dialog.id >= 0){
|
||||
if(catScroll.selected != -1 && category.id >= 0){
|
||||
Client.sendData(EnumPacketServer.DialogSave, category.id, dialog.writeToNBT(new NBTTagCompound()), true);
|
||||
PacketClient.sendClient(new DialogSavePacket(category.id, dialog.writeToNBT(new NBTTagCompound()), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(catScroll.selected != -1 && category.id >= 0)
|
||||
Client.sendData(EnumPacketServer.DialogCategorySave, category.writeNBT(new NBTTagCompound()));
|
||||
PacketClient.sendClient(new DialogCategorySavePacket(category.writeNBT(new NBTTagCompound())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,13 +527,13 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
return;
|
||||
if(id == 5) {
|
||||
if(catData.containsKey(catScroll.getSelected())) {
|
||||
Client.sendData(EnumPacketServer.DialogCategoryRemove, category.id);
|
||||
PacketClient.sendClient(new DialogCategoryRemovePacket(category.id));
|
||||
clearCategory();
|
||||
}
|
||||
}
|
||||
if(id == 2) {
|
||||
if (dialogData.containsKey(dialogScroll.getSelected())) {
|
||||
Client.sendData(EnumPacketServer.DialogRemove, dialog.id, true);
|
||||
PacketClient.sendClient(new DialogRemovePacket(dialog.id, true));
|
||||
dialog = new Dialog();
|
||||
dialogData.clear();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,302 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.effects.EffectGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.effects.EffectRemovePacket;
|
||||
import kamkeel.npcs.network.packets.request.effects.EffectSavePacket;
|
||||
import kamkeel.npcs.network.packets.request.effects.EffectsGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.CustomNpcResourceListener;
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.SubGuiEffectGeneral;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.client.renderer.ImageData;
|
||||
import noppes.npcs.controllers.CustomEffectController;
|
||||
import noppes.npcs.controllers.data.CustomEffect;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
public class GuiNPCManageEffects extends GuiNPCInterface2 implements ICustomScrollListener, IScrollData, IGuiData, ISubGuiListener, GuiYesNoCallback {
|
||||
public GuiCustomScroll scrollEffects;
|
||||
public HashMap<String, Integer> data = new HashMap<>();
|
||||
public CustomEffect effect = new CustomEffect();
|
||||
public String selected = null;
|
||||
public String search = "";
|
||||
public String originalName = "";
|
||||
boolean setNormalSound = true;
|
||||
|
||||
public GuiNPCManageEffects(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
|
||||
PacketClient.sendClient(new EffectsGetPacket(-1));
|
||||
}
|
||||
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
addButton(new GuiNpcButton(0, guiLeft + 368, guiTop + 8, 45, 20, "gui.add"));
|
||||
|
||||
addButton(new GuiNpcButton(1, guiLeft + 368, guiTop + 32, 45, 20, "gui.remove"));
|
||||
getButton(1).enabled = effect != null && effect.id != -1;
|
||||
|
||||
addButton(new GuiNpcButton(2, guiLeft + 368, guiTop + 56, 45, 20, "gui.clone"));
|
||||
getButton(2).enabled = effect != null && effect.id != -1;
|
||||
|
||||
addButton(new GuiNpcButton(3, guiLeft + 368, guiTop + 80, 45, 20, "gui.edit"));
|
||||
getButton(3).enabled = effect != null && effect.id != -1;
|
||||
|
||||
if (scrollEffects == null) {
|
||||
scrollEffects = new GuiCustomScroll(this, 0, 0);
|
||||
scrollEffects.setSize(143, 185);
|
||||
}
|
||||
scrollEffects.guiLeft = guiLeft + 220;
|
||||
scrollEffects.guiTop = guiTop + 4;
|
||||
addScroll(scrollEffects);
|
||||
scrollEffects.setList(getSearchList());
|
||||
|
||||
addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 220, guiTop + 4 + 3 + 185, 143, 20, search));
|
||||
if (effect != null && effect.id != -1) {
|
||||
addLabel(new GuiNpcLabel(10, "ID", guiLeft + 368, guiTop + 4 + 3 + 185));
|
||||
addLabel(new GuiNpcLabel(11, effect.id + "", guiLeft + 368, guiTop + 4 + 3 + 195));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
if (button.id == 0) {
|
||||
save();
|
||||
String name = "New";
|
||||
while (data.containsKey(name))
|
||||
name += "_";
|
||||
CustomEffect effect = new CustomEffect(-1, name);
|
||||
PacketClient.sendClient(new EffectSavePacket(effect.writeToNBT(false), ""));
|
||||
} else if (button.id == 1) {
|
||||
if (data.containsKey(scrollEffects.getSelected())) {
|
||||
GuiYesNo guiyesno = new GuiYesNo(this, scrollEffects.getSelected(), StatCollector.translateToLocal("gui.delete"), 1);
|
||||
displayGuiScreen(guiyesno);
|
||||
}
|
||||
} else if (button.id == 2) {
|
||||
CustomEffect effect = this.effect.cloneEffect();
|
||||
while (data.containsKey(effect.name))
|
||||
effect.name += "_";
|
||||
PacketClient.sendClient(new EffectSavePacket(effect.writeToNBT(false), ""));
|
||||
}
|
||||
|
||||
if (effect == null)
|
||||
return;
|
||||
|
||||
if (button.id == 3) {
|
||||
if (data.containsKey(scrollEffects.getSelected()) && effect != null && effect.id >= 0) {
|
||||
setSubGui(new SubGuiEffectGeneral(this, effect));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
this.effect = new CustomEffect();
|
||||
effect.readFromNBT(compound);
|
||||
setSelected(effect.name);
|
||||
if (effect.id != -1) {
|
||||
CustomEffectController.getInstance().customEffects.replace(effect.id, effect);
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void drawScreen(int i, int j, float f) {
|
||||
super.drawScreen(i, j, f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground() {
|
||||
super.drawBackground();
|
||||
renderScreen();
|
||||
}
|
||||
|
||||
private void renderScreen() {
|
||||
drawGradientRect(guiLeft + 5, guiTop + 4, guiLeft + 218, guiTop + 24, 0xC0101010, 0xC0101010);
|
||||
drawHorizontalLine(guiLeft + 5, guiLeft + 218, guiTop + 25, 0xFF000000 + CustomNpcResourceListener.DefaultTextColor);
|
||||
drawGradientRect(guiLeft + 5, guiTop + 27, guiLeft + 218, guiTop + ySize + 9, 0xA0101010, 0xA0101010);
|
||||
|
||||
|
||||
if (effect == null)
|
||||
return;
|
||||
if (effect.id == -1)
|
||||
return;
|
||||
|
||||
String drawString = effect.getMenuName();
|
||||
int textWidth = getStringWidthWithoutColor(drawString);
|
||||
int centerX = guiLeft + 5 + ((218 - 10 - textWidth) / 2); // Adjusted centerX calculation
|
||||
fontRendererObj.drawString(drawString, centerX, guiTop + 10, CustomNpcResourceListener.DefaultTextColor, true);
|
||||
int y = guiTop + 33;
|
||||
int x = guiLeft + 12;
|
||||
|
||||
int iconRenderSize = 48;
|
||||
|
||||
TextureManager textureManager = mc.getTextureManager();
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
ImageData data = ClientCacheHandler.getImageData(effect.icon);
|
||||
if (data.imageLoaded()) {
|
||||
data.bindTexture();
|
||||
int iconX = effect.iconX;
|
||||
int iconY = effect.iconY;
|
||||
int iconWidth = effect.getWidth();
|
||||
int iconHeight = effect.getHeight();
|
||||
int width = data.getTotalWidth();
|
||||
int height = data.getTotalWidth();
|
||||
|
||||
|
||||
func_152125_a(x, y, iconX, iconY, iconWidth, iconHeight, iconRenderSize, iconRenderSize, width, height);
|
||||
|
||||
} else {
|
||||
textureManager.bindTexture(new ResourceLocation("customnpcs", "textures/marks/question.png"));
|
||||
func_152125_a(x, y, 0, 0, 1, 1, iconRenderSize, iconRenderSize, 1, 1);
|
||||
}
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
// TODO: Fix ICONS
|
||||
// textureManager.bindTexture(new ResourceLocation(CustomNpcPlusDBC.ID + ":textures/gui/icons.png"));
|
||||
func_152125_a(x, y, 0, 240, 16, 16, iconRenderSize, iconRenderSize, 256, 256);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
x += iconRenderSize + 3;
|
||||
y += 2;
|
||||
|
||||
String translated = StatCollector.translateToLocal("gui.name") + ": " + effect.name;
|
||||
fontRendererObj.drawString(translated, x, y, 0xFFFFFF, false);
|
||||
int transLength = getStringWidthWithoutColor(translated);
|
||||
fontRendererObj.drawString(" (ID: "+ effect.id+ ")", x + transLength, y, 0xB5B5B5, false);
|
||||
y += 12;
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("general.menuName") + ": " + effect.menuName, x, y, 0xFFFFFF, false);
|
||||
y += 12;
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("effect.runsEveryX") + ": " + effect.everyXTick + "t", x, y, 0xB5B5B5, false);
|
||||
y += 12;
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("effect.defaultLength") + ": " + effect.length + "s", x, y, 0xB5B5B5, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int i) {
|
||||
super.keyTyped(c, i);
|
||||
|
||||
if (getTextField(55) != null) {
|
||||
if (getTextField(55).isFocused()) {
|
||||
if (search.equals(getTextField(55).getText()))
|
||||
return;
|
||||
search = getTextField(55).getText().toLowerCase();
|
||||
scrollEffects.resetScroll();
|
||||
scrollEffects.setList(getSearchList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getSearchList() {
|
||||
if (search.isEmpty()) {
|
||||
return new ArrayList<String>(this.data.keySet());
|
||||
}
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (String name : this.data.keySet()) {
|
||||
if (name.toLowerCase().contains(search))
|
||||
list.add(name);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(Vector<String> list, HashMap<String, Integer> data) {
|
||||
String name = scrollEffects.getSelected();
|
||||
this.data = data;
|
||||
scrollEffects.setList(getSearchList());
|
||||
|
||||
if (name != null)
|
||||
scrollEffects.setSelected(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelected(String selected) {
|
||||
this.selected = selected;
|
||||
scrollEffects.setSelected(selected);
|
||||
originalName = scrollEffects.getSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
if (guiCustomScroll.id == 0) {
|
||||
save();
|
||||
effect = null;
|
||||
selected = scrollEffects.getSelected();
|
||||
originalName = scrollEffects.getSelected();
|
||||
if (selected != null && !selected.isEmpty()) {
|
||||
PacketClient.sendClient(new EffectGetPacket(data.get(selected)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) {
|
||||
// ICustomScrollListener.super.customScrollDoubleClicked(selection, scroll);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
if (this.selected != null && this.data.containsKey(this.selected) && this.effect != null) {
|
||||
PacketClient.sendClient(new EffectSavePacket(effect.writeToNBT(false), originalName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirmClicked(boolean result, int id) {
|
||||
NoppesUtil.openGUI(player, this);
|
||||
if (!result)
|
||||
return;
|
||||
if (id == 1) {
|
||||
if (data.containsKey(scrollEffects.getSelected())) {
|
||||
PacketClient.sendClient(new EffectRemovePacket(data.get(scrollEffects.getSelected())));
|
||||
scrollEffects.clear();
|
||||
effect = new CustomEffect();
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getStringWidthWithoutColor(String text) {
|
||||
int width = 0;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
char c = text.charAt(i);
|
||||
|
||||
if (c == '§') {
|
||||
if (i < text.length() - 1) {
|
||||
i += 1;
|
||||
}
|
||||
} else {
|
||||
// If not a color code, calculate the width
|
||||
width += fontRendererObj.getCharWidth(c);
|
||||
}
|
||||
}
|
||||
return width;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,21 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.faction.FactionGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.faction.FactionRemovePacket;
|
||||
import kamkeel.npcs.network.packets.request.faction.FactionSavePacket;
|
||||
import kamkeel.npcs.network.packets.request.faction.FactionsGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.SubGuiColorSelector;
|
||||
import noppes.npcs.client.gui.SubGuiNpcFactionPoints;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.Faction;
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
@@ -28,7 +33,7 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat
|
||||
public GuiNPCManageFactions(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
Client.sendData(EnumPacketServer.FactionsGet);
|
||||
PacketClient.sendClient(new FactionsGetPacket());
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
@@ -106,7 +111,7 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
faction.writeNBT(compound);
|
||||
Client.sendData(EnumPacketServer.FactionSave, compound);
|
||||
PacketClient.sendClient(new FactionSavePacket(compound));
|
||||
}
|
||||
if(button.id == 1){
|
||||
if(data.containsKey(scrollFactions.getSelected())) {
|
||||
@@ -186,7 +191,7 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat
|
||||
{
|
||||
save();
|
||||
selected = scrollFactions.getSelected();
|
||||
Client.sendData(EnumPacketServer.FactionGet, data.get(selected));
|
||||
FactionGetPacket.getFaction(data.get(selected));
|
||||
}
|
||||
else if(guiCustomScroll.id == 1)
|
||||
{
|
||||
@@ -205,7 +210,7 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
faction.writeNBT(compound);
|
||||
|
||||
Client.sendData(EnumPacketServer.FactionSave, compound);
|
||||
PacketClient.sendClient(new FactionSavePacket(compound));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +258,7 @@ public class GuiNPCManageFactions extends GuiNPCInterface2 implements IScrollDat
|
||||
return;
|
||||
if(id == 1) {
|
||||
if(data.containsKey(scrollFactions.getSelected())) {
|
||||
Client.sendData(EnumPacketServer.FactionRemove, data.get(selected));
|
||||
PacketClient.sendClient(new FactionRemovePacket(data.get(selected)));
|
||||
scrollFactions.clear();
|
||||
faction = new Faction();
|
||||
initGui();
|
||||
|
||||
+11
-7
@@ -1,11 +1,15 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedAddPacket;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedGetAllPacket;
|
||||
import kamkeel.npcs.network.packets.request.linked.LinkedRemovePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.SubGuiEditText;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -13,17 +17,17 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
public class GuiNPCManageLinkedNpc extends GuiNPCInterface2 implements IScrollData, ISubGuiListener{
|
||||
public class GuiNPCManageLinked extends GuiNPCInterface2 implements IScrollData, ISubGuiListener{
|
||||
private GuiCustomScroll scroll;
|
||||
private List<String> data = new ArrayList<String>();
|
||||
private String search = "";
|
||||
|
||||
public static GuiScreen Instance;
|
||||
|
||||
public GuiNPCManageLinkedNpc(EntityNPCInterface npc){
|
||||
public GuiNPCManageLinked(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
Instance = this;
|
||||
Client.sendData(EnumPacketServer.LinkedGetAll);
|
||||
PacketClient.sendClient(new LinkedGetAllPacket());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,7 +83,7 @@ public class GuiNPCManageLinkedNpc extends GuiNPCInterface2 implements IScrollDa
|
||||
}
|
||||
if(button.id == 2){
|
||||
if(scroll.hasSelected())
|
||||
Client.sendData(EnumPacketServer.LinkedRemove, scroll.getSelected());
|
||||
PacketClient.sendClient(new LinkedRemovePacket(scroll.getSelected()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -87,7 +91,7 @@ public class GuiNPCManageLinkedNpc extends GuiNPCInterface2 implements IScrollDa
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
if(!((SubGuiEditText)subgui).cancelled){
|
||||
Client.sendData(EnumPacketServer.LinkedAdd, ((SubGuiEditText)subgui).text);
|
||||
PacketClient.sendClient(new LinkedAddPacket(((SubGuiEditText)subgui).text));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import noppes.npcs.client.gui.GuiMagicMap;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface2;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class GuiNPCManageMagic extends GuiNPCInterface2 {
|
||||
|
||||
private GuiMagicMap magicMap;
|
||||
|
||||
public GuiNPCManageMagic(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
// Position the map in a designated area (e.g., right panel)
|
||||
int mapX = guiLeft + xSize - 230 + 10;
|
||||
int mapY = guiTop + 10;
|
||||
int mapWidth = 210;
|
||||
int mapHeight = 200;
|
||||
|
||||
magicMap = new GuiMagicMap(this, mapX, mapY, mapWidth, mapHeight);
|
||||
addDiagram(0, magicMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
|
||||
if (magicMap != null) {
|
||||
magicMap.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
|
||||
}
|
||||
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseMovedOrUp(int mouseX, int mouseY, int state) {
|
||||
if (magicMap != null) {
|
||||
magicMap.mouseReleased(mouseX, mouseY, state);
|
||||
}
|
||||
super.mouseMovedOrUp(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(net.minecraft.client.gui.GuiButton button) {
|
||||
// your existing action handling
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// your save logic
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,19 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.quest.*;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.SubGuiEditText;
|
||||
import noppes.npcs.client.gui.SubGuiNpcQuest;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
import noppes.npcs.controllers.data.QuestCategory;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
@@ -22,421 +23,492 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup, IScrollData, ISubGuiListener, ICustomScrollListener, IGuiData, GuiYesNoCallback
|
||||
{
|
||||
private GuiCustomScroll catScroll;
|
||||
public GuiCustomScroll questScroll;
|
||||
public class GuiNPCManageQuest extends GuiNPCInterface2 implements IScrollGroup, IScrollData, ISubGuiListener, ICustomScrollListener, IGuiData, GuiYesNoCallback {
|
||||
|
||||
private String prevCatName = "";
|
||||
private String prevQuestName = "";
|
||||
private GuiCustomScroll catScroll;
|
||||
public GuiCustomScroll questScroll;
|
||||
|
||||
public QuestCategory category = new QuestCategory();
|
||||
public static Quest quest = new Quest();
|
||||
public String nextQuestName = "";
|
||||
private String prevCatName = "";
|
||||
private String prevQuestName = "";
|
||||
|
||||
private HashMap<String,Integer> catData = new HashMap<String,Integer>();
|
||||
public HashMap<String,Integer> questData = new HashMap<String,Integer>();
|
||||
public QuestCategory category = new QuestCategory();
|
||||
public static Quest quest = new Quest();
|
||||
public String nextQuestName = "";
|
||||
|
||||
private String catSearch = "";
|
||||
private String questSearch = "";
|
||||
private HashMap<String, Integer> catData = new HashMap<String, Integer>();
|
||||
public HashMap<String, Integer> questData = new HashMap<String, Integer>();
|
||||
|
||||
public static GuiScreen Instance;
|
||||
private String catSearch = "";
|
||||
private String questSearch = "";
|
||||
|
||||
public GuiNPCManageQuest(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
Instance = this;
|
||||
quest = new Quest();
|
||||
Client.sendData(EnumPacketServer.QuestCategoriesGet);
|
||||
}
|
||||
public static GuiScreen Instance;
|
||||
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
// Divider variables
|
||||
private boolean isResizing = false;
|
||||
private int initialDragX = 0;
|
||||
private int dividerOffset = 143;
|
||||
private final int dividerWidth = 5;
|
||||
private final int minScrollWidth = 50;
|
||||
private int dividerLineHeight = 20;
|
||||
private int dividerLineYOffset = 0;
|
||||
|
||||
if(questScroll == null){
|
||||
questScroll = new GuiCustomScroll(this,1, 0);
|
||||
questScroll.setSize(143, 185);
|
||||
}
|
||||
questScroll.guiLeft = guiLeft + 212;
|
||||
questScroll.guiTop = guiTop + 4;
|
||||
this.addScroll(questScroll);
|
||||
public GuiNPCManageQuest(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
Instance = this;
|
||||
quest = new Quest();
|
||||
PacketClient.sendClient(new QuestCategoriesGetPacket());
|
||||
}
|
||||
|
||||
if(catScroll == null){
|
||||
catScroll = new GuiCustomScroll(this,0, 0);
|
||||
catScroll.setSize(143, 185);
|
||||
}
|
||||
catScroll.guiLeft = guiLeft + 64;
|
||||
catScroll.guiTop = guiTop + 4;
|
||||
this.addScroll(catScroll);
|
||||
addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 64, guiTop + 4 + 3 + 185, 143, 20, catSearch));
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
this.addButton(new GuiNpcButton(44,guiLeft + 3, guiTop + 8, 58, 20, "gui.categories"));
|
||||
getButton(44).setEnabled(false);
|
||||
this.addButton(new GuiNpcButton(4,guiLeft + 3, guiTop + 38, 58, 20, "gui.add"));
|
||||
this.addButton(new GuiNpcButton(5,guiLeft + 3, guiTop + 61, 58, 20, "gui.remove"));
|
||||
this.addButton(new GuiNpcButton(6,guiLeft + 3, guiTop + 94, 58, 20, "gui.edit"));
|
||||
// Define overall horizontal region.
|
||||
int regionLeft = guiLeft + 64;
|
||||
int regionRight = guiLeft + 355;
|
||||
int dividerX = regionLeft + dividerOffset;
|
||||
|
||||
addTextField(new GuiNpcTextField(66, this, fontRendererObj, guiLeft + 212, guiTop + 4 + 3 + 185, 143, 20, questSearch));
|
||||
// Left scroll (catScroll)
|
||||
if (catScroll == null) {
|
||||
catScroll = new GuiCustomScroll(this, 0, 0);
|
||||
}
|
||||
catScroll.guiLeft = regionLeft;
|
||||
catScroll.guiTop = guiTop + 4;
|
||||
catScroll.setSize(dividerX - regionLeft, 185);
|
||||
this.addScroll(catScroll);
|
||||
|
||||
this.addButton(new GuiNpcButton(33,guiLeft + 358, guiTop + 8, 58, 20, "quest.quests"));
|
||||
getButton(33).setEnabled(false);
|
||||
this.addButton(new GuiNpcButton(0,guiLeft + 358, guiTop + 94, 58, 20, "gui.edit"));
|
||||
this.addButton(new GuiNpcButton(1,guiLeft + 358, guiTop + 38, 58, 20, "gui.add"));
|
||||
this.addButton(new GuiNpcButton(2,guiLeft + 358, guiTop + 61, 58, 20, "gui.remove"));
|
||||
this.addButton(new GuiNpcButton(3,guiLeft + 358, guiTop + 117, 58, 20, "gui.copy"));
|
||||
// Right scroll (questScroll)
|
||||
if (questScroll == null) {
|
||||
questScroll = new GuiCustomScroll(this, 1, 0);
|
||||
}
|
||||
questScroll.guiLeft = dividerX + dividerWidth;
|
||||
questScroll.guiTop = guiTop + 4;
|
||||
questScroll.setSize(regionRight - (dividerX + dividerWidth), 185);
|
||||
this.addScroll(questScroll);
|
||||
|
||||
if(quest != null) {
|
||||
if(quest.id != -1){
|
||||
addLabel(new GuiNpcLabel(0, "ID", guiLeft + 358, guiTop + 4 + 3 + 185));
|
||||
addLabel(new GuiNpcLabel(1, quest.id + "", guiLeft + 358, guiTop + 4 + 3 + 195));
|
||||
}
|
||||
}
|
||||
// Adjust text fields:
|
||||
addTextField(new GuiNpcTextField(55, this, fontRendererObj, regionLeft, guiTop + 4 + 3 + 185, dividerX - regionLeft, 20, catSearch));
|
||||
addTextField(new GuiNpcTextField(66, this, fontRendererObj, dividerX + dividerWidth, guiTop + 4 + 3 + 185, regionRight - (dividerX + dividerWidth), 20, questSearch));
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
this.addButton(new GuiNpcButton(44, guiLeft + 3, guiTop + 8, 58, 20, "gui.categories"));
|
||||
getButton(44).setEnabled(false);
|
||||
this.addButton(new GuiNpcButton(4, guiLeft + 3, guiTop + 38, 58, 20, "gui.add"));
|
||||
this.addButton(new GuiNpcButton(5, guiLeft + 3, guiTop + 61, 58, 20, "gui.remove"));
|
||||
this.addButton(new GuiNpcButton(6, guiLeft + 3, guiTop + 94, 58, 20, "gui.edit"));
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int i)
|
||||
{
|
||||
super.keyTyped(c, i);
|
||||
if(getTextField(55) != null){
|
||||
if(getTextField(55).isFocused()){
|
||||
if(catSearch.equals(getTextField(55).getText()))
|
||||
return;
|
||||
catSearch = getTextField(55).getText().toLowerCase();
|
||||
this.addButton(new GuiNpcButton(33, guiLeft + 358, guiTop + 8, 58, 20, "quest.quests"));
|
||||
getButton(33).setEnabled(false);
|
||||
this.addButton(new GuiNpcButton(0, guiLeft + 358, guiTop + 94, 58, 20, "gui.edit"));
|
||||
this.addButton(new GuiNpcButton(1, guiLeft + 358, guiTop + 38, 58, 20, "gui.add"));
|
||||
this.addButton(new GuiNpcButton(2, guiLeft + 358, guiTop + 61, 58, 20, "gui.remove"));
|
||||
this.addButton(new GuiNpcButton(3, guiLeft + 358, guiTop + 117, 58, 20, "gui.copy"));
|
||||
|
||||
if (quest != null) {
|
||||
if (quest.id != -1) {
|
||||
addLabel(new GuiNpcLabel(0, "ID", guiLeft + 358, guiTop + 4 + 3 + 185));
|
||||
addLabel(new GuiNpcLabel(1, quest.id + "", guiLeft + 358, guiTop + 4 + 3 + 195));
|
||||
}
|
||||
}
|
||||
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
if (!hasSubGui()) {
|
||||
int regionLeft = guiLeft + 64;
|
||||
int dividerX = regionLeft + dividerOffset;
|
||||
int regionTop = guiTop + 4;
|
||||
int regionHeight = 185;
|
||||
int handleTop = regionTop + (regionHeight - dividerLineHeight) / 2 + dividerLineYOffset;
|
||||
drawRect(dividerX + 1, handleTop, dividerX + dividerWidth - 1, handleTop + dividerLineHeight, 0xFF707070);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
if (!hasSubGui()) {
|
||||
int regionLeft = guiLeft + 64;
|
||||
int dividerX = regionLeft + dividerOffset;
|
||||
int regionTop = guiTop + 4;
|
||||
int regionHeight = 185;
|
||||
int handleTop = regionTop + (regionHeight - dividerLineHeight) / 2 + dividerLineYOffset;
|
||||
int handleBottom = handleTop + dividerLineHeight;
|
||||
if (mouseX >= dividerX && mouseX <= dividerX + dividerWidth &&
|
||||
mouseY >= handleTop && mouseY <= handleBottom) {
|
||||
isResizing = true;
|
||||
resizingActive = true;
|
||||
initialDragX = mouseX;
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
|
||||
if (isResizing) {
|
||||
int dx = mouseX - initialDragX;
|
||||
initialDragX = mouseX;
|
||||
dividerOffset += dx;
|
||||
int regionLeft = guiLeft + 64;
|
||||
int regionRight = guiLeft + 355;
|
||||
int minOffset = minScrollWidth;
|
||||
int maxOffset = (regionRight - regionLeft) - dividerWidth - minScrollWidth;
|
||||
if (dividerOffset < minOffset) {
|
||||
dividerOffset = minOffset;
|
||||
}
|
||||
if (dividerOffset > maxOffset) {
|
||||
dividerOffset = maxOffset;
|
||||
}
|
||||
int dividerX = regionLeft + dividerOffset;
|
||||
catScroll.setSize(dividerX - regionLeft, 185);
|
||||
questScroll.guiLeft = dividerX + dividerWidth;
|
||||
questScroll.setSize(regionRight - (dividerX + dividerWidth), 185);
|
||||
if (getTextField(55) != null) {
|
||||
getTextField(55).width = dividerX - regionLeft;
|
||||
}
|
||||
if (getTextField(66) != null) {
|
||||
getTextField(66).width = regionRight - (dividerX + dividerWidth);
|
||||
getTextField(66).xPosition = dividerX + dividerWidth;
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseMovedOrUp(int mouseX, int mouseY, int state) {
|
||||
if (isResizing) {
|
||||
isResizing = false;
|
||||
resizingActive = false;
|
||||
return;
|
||||
}
|
||||
super.mouseMovedOrUp(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int i) {
|
||||
super.keyTyped(c, i);
|
||||
if (getTextField(55) != null) {
|
||||
if (getTextField(55).isFocused()) {
|
||||
if (catSearch.equals(getTextField(55).getText()))
|
||||
return;
|
||||
catSearch = getTextField(55).getText().toLowerCase();
|
||||
catScroll.resetScroll();
|
||||
catScroll.setList(getCatSearch());
|
||||
}
|
||||
}
|
||||
if(getTextField(66) != null){
|
||||
if(getTextField(66).isFocused()){
|
||||
if(questSearch.equals(getTextField(66).getText()))
|
||||
return;
|
||||
questSearch = getTextField(66).getText().toLowerCase();
|
||||
catScroll.setList(getCatSearch());
|
||||
}
|
||||
}
|
||||
if (getTextField(66) != null) {
|
||||
if (getTextField(66).isFocused()) {
|
||||
if (questSearch.equals(getTextField(66).getText()))
|
||||
return;
|
||||
questSearch = getTextField(66).getText().toLowerCase();
|
||||
questScroll.resetScroll();
|
||||
questScroll.setList(getQuestSearch());
|
||||
}
|
||||
}
|
||||
}
|
||||
questScroll.setList(getQuestSearch());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetQuestList(){
|
||||
if(questScroll != null){
|
||||
questSearch = "";
|
||||
if(getTextField(66) != null){
|
||||
getTextField(66).setText("");
|
||||
}
|
||||
questScroll.setList(getQuestSearch());
|
||||
}
|
||||
}
|
||||
public void resetQuestList() {
|
||||
if (questScroll != null) {
|
||||
questSearch = "";
|
||||
if (getTextField(66) != null) {
|
||||
getTextField(66).setText("");
|
||||
}
|
||||
questScroll.setList(getQuestSearch());
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getCatSearch(){
|
||||
if(catSearch.isEmpty()){
|
||||
return new ArrayList<String>(this.catData.keySet());
|
||||
}
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(String name : this.catData.keySet()){
|
||||
if(name.toLowerCase().contains(catSearch))
|
||||
list.add(name);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
private List<String> getCatSearch() {
|
||||
if (catSearch.isEmpty()) {
|
||||
return new ArrayList<String>(this.catData.keySet());
|
||||
}
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (String name : this.catData.keySet()) {
|
||||
if (name.toLowerCase().contains(catSearch))
|
||||
list.add(name);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<String> getQuestSearch(){
|
||||
if(category != null){
|
||||
if(category.id < 0){
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
else {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
private List<String> getQuestSearch() {
|
||||
if (category != null) {
|
||||
if (category.id < 0) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
} else {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
if (questSearch.isEmpty()) {
|
||||
return new ArrayList<String>(this.questData.keySet());
|
||||
}
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (String name : this.questData.keySet()) {
|
||||
if (name.toLowerCase().contains(questSearch))
|
||||
list.add(name);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
if(questSearch.isEmpty()){
|
||||
return new ArrayList<String>(this.questData.keySet());
|
||||
}
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(String name : this.questData.keySet()){
|
||||
if(name.toLowerCase().contains(questSearch))
|
||||
list.add(name);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void buttonEvent(GuiButton guibutton)
|
||||
{
|
||||
int id = guibutton.id;
|
||||
// Edit Cat
|
||||
if(id == 6){
|
||||
if(category != null && category.id > -1){
|
||||
setSubGui(new SubGuiEditText(category.title));
|
||||
}
|
||||
else {
|
||||
getCategory(false);
|
||||
}
|
||||
}
|
||||
// Add Cat
|
||||
if(id == 4){
|
||||
String name = "New";
|
||||
while(catData.containsKey(name))
|
||||
name += "_";
|
||||
|
||||
if(catScroll != null){
|
||||
setPrevCatName(name);
|
||||
}
|
||||
QuestCategory category = new QuestCategory();
|
||||
category.title = name;
|
||||
Client.sendData(EnumPacketServer.QuestCategorySave, category.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
// Remove Cat
|
||||
if(id == 5){
|
||||
if(catData.containsKey(catScroll.getSelected())) {
|
||||
public void buttonEvent(GuiButton guibutton) {
|
||||
int id = guibutton.id;
|
||||
// Edit Category
|
||||
if (id == 6) {
|
||||
if (category != null && category.id > -1) {
|
||||
setSubGui(new SubGuiEditText(category.title));
|
||||
} else {
|
||||
getCategory(false);
|
||||
}
|
||||
}
|
||||
// Add Category
|
||||
if (id == 4) {
|
||||
String name = "New";
|
||||
while (catData.containsKey(name))
|
||||
name += "_";
|
||||
if (catScroll != null) {
|
||||
setPrevCatName(name);
|
||||
}
|
||||
QuestCategory category = new QuestCategory();
|
||||
category.title = name;
|
||||
PacketClient.sendClient(new QuestCategorySavePacket(category.writeNBT(new NBTTagCompound())));
|
||||
}
|
||||
// Remove Category
|
||||
if (id == 5) {
|
||||
if (catData.containsKey(catScroll.getSelected())) {
|
||||
GuiYesNo guiyesno = new GuiYesNo(this, catScroll.getSelected(), StatCollector.translateToLocal("gui.delete"), 5);
|
||||
displayGuiScreen(guiyesno);
|
||||
}
|
||||
}
|
||||
if(category != null && category.id >= 0){
|
||||
// Add Quest
|
||||
if(id == 1){
|
||||
String name = "New";
|
||||
while(questData.containsKey(name))
|
||||
name += "_";
|
||||
|
||||
if(questScroll != null){
|
||||
setPrevQuestName(name);
|
||||
}
|
||||
Quest quest = new Quest();
|
||||
quest.title = name;
|
||||
Client.sendData(EnumPacketServer.QuestSave, category.id, quest.writeToNBT(new NBTTagCompound()), true);
|
||||
}
|
||||
// Remove Quest
|
||||
if(id == 2) {
|
||||
if (questData.containsKey(questScroll.getSelected())) {
|
||||
}
|
||||
}
|
||||
if (category != null && category.id >= 0) {
|
||||
// Add Quest
|
||||
if (id == 1) {
|
||||
String name = "New";
|
||||
while (questData.containsKey(name))
|
||||
name += "_";
|
||||
if (questScroll != null) {
|
||||
setPrevQuestName(name);
|
||||
}
|
||||
Quest quest = new Quest();
|
||||
quest.title = name;
|
||||
PacketClient.sendClient(new QuestSavePacket(category.id, quest.writeToNBT(new NBTTagCompound()), true));
|
||||
}
|
||||
// Remove Quest
|
||||
if (id == 2) {
|
||||
if (questData.containsKey(questScroll.getSelected())) {
|
||||
GuiYesNo guiyesno = new GuiYesNo(this, questScroll.getSelected(), StatCollector.translateToLocal("gui.delete"), 2);
|
||||
displayGuiScreen(guiyesno);
|
||||
}
|
||||
}
|
||||
// Edit Quest
|
||||
if(id == 0) {
|
||||
if (questData.containsKey(questScroll.getSelected()) && quest != null && quest.id >= 0) {
|
||||
setSubGui(new SubGuiNpcQuest(this, quest, category.id));
|
||||
}
|
||||
}
|
||||
// Clone Quest
|
||||
if(id == 3) {
|
||||
if (questData.containsKey(questScroll.getSelected()) && quest != null && quest.id >= 0) {
|
||||
String name = quest.title;
|
||||
while(questData.containsKey(name))
|
||||
name += "_";
|
||||
}
|
||||
}
|
||||
// Edit Quest
|
||||
if (id == 0) {
|
||||
if (questData.containsKey(questScroll.getSelected()) && quest != null && quest.id >= 0) {
|
||||
setSubGui(new SubGuiNpcQuest(this, quest, category.id));
|
||||
}
|
||||
}
|
||||
// Clone Quest
|
||||
if (id == 3) {
|
||||
if (questData.containsKey(questScroll.getSelected()) && quest != null && quest.id >= 0) {
|
||||
String name = quest.title;
|
||||
while (questData.containsKey(name))
|
||||
name += "_";
|
||||
if (questScroll != null) {
|
||||
setPrevQuestName(name);
|
||||
}
|
||||
Quest quest = new Quest();
|
||||
quest.readNBTPartial(this.quest.writeToNBT(new NBTTagCompound()));
|
||||
quest.title = name;
|
||||
PacketClient.sendClient(new QuestSavePacket(category.id, quest.writeToNBT(new NBTTagCompound()), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
if(questScroll != null){
|
||||
setPrevQuestName(name);
|
||||
}
|
||||
public void updateButtons() {
|
||||
boolean enabled = category != null;
|
||||
if (enabled) {
|
||||
if (!(category.id >= 0)) {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
boolean questEnabled = questData != null;
|
||||
if (questEnabled) {
|
||||
if (quest == null || !(quest.id >= 0)) {
|
||||
questEnabled = false;
|
||||
}
|
||||
}
|
||||
getButton(6).setEnabled(enabled);
|
||||
getButton(1).setEnabled(enabled);
|
||||
getButton(2).setEnabled(enabled);
|
||||
getButton(0).setEnabled(enabled && questEnabled);
|
||||
getButton(3).setEnabled(enabled && questEnabled);
|
||||
}
|
||||
|
||||
Quest quest = new Quest();
|
||||
quest.readNBTPartial(this.quest.writeToNBT(new NBTTagCompound()));
|
||||
quest.title = name;
|
||||
Client.sendData(EnumPacketServer.QuestSave, category.id, quest.writeToNBT(new NBTTagCompound()), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateButtons();
|
||||
}
|
||||
@Override
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
if (compound.hasKey("NextQuestId")) {
|
||||
quest.readNBT(compound);
|
||||
setPrevQuestName(quest.title);
|
||||
if (compound.hasKey("NextQuestTitle")) {
|
||||
nextQuestName = compound.getString("NextQuestTitle");
|
||||
} else {
|
||||
nextQuestName = "";
|
||||
}
|
||||
} else {
|
||||
category.readNBT(compound);
|
||||
setPrevCatName(category.title);
|
||||
PacketClient.sendClient(new QuestsGetPacket(category.id, true));
|
||||
resetQuestList();
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
|
||||
public void updateButtons(){
|
||||
boolean enabled = category != null;
|
||||
if(enabled){
|
||||
if(!(category.id >= 0)){
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean questEnabled = questData != null;
|
||||
if(questEnabled){
|
||||
if(quest == null || !(quest.id >= 0)){
|
||||
questEnabled = false;
|
||||
}
|
||||
}
|
||||
getButton(6).setEnabled(enabled);
|
||||
|
||||
getButton(1).setEnabled(enabled);
|
||||
getButton(2).setEnabled(enabled);
|
||||
|
||||
getButton(0).setEnabled(enabled && questEnabled);
|
||||
getButton(3).setEnabled(enabled && questEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
if(compound.hasKey("NextQuestId")){
|
||||
quest.readNBT(compound);
|
||||
setPrevQuestName(quest.title);
|
||||
if(compound.hasKey("NextQuestTitle")){
|
||||
nextQuestName = compound.getString("NextQuestTitle");
|
||||
}
|
||||
else {
|
||||
nextQuestName = "";
|
||||
}
|
||||
}
|
||||
else {
|
||||
category.readNBT(compound);
|
||||
setPrevCatName(category.title);
|
||||
Client.sendData(EnumPacketServer.QuestsGet, category.id, true);
|
||||
resetQuestList();
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui){
|
||||
if(subgui instanceof SubGuiEditText){
|
||||
if(!((SubGuiEditText)subgui).cancelled){
|
||||
if(category != null && category.id > -1){
|
||||
String name = ((SubGuiEditText)subgui).text;
|
||||
if(name != null && !name.equalsIgnoreCase(category.title)){
|
||||
if(!(name.isEmpty() || catData.containsKey(name))){
|
||||
String old = category.title;
|
||||
catData.remove(category.title);
|
||||
category.title = name;
|
||||
catData.put(category.title, category.id);
|
||||
catScroll.replace(old,category.title);
|
||||
}
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
if (subgui instanceof SubGuiEditText) {
|
||||
if (!((SubGuiEditText) subgui).cancelled) {
|
||||
if (category != null && category.id > -1) {
|
||||
String name = ((SubGuiEditText) subgui).text;
|
||||
if (name != null && !name.equalsIgnoreCase(category.title)) {
|
||||
if (!(name.isEmpty() || catData.containsKey(name))) {
|
||||
String old = category.title;
|
||||
catData.remove(category.title);
|
||||
category.title = name;
|
||||
catData.put(category.title, category.id);
|
||||
catScroll.replace(old, category.title);
|
||||
}
|
||||
saveType(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
clearCategory();
|
||||
}
|
||||
if(subgui instanceof SubGuiNpcQuest){
|
||||
saveType(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
clearCategory();
|
||||
}
|
||||
if (subgui instanceof SubGuiNpcQuest) {
|
||||
saveType(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPrevCatName(String selectedCat){
|
||||
prevCatName = selectedCat;
|
||||
this.catScroll.setSelected(prevCatName);
|
||||
}
|
||||
public void setPrevCatName(String selectedCat) {
|
||||
prevCatName = selectedCat;
|
||||
this.catScroll.setSelected(prevCatName);
|
||||
}
|
||||
|
||||
public void setPrevQuestName(String selectedCat){
|
||||
prevQuestName = selectedCat;
|
||||
this.questScroll.setSelected(prevQuestName);
|
||||
}
|
||||
public void setPrevQuestName(String selectedQuest) {
|
||||
prevQuestName = selectedQuest;
|
||||
this.questScroll.setSelected(prevQuestName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
if(guiCustomScroll.id == 0)
|
||||
{
|
||||
getCategory(false);
|
||||
}
|
||||
if(guiCustomScroll.id == 1)
|
||||
{
|
||||
getQuest(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void getCategory(boolean override){
|
||||
if(catScroll.selected != -1){
|
||||
String selected = catScroll.getSelected();
|
||||
if(!selected.equals(prevCatName) || override){
|
||||
category = new QuestCategory();
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
if (guiCustomScroll.id == 0) {
|
||||
getCategory(false);
|
||||
}
|
||||
if (guiCustomScroll.id == 1) {
|
||||
getQuest(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void getCategory(boolean override) {
|
||||
if (catScroll.selected != -1) {
|
||||
String selected = catScroll.getSelected();
|
||||
if (!selected.equals(prevCatName) || override) {
|
||||
category = new QuestCategory();
|
||||
questScroll.selected = -1;
|
||||
questScroll.resetScroll();
|
||||
questSearch = "";
|
||||
quest = null;
|
||||
getTextField(66).setText("");
|
||||
PacketClient.sendClient(new QuestCategoryGetPacket(catData.get(selected)));
|
||||
setPrevCatName(selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Client.sendData(EnumPacketServer.QuestCategoryGet, catData.get(selected));
|
||||
setPrevCatName(selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void getQuest(boolean override) {
|
||||
if (questScroll.selected != -1) {
|
||||
String selected = questScroll.getSelected();
|
||||
if (!selected.equals(prevQuestName) || override) {
|
||||
quest = new Quest();
|
||||
QuestGetPacket.getQuest(questData.get(selected));
|
||||
setPrevQuestName(selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getQuest(boolean override){
|
||||
if(questScroll.selected != -1){
|
||||
String selected = questScroll.getSelected();
|
||||
if(!selected.equals(prevQuestName) || override){
|
||||
quest = new Quest();
|
||||
Client.sendData(EnumPacketServer.QuestGet, questData.get(selected));
|
||||
setPrevQuestName(selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void clearCategory() {
|
||||
catScroll.setList(getCatSearch());
|
||||
catScroll.selected = -1;
|
||||
prevCatName = "";
|
||||
category = new QuestCategory();
|
||||
this.questData.clear();
|
||||
resetQuestList();
|
||||
}
|
||||
|
||||
public void clearCategory(){
|
||||
catScroll.setList(getCatSearch());
|
||||
catScroll.selected = -1;
|
||||
prevCatName = "";
|
||||
category = new QuestCategory();
|
||||
this.questData.clear();
|
||||
resetQuestList();
|
||||
}
|
||||
public void saveType(boolean saveQuest) {
|
||||
if (saveQuest) {
|
||||
if (questScroll.selected != -1 && quest.id >= 0) {
|
||||
if (catScroll.selected != -1 && category.id >= 0) {
|
||||
PacketClient.sendClient(new QuestSavePacket(category.id, quest.writeToNBT(new NBTTagCompound()), true));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (catScroll.selected != -1 && category.id >= 0)
|
||||
PacketClient.sendClient(new QuestCategorySavePacket(category.writeNBT(new NBTTagCompound())));
|
||||
}
|
||||
}
|
||||
|
||||
public void saveType(boolean saveQuest){
|
||||
if(saveQuest){
|
||||
if(questScroll.selected != -1 && quest.id >= 0){
|
||||
if(catScroll.selected != -1 && category.id >= 0){
|
||||
Client.sendData(EnumPacketServer.QuestSave, category.id, quest.writeToNBT(new NBTTagCompound()), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(catScroll.selected != -1 && category.id >= 0)
|
||||
Client.sendData(EnumPacketServer.QuestCategorySave, category.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
public void save() {}
|
||||
|
||||
public void save() {}
|
||||
@Override
|
||||
public void setData(Vector<String> list, HashMap<String, Integer> data) {
|
||||
String name = catScroll.getSelected();
|
||||
this.catData = data;
|
||||
catScroll.setList(getCatSearch());
|
||||
if (name != null) {
|
||||
catScroll.setSelected(name);
|
||||
getCategory(false);
|
||||
} else {
|
||||
catScroll.setSelected(prevCatName);
|
||||
getCategory(true);
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(Vector<String> list, HashMap<String, Integer> data) {
|
||||
String name = catScroll.getSelected();
|
||||
this.catData = data;
|
||||
catScroll.setList(getCatSearch());
|
||||
if(name != null){
|
||||
catScroll.setSelected(name);
|
||||
getCategory(false);
|
||||
} else {
|
||||
catScroll.setSelected(prevCatName);
|
||||
getCategory(true);
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
@Override
|
||||
public void setSelected(String selected) {}
|
||||
|
||||
@Override
|
||||
public void setSelected(String selected) {}
|
||||
@Override
|
||||
public void setScrollGroup(Vector<String> list, HashMap<String, Integer> data) {
|
||||
String name = questScroll.getSelected();
|
||||
this.questData = data;
|
||||
questScroll.setList(getQuestSearch());
|
||||
if (name != null) {
|
||||
questScroll.setSelected(name);
|
||||
getQuest(false);
|
||||
} else {
|
||||
questScroll.setSelected(prevQuestName);
|
||||
getQuest(true);
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScrollGroup(Vector<String> list, HashMap<String, Integer> data) {
|
||||
String name = questScroll.getSelected();
|
||||
this.questData = data;
|
||||
questScroll.setList(getQuestSearch());
|
||||
if(name != null){
|
||||
questScroll.setSelected(name);
|
||||
getQuest(false);
|
||||
} else {
|
||||
questScroll.setSelected(prevQuestName);
|
||||
getQuest(true);
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedGroup(String selected) {}
|
||||
@Override
|
||||
public void setSelectedGroup(String selected) {}
|
||||
|
||||
@Override
|
||||
public void confirmClicked(boolean result, int id) {
|
||||
NoppesUtil.openGUI(player, this);
|
||||
if(!result)
|
||||
if (!result)
|
||||
return;
|
||||
if(id == 5) {
|
||||
if(catData.containsKey(catScroll.getSelected())) {
|
||||
Client.sendData(EnumPacketServer.QuestCategoryRemove, category.id);
|
||||
if (id == 5) {
|
||||
if (catData.containsKey(catScroll.getSelected())) {
|
||||
PacketClient.sendClient(new QuestCategoryRemovePacket(category.id));
|
||||
clearCategory();
|
||||
}
|
||||
}
|
||||
if(id == 2) {
|
||||
Client.sendData(EnumPacketServer.QuestRemove, quest.id, true);
|
||||
if (id == 2) {
|
||||
PacketClient.sendClient(new QuestRemovePacket(quest.id, true));
|
||||
quest = new Quest();
|
||||
questData.clear();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagsGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagRemovePacket;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagSavePacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.gui.SubGuiColorSelector;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.controllers.data.Tag;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
@@ -25,7 +30,7 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
|
||||
public GuiNPCManageTags(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
Client.sendData(EnumPacketServer.TagsGet);
|
||||
PacketClient.sendClient(new TagsGetPacket());
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
@@ -104,11 +109,11 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tag.writeNBT(compound);
|
||||
Client.sendData(EnumPacketServer.TagSave, compound);
|
||||
PacketClient.sendClient(new TagSavePacket(compound));
|
||||
}
|
||||
if(button.id == 1){
|
||||
if(data.containsKey(scrollTags.getSelected())) {
|
||||
Client.sendData(EnumPacketServer.TagRemove, data.get(selected));
|
||||
PacketClient.sendClient(new TagRemovePacket(data.get(selected)));
|
||||
scrollTags.clear();
|
||||
tag = new Tag();
|
||||
initGui();
|
||||
@@ -154,7 +159,7 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
|
||||
{
|
||||
save();
|
||||
selected = scrollTags.getSelected();
|
||||
Client.sendData(EnumPacketServer.TagGet, data.get(selected));
|
||||
PacketClient.sendClient(new TagGetPacket(data.get(selected)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +168,7 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tag.writeNBT(compound);
|
||||
|
||||
Client.sendData(EnumPacketServer.TagSave, compound);
|
||||
PacketClient.sendClient(new TagSavePacket(compound));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.transport.TransportCategoriesGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.transport.TransportCategoryRemovePacket;
|
||||
import kamkeel.npcs.network.packets.request.transport.TransportRemovePacket;
|
||||
import kamkeel.npcs.network.packets.request.transport.TransportsGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import noppes.npcs.client.Client;
|
||||
|
||||
import noppes.npcs.client.NoppesUtil;
|
||||
import noppes.npcs.client.gui.GuiNPCTransportCategoryEdit;
|
||||
import noppes.npcs.client.gui.mainmenu.GuiNPCGlobalMainMenu;
|
||||
@@ -9,7 +14,7 @@ import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.GuiNPCStringSlot;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.IScrollData;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -24,7 +29,7 @@ public class GuiNPCManageTransporters extends GuiNPCInterface implements IScroll
|
||||
public GuiNPCManageTransporters(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
Client.sendData(EnumPacketServer.TransportCategoriesGet);
|
||||
PacketClient.sendClient(new TransportCategoriesGetPacket());
|
||||
drawDefaultBackground = false;
|
||||
title = "Transport Categories";
|
||||
data = new HashMap<String, Integer>();
|
||||
@@ -36,7 +41,7 @@ public class GuiNPCManageTransporters extends GuiNPCInterface implements IScroll
|
||||
Vector<String> list = new Vector<String>();
|
||||
slot = new GuiNPCStringSlot(list,this,false,18);
|
||||
slot.registerScrollButtons(4, 5);
|
||||
|
||||
|
||||
|
||||
this.addButton(new GuiNpcButton(0,width / 2 - 100, height - 52, 65, 20, "gui.add"));
|
||||
this.addButton(new GuiNpcButton(1,width / 2 - 33 , height - 52, 65, 20, "selectServer.edit"));
|
||||
@@ -63,7 +68,7 @@ public class GuiNPCManageTransporters extends GuiNPCInterface implements IScroll
|
||||
if(selectCategory){
|
||||
NoppesUtil.openGUI(player, new GuiNPCTransportCategoryEdit(npc, this, "", -1));
|
||||
}else{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if(id == 1)
|
||||
@@ -73,7 +78,7 @@ public class GuiNPCManageTransporters extends GuiNPCInterface implements IScroll
|
||||
if(selectCategory){
|
||||
NoppesUtil.openGUI(player, new GuiNPCTransportCategoryEdit(npc, this,slot.selected, data.get(slot.selected)));
|
||||
}else{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if(id == 4)
|
||||
@@ -84,7 +89,7 @@ public class GuiNPCManageTransporters extends GuiNPCInterface implements IScroll
|
||||
}else{
|
||||
title = "Transport Categories";
|
||||
selectCategory = true;
|
||||
Client.sendData(EnumPacketServer.TransportCategoriesGet);
|
||||
PacketClient.sendClient(new TransportCategoriesGetPacket());
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
@@ -94,10 +99,10 @@ public class GuiNPCManageTransporters extends GuiNPCInterface implements IScroll
|
||||
return;
|
||||
save();
|
||||
if(selectCategory){
|
||||
Client.sendData(EnumPacketServer.TransportCategoryRemove,data.get(slot.selected));
|
||||
PacketClient.sendClient(new TransportCategoryRemovePacket(data.get(slot.selected)));
|
||||
}
|
||||
else{
|
||||
Client.sendData(EnumPacketServer.TransportRemove,data.get(slot.selected));
|
||||
PacketClient.sendClient(new TransportRemovePacket(data.get(slot.selected)));
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
@@ -112,10 +117,10 @@ public class GuiNPCManageTransporters extends GuiNPCInterface implements IScroll
|
||||
if(selectCategory){
|
||||
selectCategory = false;
|
||||
title = "TransportLocations";
|
||||
Client.sendData(EnumPacketServer.TransportsGet,data.get(slot.selected));
|
||||
PacketClient.sendClient(new TransportsGetPacket(data.get(slot.selected)));
|
||||
initGui();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public void save() {
|
||||
}
|
||||
@@ -128,8 +133,8 @@ public class GuiNPCManageTransporters extends GuiNPCInterface implements IScroll
|
||||
|
||||
@Override
|
||||
public void setSelected(String selected) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loaded 100 of 602 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user