mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 16:24:26 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37e9d5f899 | ||
|
|
09423427a0 | ||
|
|
f213cab261 | ||
|
|
bf78c1be0f | ||
|
|
ff5e7de1be | ||
|
|
01339e7baf | ||
|
|
62ee42a23d | ||
|
|
a8a0528275 | ||
|
|
0e9ddd75b6 | ||
|
|
0c25d7ec1c | ||
|
|
b3a5854ff1 | ||
|
|
7000b525f3 | ||
|
|
9bcb8133bb | ||
|
|
9d727499df | ||
|
|
075e3fdb41 | ||
|
|
5befe141bd | ||
|
|
895d20335f | ||
|
|
1ce5b7b302 | ||
|
|
7c4965d368 | ||
|
|
a0adf0d7bd | ||
|
|
2ec6e5b753 | ||
|
|
130ac26879 | ||
|
|
cbf99be297 | ||
|
|
dc42beee15 | ||
|
|
b49402f8bd | ||
|
|
8df94aaf67 | ||
|
|
ed5cfad00d | ||
|
|
a9961ed740 | ||
|
|
6700030890 | ||
|
|
02b44953cb | ||
|
|
b8c3e9bef2 | ||
|
|
5b361d779f | ||
|
|
6df7d3643f | ||
|
|
e7ed34a591 | ||
|
|
a6cd55fcea | ||
|
|
13b153d922 | ||
|
|
f77a2ff101 | ||
|
|
49fab85291 | ||
|
|
6f1914c002 | ||
|
|
d1901dcf0c | ||
|
|
204e7a9c15 | ||
|
|
892d11b89b | ||
|
|
b965d2e097 | ||
|
|
3c1d7e6689 | ||
|
|
99298226f7 | ||
|
|
0306cff24e | ||
|
|
b77d98eba5 | ||
|
|
44f4301239 | ||
|
|
9e7e3c8e5d | ||
|
|
112305f059 | ||
|
|
45f006b7bf |
No files matched your search
+6
-6
@@ -34,7 +34,7 @@ configurations {
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "1.8.2"
|
||||
version = "1.8.4"
|
||||
group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "CustomNPC-Plus"
|
||||
|
||||
@@ -195,13 +195,13 @@ afterEvaluate {
|
||||
}
|
||||
}
|
||||
|
||||
task deobfJar(type: Jar) {
|
||||
classifier = 'dev'
|
||||
from sourceSets.main.output
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
ext.refMap = refMapForYourConfig
|
||||
}
|
||||
}
|
||||
|
||||
task deobfJar(type: Jar) {
|
||||
from sourceSets.main.output
|
||||
classifier = 'dev'
|
||||
}
|
||||
+1
-1
Submodule src/api updated: 5685f9a0f8...8c61d07b10.
@@ -1,14 +1,16 @@
|
||||
package kamkeel.developer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Developer {
|
||||
|
||||
public static ArrayList<UUID> Universal = new ArrayList<>();
|
||||
public static ArrayList<UUID> ScriptUser = new ArrayList<>();
|
||||
public static ArrayList<UUID> WandUser = new ArrayList<>();
|
||||
public static ArrayList<UUID> QuestMaker = new ArrayList<>();
|
||||
public static HashSet<UUID> Universal = new HashSet<>();
|
||||
public static HashSet<UUID> ScriptUser = new HashSet<>();
|
||||
public static HashSet<UUID> WandUser = new HashSet<>();
|
||||
public static HashSet<UUID> QuestMaker = new HashSet<>();
|
||||
public static Developer instance;
|
||||
|
||||
public Developer(){
|
||||
@@ -18,10 +20,16 @@ public class Developer {
|
||||
}
|
||||
|
||||
public boolean hasUniversal(UUID uuid){
|
||||
if(Universal == null){
|
||||
Universal = new HashSet<>();
|
||||
}
|
||||
return Universal.contains(uuid);
|
||||
}
|
||||
|
||||
public boolean hasScriptUser(UUID uuid){
|
||||
if(ScriptUser == null){
|
||||
ScriptUser = new HashSet<>();
|
||||
}
|
||||
return ScriptUser.contains(uuid);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,11 +94,8 @@ public class CommonProxy implements IGuiHandler {
|
||||
if(gui == EnumGuiType.MerchantAdd)
|
||||
return new ContainerMerchantAdd(player, ServerEventsHandler.Merchant, player.worldObj);
|
||||
|
||||
if(gui == EnumGuiType.Crate){
|
||||
if(player.inventory != null && (TileNpcContainer)player.worldObj.getTileEntity(x, y, z) != null){
|
||||
return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z));
|
||||
}
|
||||
}
|
||||
if(gui == EnumGuiType.Crate)
|
||||
return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z));
|
||||
|
||||
if(gui == EnumGuiType.PlayerMailman)
|
||||
return new ContainerMail(player, x == 1, y == 1);
|
||||
|
||||
@@ -10,6 +10,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import foxz.command.CommandNoppes;
|
||||
import kamkeel.command.CommandKamkeel;
|
||||
import kamkeel.developer.Developer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockIce;
|
||||
import net.minecraft.block.BlockLeavesBase;
|
||||
@@ -35,7 +36,7 @@ import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.8.2")
|
||||
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.8.4")
|
||||
public class CustomNpcs {
|
||||
|
||||
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
|
||||
@@ -166,6 +167,7 @@ public class CustomNpcs {
|
||||
ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkController());
|
||||
|
||||
new CustomNpcsPermissions();
|
||||
new Developer();
|
||||
|
||||
PixelmonHelper.load();
|
||||
}
|
||||
|
||||
@@ -75,11 +75,15 @@ public class CustomNpcsPermissions{
|
||||
}
|
||||
|
||||
public static boolean hasPermission(EntityPlayer player, Permission permission){
|
||||
if(Developer.instance.hasUniversal(player.getUniqueID())){
|
||||
return true;
|
||||
}
|
||||
if(Instance.bukkit != null){
|
||||
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name);
|
||||
if(player != null){
|
||||
if(Developer.instance.hasUniversal(player.getUniqueID())){
|
||||
return true;
|
||||
}
|
||||
if(permission != null){
|
||||
if(Instance.bukkit != null){
|
||||
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -441,6 +441,8 @@ public class NoppesUtilPlayer {
|
||||
questData.trackQuest(nextQuest.quest);
|
||||
}
|
||||
|
||||
playerData.save();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ import noppes.npcs.roles.RoleTransporter;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptSound;
|
||||
import noppes.npcs.scripted.event.DialogEvent;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@@ -175,7 +174,7 @@ public class NoppesUtilServer {
|
||||
|
||||
if(npc instanceof EntityDialogNpc || dia.id < 0){
|
||||
dialog.hideNPC = true;
|
||||
Server.sendDataDelayed((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, 100, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG, npc.getEntityId(), dialog.writeToNBT(new NBTTagCompound()));
|
||||
@@ -256,20 +255,18 @@ public class NoppesUtilServer {
|
||||
setEditingNpc(player, npc);
|
||||
sendExtraData(player, npc,gui, i, j, k);
|
||||
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
if(CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null){
|
||||
player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k);
|
||||
return;
|
||||
}
|
||||
else{
|
||||
Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
|
||||
}
|
||||
ArrayList<String> list = getScrollData(player, gui, npc);
|
||||
if(list == null || list.isEmpty())
|
||||
return;
|
||||
if(CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null){
|
||||
player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k);
|
||||
return;
|
||||
}
|
||||
else{
|
||||
Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
|
||||
}
|
||||
ArrayList<String> list = getScrollData(player, gui, npc);
|
||||
if(list == null || list.isEmpty())
|
||||
return;
|
||||
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SCROLL_LIST, list);
|
||||
}, 100);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SCROLL_LIST, list);
|
||||
}
|
||||
|
||||
public static void sendOpenGuiNoDelay(final EntityPlayer player,
|
||||
|
||||
@@ -227,7 +227,9 @@ public class PacketHandlerServer{
|
||||
data.getScripts().add(new ScriptContainer(data));
|
||||
}
|
||||
NBTTagCompound tabCompound = Server.readNBT(buffer);
|
||||
data.getScripts().get(tab).readFromNBT(tabCompound);
|
||||
ScriptContainer script = new ScriptContainer(data);
|
||||
script.readFromNBT(tabCompound);
|
||||
data.getScripts().set(tab,script);
|
||||
} else {
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
data.setLanguage(compound.getString("ScriptLanguage"));
|
||||
@@ -239,6 +241,9 @@ public class PacketHandlerServer{
|
||||
}
|
||||
}
|
||||
data.setEnabled(compound.getBoolean("ScriptEnabled"));
|
||||
for (ScriptContainer container : data.getScripts()) {
|
||||
container.setEngine(data.getLanguage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,6 +294,7 @@ public class PacketHandlerServer{
|
||||
private void itemScriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws Exception {
|
||||
if (type == EnumPacketServer.ScriptItemDataGet) {
|
||||
ScriptCustomItem iw = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem());
|
||||
iw.loadScriptData();
|
||||
NBTTagCompound compound = iw.getMCNbt();
|
||||
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, new Object[]{compound});
|
||||
@@ -300,7 +306,8 @@ public class PacketHandlerServer{
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
ScriptCustomItem wrapper = (ScriptCustomItem) NpcAPI.Instance().getIItemStack(player.getHeldItem());
|
||||
wrapper.setMCNbt(compound);
|
||||
wrapper.lastInited = -1L;
|
||||
wrapper.loadScriptData();
|
||||
wrapper.loaded = false;
|
||||
wrapper.saveScriptData();
|
||||
player.sendContainerToPlayer(player.inventoryContainer);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ScriptItemEventHandler {
|
||||
try {
|
||||
if (event.entityItem.getEntityItem().getItem() == CustomItems.scripted_item && !event.isCanceled()) {
|
||||
IItemCustom isw = ItemScripted.GetWrapper(event.entityItem.getEntityItem());
|
||||
EventHooks.onScriptItemTossed(isw, event.player, event.entityItem);
|
||||
event.setCanceled(EventHooks.onScriptItemTossed(isw, event.player, event.entityItem));
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ public class ScriptPlayerEventHandler {
|
||||
if(event.player.worldObj instanceof WorldServer) {
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
|
||||
EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem);
|
||||
event.setCanceled(EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
import noppes.npcs.util.CustomNPCsThreader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -22,20 +22,7 @@ import java.util.Map;
|
||||
public class Server {
|
||||
|
||||
public static void sendData(final EntityPlayerMP player, final EnumPacketClient enu, final Object... obs) {
|
||||
sendDataDelayed(player, enu, 0, obs);
|
||||
}
|
||||
|
||||
public static void sendDataDelayed(final EntityPlayerMP player, final EnumPacketClient type, int delay, final Object... obs) {
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
|
||||
try {
|
||||
if (!fillBuffer(buffer, type, obs))
|
||||
return;
|
||||
CustomNpcs.Channel.sendTo(new FMLProxyPacket(buffer, "CustomNPCs"), player);
|
||||
} catch (IOException e) {
|
||||
LogWriter.error(type + " Errored", e);
|
||||
}
|
||||
}, delay);
|
||||
sendDataChecked(player, enu, obs);
|
||||
}
|
||||
|
||||
public static boolean sendDataChecked(EntityPlayerMP player, EnumPacketClient type, Object... obs) {
|
||||
@@ -51,17 +38,15 @@ public class Server {
|
||||
}
|
||||
|
||||
public static void sendAssociatedData(final Entity entity, final EnumPacketClient enu, final Object... obs) {
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
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();
|
||||
}
|
||||
});
|
||||
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();
|
||||
}
|
||||
}
|
||||
public static void sendToAll(EnumPacketClient enu, Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -20,6 +21,7 @@ import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
@@ -253,7 +255,7 @@ public class ServerEventsHandler {
|
||||
doExcalibur((EntityPlayer) event.source.getEntity(),event.entityLiving);
|
||||
}
|
||||
|
||||
if(event.source.getEntity() instanceof EntityNPCInterface && event.entityLiving != null){
|
||||
if(event.source.getEntity() instanceof EntityNPCInterface){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity();
|
||||
Line line = npc.advanced.getKillLine();
|
||||
if(line != null)
|
||||
@@ -358,6 +360,12 @@ public class ServerEventsHandler {
|
||||
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void world(PlayerEvent.SaveToFile event){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
|
||||
data.save();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void world(EntityJoinWorldEvent event){
|
||||
if(event.world.isRemote || !(event.entity instanceof EntityPlayer))
|
||||
@@ -366,12 +374,6 @@ public class ServerEventsHandler {
|
||||
data.updateCompanion(event.world);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void world(PlayerEvent.SaveToFile event){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
|
||||
data.save();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void populateChunk(PopulateChunkEvent.Post event){
|
||||
NPCSpawning.performWorldGenSpawning(event.world, event.chunkX, event.chunkZ, event.rand);
|
||||
|
||||
@@ -3,17 +3,14 @@ package noppes.npcs.client;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import noppes.npcs.AnimationData;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.gui.OverlayQuestTracking;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import noppes.npcs.client.renderer.customitem.ImageData;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
@@ -27,16 +24,14 @@ public class Client {
|
||||
private static HashMap<String, ImageData> imageDataCache = new HashMap<>();
|
||||
|
||||
public static void sendData(final EnumPacketServer enu, final Object... obs) {
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!Server.fillBuffer(buffer, enu, obs))
|
||||
return;
|
||||
CustomNpcs.Channel.sendToServer(new FMLProxyPacket(buffer, "CustomNPCs"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!Server.fillBuffer(buffer, enu, obs))
|
||||
return;
|
||||
CustomNpcs.Channel.sendToServer(new FMLProxyPacket(buffer, "CustomNPCs"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static ImageData getImageData(String directory) {
|
||||
|
||||
@@ -219,13 +219,12 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
|
||||
private GuiScreen getGui(EntityNPCInterface npc, EnumGuiType gui, Container container, int x, int y, int z) {
|
||||
if (gui == EnumGuiType.MainMenuDisplay){
|
||||
if(npc != null)
|
||||
if (gui == EnumGuiType.MainMenuDisplay) {
|
||||
if (npc != null)
|
||||
return new GuiNpcDisplay(npc);
|
||||
else
|
||||
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Unable to find npc"));
|
||||
}
|
||||
else if (gui == EnumGuiType.MainMenuStats)
|
||||
} else if (gui == EnumGuiType.MainMenuStats)
|
||||
return new GuiNpcStats(npc);
|
||||
|
||||
else if (gui == EnumGuiType.MainMenuInv)
|
||||
@@ -234,10 +233,10 @@ public class ClientProxy extends CommonProxy {
|
||||
else if (gui == EnumGuiType.MainMenuAdvanced)
|
||||
return new GuiNpcAdvanced(npc);
|
||||
|
||||
else if(gui == EnumGuiType.QuestReward)
|
||||
else if (gui == EnumGuiType.QuestReward)
|
||||
return new GuiNpcQuestReward(npc, (ContainerNpcQuestReward) container);
|
||||
|
||||
else if(gui == EnumGuiType.QuestItem)
|
||||
else if (gui == EnumGuiType.QuestItem)
|
||||
return new GuiNpcQuestTypeItem(npc, (ContainerNpcQuestTypeItem) container);
|
||||
|
||||
else if (gui == EnumGuiType.MovingPath)
|
||||
@@ -261,16 +260,14 @@ public class ClientProxy extends CommonProxy {
|
||||
animNpc.display.texture = "customnpcs:textures/entity/humanmale/AnimationBody.png";
|
||||
}
|
||||
return new GuiNPCManageAnimations(animNpc);
|
||||
}
|
||||
|
||||
else if (gui == EnumGuiType.ManageLinked)
|
||||
} else if (gui == EnumGuiType.ManageLinked)
|
||||
return new GuiNPCManageLinkedNpc(npc);
|
||||
|
||||
else if (gui == EnumGuiType.ManageTransport)
|
||||
return new GuiNPCManageTransporters(npc);
|
||||
|
||||
else if (gui == EnumGuiType.ManageRecipes)
|
||||
return new GuiNpcManageRecipes(npc,(ContainerManageRecipes) container);
|
||||
return new GuiNpcManageRecipes(npc, (ContainerManageRecipes) container);
|
||||
|
||||
else if (gui == EnumGuiType.ManageDialogs)
|
||||
return new GuiNPCManageDialogs(npc);
|
||||
@@ -278,8 +275,8 @@ public class ClientProxy extends CommonProxy {
|
||||
else if (gui == EnumGuiType.ManageQuests)
|
||||
return new GuiNPCManageQuest(npc);
|
||||
|
||||
else if(gui == EnumGuiType.ManageBanks)
|
||||
return new GuiNPCManageBanks(npc,(ContainerManageBanks) container);
|
||||
else if (gui == EnumGuiType.ManageBanks)
|
||||
return new GuiNPCManageBanks(npc, (ContainerManageBanks) container);
|
||||
|
||||
else if (gui == EnumGuiType.MainMenuGlobal)
|
||||
return new GuiNPCGlobalMainMenu(npc);
|
||||
@@ -293,56 +290,56 @@ public class ClientProxy extends CommonProxy {
|
||||
else if (gui == EnumGuiType.PlayerFollower)
|
||||
return new GuiNpcFollower(npc, (ContainerNPCFollower) container);
|
||||
|
||||
else if(gui == EnumGuiType.PlayerTrader)
|
||||
else if (gui == EnumGuiType.PlayerTrader)
|
||||
return new GuiNPCTrader(npc, (ContainerNPCTrader) container);
|
||||
|
||||
else if(gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge)
|
||||
else if (gui == EnumGuiType.PlayerBankSmall || gui == EnumGuiType.PlayerBankUnlock || gui == EnumGuiType.PlayerBankUprade || gui == EnumGuiType.PlayerBankLarge)
|
||||
return new GuiNPCBankChest(npc, (ContainerNPCBankInterface) container);
|
||||
|
||||
else if(gui == EnumGuiType.PlayerTransporter)
|
||||
else if (gui == EnumGuiType.PlayerTransporter)
|
||||
return new GuiTransportSelection(npc);
|
||||
|
||||
else if(gui == EnumGuiType.Script && ConfigScript.ScriptingEnabled)
|
||||
else if (gui == EnumGuiType.Script && ConfigScript.ScriptingEnabled)
|
||||
return new GuiScript(npc);
|
||||
|
||||
else if (gui == EnumGuiType.ScriptItem)
|
||||
return new GuiScriptItem();
|
||||
|
||||
else if(gui == EnumGuiType.PlayerAnvil)
|
||||
else if (gui == EnumGuiType.PlayerAnvil)
|
||||
return new GuiNpcCarpentryBench((ContainerCarpentryBench) container);
|
||||
|
||||
else if (gui == EnumGuiType.SetupFollower)
|
||||
return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container);
|
||||
return new GuiNpcFollowerSetup(npc, (ContainerNPCFollowerSetup) container);
|
||||
|
||||
else if (gui == EnumGuiType.SetupItemGiver)
|
||||
return new GuiNpcItemGiver(npc, (ContainerNpcItemGiver) container);
|
||||
|
||||
else if(gui == EnumGuiType.SetupTrader)
|
||||
else if (gui == EnumGuiType.SetupTrader)
|
||||
return new GuiNpcTraderSetup(npc, (ContainerNPCTraderSetup) container);
|
||||
|
||||
else if(gui == EnumGuiType.SetupTransporter)
|
||||
else if (gui == EnumGuiType.SetupTransporter)
|
||||
return new GuiNpcTransporter(npc);
|
||||
|
||||
else if(gui == EnumGuiType.SetupBank)
|
||||
else if (gui == EnumGuiType.SetupBank)
|
||||
return new GuiNpcBankSetup(npc);
|
||||
|
||||
else if(gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null)
|
||||
else if (gui == EnumGuiType.NpcRemote && Minecraft.getMinecraft().currentScreen == null)
|
||||
return new GuiNpcRemoteEditor();
|
||||
|
||||
else if(gui == EnumGuiType.ScriptEvent && Minecraft.getMinecraft().currentScreen == null)
|
||||
else if (gui == EnumGuiType.ScriptEvent && Minecraft.getMinecraft().currentScreen == null)
|
||||
return new GuiScriptGlobal();
|
||||
|
||||
else if(gui == EnumGuiType.PlayerMailman)
|
||||
else if (gui == EnumGuiType.PlayerMailman)
|
||||
return new GuiMailmanWrite((ContainerMail) container, x == 1, y == 1);
|
||||
|
||||
else if(gui == EnumGuiType.PlayerMailbox)
|
||||
else if (gui == EnumGuiType.PlayerMailbox)
|
||||
return new GuiMailbox();
|
||||
|
||||
else if(gui == EnumGuiType.MerchantAdd)
|
||||
else if (gui == EnumGuiType.MerchantAdd)
|
||||
return new GuiMerchantAdd();
|
||||
|
||||
else if(gui == EnumGuiType.Crate)
|
||||
return new GuiCrate((ContainerCrate)container);
|
||||
else if (gui == EnumGuiType.Crate)
|
||||
return new GuiCrate((ContainerCrate) container);
|
||||
|
||||
else if(gui == EnumGuiType.NpcDimensions)
|
||||
return new GuiNpcDimension();
|
||||
|
||||
@@ -42,6 +42,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
private int posX,posY,posZ;
|
||||
|
||||
private List<String> list;
|
||||
private List<String> rawList;
|
||||
private List<String> tagList;
|
||||
|
||||
private static int showingClones = 0;
|
||||
@@ -181,6 +182,7 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
}
|
||||
this.list = list;
|
||||
this.rawList = new ArrayList<String>(this.list);
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
private void showClones() {
|
||||
@@ -198,6 +200,26 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
|
||||
this.tagMap = ClientTagMapController.Instance.getTagMap(activeTab);
|
||||
this.rawList = new ArrayList<String>(this.list);
|
||||
if(this.tagMap != null){
|
||||
if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){
|
||||
for(int i = 0; i < this.list.size(); i++){
|
||||
StringBuilder npcName = new StringBuilder(list.get(i));
|
||||
if (this.tagMap.hasClone(list.get(i))) {
|
||||
for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))){
|
||||
Tag tag = tags.get(tagUUID);
|
||||
if(tag != null){
|
||||
if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){
|
||||
npcName.append(" [" + tag.name + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.rawList.set(i, npcName.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
public void keyTyped(char c, int i)
|
||||
@@ -222,6 +244,9 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
if(this.list == null){
|
||||
this.list = new ArrayList<String>();
|
||||
}
|
||||
if(this.rawList == null){
|
||||
this.rawList = new ArrayList<String>();
|
||||
}
|
||||
|
||||
// No Filters - or - Entities
|
||||
if(tagFilters.size() == 0 || showingClones == 1){
|
||||
@@ -231,9 +256,10 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
// Yes Search
|
||||
else {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(String name : this.list){
|
||||
if(name.toLowerCase().contains(search))
|
||||
list.add(name);
|
||||
for(int i = 0; i < this.list.size(); i++){
|
||||
if(this.rawList.get(i).toLowerCase().contains(search)){
|
||||
list.add(this.list.get(i));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -257,14 +283,16 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
|
||||
// Yes Search
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(String name : this.list){
|
||||
if(name.toLowerCase().contains(search)) {
|
||||
if(tagMap.hasClone(name)){
|
||||
if(meetsCondition(name)){
|
||||
list.add(name);
|
||||
for(int i = 0; i < this.list.size(); i++){
|
||||
if(this.rawList.get(i).toLowerCase().contains(search)){
|
||||
String npcName = this.list.get(i);
|
||||
if(tagMap.hasClone(npcName)){
|
||||
if(meetsCondition(npcName)){
|
||||
list.add(npcName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -481,6 +509,27 @@ public class GuiNpcMobSpawner extends GuiNPCInterface implements IGuiData {
|
||||
}
|
||||
|
||||
this.list = list;
|
||||
|
||||
this.rawList = new ArrayList<String>(this.list);
|
||||
if(this.tagMap != null){
|
||||
if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){
|
||||
for(int i = 0; i < this.list.size(); i++){
|
||||
StringBuilder npcName = new StringBuilder(list.get(i));
|
||||
if (this.tagMap.hasClone(list.get(i))) {
|
||||
for (UUID tagUUID : this.tagMap.getUUIDsList(list.get(i))){
|
||||
Tag tag = tags.get(tagUUID);
|
||||
if(tag != null){
|
||||
if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){
|
||||
npcName.append(" [" + tag.name + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.rawList.set(i, npcName.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scroll.setList(getSearchList(), ascending == 0, sortType == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +172,10 @@ public class GuiNpcMobSpawnerAdd extends GuiNPCInterface implements GuiYesNoCall
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
if(subgui instanceof SubGuiClonerNPCTags){
|
||||
close();
|
||||
return;
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
|
||||
setBackground("menubg.png");
|
||||
xSize = 305;
|
||||
ySize = 220;
|
||||
closeOnEsc = false;
|
||||
this.npc = npc;
|
||||
closeOnEsc = false;
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
@@ -86,6 +86,7 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
|
||||
tagNames.clear();
|
||||
}
|
||||
if (guibutton.id == 66) {
|
||||
save();
|
||||
close();
|
||||
}
|
||||
initGui();
|
||||
@@ -154,11 +155,4 @@ public class SubGuiClonerNPCTags extends SubGuiInterface implements IGuiData,ISc
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
save();
|
||||
super.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,9 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
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.Tag;
|
||||
import noppes.npcs.controllers.data.TagMap;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -16,6 +11,7 @@ public class SubGuiClonerQuickTags extends SubGuiInterface implements IScrollDat
|
||||
{
|
||||
public GuiNpcMobSpawnerAdd parent;
|
||||
public GuiCustomScroll quickScroll = new GuiCustomScroll(this,0);
|
||||
public GuiCustomScroll selectedScroll = new GuiCustomScroll(this,5);
|
||||
private static String quickSearch = "";
|
||||
|
||||
public SubGuiClonerQuickTags(GuiNpcMobSpawnerAdd par){
|
||||
@@ -36,35 +32,60 @@ public class SubGuiClonerQuickTags extends SubGuiInterface implements IScrollDat
|
||||
quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags);
|
||||
this.addScroll(quickScroll);
|
||||
|
||||
addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("cloner.wandtags"), guiLeft + 7, guiTop + 7));
|
||||
addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("cloner.wandTags"), guiLeft + 7, guiTop + 7));
|
||||
addScroll(quickScroll);
|
||||
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft + 4, guiTop + 190, 140, 20, quickSearch));
|
||||
|
||||
addButton(new GuiNpcButton(10, guiLeft + 150, guiTop + 20, 120, 20, "gui.selectAll"));
|
||||
addButton(new GuiNpcButton(11, guiLeft + 150, guiTop + 43, 120, 20, "gui.deselectAll"));
|
||||
|
||||
addButton(new GuiNpcButton(66, guiLeft + 240, guiTop + 175, 60, 20, "gui.done"));
|
||||
selectedScroll.clear();
|
||||
selectedScroll.setSize(145, 103);
|
||||
selectedScroll.guiLeft = guiLeft + 150;
|
||||
selectedScroll.guiTop = guiTop + 82;
|
||||
selectedScroll.setUnselectable();
|
||||
this.addScroll(selectedScroll);
|
||||
|
||||
getSelected();
|
||||
addLabel(new GuiNpcLabel(3, StatCollector.translateToLocal("tags.selectedTags"), guiLeft + 153, guiTop + 68));
|
||||
addScroll(selectedScroll);
|
||||
|
||||
addButton(new GuiNpcButton(66, guiLeft + 240, guiTop + 190, 60, 20, "gui.done"));
|
||||
|
||||
setSelected();
|
||||
refreshSelected();
|
||||
}
|
||||
protected void actionPerformed(GuiButton guibutton){
|
||||
if (guibutton.id == 10) {
|
||||
GuiNpcMobSpawnerAdd.addTags = new HashSet<>(parent.allTags);
|
||||
quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags);
|
||||
refreshSelected();
|
||||
}
|
||||
if (guibutton.id == 11) {
|
||||
GuiNpcMobSpawnerAdd.addTags = new HashSet<>();
|
||||
quickScroll.setSelectedList(GuiNpcMobSpawnerAdd.addTags);
|
||||
refreshSelected();
|
||||
}
|
||||
if (guibutton.id == 66) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
public void getSelected(){
|
||||
@Override
|
||||
public void mouseClicked(int i, int j, int k)
|
||||
{
|
||||
super.mouseClicked(i, j, k);
|
||||
refreshSelected();
|
||||
}
|
||||
|
||||
public void setSelected(){
|
||||
quickScroll.setList(getQuickTags());
|
||||
}
|
||||
|
||||
public void refreshSelected(){
|
||||
List<String> sortedList = new ArrayList<>(new TreeSet<>(GuiNpcMobSpawnerAdd.addTags));
|
||||
selectedScroll.setList(sortedList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char c, int i)
|
||||
{
|
||||
|
||||
@@ -9,26 +9,19 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.api.gui.ICustomGuiComponent;
|
||||
import noppes.npcs.client.ImageDownloadAlt;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.custom.GuiCustom;
|
||||
import noppes.npcs.client.gui.custom.interfaces.IClickListener;
|
||||
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
|
||||
import noppes.npcs.client.renderer.customitem.ImageData;
|
||||
import noppes.npcs.scripted.gui.ScriptGuiButton;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class CustomGuiButton extends GuiButton implements IClickListener {
|
||||
GuiCustom parent;
|
||||
ResourceLocation location = null;
|
||||
|
||||
ImageData imageData = null;
|
||||
String texture;
|
||||
public int textureX;
|
||||
public int textureY;
|
||||
boolean field_146123_n;
|
||||
@@ -39,11 +32,6 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
|
||||
float alpha;
|
||||
float scale = 1.0F;
|
||||
|
||||
private int totalWidth, totalHeight;
|
||||
private ImageDownloadAlt imageDownloadAlt = null;
|
||||
private boolean isUrl = false;
|
||||
private boolean gotWidthHeight = false;
|
||||
|
||||
public CustomGuiButton(int id, String buttonText, int x, int y) {
|
||||
super(id, x, y, buttonText);
|
||||
}
|
||||
@@ -58,24 +46,12 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
|
||||
|
||||
public CustomGuiButton(int buttonId, String buttonText, int x, int y, int width, int height, String texture, int textureX, int textureY) {
|
||||
this(buttonId, buttonText, x, y, width, height);
|
||||
this.texture = texture;
|
||||
this.textureX = textureX;
|
||||
this.textureY = textureY;
|
||||
this.label = buttonText;
|
||||
if (texture != null && !texture.isEmpty()) {
|
||||
this.location = new ResourceLocation(texture);
|
||||
if(texture.startsWith("https://")){
|
||||
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
||||
ITextureObject object = new ImageDownloadAlt(null, texture, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
|
||||
texturemanager.loadTexture(this.location, object);
|
||||
} else {
|
||||
try {
|
||||
this.getWidthHeight();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.location = null;
|
||||
this.imageData = Client.getImageData(texture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,42 +91,36 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
|
||||
|
||||
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
|
||||
this.field_146123_n = mouseX >= this.xPosition + GuiCustom.guiLeft && mouseY >= this.yPosition + GuiCustom.guiTop && mouseX < this.xPosition + GuiCustom.guiLeft + this.width * this.scale && mouseY < this.yPosition + GuiCustom.guiTop + this.height * this.scale;
|
||||
|
||||
if (this.location == null) {
|
||||
totalWidth = totalHeight = 256;
|
||||
textureX = textureY = 0;
|
||||
}
|
||||
|
||||
float u1 = (float)textureX/(float)totalWidth;
|
||||
float u2 = u1 + (float)width/(float)totalWidth;
|
||||
float v1 = (float)textureY/(float)totalHeight;
|
||||
float v2 = v1 + (float)height/(float)totalHeight;
|
||||
|
||||
if (this.location != null && this.enabled) {
|
||||
if (this.field_146123_n) {
|
||||
v1 = (float)(textureY + 2 * this.height)/(float)totalHeight;
|
||||
} else {
|
||||
v1 = (float)(textureY + this.height)/(float)totalHeight;
|
||||
}
|
||||
v2 = v1 + (float)height/(float)totalHeight;
|
||||
}
|
||||
|
||||
if(imageDownloadAlt != null && isUrl && !gotWidthHeight){
|
||||
getURLWidthHeight();
|
||||
}
|
||||
|
||||
FontRenderer fontRenderer = mc.fontRenderer;
|
||||
GL11.glPushMatrix();
|
||||
float red = (color >> 16 & 255) / 255f;
|
||||
float green = (color >> 8 & 255) / 255f;
|
||||
float blue = (color & 255) / 255f;
|
||||
GL11.glColor4f(red,green,blue,this.alpha);
|
||||
|
||||
GL11.glTranslatef(GuiCustom.guiLeft + this.xPosition - u1 * totalWidth * this.scale, GuiCustom.guiTop + this.yPosition - v1 * totalHeight * this.scale,(float)this.id);
|
||||
GL11.glScalef(this.scale,this.scale,1.0F);
|
||||
if (this.imageData != null && this.imageData.imageLoaded()) {
|
||||
int totalWidth = this.imageData.getTotalWidth();
|
||||
int totalHeight = this.imageData.getTotalHeight();
|
||||
|
||||
if (this.location != null) {
|
||||
mc.getTextureManager().bindTexture(this.location);
|
||||
float u1 = (float)textureX/(float)totalWidth;
|
||||
float u2 = u1 + (float)width/(float)totalWidth;
|
||||
float v1 = (float)textureY/(float)totalHeight;
|
||||
float v2 = v1 + (float)height/(float)totalHeight;
|
||||
|
||||
if (this.enabled) {
|
||||
if (this.field_146123_n) {
|
||||
v1 = (float)(textureY + 2 * this.height)/(float)totalHeight;
|
||||
} else {
|
||||
v1 = (float)(textureY + this.height)/(float)totalHeight;
|
||||
}
|
||||
v2 = v1 + (float)height/(float)totalHeight;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
float red = (color >> 16 & 255) / 255f;
|
||||
float green = (color >> 8 & 255) / 255f;
|
||||
float blue = (color & 255) / 255f;
|
||||
GL11.glColor4f(red,green,blue,this.alpha);
|
||||
|
||||
GL11.glTranslatef(GuiCustom.guiLeft + this.xPosition - u1 * totalWidth * this.scale, GuiCustom.guiTop + this.yPosition - v1 * totalHeight * this.scale,(float)this.id);
|
||||
GL11.glScalef(this.scale,this.scale,1.0F);
|
||||
|
||||
this.imageData.bindTexture();
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
@@ -163,7 +133,9 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
|
||||
tessellator.draw();
|
||||
GL11.glTranslated(0.0D, 0.0D, 0.1D);
|
||||
this.drawCenteredString(fontRenderer, this.label, this.width / 2, (this.height - 8) / 2, this.color);
|
||||
} else {
|
||||
GL11.glPopMatrix();
|
||||
} else {
|
||||
GL11.glPushMatrix();
|
||||
mc.getTextureManager().bindTexture(buttonTextures);
|
||||
int i = this.getHoverState(this.field_146123_n);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -179,9 +151,9 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
|
||||
j = 16777120;
|
||||
}
|
||||
GL11.glTranslated(0.0D, 0.0D, 0.1D);
|
||||
this.drawCenteredString(fontRenderer, this.displayString, this.width / 2, (this.height-8)/2, j);
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
this.drawCenteredString(fontRenderer, this.displayString, this.width / 2, (this.height - 8) / 2, j);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) {
|
||||
this.parent.hoverText = this.hoverText;
|
||||
@@ -189,7 +161,7 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
|
||||
}
|
||||
|
||||
public ICustomGuiComponent toComponent() {
|
||||
ScriptGuiButton component = new ScriptGuiButton(this.id, this.label, this.xPosition, this.yPosition, this.width, this.height, this.location.toString(), this.textureX, this.textureY);
|
||||
ScriptGuiButton component = new ScriptGuiButton(this.id, this.label, this.xPosition, this.yPosition, this.width, this.height, this.texture, this.textureX, this.textureY);
|
||||
component.setHoverText(this.hoverText);
|
||||
component.setColor(this.color);
|
||||
component.setAlpha(this.alpha);
|
||||
@@ -204,40 +176,4 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void getWidthHeight() throws IOException {
|
||||
InputStream inputstream = null;
|
||||
|
||||
try {
|
||||
IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(this.location);
|
||||
inputstream = iresource.getInputStream();
|
||||
BufferedImage bufferedimage = ImageIO.read(inputstream);
|
||||
gotWidthHeight = true;
|
||||
this.totalWidth = bufferedimage.getWidth();
|
||||
this.totalHeight = bufferedimage.getHeight();
|
||||
correctWidthHeight();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inputstream != null) {
|
||||
inputstream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getURLWidthHeight(){
|
||||
if(imageDownloadAlt.getBufferedImage() != null) {
|
||||
gotWidthHeight = true;
|
||||
this.totalWidth = imageDownloadAlt.getBufferedImage().getWidth();
|
||||
this.totalHeight = imageDownloadAlt.getBufferedImage().getHeight();
|
||||
correctWidthHeight();
|
||||
}
|
||||
}
|
||||
|
||||
public void correctWidthHeight(){
|
||||
totalWidth = Math.max(totalWidth, 1);
|
||||
totalHeight = Math.max(totalHeight, 1);
|
||||
this.width = width < 0 ? totalWidth : width;
|
||||
this.height = height < 0 ? totalHeight : height;
|
||||
}
|
||||
}
|
||||
@@ -8,25 +8,19 @@ package noppes.npcs.client.gui.custom.components;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.api.gui.ICustomGuiComponent;
|
||||
import noppes.npcs.client.ImageDownloadAlt;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.gui.custom.GuiCustom;
|
||||
import noppes.npcs.client.gui.custom.interfaces.IGuiComponent;
|
||||
import noppes.npcs.client.renderer.ImageBufferDownloadAlt;
|
||||
import noppes.npcs.client.renderer.customitem.ImageData;
|
||||
import noppes.npcs.scripted.gui.ScriptGuiTexturedRect;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
||||
GuiCustom parent;
|
||||
ResourceLocation location;
|
||||
|
||||
ImageData imageData = null;
|
||||
String texture;
|
||||
int id;
|
||||
int x;
|
||||
int y;
|
||||
@@ -41,11 +35,6 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
||||
float alpha;
|
||||
float rotation;
|
||||
|
||||
private int totalWidth, totalHeight;
|
||||
private ImageDownloadAlt imageDownloadAlt = null;
|
||||
private boolean isUrl = false;
|
||||
private boolean gotWidthHeight = false;
|
||||
|
||||
public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height) {
|
||||
this(id, texture, x, y, width, height, 0, 0);
|
||||
}
|
||||
@@ -53,25 +42,15 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
||||
public CustomGuiTexturedRect(int id, String directory, int x, int y, int width, int height, int textureX, int textureY) {
|
||||
this.scale = 1.0F;
|
||||
this.id = id;
|
||||
this.location = new ResourceLocation(directory);
|
||||
this.texture = directory;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.textureX = textureX;
|
||||
this.textureY = textureY;
|
||||
|
||||
if(directory.startsWith("https://")){
|
||||
this.isUrl = true;
|
||||
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
||||
this.imageDownloadAlt = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true,false));
|
||||
texturemanager.loadTexture(this.location, this.imageDownloadAlt);
|
||||
} else {
|
||||
try {
|
||||
this.getWidthHeight();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (texture != null && !texture.isEmpty()) {
|
||||
this.imageData = Client.getImageData(texture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,37 +64,38 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
||||
|
||||
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
|
||||
boolean hovered = mouseX >= this.x + GuiCustom.guiLeft && mouseY >= this.y + GuiCustom.guiTop && mouseX < this.x + GuiCustom.guiLeft + this.width && mouseY < this.y + GuiCustom.guiTop + this.height;
|
||||
mc.getTextureManager().bindTexture(this.location);
|
||||
|
||||
float u1 = (float)textureX/(float)totalWidth;
|
||||
float u2 = u1 + (float)width/(float)totalWidth;
|
||||
float v1 = (float)textureY/(float)totalHeight;
|
||||
float v2 = v1 + (float)height/(float)totalHeight;
|
||||
if (this.imageData != null && this.imageData.imageLoaded()) {
|
||||
int totalWidth = this.imageData.getTotalWidth();
|
||||
int totalHeight = this.imageData.getTotalHeight();
|
||||
|
||||
if(imageDownloadAlt != null && isUrl && !gotWidthHeight){
|
||||
getURLWidthHeight();
|
||||
}
|
||||
float u1 = (float) textureX / (float) totalWidth;
|
||||
float u2 = u1 + (float) width / (float) totalWidth;
|
||||
float v1 = (float) textureY / (float) totalHeight;
|
||||
float v2 = v1 + (float) height / (float) totalHeight;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushMatrix();
|
||||
float red = (color >> 16 & 255) / 255f;
|
||||
float green = (color >> 8 & 255) / 255f;
|
||||
float green = (color >> 8 & 255) / 255f;
|
||||
float blue = (color & 255) / 255f;
|
||||
GL11.glColor4f(red,green,blue,this.alpha);
|
||||
GL11.glColor4f(red, green, blue, this.alpha);
|
||||
|
||||
GL11.glTranslatef(GuiCustom.guiLeft + this.x - u1 * totalWidth, GuiCustom.guiTop + this.y - v1 * totalHeight,(float)this.id);
|
||||
GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F);
|
||||
GL11.glTranslatef(GuiCustom.guiLeft + this.x - u1 * totalWidth, GuiCustom.guiTop + this.y - v1 * totalHeight, (float) this.id);
|
||||
GL11.glRotatef(this.rotation, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glScalef(this.scale, this.scale, this.scale);
|
||||
|
||||
this.imageData.bindTexture();
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
tessellator.setColorRGBA_F(red, green, blue, alpha);
|
||||
tessellator.addVertexWithUV( u2 * totalWidth, v2 * totalHeight, 0, u2, v2);
|
||||
tessellator.addVertexWithUV( u2 * totalWidth, v1 * totalHeight, 0, u2, v1);
|
||||
tessellator.addVertexWithUV( u1 * totalWidth, v1 * totalHeight, 0, u1, v1);
|
||||
tessellator.addVertexWithUV( u1 * totalWidth, v2 * totalHeight, 0, u1, v2);
|
||||
tessellator.addVertexWithUV(u2 * totalWidth, v2 * totalHeight, 0, u2, v2);
|
||||
tessellator.addVertexWithUV(u2 * totalWidth, v1 * totalHeight, 0, u2, v1);
|
||||
tessellator.addVertexWithUV(u1 * totalWidth, v1 * totalHeight, 0, u1, v1);
|
||||
tessellator.addVertexWithUV(u1 * totalWidth, v2 * totalHeight, 0, u1, v2);
|
||||
tessellator.draw();
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
|
||||
this.parent.hoverText = this.hoverText;
|
||||
@@ -123,7 +103,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
||||
}
|
||||
|
||||
public ICustomGuiComponent toComponent() {
|
||||
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(this.id, this.location.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY);
|
||||
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(this.id, this.texture, this.x, this.y, this.width, this.height, this.textureX, this.textureY);
|
||||
component.setHoverText(this.hoverText);
|
||||
component.setScale(this.scale);
|
||||
component.setColor(color);
|
||||
@@ -151,40 +131,4 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
public void getWidthHeight() throws IOException {
|
||||
InputStream inputstream = null;
|
||||
|
||||
try {
|
||||
IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(this.location);
|
||||
inputstream = iresource.getInputStream();
|
||||
BufferedImage bufferedimage = ImageIO.read(inputstream);
|
||||
gotWidthHeight = true;
|
||||
this.totalWidth = bufferedimage.getWidth();
|
||||
this.totalHeight = bufferedimage.getHeight();
|
||||
correctWidthHeight();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inputstream != null) {
|
||||
inputstream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getURLWidthHeight(){
|
||||
if(imageDownloadAlt.getBufferedImage() != null) {
|
||||
gotWidthHeight = true;
|
||||
this.totalWidth = imageDownloadAlt.getBufferedImage().getWidth();
|
||||
this.totalHeight = imageDownloadAlt.getBufferedImage().getHeight();
|
||||
correctWidthHeight();
|
||||
}
|
||||
}
|
||||
|
||||
public void correctWidthHeight(){
|
||||
totalWidth = Math.max(totalWidth, 1);
|
||||
totalHeight = Math.max(totalHeight, 1);
|
||||
this.width = width < 0 ? totalWidth : width;
|
||||
this.height = height < 0 ? totalHeight : height;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,9 @@ import noppes.npcs.containers.ContainerManageBanks;
|
||||
import noppes.npcs.controllers.data.Bank;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScrollData,ICustomScrollListener,ITextfieldListener, IGuiData
|
||||
@@ -20,6 +22,7 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
|
||||
private ContainerManageBanks container;
|
||||
private Bank bank = new Bank();
|
||||
private String selected = null;
|
||||
private String search = "";
|
||||
|
||||
public GuiNPCManageBanks(EntityNPCInterface npc,ContainerManageBanks container)
|
||||
{
|
||||
@@ -61,6 +64,8 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
|
||||
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+10, guiTop + 110, 16, 16, ""));
|
||||
getTextField(2).integersOnly = true;
|
||||
getTextField(2).setMaxStringLength(1);
|
||||
|
||||
addTextField(new GuiNpcTextField(33, this, fontRendererObj, guiLeft + 174, guiTop + 8 + 3 + 180, 160, 20, search));
|
||||
}
|
||||
|
||||
public void drawScreen(int x, int y, float f)
|
||||
@@ -137,12 +142,37 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
|
||||
}
|
||||
setSelected(bank.name);
|
||||
}
|
||||
|
||||
|
||||
public void keyTyped(char c, int i)
|
||||
{
|
||||
super.keyTyped(c, i);
|
||||
if(getTextField(33) != null){
|
||||
if(getTextField(33).isFocused()){
|
||||
if(search.equals(getTextField(33).getText()))
|
||||
return;
|
||||
search = getTextField(33).getText().toLowerCase();
|
||||
scroll.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 = scroll.getSelected();
|
||||
this.data = data;
|
||||
scroll.setList(list);
|
||||
scroll.setList(getSearchList());
|
||||
|
||||
if(name != null)
|
||||
scroll.setSelected(name);
|
||||
|
||||
@@ -29,6 +29,7 @@ public class GuiScriptItem extends GuiScriptInterface {
|
||||
|
||||
public void setGuiData(NBTTagCompound compound) {
|
||||
this.item.setMCNbt(compound);
|
||||
this.item.loadScriptData();
|
||||
super.setGuiData(compound);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class GuiCustomScrollCloner extends GuiCustomScroll {
|
||||
}
|
||||
|
||||
if((this.parent.getShowingClones() == 0 || this.parent.getShowingClones() == 2) && this.parent.tagMap != null){
|
||||
int tagStartX = j + fontRendererObj.getStringWidth(displayString) + 5;
|
||||
int tagStartX = j + fontRendererObj.getStringWidth(displayString) + 3;
|
||||
if(GuiNpcMobSpawner.displayTags == 0 || GuiNpcMobSpawner.displayTags == 1){
|
||||
if (this.parent.tagMap.hasClone(list.get(i))) {
|
||||
for (UUID tagUUID : this.parent.tagMap.getUUIDsList(list.get(i))){
|
||||
@@ -64,7 +64,7 @@ public class GuiCustomScrollCloner extends GuiCustomScroll {
|
||||
if(tag != null){
|
||||
if(GuiNpcMobSpawner.displayTags == 1 || !tag.getIsHidden()){
|
||||
fontRendererObj.drawString("[" + tag.name + "]", tagStartX, k, tag.color);
|
||||
tagStartX += fontRendererObj.getStringWidth("[" + tag.name + "]") + 2;
|
||||
tagStartX += fontRendererObj.getStringWidth("[" + tag.name + "]") + 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,15 +49,10 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) {
|
||||
ScriptCustomItem scriptCustomItem = ItemScripted.GetWrapper(itemStack);
|
||||
|
||||
BufferedImage bufferedImage = Client.getImageData(scriptCustomItem.texture).getBufferedImage();
|
||||
if (bufferedImage != null && (scriptCustomItem.width != bufferedImage.getWidth() || scriptCustomItem.height != bufferedImage.getHeight())) {
|
||||
scriptCustomItem.width = bufferedImage.getWidth();
|
||||
scriptCustomItem.height = bufferedImage.getHeight();
|
||||
scriptCustomItem.saveItemData();
|
||||
}
|
||||
|
||||
if(scriptCustomItem.width < 1 || scriptCustomItem.height < 1)
|
||||
ImageData imageData = Client.getImageData(scriptCustomItem.texture);
|
||||
if (!imageData.imageLoaded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == ItemRenderType.INVENTORY) {
|
||||
GL11.glPushMatrix();
|
||||
@@ -80,7 +75,6 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
GL11.glRotatef(scriptCustomItem.rotationYRate * entityRenderTicks%360, 0, 1, 0);
|
||||
GL11.glRotatef(scriptCustomItem.rotationZRate * entityRenderTicks%360, 0, 0, 1);
|
||||
|
||||
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
|
||||
GL11.glTranslatef(0.0F, bobbingY, 0.0F);
|
||||
|
||||
int color = scriptCustomItem.getColor();
|
||||
@@ -184,6 +178,7 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
|
||||
GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float)b0 / 2.0F));
|
||||
|
||||
for (int k = 0; k < b0; ++k)
|
||||
@@ -253,6 +248,7 @@ public class CustomItemRenderer implements IItemRenderer {
|
||||
for (int l = 0; l < b0; ++l)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(scriptCustomItem.scaleX, scriptCustomItem.scaleY, scriptCustomItem.scaleZ);
|
||||
|
||||
if (l > 0)
|
||||
{
|
||||
|
||||
@@ -13,12 +13,13 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ImageData {
|
||||
private ResourceLocation location;
|
||||
private final ResourceLocation location;
|
||||
private final boolean isUrl;
|
||||
|
||||
private ImageDownloadAlt imageDownloadAlt = null;
|
||||
private BufferedImage bufferedImage = null;
|
||||
private int totalWidth, totalHeight;
|
||||
|
||||
private int totalWidth, totalHeight;
|
||||
private boolean gotWidthHeight;
|
||||
private boolean invalid;
|
||||
|
||||
@@ -28,14 +29,23 @@ public class ImageData {
|
||||
this.isUrl = true;
|
||||
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
||||
this.imageDownloadAlt = new ImageDownloadAlt(null, directory, new ResourceLocation("customnpcs:textures/gui/invisible.png"), new ImageBufferDownloadAlt(true, false));
|
||||
texturemanager.loadTexture(location, this.imageDownloadAlt);
|
||||
texturemanager.loadTexture(this.location, this.imageDownloadAlt);
|
||||
} else {
|
||||
this.isUrl = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean invalidTexture() {
|
||||
return this.invalid;
|
||||
public boolean imageLoaded() {
|
||||
if (!this.gotWidthHeight) {
|
||||
try {
|
||||
if (!this.isUrl) {
|
||||
this.getWidthHeight();
|
||||
} else {
|
||||
this.getURLWidthHeight();
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
return !this.invalid && this.location != null && this.gotWidthHeight;
|
||||
}
|
||||
|
||||
public void bindTexture() {
|
||||
@@ -49,7 +59,7 @@ public class ImageData {
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceLocation getLocation() {
|
||||
private ResourceLocation getLocation() {
|
||||
return this.isUrl && this.imageDownloadAlt.getBufferedImage() == null ? null : this.location;
|
||||
}
|
||||
|
||||
@@ -69,6 +79,10 @@ public class ImageData {
|
||||
}
|
||||
|
||||
private void getWidthHeight() throws IOException {
|
||||
if (this.invalid) {
|
||||
return;
|
||||
}
|
||||
|
||||
InputStream inputstream = null;
|
||||
|
||||
try {
|
||||
@@ -80,7 +94,7 @@ public class ImageData {
|
||||
this.totalHeight = bufferedimage.getHeight();
|
||||
correctWidthHeight();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
this.invalid = true;
|
||||
} finally {
|
||||
if (inputstream != null) {
|
||||
inputstream.close();
|
||||
@@ -89,7 +103,7 @@ public class ImageData {
|
||||
}
|
||||
|
||||
private void getURLWidthHeight(){
|
||||
if(this.imageDownloadAlt.getBufferedImage() != null) {
|
||||
if(this.imageDownloadAlt.getBufferedImage() != null && !this.invalid) {
|
||||
this.gotWidthHeight = true;
|
||||
this.totalWidth = this.imageDownloadAlt.getBufferedImage().getWidth();
|
||||
this.totalHeight = this.imageDownloadAlt.getBufferedImage().getHeight();
|
||||
@@ -103,34 +117,10 @@ public class ImageData {
|
||||
}
|
||||
|
||||
public int getTotalWidth() {
|
||||
if (!this.gotWidthHeight) {
|
||||
try {
|
||||
if (!this.isUrl) {
|
||||
this.getWidthHeight();
|
||||
} else {
|
||||
this.getURLWidthHeight();
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
if (!this.gotWidthHeight) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return this.totalWidth;
|
||||
return this.gotWidthHeight ? this.totalWidth : -1;
|
||||
}
|
||||
|
||||
public int getTotalHeight() {
|
||||
if (!this.gotWidthHeight) {
|
||||
try {
|
||||
if (!this.isUrl) {
|
||||
this.getWidthHeight();
|
||||
} else {
|
||||
this.getURLWidthHeight();
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
if (!this.gotWidthHeight) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return this.totalHeight;
|
||||
return this.gotWidthHeight ? this.totalHeight : -1;
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,9 @@ package noppes.npcs.containers;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
@@ -19,7 +17,6 @@ import noppes.npcs.api.gui.IItemSlot;
|
||||
import noppes.npcs.client.gui.custom.components.CustomGuiSlot;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.gui.ScriptGui;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@@ -111,6 +108,11 @@ public class ContainerCustomGui extends Container {
|
||||
public ItemStack slotClick(int slotId, int dragType, int clickTypeIn, EntityPlayer player) {
|
||||
if(slotId < 0)
|
||||
return super.slotClick(slotId, dragType, clickTypeIn, player);
|
||||
|
||||
if (slotId >= this.inventorySlots.size()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Slot mcSlot = (Slot)this.inventorySlots.get(slotId);
|
||||
if(!player.worldObj.isRemote && mcSlot != null) {
|
||||
IItemSlot slot = null;
|
||||
@@ -135,7 +137,7 @@ public class ContainerCustomGui extends Container {
|
||||
}
|
||||
|
||||
EntityPlayerMP p = (EntityPlayerMP) player;
|
||||
CustomNPCsScheduler.runTack(() -> {p.sendContainerToPlayer(this);}, 10);
|
||||
p.sendContainerToPlayer(this);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,21 +9,19 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import static noppes.npcs.util.CustomNPCsThreader.playerDataThread;
|
||||
|
||||
public class PlayerDataController {
|
||||
public static PlayerDataController instance;
|
||||
public HashMap<String, String> nameUUIDs;
|
||||
@@ -168,8 +166,8 @@ public class PlayerDataController {
|
||||
readNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
public void savePlayerDataMap(){
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
public synchronized void savePlayerDataMap(){
|
||||
playerDataThread.execute(() -> {
|
||||
try {
|
||||
File saveDir = getSaveDir();
|
||||
File file = new File(saveDir, "___playermap.dat_new");
|
||||
@@ -273,7 +271,7 @@ public class PlayerDataController {
|
||||
if(data == null){
|
||||
player.registerExtendedProperties("CustomNpcsData", data = new PlayerData());
|
||||
data.player = player;
|
||||
data.loadPlayerDataFromFile();
|
||||
data.load();
|
||||
}
|
||||
data.player = player;
|
||||
return data;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class ScriptContainer {
|
||||
private String currentScriptLanguage = null;
|
||||
public ScriptEngine engine = null;
|
||||
private IScriptHandler handler = null;
|
||||
private boolean init = false;
|
||||
private boolean evaluated = false;
|
||||
private static Method luaCoerce;
|
||||
private static Method luaCall;
|
||||
private CompiledScript compScript = null;
|
||||
@@ -43,6 +43,7 @@ public class ScriptContainer {
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
String prevScript = this.script;
|
||||
this.script = compound.getString("Script");
|
||||
for (int i = 0; i < ConfigScript.ExpandedScriptLimit; i++) {
|
||||
if (compound.hasKey("ExpandedScript"+i)) {
|
||||
@@ -51,7 +52,11 @@ public class ScriptContainer {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//this.type = compound.getString("Type");
|
||||
|
||||
if (!this.script.equals(prevScript)) {
|
||||
this.evaluated = false;
|
||||
}
|
||||
|
||||
this.console = NBTTags.GetLongStringMap(compound.getTagList("Console", 10));
|
||||
this.scripts = NBTTags.getStringList(compound.getTagList("ScriptList", 10));
|
||||
this.lastCreated = 0L;
|
||||
@@ -88,7 +93,7 @@ public class ScriptContainer {
|
||||
}
|
||||
|
||||
private String getFullCode() {
|
||||
if(!this.init) {
|
||||
if(!this.evaluated) {
|
||||
this.fullscript = this.script;
|
||||
if(!this.fullscript.isEmpty()) {
|
||||
this.fullscript = this.fullscript + "\n";
|
||||
@@ -145,12 +150,11 @@ public class ScriptContainer {
|
||||
if(errored || !hasCode() || unknownFunctions.contains(type) || !ConfigScript.ScriptingEnabled)
|
||||
return;
|
||||
|
||||
this.setEngine(handler.getLanguage());
|
||||
if(engine == null)
|
||||
return;
|
||||
if(ScriptController.Instance.lastLoaded > this.lastCreated){
|
||||
this.lastCreated = ScriptController.Instance.lastLoaded;
|
||||
init = false;
|
||||
evaluated = false;
|
||||
}
|
||||
|
||||
synchronized (lock) {
|
||||
@@ -170,9 +174,9 @@ public class ScriptContainer {
|
||||
}
|
||||
|
||||
try {
|
||||
if(!init){
|
||||
if(!evaluated){
|
||||
engine.eval(getFullCode());
|
||||
init = true;
|
||||
evaluated = true;
|
||||
}
|
||||
if(engine.getFactory().getLanguageName().equals("lua")){
|
||||
Object ob = engine.get(type);
|
||||
@@ -220,7 +224,7 @@ public class ScriptContainer {
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return init && !errored;
|
||||
return evaluated && !errored;
|
||||
}
|
||||
|
||||
public boolean hasCode() {
|
||||
@@ -233,9 +237,9 @@ public class ScriptContainer {
|
||||
if (ConfigScript.ScriptingECMA6 && scriptLanguage.equals("ECMAScript")) {
|
||||
System.setProperty("nashorn.args", "--language=es6");
|
||||
}
|
||||
this.engine = new ScriptEngineManager().getEngineByName(scriptLanguage.toLowerCase());
|
||||
this.engine = ScriptController.Instance.getEngineByName(scriptLanguage.toLowerCase());
|
||||
|
||||
currentScriptLanguage = scriptLanguage;
|
||||
init = false;
|
||||
evaluated = false;
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class ScriptController {
|
||||
|
||||
public static ScriptController Instance;
|
||||
public static boolean HasStart = false;
|
||||
private ScriptEngineManager manager;
|
||||
private final ScriptEngineManager manager;
|
||||
public Map<String, String> languages = new HashMap<String, String>();
|
||||
public Map<String, String> scripts = new HashMap<String, String>();
|
||||
public long lastLoaded = 0;
|
||||
|
||||
@@ -15,7 +15,7 @@ import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.containers.ContainerNPCBankInterface;
|
||||
import noppes.npcs.controllers.BankController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
import noppes.npcs.util.CustomNPCsThreader;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -100,18 +100,16 @@ public class BankData {
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.PlayerBankSmall, npc, slot, bank.id, 0);
|
||||
}
|
||||
final ItemStack item = currency;
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("MaxSlots", bank.getMaxSlots());
|
||||
compound.setInteger("UnlockedSlots", unlockedSlots);
|
||||
if (item != null) {
|
||||
compound.setTag("Currency", NoppesUtilServer.writeItem(item, new NBTTagCompound()));
|
||||
ContainerNPCBankInterface container = getContainer(player);
|
||||
if (container != null)
|
||||
container.setCurrency(item);
|
||||
}
|
||||
Server.sendDataChecked((EntityPlayerMP) player, EnumPacketClient.GUI_DATA, compound);
|
||||
}, 300);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("MaxSlots", bank.getMaxSlots());
|
||||
compound.setInteger("UnlockedSlots", unlockedSlots);
|
||||
if (item != null) {
|
||||
compound.setTag("Currency", NoppesUtilServer.writeItem(item, new NBTTagCompound()));
|
||||
ContainerNPCBankInterface container = getContainer(player);
|
||||
if (container != null)
|
||||
container.setCurrency(item);
|
||||
}
|
||||
Server.sendDataChecked((EntityPlayerMP) player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
private ContainerNPCBankInterface getContainer(EntityPlayer player){
|
||||
Container con = player.openContainer;
|
||||
|
||||
@@ -72,11 +72,19 @@ public class DataScript implements IScriptHandler {
|
||||
this.scriptLanguage = "ECMAScript";
|
||||
}
|
||||
}
|
||||
|
||||
for (ScriptContainer container : this.scripts.values()) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
|
||||
enabled = compound.getBoolean("ScriptEnabled");
|
||||
}
|
||||
|
||||
public void readEventsFromNBT(NBTTagCompound compound) {
|
||||
eventScripts = NBTTags.GetScript(compound,this);
|
||||
for (ScriptContainer container : this.eventScripts) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
@@ -149,7 +157,6 @@ public class DataScript implements IScriptHandler {
|
||||
ScriptContainer script = scripts.get(type);
|
||||
if(script == null || script.errored || !script.hasCode())
|
||||
return false;
|
||||
script.setEngine(scriptLanguage);
|
||||
if(script.engine == null)
|
||||
return false;
|
||||
for(int i = 0; i + 1 < obs.length; i += 2){
|
||||
@@ -173,7 +180,7 @@ public class DataScript implements IScriptHandler {
|
||||
engine.put("npc", dummyNpc);
|
||||
engine.put("world", dummyWorld);
|
||||
engine.put("event", event);
|
||||
engine.put("API", new NpcAPI());
|
||||
engine.put("API", NpcAPI.Instance());
|
||||
engine.put("EntityType", entities);
|
||||
engine.put("RoleType", roles);
|
||||
engine.put("JobType", jobs);
|
||||
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.api.entity.ICustomNpc;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.handler.IPlayerFactionData;
|
||||
import noppes.npcs.api.handler.data.IFaction;
|
||||
import noppes.npcs.controllers.FactionController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
@@ -133,8 +134,8 @@ public class Faction implements IFaction {
|
||||
}
|
||||
|
||||
public int playerStatus(IPlayer player) {
|
||||
PlayerFactionData data = PlayerData.get((EntityPlayer) player.getMCEntity()).factionData;
|
||||
int points = data.getFactionPoints(this.id);
|
||||
IPlayerFactionData data = player.getData().getFactionData();
|
||||
int points = data.getPoints(this.id);
|
||||
if (points >= this.friendlyPoints) {
|
||||
return 1;
|
||||
} else {
|
||||
|
||||
@@ -46,6 +46,10 @@ public class ForgeDataScript implements IScriptHandler {
|
||||
}
|
||||
}
|
||||
this.enabled = compound.getBoolean("ScriptEnabled");
|
||||
|
||||
for (ScriptContainer container : this.scripts) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
|
||||
@@ -49,6 +49,10 @@ public class GlobalNPCDataScript implements IScriptHandler {
|
||||
}
|
||||
}
|
||||
this.enabled = compound.getBoolean("ScriptEnabled");
|
||||
|
||||
for (ScriptContainer container : this.scripts) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
}
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setInteger("TotalScripts",this.scripts.size());
|
||||
|
||||
@@ -2,7 +2,6 @@ package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IExtendedEntityProperties;
|
||||
@@ -19,11 +18,10 @@ import noppes.npcs.entity.data.DataSkinOverlays;
|
||||
import noppes.npcs.entity.data.DataTimers;
|
||||
import noppes.npcs.roles.RoleCompanion;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
import noppes.npcs.util.CustomNPCsThreader;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
public PlayerDialogData dialogData = new PlayerDialogData(this);
|
||||
@@ -53,20 +51,10 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
|
||||
@Override
|
||||
public void saveNBTData(NBTTagCompound nbtTagCompound) {
|
||||
//Do Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadNBTData(NBTTagCompound compound) {
|
||||
//Do Nothing
|
||||
}
|
||||
|
||||
public void loadPlayerDataFromFile() {
|
||||
NBTTagCompound data = PlayerDataController.instance.loadPlayerData(player.getPersistentID().toString());
|
||||
if(data.hasNoTags()){
|
||||
data = PlayerDataController.instance.loadPlayerDataOld(player.getCommandSenderName());
|
||||
}
|
||||
setNBT(data);
|
||||
}
|
||||
|
||||
public void setNBT(NBTTagCompound data){
|
||||
@@ -138,13 +126,11 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
}
|
||||
|
||||
public void setGUIOpen(boolean bool) {
|
||||
isGUIOpen = bool;
|
||||
save();
|
||||
this.isGUIOpen = bool;
|
||||
}
|
||||
|
||||
public boolean getGUIOpen() {
|
||||
loadPlayerDataFromFile();
|
||||
return isGUIOpen;
|
||||
return this.isGUIOpen;
|
||||
}
|
||||
|
||||
public boolean hasCompanion(){
|
||||
@@ -180,44 +166,6 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
world.spawnEntityInWorld(npc);
|
||||
}
|
||||
|
||||
public static NBTTagCompound loadPlayerDataOld(String player) {
|
||||
File saveDir = CustomNpcs.getWorldSaveDirectory("playerdata");
|
||||
String filename = player;
|
||||
if (player.isEmpty()) {
|
||||
filename = "noplayername";
|
||||
}
|
||||
|
||||
filename = filename + ".dat";
|
||||
|
||||
File file;
|
||||
try {
|
||||
file = new File(saveDir, filename);
|
||||
if (file.exists()) {
|
||||
NBTTagCompound comp = CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||
file.delete();
|
||||
file = new File(saveDir, filename + "_old");
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
return comp;
|
||||
}
|
||||
} catch (Exception var6) {
|
||||
LogWriter.except(var6);
|
||||
}
|
||||
|
||||
try {
|
||||
file = new File(saveDir, filename + "_old");
|
||||
if (file.exists()) {
|
||||
return CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||
}
|
||||
} catch (Exception var5) {
|
||||
LogWriter.except(var5);
|
||||
}
|
||||
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
|
||||
public static NBTTagCompound loadPlayerData(String player) {
|
||||
File saveDir = CustomNpcs.getWorldSaveDirectory("playerdata");
|
||||
String filename = player;
|
||||
@@ -240,25 +188,6 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
|
||||
public static PlayerData get(EntityPlayer player) {
|
||||
if(player.worldObj.isRemote) {
|
||||
return CustomNpcs.proxy.getPlayerData(player);
|
||||
} else {
|
||||
PlayerData data = new PlayerData();
|
||||
if (data.player == null) {
|
||||
data.player = player;
|
||||
NBTTagCompound compound = loadPlayerData(player.getPersistentID().toString());
|
||||
if (compound.hasNoTags()) {
|
||||
compound = loadPlayerDataOld(player.getCommandSenderName());
|
||||
}
|
||||
|
||||
data.setNBT(compound);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public void setCompanion(ICustomNpc npc) {
|
||||
this.setCompanion((EntityNPCInterface) npc.getMCEntity());
|
||||
}
|
||||
@@ -302,8 +231,7 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
public synchronized void save() {
|
||||
final NBTTagCompound compound = getNBT();
|
||||
final String filename = uuid + ".json";
|
||||
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
CustomNPCsThreader.playerDataThread.execute(() -> {
|
||||
try {
|
||||
File saveDir = PlayerDataController.instance.getSaveDir();
|
||||
File file = new File(saveDir, filename + "_new");
|
||||
@@ -316,8 +244,15 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
} catch (Exception e) {
|
||||
LogWriter.except(e);
|
||||
}
|
||||
|
||||
PlayerDataController.instance.putPlayerMap(playername, uuid);
|
||||
});
|
||||
PlayerDataController.instance.putPlayerMap(playername, uuid);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
NBTTagCompound data = PlayerDataController.instance.loadPlayerData(player.getPersistentID().toString());
|
||||
if(data.hasNoTags()){
|
||||
data = PlayerDataController.instance.loadPlayerDataOld(player.getCommandSenderName());
|
||||
}
|
||||
setNBT(data);
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,10 @@ public class PlayerDataScript implements IScriptHandler {
|
||||
}
|
||||
}
|
||||
this.enabled = compound.getBoolean("ScriptEnabled");
|
||||
|
||||
for (ScriptContainer container : this.scripts) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
}
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setInteger("TotalScripts",this.scripts.size());
|
||||
|
||||
@@ -124,10 +124,6 @@ public class PlayerQuestData implements IPlayerQuestData {
|
||||
QuestInterface inter = data.quest.questInterface;
|
||||
if(inter.isCompleted(playerData)){
|
||||
if((!data.isCompleted && data.quest.completion == EnumQuestCompletion.Npc) || data.quest.instantComplete(player,data)){
|
||||
if (data.quest.completeText.isEmpty() && data.sendAlerts) {
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.MESSAGE, "quest.completed", data.quest.title);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.CHAT, "quest.completed",": ",data.quest.title);
|
||||
}
|
||||
data.isCompleted = true;
|
||||
if (data.quest.completion == EnumQuestCompletion.Npc) {
|
||||
EventHooks.onQuestFinished(player, data.quest);
|
||||
|
||||
@@ -18,7 +18,6 @@ import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
public class ItemNpcWand extends Item{
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ public abstract class MixinModelRenderer {
|
||||
}
|
||||
if (ClientEventHandler.renderingPlayer != null && Client.playerAnimations.containsKey(ClientEventHandler.renderingPlayer.getUniqueID())) {
|
||||
animData = Client.playerAnimations.get(ClientEventHandler.renderingPlayer.getUniqueID());
|
||||
EnumAnimationPart mainPartType = null;
|
||||
EnumAnimationPart mainPartType = this.getPlayerPartType((ModelRenderer) (Object) this);
|
||||
EnumAnimationPart pivotEqualPart = null;
|
||||
if (mainPartType == null) {
|
||||
pivotEqualPart = this.pivotEqualPart((ModelRenderer) (Object) this);
|
||||
|
||||
@@ -146,8 +146,11 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerQuestData playerdata = data.questData;
|
||||
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
|
||||
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
|
||||
return !killed.containsKey(this.entity) ? 0 : (Integer)killed.get(this.entity);
|
||||
if(questdata != null){
|
||||
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
|
||||
return !killed.containsKey(this.entity) ? 0 : (Integer)killed.get(this.entity);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
@@ -155,13 +158,15 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerQuestData playerdata = data.questData;
|
||||
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
|
||||
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
|
||||
if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) {
|
||||
killed.put(this.entity, progress);
|
||||
this.parent.setKilled(questdata, killed);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]);
|
||||
data.save();
|
||||
if(questdata != null){
|
||||
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
|
||||
if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) {
|
||||
killed.put(this.entity, progress);
|
||||
this.parent.setKilled(questdata, killed);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]);
|
||||
data.save();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]);
|
||||
|
||||
@@ -74,7 +74,7 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
public static final EventBus EVENT_BUS = new EventBus();
|
||||
private static AbstractNpcAPI instance = null;
|
||||
|
||||
public NpcAPI() {
|
||||
private NpcAPI() {
|
||||
}
|
||||
|
||||
public static void clearCache() {
|
||||
@@ -248,10 +248,14 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
}
|
||||
|
||||
public IBlock getIBlock(IWorld world, IPos pos) {
|
||||
return this.getIBlock(world, pos.getX(),pos.getY(),pos.getZ());
|
||||
return pos == null ? null : this.getIBlock(world, pos.getX(),pos.getY(),pos.getZ());
|
||||
}
|
||||
|
||||
public ITileEntity getITileEntity(IWorld world, IPos pos) {
|
||||
if (pos == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TileEntity tileEntity = world.getMCWorld().getTileEntity(pos.getX(), pos.getY(),pos.getZ());
|
||||
return this.getITileEntity(tileEntity);
|
||||
}
|
||||
@@ -282,11 +286,13 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
}
|
||||
|
||||
public IPos[] getAllInBox(IPos from, IPos to, boolean sortByDistance) {
|
||||
Iterator<BlockPos> posIterable = BlockPos.getAllInBox(from.getMCPos(),to.getMCPos()).iterator();
|
||||
ArrayList<IPos> list = new ArrayList<>();
|
||||
posIterable.forEachRemaining(BlockPos -> list.add(this.getIPos(BlockPos)));
|
||||
if (sortByDistance) {
|
||||
list.sort(Comparator.comparingDouble(pos -> pos.distanceTo(from)));
|
||||
if (from != null && to != null) {
|
||||
Iterator<BlockPos> posIterable = BlockPos.getAllInBox(from.getMCPos(),to.getMCPos()).iterator();
|
||||
posIterable.forEachRemaining(BlockPos -> list.add(this.getIPos(BlockPos)));
|
||||
if (sortByDistance) {
|
||||
list.sort(Comparator.comparingDouble(pos -> pos.distanceTo(from)));
|
||||
}
|
||||
}
|
||||
return list.toArray(new IPos[0]);
|
||||
}
|
||||
@@ -333,6 +339,9 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
}
|
||||
|
||||
public ICustomNpc<?> spawnNPC(IWorld world, IPos pos) {
|
||||
if (pos == null) {
|
||||
return null;
|
||||
}
|
||||
return this.spawnNPC(world, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockAir;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -15,6 +17,8 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntitySign;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
@@ -520,36 +524,229 @@ public class ScriptWorld implements IWorld {
|
||||
return this.isBreakCancelled(pos.getX(),pos.getY(),pos.getZ());
|
||||
}
|
||||
|
||||
public MovingObjectPosition func_147447_a(Vec3 startVec, Vec3 endVec, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision)
|
||||
{
|
||||
if (!Double.isNaN(startVec.xCoord) && !Double.isNaN(startVec.yCoord) && !Double.isNaN(startVec.zCoord))
|
||||
{
|
||||
if (!Double.isNaN(endVec.xCoord) && !Double.isNaN(endVec.yCoord) && !Double.isNaN(endVec.zCoord))
|
||||
{
|
||||
int endX = MathHelper.floor_double(endVec.xCoord);
|
||||
int endY = MathHelper.floor_double(endVec.yCoord);
|
||||
int endZ = MathHelper.floor_double(endVec.zCoord);
|
||||
int l = MathHelper.floor_double(startVec.xCoord);
|
||||
int i1 = MathHelper.floor_double(startVec.yCoord);
|
||||
int j1 = MathHelper.floor_double(startVec.zCoord);
|
||||
Block block = this.world.getBlock(l, i1, j1);
|
||||
int k1 = this.world.getBlockMetadata(l, i1, j1);
|
||||
|
||||
if (block.canCollideCheck(k1, false))
|
||||
{
|
||||
MovingObjectPosition movingobjectposition = block.collisionRayTrace(this.world, l, i1, j1, startVec, endVec);
|
||||
|
||||
if (movingobjectposition != null)
|
||||
{
|
||||
return movingobjectposition;
|
||||
}
|
||||
}
|
||||
|
||||
k1 = 200;
|
||||
|
||||
while (k1-- >= 0)
|
||||
{
|
||||
if (Double.isNaN(startVec.xCoord) || Double.isNaN(startVec.yCoord) || Double.isNaN(startVec.zCoord))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (l == endX && i1 == endY && j1 == endZ)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean flag6 = true;
|
||||
boolean flag3 = true;
|
||||
boolean flag4 = true;
|
||||
double d0 = 999.0D;
|
||||
double d1 = 999.0D;
|
||||
double d2 = 999.0D;
|
||||
|
||||
if (endX > l)
|
||||
{
|
||||
d0 = (double)l + 1.0D;
|
||||
}
|
||||
else if (endX < l)
|
||||
{
|
||||
d0 = (double)l + 0.0D;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag6 = false;
|
||||
}
|
||||
|
||||
if (endY > i1)
|
||||
{
|
||||
d1 = (double)i1 + 1.0D;
|
||||
}
|
||||
else if (endY < i1)
|
||||
{
|
||||
d1 = (double)i1 + 0.0D;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag3 = false;
|
||||
}
|
||||
|
||||
if (endZ > j1)
|
||||
{
|
||||
d2 = (double)j1 + 1.0D;
|
||||
}
|
||||
else if (endZ < j1)
|
||||
{
|
||||
d2 = (double)j1 + 0.0D;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag4 = false;
|
||||
}
|
||||
|
||||
double d3 = 999.0D;
|
||||
double d4 = 999.0D;
|
||||
double d5 = 999.0D;
|
||||
double d6 = endVec.xCoord - startVec.xCoord;
|
||||
double d7 = endVec.yCoord - startVec.yCoord;
|
||||
double d8 = endVec.zCoord - startVec.zCoord;
|
||||
|
||||
if (flag6)
|
||||
{
|
||||
d3 = (d0 - startVec.xCoord) / d6;
|
||||
}
|
||||
|
||||
if (flag3)
|
||||
{
|
||||
d4 = (d1 - startVec.yCoord) / d7;
|
||||
}
|
||||
|
||||
if (flag4)
|
||||
{
|
||||
d5 = (d2 - startVec.zCoord) / d8;
|
||||
}
|
||||
|
||||
byte b0;
|
||||
|
||||
if (d3 < d4 && d3 < d5)
|
||||
{
|
||||
if (endX > l)
|
||||
{
|
||||
b0 = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
b0 = 5;
|
||||
}
|
||||
|
||||
startVec.xCoord = d0;
|
||||
startVec.yCoord += d7 * d3;
|
||||
startVec.zCoord += d8 * d3;
|
||||
}
|
||||
else if (d4 < d5)
|
||||
{
|
||||
if (endY > i1)
|
||||
{
|
||||
b0 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
b0 = 1;
|
||||
}
|
||||
|
||||
startVec.xCoord += d6 * d4;
|
||||
startVec.yCoord = d1;
|
||||
startVec.zCoord += d8 * d4;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (endZ > j1)
|
||||
{
|
||||
b0 = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
b0 = 3;
|
||||
}
|
||||
|
||||
startVec.xCoord += d6 * d5;
|
||||
startVec.yCoord += d7 * d5;
|
||||
startVec.zCoord = d2;
|
||||
}
|
||||
|
||||
Vec3 vec32 = Vec3.createVectorHelper(startVec.xCoord, startVec.yCoord, startVec.zCoord);
|
||||
l = (int)(vec32.xCoord = (double)MathHelper.floor_double(startVec.xCoord));
|
||||
|
||||
if (b0 == 5)
|
||||
{
|
||||
--l;
|
||||
++vec32.xCoord;
|
||||
}
|
||||
|
||||
i1 = (int)(vec32.yCoord = (double)MathHelper.floor_double(startVec.yCoord));
|
||||
|
||||
if (b0 == 1)
|
||||
{
|
||||
--i1;
|
||||
++vec32.yCoord;
|
||||
}
|
||||
|
||||
j1 = (int)(vec32.zCoord = (double)MathHelper.floor_double(startVec.zCoord));
|
||||
|
||||
if (b0 == 3)
|
||||
{
|
||||
--j1;
|
||||
++vec32.zCoord;
|
||||
}
|
||||
|
||||
Block block1 = this.world.getBlock(l, i1, j1);
|
||||
int l1 = this.world.getBlockMetadata(l, i1, j1);
|
||||
|
||||
MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(this.world, l, i1, j1, startVec, endVec);
|
||||
if (movingobjectposition1 != null)
|
||||
{
|
||||
if (block1.canCollideCheck(l1, false) && stopOnBlock ||
|
||||
block1.getMaterial().isLiquid() && stopOnLiquid ||
|
||||
!(block1 instanceof BlockAir) && block1.getCollisionBoundingBoxFromPool(this.world,l,i1,j1) == null && !stopOnCollision)
|
||||
{
|
||||
return movingobjectposition1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
|
||||
if (startPos.length != 3 || lookVector.length != 3) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IPos pos;
|
||||
Vec3 currentPos = Vec3.createVectorHelper(startPos[0], startPos[1], startPos[2]); int rep = 0;
|
||||
Vec3 startVec = Vec3.createVectorHelper(startPos[0], startPos[1], startPos[2]);
|
||||
Vec3 endVec = startVec.addVector(lookVector[0]*maxDistance,lookVector[1]*maxDistance,lookVector[2]*maxDistance);
|
||||
|
||||
while (rep++ < maxDistance + 10) {
|
||||
currentPos = currentPos.addVector(lookVector[0], lookVector[1], lookVector[2]);
|
||||
pos = NpcAPI.Instance().getIPos(currentPos.xCoord, currentPos.yCoord, currentPos.zCoord);
|
||||
|
||||
IBlock block = getBlock((int)currentPos.xCoord, (int)currentPos.yCoord, (int)currentPos.zCoord);
|
||||
if (block != null && stopOnBlock) {
|
||||
if ((!stopOnLiquid || block.getMCBlock() instanceof BlockLiquid)
|
||||
&& (!stopOnCollision || block.canCollide()))
|
||||
return pos;
|
||||
}
|
||||
|
||||
double distance = Math.pow(
|
||||
Math.pow(currentPos.xCoord-startPos[0],2)
|
||||
+Math.pow(currentPos.yCoord-startPos[1],2)
|
||||
+Math.pow(currentPos.zCoord-startPos[2],2)
|
||||
, 0.5);
|
||||
if (distance > maxDistance) {
|
||||
return pos;
|
||||
}
|
||||
IPos endPos = NpcAPI.Instance().getIPos(endVec.xCoord,endVec.yCoord,endVec.zCoord);
|
||||
if (!stopOnBlock && !stopOnLiquid && !stopOnCollision) {
|
||||
return endPos;
|
||||
}
|
||||
|
||||
return null;
|
||||
MovingObjectPosition mob = this.func_147447_a(startVec,endVec,stopOnBlock,stopOnLiquid,stopOnCollision);
|
||||
return mob != null ? NpcAPI.Instance().getIPos(mob.blockX,mob.blockY,mob.blockZ) : endPos;
|
||||
}
|
||||
|
||||
public IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance) {
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package noppes.npcs.scripted.entity;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.IProjectile;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -12,9 +9,6 @@ import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> implements IDBCPlayer {
|
||||
public T player;
|
||||
|
||||
@@ -522,8 +516,9 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
|
||||
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState2");
|
||||
}
|
||||
|
||||
public double getFormMastery(String formTree, byte form) {
|
||||
public double getRacialFormMastery(byte form) {
|
||||
try {
|
||||
String formTree = this.getRacialTreeName();
|
||||
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) {
|
||||
String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted").
|
||||
getString("jrmcFormMastery" + formTree).split(";");
|
||||
@@ -534,8 +529,9 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
|
||||
return 0.0D;
|
||||
}
|
||||
|
||||
public void setFormMastery(String formTree, byte form, double value) {
|
||||
public void setRacialFormMastery(byte form, double value) {
|
||||
try {
|
||||
String formTree = this.getRacialTreeName();
|
||||
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) {
|
||||
String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted").
|
||||
getString("jrmcFormMastery" + formTree).split(";");
|
||||
@@ -558,8 +554,9 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
public void addFormMastery(String formTree, byte form, double value) {
|
||||
public void addRacialFormMastery(byte form, double value) {
|
||||
try {
|
||||
String formTree = this.getRacialTreeName();
|
||||
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) {
|
||||
String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted").
|
||||
getString("jrmcFormMastery" + formTree).split(";");
|
||||
@@ -583,6 +580,107 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
private String getRacialTreeName() {
|
||||
switch (this.getRace()) {
|
||||
case 0:
|
||||
return "Racial_Human";
|
||||
case 1:
|
||||
return "Racial_Saiyan";
|
||||
case 2:
|
||||
return "Racial_Half-Saiyan";
|
||||
case 3:
|
||||
return "Racial_Namekian";
|
||||
case 4:
|
||||
return "Racial_Arcosian";
|
||||
case 5:
|
||||
return "Racial_Majin";
|
||||
}
|
||||
return "Racial_Human";
|
||||
}
|
||||
|
||||
public double getOtherFormMastery(String formName) {
|
||||
try {
|
||||
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) {
|
||||
String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted").
|
||||
getString("jrmcFormMasteryNonRacial");
|
||||
if (!masteryData.contains(formName)) {
|
||||
return 0.0D;
|
||||
}
|
||||
|
||||
String[] formMasteries = masteryData.split(";");
|
||||
for (String masteryString : formMasteries) {
|
||||
if (masteryString.split(",")[0].equals(formName)) {
|
||||
return Double.parseDouble(masteryString.split(",")[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
return 0.0D;
|
||||
}
|
||||
|
||||
public void setOtherFormMastery(String formName, double value) {
|
||||
try {
|
||||
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) {
|
||||
String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted").
|
||||
getString("jrmcFormMasteryNonRacial");
|
||||
if (!masteryData.contains(formName)) {
|
||||
return;
|
||||
}
|
||||
String[] formMasteries = masteryData.split(";");
|
||||
|
||||
for (int i = 0; i < formMasteries.length; i++) {
|
||||
String name = formMasteries[i].split(",")[0];
|
||||
if (name.equals(formName)) {
|
||||
formMasteries[i] = name + "," + value;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder masteryString = new StringBuilder();
|
||||
for (int i = 0; i < formMasteries.length; i++) {
|
||||
masteryString.append(formMasteries[i]);
|
||||
if (i < formMasteries.length - 1) {
|
||||
masteryString.append(';');
|
||||
}
|
||||
}
|
||||
|
||||
player.getEntityData().getCompoundTag("PlayerPersisted").
|
||||
setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString));
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
public void addOtherFormMastery(String formName, double value) {
|
||||
try {
|
||||
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) {
|
||||
String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted").
|
||||
getString("jrmcFormMasteryNonRacial");
|
||||
if (!masteryData.contains(formName)) {
|
||||
return;
|
||||
}
|
||||
String[] formMasteries = masteryData.split(";");
|
||||
|
||||
for (int i = 0; i < formMasteries.length; i++) {
|
||||
String name = formMasteries[i].split(",")[0];
|
||||
if (name.equals(formName)) {
|
||||
double newMastery = Double.parseDouble(formMasteries[i].split(",")[1]) + value;
|
||||
formMasteries[i] = name + "," + newMastery;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder masteryString = new StringBuilder();
|
||||
for (int i = 0; i < formMasteries.length; i++) {
|
||||
masteryString.append(formMasteries[i]);
|
||||
if (i < formMasteries.length - 1) {
|
||||
masteryString.append(';');
|
||||
}
|
||||
}
|
||||
|
||||
player.getEntityData().getCompoundTag("PlayerPersisted").
|
||||
setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString));
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
public void setPowerPoints(int points){
|
||||
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcArcRsrv",points);
|
||||
}
|
||||
|
||||
@@ -162,11 +162,7 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
||||
}
|
||||
|
||||
public IBlock getLookingAtBlock(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
|
||||
Vec3 lookVec = entity.getLookVec();
|
||||
return getWorld().rayCastBlock(
|
||||
new double[] {entity.posX, entity.posY+entity.getEyeHeight(), entity.posZ},
|
||||
new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord},
|
||||
maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision);
|
||||
return NpcAPI.Instance().getIBlock(getWorld(),getLookingAtPos(maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision));
|
||||
}
|
||||
|
||||
public IBlock getLookingAtBlock(int maxDistance) {
|
||||
@@ -176,7 +172,7 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
||||
public IPos getLookingAtPos(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
|
||||
Vec3 lookVec = entity.getLookVec();
|
||||
return getWorld().rayCastPos(
|
||||
new double[] {entity.posX, entity.posY+entity.getEyeHeight(), entity.posZ},
|
||||
new double[] {entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ},
|
||||
new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord},
|
||||
maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
|
||||
public List<Integer> errored = new ArrayList();
|
||||
public String scriptLanguage = "ECMAScript";
|
||||
public boolean enabled = false;
|
||||
public long lastInited = -1L;
|
||||
public boolean loaded = false;
|
||||
|
||||
public boolean durabilityShow = false;
|
||||
@@ -43,11 +42,8 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
|
||||
public float rotationX, rotationY, rotationZ;
|
||||
public float rotationXRate, rotationYRate, rotationZRate;
|
||||
|
||||
public int width = -1, height = -1;
|
||||
|
||||
public ScriptCustomItem(ItemStack item) {
|
||||
super(item);
|
||||
loadScriptData();
|
||||
loadItemData();
|
||||
}
|
||||
|
||||
@@ -74,16 +70,12 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
|
||||
if (!this.loaded) {
|
||||
this.loadScriptData();
|
||||
this.loaded = true;
|
||||
if (type != EnumScriptType.INIT) {
|
||||
EventHooks.onScriptItemInit(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isEnabled()) {
|
||||
if (ScriptController.Instance.lastLoaded > this.lastInited) {
|
||||
this.lastInited = ScriptController.Instance.lastLoaded;
|
||||
if (type != EnumScriptType.INIT) {
|
||||
EventHooks.onScriptItemInit(this);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.scripts.size(); i++) {
|
||||
ScriptContainer script = this.scripts.get(i);
|
||||
if (!this.errored.contains(i)) {
|
||||
@@ -421,12 +413,18 @@ public class ScriptCustomItem extends ScriptItemStack implements IItemCustom, IS
|
||||
}
|
||||
|
||||
c.setTag("ScriptedData", this.getScriptNBT(new NBTTagCompound()));
|
||||
for (ScriptContainer container : this.scripts) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
}
|
||||
|
||||
public void loadScriptData() {
|
||||
NBTTagCompound c = this.item.getTagCompound();
|
||||
if (c != null) {
|
||||
this.setScriptNBT(c.getCompoundTag("ScriptedData"));
|
||||
for (ScriptContainer container : this.scripts) {
|
||||
container.setEngine(this.getLanguage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-9
@@ -1,17 +1,11 @@
|
||||
package noppes.npcs.util;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CustomNPCsScheduler {
|
||||
public class CustomNPCsThreader {
|
||||
private final static ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||
|
||||
public static void runTack(Runnable task, int delay){
|
||||
executor.schedule(task, delay, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public static void runTack(Runnable task){
|
||||
executor.schedule(task, 0, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
public static final Executor playerDataThread = Executors.newSingleThreadExecutor();
|
||||
}
|
||||
@@ -24,8 +24,8 @@ public class NBTJsonUtil {
|
||||
json = json.trim();
|
||||
JsonFile file = new JsonFile(json);
|
||||
if(!json.startsWith("{") || !json.endsWith("}"))
|
||||
throw new JsonException("Not properly incapsulated between { }", file);
|
||||
|
||||
throw new JsonException("Not properly encapsulated between { }", file);
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
FillCompound(compound, file);
|
||||
return compound;
|
||||
@@ -36,7 +36,7 @@ public class NBTJsonUtil {
|
||||
json.cut(1);
|
||||
if(json.startsWith("}"))
|
||||
return;
|
||||
int index = json.indexOf(":");
|
||||
int index = json.findObjectColonIndex();
|
||||
if(index < 1)
|
||||
throw new JsonException("Expected key after ," ,json);
|
||||
|
||||
@@ -85,6 +85,16 @@ public class NBTJsonUtil {
|
||||
if(!json.startsWith("]")){
|
||||
throw new JsonException("Expected ]", json);
|
||||
}
|
||||
|
||||
if (json.startsWith("]b")) {
|
||||
json.cut(2);
|
||||
byte[] arr = new byte[list.tagCount()];
|
||||
for(int i = 0; list.tagCount() > 0 ; i++){
|
||||
arr[i] = ((NBTTagInt)list.removeTag(0)).func_150290_f();
|
||||
}
|
||||
return new NBTTagByteArray(arr);
|
||||
}
|
||||
|
||||
json.cut(1);
|
||||
|
||||
if(list.func_150303_d() == 3){
|
||||
@@ -156,7 +166,19 @@ public class NBTJsonUtil {
|
||||
private static JsonLine ReadTag(String name, NBTBase base, List<JsonLine> list){
|
||||
if(!name.isEmpty())
|
||||
name = "\"" + name + "\": ";
|
||||
if(base.getId() == 8){//NBTTagString
|
||||
if (base.getId() == 7) {//NBTTagByteArray
|
||||
list.add(new JsonLine(name + "["));
|
||||
byte[] bytes = ((NBTTagByteArray) base).func_150292_c();
|
||||
|
||||
for(int i = 0; i < (bytes.length-1); i++) {
|
||||
list.add(new JsonLine(String.format("%s,", bytes[i])));
|
||||
}
|
||||
if (bytes.length > 0) {
|
||||
list.add(new JsonLine(String.format("%s", bytes[bytes.length-1])));
|
||||
}
|
||||
list.add(new JsonLine("]b"));
|
||||
}
|
||||
else if(base.getId() == 8){//NBTTagString
|
||||
String data = ((NBTTagString)base).func_150285_a_();
|
||||
data = data.replace("\"", "\\\""); //replace " with \"
|
||||
list.add(new JsonLine(name + "\"" + data + "\""));
|
||||
@@ -225,7 +247,8 @@ public class NBTJsonUtil {
|
||||
public boolean reduceTab(){
|
||||
int length = line.length();
|
||||
return length == 1 && (line.endsWith("}") || line.endsWith("]"))
|
||||
|| length == 2 && (line.endsWith("},") ||line.endsWith("],"));
|
||||
|| length == 2 && (line.endsWith("},") ||line.endsWith("],") || line.endsWith("]b"))
|
||||
|| length == 3 && (line.endsWith("]b,"));
|
||||
}
|
||||
|
||||
public boolean increaseTab(){
|
||||
@@ -283,6 +306,24 @@ public class NBTJsonUtil {
|
||||
return "Line: " + lines.length + ", Pos: " + pos + ", Text: " + line;
|
||||
}
|
||||
|
||||
public int findObjectColonIndex() {
|
||||
int trueQuotesAmount = 0;
|
||||
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (text.charAt(i) == '"') {
|
||||
if (i > 1 && text.charAt(i-1) != '\\' || i == 0) {
|
||||
trueQuotesAmount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (trueQuotesAmount == 2) {
|
||||
return text.indexOf(":", i);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean startsWith(String... ss) {
|
||||
for(String s : ss)
|
||||
if(text.startsWith(s))
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.client.gui.player.GuiFaction;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
public class InventoryTabFactions extends AbstractTab {
|
||||
public InventoryTabFactions() {
|
||||
@@ -16,10 +15,19 @@ public class InventoryTabFactions extends AbstractTab {
|
||||
|
||||
@Override
|
||||
public void onTabClicked() {
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.displayGuiScreen(new GuiFaction());
|
||||
}, 100);
|
||||
Thread t = new Thread(){
|
||||
@Override
|
||||
public void run(){
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.displayGuiScreen(new GuiFaction());
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,11 +3,8 @@ package tconstruct.client.tabs;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.play.client.C0DPacketCloseWindow;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.client.gui.player.GuiFaction;
|
||||
import noppes.npcs.client.gui.player.GuiQuestLog;
|
||||
import noppes.npcs.util.CustomNPCsScheduler;
|
||||
|
||||
public class InventoryTabQuests extends AbstractTab {
|
||||
public InventoryTabQuests() {
|
||||
@@ -19,10 +16,19 @@ public class InventoryTabQuests extends AbstractTab {
|
||||
|
||||
@Override
|
||||
public void onTabClicked() {
|
||||
CustomNPCsScheduler.runTack(() -> {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
|
||||
}, 100);
|
||||
Thread t = new Thread(){
|
||||
@Override
|
||||
public void run(){
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.displayGuiScreen(new GuiQuestLog(mc.thePlayer));
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -410,13 +410,13 @@ cloner.tagFilters=Tag Filters
|
||||
cloner.tagVisibility=Tag Visibility
|
||||
cloner.wandTags=Wand Tags
|
||||
cloner.npcTags=NPC Tags
|
||||
cloner.selectedTags=Selected Tags
|
||||
cloner.order=Sort Order
|
||||
cloner.ascending=Ascending
|
||||
cloner.descending=Descending
|
||||
cloner.type=Sort Type
|
||||
cloner.name=Name
|
||||
cloner.date=Date
|
||||
cloner.wandtags=Wand Tags
|
||||
cloner.wandtagsapplied=Wand Tags will be applied
|
||||
|
||||
tags.allTags=All Tags
|
||||
|
||||
Reference in new issue
Block a user