Merge branch 'dev'
No files matched your search
@@ -17,7 +17,7 @@ buildscript {
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "1.6-beta2"
|
||||
version = "1.6"
|
||||
group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "CustomNPC-Plus"
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.block.BlockVine;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -29,9 +30,11 @@ import noppes.npcs.entity.old.*;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.6-beta2")
|
||||
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.6")
|
||||
public class CustomNpcs {
|
||||
|
||||
@ConfigProp(info = "Disable Chat Bubbles")
|
||||
@@ -51,6 +54,11 @@ public class CustomNpcs {
|
||||
@ConfigProp(info = "Enables global NPC scripts to be used in the scripter. You can still see and write code in the scripter, but these scripts won't run. False by default, use with caution!")
|
||||
public static boolean GlobalNPCScripts = false;
|
||||
|
||||
@ConfigProp(info = "If scripts are too long (>65535 characters), they normally won't be saved in NBT data.\n" +
|
||||
"This config adds additional compound tags to scripts that need it, so you can store much larger scripts!\n" +
|
||||
"Every additional compound tag adds 65535 more characters to your script length limit. Use incrementally, with caution.")
|
||||
public static int ExpandedScriptLimit = 2;
|
||||
|
||||
@ConfigProp(info = "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server. Minimum of 16, maximum of 96.")
|
||||
public static int NpcNavRange = 32;
|
||||
|
||||
@@ -91,6 +99,16 @@ public class CustomNpcs {
|
||||
|
||||
@ConfigProp(info = "Only ops can create and edit npcs")
|
||||
public static boolean OpsOnly = false;
|
||||
|
||||
@ConfigProp(info = "Only ops can see and edit scripts")
|
||||
public static boolean ScriptOpsOnly = false;
|
||||
|
||||
@ConfigProp(info = "Comma separated list of player UUIDs that can see and edit scripts. If ScriptsOpsOnly is true,\n" +
|
||||
"ops and players with these IDs can see and edit scripts. Example:\n" +
|
||||
"b876ec32-e396-476b-a115-8438d83c67d4,069a79f4-44e9-4726-a5be-fca90e38aaf5,be951074-c7ea-4f02-a725-bf017bc88650\n" +
|
||||
"Get a player's UUID from a site like NameMC or the API IPlayer.getUniqueID() function!\n" +
|
||||
"If left empty and ScriptsOpsOnly is false, anyone can see and edit scripts with a scripter.")
|
||||
public static String ScriptDevIDs = "";
|
||||
|
||||
@ConfigProp(info = "Default interact line. Leave empty to not have one")
|
||||
public static String DefaultInteractLine = "Hello @p";
|
||||
@@ -146,6 +164,8 @@ public class CustomNpcs {
|
||||
|
||||
public static ConfigLoader Config;
|
||||
|
||||
public static ArrayList<UUID> ScriptDevs = new ArrayList<>();
|
||||
|
||||
public static final MarkovGenerator[] MARKOV_GENERATOR = new MarkovGenerator[10];
|
||||
|
||||
public CustomNpcs() {
|
||||
@@ -170,6 +190,14 @@ public class CustomNpcs {
|
||||
Config = new ConfigLoader(this.getClass(), new File(dir, "config"), "CustomNpcs");
|
||||
Config.loadConfig();
|
||||
|
||||
try {
|
||||
ScriptDevs.clear();
|
||||
String[] uuidStrings = ScriptDevIDs.split(";");
|
||||
for (String s : uuidStrings) {
|
||||
ScriptDevs.add(UUID.fromString(s));
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
if (NpcNavRange < 16) {
|
||||
NpcNavRange = 16;
|
||||
}
|
||||
@@ -193,6 +221,9 @@ public class CustomNpcs {
|
||||
if (TrackingInfoAlignment > 8)
|
||||
TrackingInfoAlignment = 8;
|
||||
|
||||
if (ExpandedScriptLimit < 0)
|
||||
ExpandedScriptLimit = 0;
|
||||
|
||||
EnchantInterface.load();
|
||||
CustomItems.load();
|
||||
|
||||
@@ -379,4 +410,11 @@ public class CustomNpcs {
|
||||
public static MinecraftServer getServer(){
|
||||
return MinecraftServer.getServer();
|
||||
}
|
||||
|
||||
public static boolean isScriptDev(EntityPlayer player) {
|
||||
if(CustomNpcs.ScriptOpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile()) ||
|
||||
ScriptDevs.contains(player.getUniqueID())){
|
||||
return true;
|
||||
} else return ScriptDevIDs.isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -351,6 +351,11 @@ public class EventHooks {
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onPlayerAttacked(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.AttackedEvent event) {
|
||||
handler.callScript(EnumScriptType.ATTACKED, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onPlayerDamaged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.DamagedEvent event) {
|
||||
handler.callScript(EnumScriptType.DAMAGED, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
@@ -431,6 +436,11 @@ public class EventHooks {
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onPlayerAttack(PlayerDataScript handler, PlayerEvent.AttackEvent event) {
|
||||
handler.callScript(EnumScriptType.ATTACK, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static boolean onPlayerDamagedEntity(PlayerDataScript handler, DamagedEntityEvent event) {
|
||||
handler.callScript(EnumScriptType.DAMAGED_ENTITY, event);
|
||||
return NpcAPI.EVENT_BUS.post(event);
|
||||
@@ -442,9 +452,9 @@ public class EventHooks {
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown) {
|
||||
public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, int[] heldKeys) {
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((IPlayer)NpcAPI.Instance().getIEntity(player), button, mouseWheel, buttonDown);
|
||||
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((IPlayer)NpcAPI.Instance().getIEntity(player), button, mouseWheel, buttonDown, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, heldKeys);
|
||||
handler.callScript(EnumScriptType.MOUSE_CLICKED, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
@@ -33,10 +33,12 @@ import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleFollower;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import noppes.npcs.scripted.ScriptSound;
|
||||
import noppes.npcs.scripted.event.DialogEvent;
|
||||
import noppes.npcs.scripted.event.QuestEvent;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IQuestObjective;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ISound;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
|
||||
@@ -482,4 +484,27 @@ public class NoppesUtilPlayer {
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void playSoundTo(EntityPlayerMP player, int id, ScriptSound sound) {
|
||||
NBTTagCompound compound = sound.writeToNBT();
|
||||
if (sound.sourceEntity == null || player.worldObj.provider.dimensionId == sound.sourceEntity.getDimension()) {
|
||||
Server.sendData(player, EnumPacketClient.PLAY_SOUND_TO, id, compound);
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopSoundFor(EntityPlayerMP player, int id) {
|
||||
Server.sendData(player, EnumPacketClient.STOP_SOUND_FOR, id);
|
||||
}
|
||||
|
||||
public static void pauseSoundsFor(EntityPlayerMP player) {
|
||||
Server.sendData(player, EnumPacketClient.PAUSE_SOUNDS);
|
||||
}
|
||||
|
||||
public static void continueSoundsFor(EntityPlayerMP player) {
|
||||
Server.sendData(player, EnumPacketClient.CONTINUE_SOUNDS);
|
||||
}
|
||||
|
||||
public static void stopSoundsFor(EntityPlayerMP player) {
|
||||
Server.sendData(player, EnumPacketClient.STOP_SOUNDS);
|
||||
}
|
||||
}
|
||||
@@ -71,6 +71,7 @@ import noppes.npcs.entity.EntityDialogNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleTransporter;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptSound;
|
||||
import noppes.npcs.scripted.event.DialogEvent;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
|
||||
@@ -324,6 +325,41 @@ public class NoppesUtilServer {
|
||||
}
|
||||
}
|
||||
|
||||
public static void playSound(int id, ScriptSound sound) {
|
||||
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
for (EntityPlayer player : list) {
|
||||
NoppesUtilPlayer.playSoundTo((EntityPlayerMP) player, id, sound);
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopSound(int id) {
|
||||
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
for (EntityPlayer player : list) {
|
||||
NoppesUtilPlayer.stopSoundFor((EntityPlayerMP) player, id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void pauseSounds() {
|
||||
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
for (EntityPlayer player : list) {
|
||||
NoppesUtilPlayer.pauseSoundsFor((EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void continueSounds() {
|
||||
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
for (EntityPlayer player : list) {
|
||||
NoppesUtilPlayer.continueSoundsFor((EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopSounds() {
|
||||
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
for (EntityPlayer player : list) {
|
||||
NoppesUtilPlayer.stopSoundsFor((EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteNpc(EntityNPCInterface npc,EntityPlayer player) {
|
||||
Server.sendAssociatedData(npc, EnumPacketClient.DELETE_NPC, npc.getEntityId());
|
||||
}
|
||||
@@ -636,9 +672,29 @@ public class NoppesUtilServer {
|
||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE, i, comp);
|
||||
}
|
||||
|
||||
public static Entity spawnClone(NBTTagCompound compound, int x, int y,
|
||||
public static Entity spawnCloneWithProtection(NBTTagCompound compound, int x, int y,
|
||||
int z, World worldObj) {
|
||||
ServerCloneController.Instance.cleanTags(compound);
|
||||
compound.setTag("Pos", NBTTags.nbtDoubleList(x + 0.5, y, z + 0.5));
|
||||
Entity entity = EntityList.createEntityFromNBT(compound, worldObj);
|
||||
if(entity == null){
|
||||
return null;
|
||||
}
|
||||
entity.setPosition((double) x + 0.5, (double) y, (double) z + 0.5);
|
||||
if(entity instanceof EntityNPCInterface){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
npc.ai.startPos = new int[]{MathHelper.floor_double(npc.posX),MathHelper.floor_double(npc.posY),MathHelper.floor_double(npc.posZ)};
|
||||
npc.ticksExisted = 0;
|
||||
npc.totalTicksAlive = 0;
|
||||
}
|
||||
worldObj.spawnEntityInWorld(entity);
|
||||
entity.prevPosY = entity.lastTickPosY = entity.posY = y + 1;
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static Entity spawnClone(NBTTagCompound compound, int x, int y,
|
||||
int z, World worldObj) {
|
||||
ServerCloneController.Instance.cleanTags(compound);
|
||||
compound.setTag("Pos", NBTTags.nbtDoubleList(x + 0.5, y + 1, z + 0.5));
|
||||
Entity entity = EntityList.createEntityFromNBT(compound, worldObj);
|
||||
if(entity == null){
|
||||
@@ -653,6 +709,7 @@ public class NoppesUtilServer {
|
||||
worldObj.spawnEntityInWorld(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public static boolean isOp(EntityPlayer player) {
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile());
|
||||
}
|
||||
|
||||
@@ -94,7 +94,33 @@ public class PacketHandlerPlayer{
|
||||
return;
|
||||
}
|
||||
|
||||
EventHooks.onPlayerMouseClicked(player, buffer.readInt(), buffer.readInt(), buffer.readBoolean());
|
||||
int button = buffer.readInt();
|
||||
int mouseWheel = buffer.readInt();
|
||||
boolean buttonDown = buffer.readBoolean();
|
||||
|
||||
boolean isCtrlPressed = buffer.readBoolean();
|
||||
boolean isShiftPressed = buffer.readBoolean();
|
||||
boolean isAltPressed = buffer.readBoolean();
|
||||
boolean isMetaPressed = buffer.readBoolean();
|
||||
|
||||
String ints = Server.readString(buffer);
|
||||
String[] split = ints.split(",");
|
||||
int[] keysDown;
|
||||
|
||||
if(ints.length() > 0) {
|
||||
keysDown = new int[split.length];
|
||||
try {
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
keysDown[i] = Integer.parseInt(split[i]);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ignored){
|
||||
}
|
||||
} else {
|
||||
keysDown = new int[0];
|
||||
}
|
||||
|
||||
EventHooks.onPlayerMouseClicked(player, button, mouseWheel, buttonDown, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, keysDown);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.FollowerHire){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
|
||||
@@ -102,7 +102,7 @@ public class PacketHandlerServer{
|
||||
if(type.needsNpc && npc == null){
|
||||
|
||||
}
|
||||
else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){
|
||||
else if(type.hasPermission() && !CustomNpcsPermissions.hasPermission(player, type.permission)){
|
||||
//player doesnt have permission to do this
|
||||
}
|
||||
else if(item == null && (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave || type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave || type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave))
|
||||
@@ -119,20 +119,22 @@ public class PacketHandlerServer{
|
||||
clonePackets(type, buffer, player);
|
||||
else if (item.getItem() == CustomItems.teleporter)
|
||||
featherPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
|
||||
playerScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave)
|
||||
npcScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
|
||||
forgeScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptItemDataGet || type == EnumPacketServer.ScriptItemDataSave)
|
||||
itemScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptGlobalGuiDataGet || type == EnumPacketServer.ScriptGlobalGuiDataSave)
|
||||
getScriptsEnabled(type, buffer, player);
|
||||
else if (item.getItem() == CustomItems.scripter)
|
||||
scriptPackets(type, buffer, player, npc);
|
||||
else if (item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock))
|
||||
blockPackets(type, buffer, player);
|
||||
else if (CustomNpcs.isScriptDev(player)) {
|
||||
if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
|
||||
playerScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptNPCGet || type == EnumPacketServer.ScriptNPCSave)
|
||||
npcScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptForgeGet || type == EnumPacketServer.ScriptForgeSave)
|
||||
forgeScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptItemDataGet || type == EnumPacketServer.ScriptItemDataSave)
|
||||
itemScriptPackets(type, buffer, player);
|
||||
else if (type == EnumPacketServer.ScriptGlobalGuiDataGet || type == EnumPacketServer.ScriptGlobalGuiDataSave)
|
||||
getScriptsEnabled(type, buffer, player);
|
||||
else if (item.getItem() == CustomItems.scripter)
|
||||
scriptPackets(type, buffer, player, npc);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -22,10 +22,7 @@ import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
|
||||
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
|
||||
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.living.*;
|
||||
import net.minecraftforge.event.entity.player.*;
|
||||
import net.minecraftforge.event.world.*;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
@@ -394,6 +391,26 @@ public class ScriptPlayerEventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(LivingAttackEvent event) {
|
||||
if(event.entityLiving == null || event.entityLiving.worldObj == null)
|
||||
return;
|
||||
|
||||
if(event.entityLiving.worldObj instanceof WorldServer) {
|
||||
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
if(event.entityLiving instanceof EntityPlayer) {
|
||||
noppes.npcs.scripted.event.PlayerEvent.AttackedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.AttackedEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source);
|
||||
event.setCanceled(EventHooks.onPlayerAttacked(handler, pevent));
|
||||
}
|
||||
|
||||
if(source instanceof EntityPlayer) {
|
||||
noppes.npcs.scripted.event.PlayerEvent.AttackEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.AttackEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source);
|
||||
event.setCanceled(EventHooks.onPlayerAttack(handler, pevent1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(LivingHurtEvent event) {
|
||||
if(event.entityLiving == null || event.entityLiving.worldObj == null)
|
||||
|
||||
@@ -19,17 +19,11 @@ public class VersionCompatibility {
|
||||
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
|
||||
if(npc.npcVersion == ModRev)
|
||||
return;
|
||||
if(npc.npcVersion < 19){
|
||||
// Fix 64-Textures
|
||||
String texture = compound.getString("Texture");
|
||||
texture = texture.replace("64-Textures/", "");
|
||||
compound.setString("Texture", texture);
|
||||
|
||||
if(npc.npcVersion < 19) {
|
||||
if (compound.hasKey("CanDrown")) {
|
||||
compound.setInteger("DrowningType", (compound.getBoolean("CanDrown") ? 1 : 0));
|
||||
compound.removeTag("CanDrown");
|
||||
}
|
||||
|
||||
}
|
||||
if(npc.npcVersion < 18){
|
||||
// Fix CloakTexture (Reorganization)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.constants.EnumMovingType;
|
||||
@@ -34,13 +33,9 @@ public class EntityAIReturn extends EntityAIBase
|
||||
return false;
|
||||
}
|
||||
|
||||
if (npc.getNavigator().noPath() || (!npc.isAttacking() && wasAttacked)){
|
||||
return true;
|
||||
if(npc.hasOwner() || npc.isKilled() || npc.isInteracting()){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(npc.hasOwner() || npc.isKilled() || npc.isInteracting()){
|
||||
return false;
|
||||
}
|
||||
|
||||
if (npc.ai.findShelter == 0 && (!npc.worldObj.isDaytime() || npc.worldObj.isRaining()) && !npc.worldObj.provider.hasNoSky){
|
||||
if (npc.worldObj.canBlockSeeTheSky((int)npc.getStartXPos(), (int)npc.getStartYPos(), (int)npc.getStartZPos()) || npc.worldObj.getFullBlockLightValue((int)npc.getStartXPos(), (int)npc.getStartYPos(), (int)npc.getStartZPos()) <= 8){
|
||||
@@ -63,7 +58,11 @@ public class EntityAIReturn extends EntityAIBase
|
||||
|
||||
if(npc.ai.movingType == EnumMovingType.MovingPath && npc.ai.getDistanceSqToPathPoint() < CustomNpcs.NpcNavRange * CustomNpcs.NpcNavRange)
|
||||
return false;
|
||||
|
||||
|
||||
if (npc.getNavigator().noPath() || (!npc.isAttacking() && wasAttacked)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(npc.ai.movingType == EnumMovingType.Wandering)
|
||||
return this.npc.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos()) > npc.ai.walkingRange * npc.ai.walkingRange;
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@ import noppes.npcs.client.renderer.blocks.BlockWeaponRackRenderer;
|
||||
import noppes.npcs.config.StringCache;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.containers.*;
|
||||
import noppes.npcs.client.controllers.ScriptSoundController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.entity.*;
|
||||
|
||||
@@ -158,6 +159,7 @@ public class ClientProxy extends CommonProxy {
|
||||
CustomNpcs.Channel.register(new PacketHandlerClient());
|
||||
CustomNpcs.ChannelPlayer.register(new PacketHandlerPlayer());
|
||||
new MusicController();
|
||||
new ScriptSoundController();
|
||||
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityNpcPony.class, new RenderNPCPony());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityNpcCrystal.class, new RenderNpcCrystal(new ModelNpcCrystal(0.5F)));
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.client.controllers.MusicController;
|
||||
import noppes.npcs.client.controllers.ScriptSoundController;
|
||||
import noppes.npcs.client.gui.player.GuiQuestLog;
|
||||
import noppes.npcs.client.renderer.RenderNPCInterface;
|
||||
import noppes.npcs.constants.EnumPlayerPacket;
|
||||
@@ -43,14 +44,30 @@ public class ClientTickHandler{
|
||||
prevWorld = mc.theWorld;
|
||||
MusicController.Instance.stopMusic();
|
||||
}
|
||||
ScriptSoundController.Instance.onUpdate();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMouse(InputEvent.MouseInputEvent event){
|
||||
if(Mouse.getEventButton() == -1 && Mouse.getDWheel() == 0)
|
||||
if(Mouse.getEventButton() == -1 && Mouse.getEventDWheel() == 0)
|
||||
return;
|
||||
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.MouseClicked, new Object[]{Mouse.getEventButton(),Mouse.getEventDWheel(),Mouse.isButtonDown(Mouse.getEventButton())});
|
||||
boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29);
|
||||
boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42);
|
||||
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
|
||||
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
|
||||
|
||||
StringBuilder keysDownString = new StringBuilder();
|
||||
for (int i = 0; i < Keyboard.getKeyCount(); i++) {//Creates a comma separated string of the integer IDs of held keys
|
||||
if (Keyboard.isKeyDown(i)) {
|
||||
keysDownString.append(Integer.valueOf(i)).append(",");
|
||||
}
|
||||
}
|
||||
if (keysDownString.length() > 0) {//Removes last comma for later parsing
|
||||
keysDownString.deleteCharAt(keysDownString.length() - 1);
|
||||
}
|
||||
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.MouseClicked, Mouse.getEventButton(),Mouse.getEventDWheel(),Mouse.isButtonDown(Mouse.getEventButton()), isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, keysDownString.toString());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -81,7 +98,7 @@ public class ClientTickHandler{
|
||||
keysDownString.deleteCharAt(keysDownString.length() - 1);
|
||||
}
|
||||
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown), keysDownString.toString()});
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, key, isCtrlPressed, isShiftPressed, isAltPressed, isMetaPressed, keyDown, keysDownString.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ import noppes.npcs.Server;
|
||||
import noppes.npcs.ServerEventsHandler;
|
||||
import noppes.npcs.client.ClientProxy.FontContainer;
|
||||
import noppes.npcs.client.controllers.MusicController;
|
||||
import noppes.npcs.client.controllers.ScriptClientSound;
|
||||
import noppes.npcs.client.controllers.ScriptSoundController;
|
||||
import noppes.npcs.client.gui.GuiNpcMobSpawnerAdd;
|
||||
import noppes.npcs.client.gui.OverlayQuestTracking;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
@@ -305,5 +307,25 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
else if(type == EnumPacketClient.PLAY_SOUND_TO) {
|
||||
int id = buffer.readInt();
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
ScriptClientSound sound = ScriptClientSound.fromScriptSound(compound, player.worldObj);
|
||||
|
||||
ScriptSoundController.Instance.playSound(id,sound);
|
||||
}
|
||||
else if(type == EnumPacketClient.STOP_SOUND_FOR) {
|
||||
int id = buffer.readInt();
|
||||
ScriptSoundController.Instance.stopSound(id);
|
||||
}
|
||||
else if(type == EnumPacketClient.PAUSE_SOUNDS) {
|
||||
ScriptSoundController.Instance.pauseAllSounds();
|
||||
}
|
||||
else if(type == EnumPacketClient.CONTINUE_SOUNDS) {
|
||||
ScriptSoundController.Instance.continueAllSounds();
|
||||
}
|
||||
else if(type == EnumPacketClient.STOP_SOUNDS) {
|
||||
ScriptSoundController.Instance.stopAllSounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package noppes.npcs.client.controllers;
|
||||
|
||||
import net.minecraft.client.audio.ITickableSound;
|
||||
import net.minecraft.client.audio.MovingSound;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.scripted.ScriptSound;
|
||||
|
||||
public class ScriptClientSound extends MovingSound implements ITickableSound {
|
||||
private Entity entity;
|
||||
public boolean paused;
|
||||
|
||||
protected ScriptClientSound(ResourceLocation location) {
|
||||
super(location);
|
||||
}
|
||||
|
||||
public static ScriptClientSound fromScriptSound(NBTTagCompound compound, World world) {
|
||||
ScriptSound sound = ScriptSound.fromNBT(compound);
|
||||
ScriptClientSound clientSound = new ScriptClientSound(new ResourceLocation(sound.directory));
|
||||
clientSound.xPosF = sound.xPosF;
|
||||
clientSound.yPosF = sound.yPosF;
|
||||
clientSound.zPosF = sound.zPosF;
|
||||
clientSound.volume = sound.volume;
|
||||
clientSound.field_147663_c = sound.pitch;
|
||||
clientSound.repeat = sound.repeat;
|
||||
clientSound.field_147665_h = sound.repeatDelay;
|
||||
if (compound.hasKey("EntityID")) {
|
||||
clientSound.entity = world.getEntityByID(compound.getInteger("EntityID"));
|
||||
clientSound.field_147666_i = AttenuationType.NONE;
|
||||
}
|
||||
return clientSound;
|
||||
}
|
||||
|
||||
public void stopSound() {
|
||||
this.repeat = false;
|
||||
this.volume = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (entity != null) {
|
||||
if (this.entity.isDead) {
|
||||
this.donePlaying = true;
|
||||
} else {
|
||||
this.xPosF = (float) (this.entity.posX);
|
||||
this.yPosF = (float) (this.entity.posY);
|
||||
this.zPosF = (float) (this.entity.posZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package noppes.npcs.client.controllers;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.SoundHandler;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ScriptSoundController {
|
||||
public HashMap<Integer, ScriptClientSound> sounds = new HashMap<>();
|
||||
public static ScriptSoundController Instance;
|
||||
|
||||
public ScriptSoundController() {
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
|
||||
final Set<Map.Entry<Integer, ScriptClientSound>> entrySet = sounds.entrySet();
|
||||
for (Map.Entry<Integer, ScriptClientSound> entry : entrySet) {
|
||||
ScriptClientSound sound = entry.getValue();
|
||||
if (!soundHandler.isSoundPlaying(sound) && !sound.canRepeat() && !sound.paused) {
|
||||
sounds.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void playSound(int id, ScriptClientSound sound) {
|
||||
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
|
||||
if (sounds.containsKey(id)) {
|
||||
soundHandler.stopSound(sound);
|
||||
sounds.get(id).stopSound();
|
||||
}
|
||||
sounds.put(id,sound);
|
||||
soundHandler.playSound(sound);
|
||||
}
|
||||
|
||||
public void stopSound(int id) {
|
||||
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
|
||||
if (sounds.containsKey(id)) {
|
||||
soundHandler.stopSound(sounds.get(id));
|
||||
sounds.get(id).stopSound();
|
||||
sounds.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
public void pauseAllSounds() {
|
||||
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
|
||||
soundHandler.pauseSounds();
|
||||
for (ScriptClientSound sound : sounds.values()) {
|
||||
sound.paused = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void continueAllSounds() {
|
||||
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
|
||||
soundHandler.resumeSounds();
|
||||
for (ScriptClientSound sound : sounds.values()) {
|
||||
sound.paused = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void stopAllSounds() {
|
||||
SoundHandler soundHandler = Minecraft.getMinecraft().getSoundHandler();
|
||||
soundHandler.stopSounds();
|
||||
sounds.clear();
|
||||
}
|
||||
}
|
||||
@@ -314,12 +314,22 @@ public class CustomFX extends EntityFX {
|
||||
} else {
|
||||
tessellator.setBrightness(240);
|
||||
}
|
||||
|
||||
float textureXScale = 1.0F, textureYScale = 1.0F;
|
||||
if (totalWidth > totalHeight) {
|
||||
textureYScale = (float) totalHeight/totalWidth;
|
||||
GL11.glScalef(1/textureYScale/2,1/textureYScale/2,1/textureYScale/2);
|
||||
} else if(totalHeight > totalWidth) {
|
||||
textureXScale = (float) totalWidth/totalHeight;
|
||||
GL11.glScalef(1/textureXScale/2,1/textureXScale/2,1/textureXScale/2);
|
||||
}
|
||||
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
|
||||
tessellator.addVertexWithUV( (u2-u1)/2, 0, (v2-v1)/2, u2, v2);
|
||||
tessellator.addVertexWithUV( (u2-u1)/2, 0, -(v2-v1)/2, u2, v1);
|
||||
tessellator.addVertexWithUV( -(u2-u1)/2, 0, -(v2-v1)/2, u1, v1);
|
||||
tessellator.addVertexWithUV( -(u2-u1)/2, 0, (v2-v1)/2, u1, v2);
|
||||
tessellator.addVertexWithUV( textureXScale * (u2-u1)/2, 0, textureYScale * (v2-v1)/2, u2, v2);
|
||||
tessellator.addVertexWithUV( textureXScale * (u2-u1)/2, 0, textureYScale * -(v2-v1)/2, u2, v1);
|
||||
tessellator.addVertexWithUV( textureXScale * -(u2-u1)/2, 0, textureYScale * -(v2-v1)/2, u1, v1);
|
||||
tessellator.addVertexWithUV( textureXScale * -(u2-u1)/2, 0, textureYScale * (v2-v1)/2, u1, v2);
|
||||
tessellator.draw();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -90,8 +90,6 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
|
||||
}
|
||||
|
||||
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
|
||||
//GL11.func_179094_E();
|
||||
//GL11.func_179109_b(0.0F, 0.0F, (float)this.id);
|
||||
GL11.glPushMatrix();
|
||||
float red = (color >> 16 & 255) / 255f;
|
||||
float green = (color >> 8 & 255) / 255f;
|
||||
@@ -131,11 +129,12 @@ public class CustomGuiButton extends GuiButton implements IClickListener {
|
||||
//GL11.func_187401_a(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, this.textureX, this.textureY + i * this.height, this.width, this.height);
|
||||
this.drawCenteredString(fontRenderer, this.label, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, this.color);
|
||||
if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) {
|
||||
this.parent.hoverText = this.hoverText;
|
||||
}
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if (this.field_146123_n && this.hoverText != null && this.hoverText.length > 0) {
|
||||
this.parent.hoverText = this.hoverText;
|
||||
}
|
||||
}
|
||||
|
||||
public ICustomGuiComponent toComponent() {
|
||||
|
||||
@@ -116,7 +116,10 @@ public class CustomGuiLabel extends Gui implements IGuiComponent {
|
||||
|
||||
public void onRender(Minecraft mc, int mouseX, int mouseY, int mouseWheel, float partialTicks) {
|
||||
boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.field_146167_a && mouseY < this.y + this.field_146161_f;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0F,0.0F,(float)this.id);
|
||||
this.drawLabel();
|
||||
GL11.glPopMatrix();
|
||||
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
|
||||
this.parent.hoverText = this.hoverText;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class CustomGuiLine extends Gui implements IGuiComponent {
|
||||
float blue = (color & 255) / 255f;
|
||||
GL11.glColor4f(red,green,blue,this.alpha);
|
||||
|
||||
GL11.glTranslatef(GuiCustom.guiLeft+this.x1,GuiCustom.guiTop+this.y1,0.0F);
|
||||
GL11.glTranslatef(GuiCustom.guiLeft+this.x1,GuiCustom.guiTop+this.y1,(float)this.id);
|
||||
GL11.glRotated(-Math.toDegrees(Math.atan2(x2-x1,y2-y1)),0.0F,0.0F,1.0F);
|
||||
GL11.glRotated(rotation,0.0D,0.0D,1.0D);
|
||||
GL11.glScaled(thickness, distance,0.0D);
|
||||
|
||||
@@ -23,17 +23,10 @@ import org.lwjgl.opengl.GL11;
|
||||
public class CustomGuiScrollComponent extends GuiCustomScroll implements IDataHolder, IClickListener {
|
||||
GuiCustom parent;
|
||||
String[] hoverText;
|
||||
public boolean multiSelect = false;
|
||||
|
||||
public boolean multiSelect;
|
||||
int color;
|
||||
float alpha;
|
||||
|
||||
public CustomGuiScrollComponent(Minecraft mc, GuiScreen parent, int id) {
|
||||
super(parent, id);
|
||||
this.mc = mc;
|
||||
this.fontRendererObj = mc.fontRenderer;
|
||||
}
|
||||
|
||||
public CustomGuiScrollComponent(Minecraft mc, GuiScreen parent, int id, boolean multiSelect) {
|
||||
super(parent, id, multiSelect);
|
||||
this.mc = mc;
|
||||
|
||||
@@ -40,7 +40,10 @@ public class CustomGuiTextField extends GuiTextField implements IKeyListener, ID
|
||||
float green = (color >> 8 & 255) / 255f;
|
||||
float blue = (color & 255) / 255f;
|
||||
GL11.glColor4f(red,green,blue,this.alpha);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.0F,0.0F,(float)this.id);
|
||||
this.drawTextBox();
|
||||
GL11.glPopMatrix();
|
||||
GL11.glColor4f(1.0F,1.0F,1.0F,1.0F);
|
||||
if (hovered && this.hoverText != null && this.hoverText.length > 0) {
|
||||
this.parent.hoverText = this.hoverText;
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.client.gui.Gui;
|
||||
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.client.ImageDownloadAlt;
|
||||
import noppes.npcs.client.gui.custom.GuiCustom;
|
||||
@@ -19,9 +20,14 @@ import noppes.npcs.scripted.gui.ScriptGuiTexturedRect;
|
||||
import noppes.npcs.scripted.interfaces.gui.ICustomGuiComponent;
|
||||
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 texture;
|
||||
ResourceLocation location;
|
||||
int id;
|
||||
int x;
|
||||
int y;
|
||||
@@ -36,14 +42,19 @@ 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);
|
||||
}
|
||||
|
||||
public CustomGuiTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
|
||||
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.texture = new ResourceLocation(texture);
|
||||
this.location = new ResourceLocation(directory);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
@@ -51,10 +62,17 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
||||
this.textureX = textureX;
|
||||
this.textureY = textureY;
|
||||
|
||||
if(texture.startsWith("https://")){
|
||||
if(directory.startsWith("https://")){
|
||||
this.isUrl = true;
|
||||
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.texture, object);
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +86,16 @@ 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.texture);
|
||||
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(imageDownloadAlt != null && isUrl && !gotWidthHeight){
|
||||
getURLWidthHeight();
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
float red = (color >> 16 & 255) / 255f;
|
||||
@@ -76,27 +103,18 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
||||
float blue = (color & 255) / 255f;
|
||||
GL11.glColor4f(red,green,blue,this.alpha);
|
||||
|
||||
GL11.glTranslatef(GuiCustom.guiLeft,GuiCustom.guiTop,0.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);
|
||||
|
||||
int p_73729_1_ = (int) (this.x/this.scale);
|
||||
int p_73729_2_ = (int) (this.y/this.scale);
|
||||
int p_73729_3_ = this.textureX;
|
||||
int p_73729_4_ = this.textureY;
|
||||
int p_73729_5_ = (int)(this.width);
|
||||
int p_73729_6_ = (int)(this.height);
|
||||
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
tessellator.setColorRGBA_F(red, green, blue, alpha);
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
|
||||
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();
|
||||
|
||||
@@ -106,7 +124,7 @@ public class CustomGuiTexturedRect extends Gui implements IGuiComponent {
|
||||
}
|
||||
|
||||
public ICustomGuiComponent toComponent() {
|
||||
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(this.id, this.texture.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY);
|
||||
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(this.id, this.location.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY);
|
||||
component.setHoverText(this.hoverText);
|
||||
component.setScale(this.scale);
|
||||
component.setColor(color);
|
||||
@@ -134,4 +152,40 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.client.gui.Gui;
|
||||
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.client.ImageDownloadAlt;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
@@ -14,12 +15,17 @@ import noppes.npcs.scripted.interfaces.overlay.ICustomOverlayComponent;
|
||||
import noppes.npcs.scripted.overlay.ScriptOverlayTexturedRect;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent {
|
||||
OverlayCustom parent;
|
||||
int alignment;
|
||||
int id;
|
||||
|
||||
ResourceLocation texture;
|
||||
ResourceLocation location;
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
@@ -32,15 +38,20 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent
|
||||
float alpha;
|
||||
float rotation;
|
||||
|
||||
private int totalWidth, totalHeight;
|
||||
private ImageDownloadAlt imageDownloadAlt = null;
|
||||
private boolean isUrl = false;
|
||||
private boolean gotWidthHeight = false;
|
||||
|
||||
public CustomOverlayTexturedRect(int id, String texture, int x, int y, int width, int height) {
|
||||
this(id, texture, x, y, width, height, 0, 0);
|
||||
}
|
||||
|
||||
public CustomOverlayTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
|
||||
public CustomOverlayTexturedRect(int id, String directory, int x, int y, int width, int height, int textureX, int textureY) {
|
||||
this.scale = 1.0F;
|
||||
this.alignment = 0;
|
||||
this.id = id;
|
||||
this.texture = new ResourceLocation(texture);
|
||||
this.location = new ResourceLocation(directory);
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
@@ -48,10 +59,17 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent
|
||||
this.textureX = textureX;
|
||||
this.textureY = textureY;
|
||||
|
||||
if(texture.startsWith("https://")){
|
||||
if(directory.startsWith("https://")){
|
||||
this.isUrl = true;
|
||||
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.texture, object);
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +82,16 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent
|
||||
}
|
||||
|
||||
public void onRender(Minecraft mc, float partialTicks) {
|
||||
mc.getTextureManager().bindTexture(this.texture);
|
||||
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(imageDownloadAlt != null && isUrl && !gotWidthHeight){
|
||||
getURLWidthHeight();
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
float red = (color >> 16 & 255) / 255f;
|
||||
@@ -72,34 +99,26 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent
|
||||
float blue = (color & 255) / 255f;
|
||||
|
||||
GL11.glTranslatef(this.alignment%3*((float)(OverlayCustom.scaledWidth)/2), (float) (Math.floor((float)(alignment/3))*((float)(OverlayCustom.scaledHeight)/2)),0.0F);
|
||||
GL11.glTranslatef( this.x - u1 * totalWidth, this.y - v1 * totalHeight,(float)this.id);
|
||||
|
||||
GL11.glScalef(this.scale, this.scale, this.scale);
|
||||
|
||||
GL11.glRotatef(this.rotation,0.0F,0.0F,1.0F);
|
||||
|
||||
int p_73729_1_ = (int) (this.x/this.scale);
|
||||
int p_73729_2_ = (int) (this.y/this.scale);
|
||||
int p_73729_3_ = this.textureX;
|
||||
int p_73729_4_ = this.textureY;
|
||||
int p_73729_5_ = (int)(this.width);
|
||||
int p_73729_6_ = (int)(this.height);
|
||||
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
tessellator.setColorRGBA_F(red, green, blue, alpha);
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + p_73729_6_), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + p_73729_6_) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + p_73729_5_), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + p_73729_5_) * f), (double)((float)(p_73729_4_ + 0) * f1));
|
||||
tessellator.addVertexWithUV((double)(p_73729_1_ + 0), (double)(p_73729_2_ + 0), (double)this.zLevel, (double)((float)(p_73729_3_ + 0) * f), (double)((float)(p_73729_4_ + 0) * f1));
|
||||
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();
|
||||
}
|
||||
|
||||
public ICustomOverlayComponent toComponent() {
|
||||
ScriptOverlayTexturedRect component = new ScriptOverlayTexturedRect(this.id, this.texture.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY);
|
||||
ScriptOverlayTexturedRect component = new ScriptOverlayTexturedRect(this.id, this.location.toString(), this.x, this.y, this.width, this.height, this.textureX, this.textureY);
|
||||
component.setScale(scale);
|
||||
component.setAlignment(alignment);
|
||||
component.setAlpha(alpha);
|
||||
@@ -124,4 +143,40 @@ public class CustomOverlayTexturedRect extends Gui implements IOverlayComponent
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -153,8 +153,6 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
|
||||
}
|
||||
if(button.id == 2){
|
||||
display.skinType = (byte) button.getValue();
|
||||
// System.out.println("Skin Type set to:" + display.skinType);
|
||||
// SKIN CHANGE
|
||||
if (display.skinType != 3){
|
||||
display.url = "";
|
||||
}
|
||||
|
||||
@@ -124,13 +124,13 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
|
||||
super.drawScreen(i, j, f);
|
||||
|
||||
if(noQuests){
|
||||
mc.fontRenderer.drawString(StatCollector.translateToLocal("quest.noquests"),guiLeft + 84,guiTop + 80, CustomNpcResourceListener.DefaultTextColor);
|
||||
fontRendererObj.drawString(StatCollector.translateToLocal("quest.noquests"),guiLeft + 84,guiTop + 80, CustomNpcResourceListener.DefaultTextColor);
|
||||
return;
|
||||
}
|
||||
for(GuiMenuSideButton button: sideButtons.values().toArray(new GuiMenuSideButton[sideButtons.size()])){
|
||||
button.drawButton(mc, i, j);
|
||||
}
|
||||
mc.fontRenderer.drawString(data.selectedCategory,guiLeft + 5,guiTop + 5, CustomNpcResourceListener.DefaultTextColor);
|
||||
fontRendererObj.drawString(data.selectedCategory,guiLeft + 5,guiTop + 5, CustomNpcResourceListener.DefaultTextColor);
|
||||
|
||||
if(!data.hasSelectedQuest())
|
||||
return;
|
||||
@@ -138,11 +138,11 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
|
||||
if (questDetails) {
|
||||
drawProgress();
|
||||
String title = StatCollector.translateToLocal("gui.text");
|
||||
mc.fontRenderer.drawString(title, guiLeft + 284 - mc.fontRenderer.getStringWidth(title), guiTop + 179, CustomNpcResourceListener.DefaultTextColor);
|
||||
fontRendererObj.drawString(title, guiLeft + 284 - fontRendererObj.getStringWidth(title), guiTop + 179, CustomNpcResourceListener.DefaultTextColor);
|
||||
} else {
|
||||
drawQuestText();
|
||||
String title = StatCollector.translateToLocal("quest.objectives");
|
||||
mc.fontRenderer.drawString(title, guiLeft + 168, guiTop + 179, CustomNpcResourceListener.DefaultTextColor);
|
||||
fontRendererObj.drawString(title, guiLeft + 168, guiTop + 179, CustomNpcResourceListener.DefaultTextColor);
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
@@ -165,7 +165,7 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
|
||||
private void drawProgress() {
|
||||
String complete = data.getComplete();
|
||||
if(complete != null && !complete.isEmpty())
|
||||
mc.fontRenderer.drawString(StatCollector.translateToLocalFormatted("quest.completewith", complete), guiLeft + 144, guiTop + 105, CustomNpcResourceListener.DefaultTextColor);
|
||||
fontRendererObj.drawString(StatCollector.translateToLocalFormatted("quest.completewith", complete), guiLeft + 144, guiTop + 105, CustomNpcResourceListener.DefaultTextColor);
|
||||
|
||||
int yoffset = guiTop + 22;
|
||||
for(String process : data.getQuestStatus()){
|
||||
@@ -181,7 +181,7 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
|
||||
}
|
||||
process = name + process.substring(index);
|
||||
}
|
||||
mc.fontRenderer.drawString("- " + process, guiLeft + 144, yoffset , CustomNpcResourceListener.DefaultTextColor);
|
||||
fontRendererObj.drawString("- " + process, guiLeft + 144, yoffset , CustomNpcResourceListener.DefaultTextColor);
|
||||
yoffset += 10;
|
||||
}
|
||||
}
|
||||
@@ -250,7 +250,7 @@ public class GuiQuestLog extends GuiNPCInterface implements ITopButtonListener,I
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
if (this.data != null && !this.data.trackedQuestKey.isEmpty())
|
||||
if (this.data != null)
|
||||
Client.sendData(EnumPacketServer.UpdateTrackedQuest, this.data.trackedQuestKey);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,8 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
||||
hookList.add("init");
|
||||
hookList.add("tick");
|
||||
hookList.add("interact");
|
||||
hookList.add("attack");
|
||||
hookList.add("attacked");
|
||||
hookList.add("damagedEntity");
|
||||
hookList.add("damaged");
|
||||
hookList.add("kills");
|
||||
@@ -318,11 +320,11 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
||||
public void confirmClicked(boolean flag, int i) {
|
||||
if(flag) {
|
||||
if(i == 0) {
|
||||
this.openLink("http://www.kodevelopment.nl/minecraft/customnpcs/scripting");
|
||||
this.openLink("https://www.curseforge.com/minecraft/mc-mods/customnpc-plus");
|
||||
}
|
||||
|
||||
if(i == 1) {
|
||||
this.openLink("http://www.kodevelopment.nl/customnpcs/api/");
|
||||
this.openLink("https://kamkeel.github.io/CustomNPC-Plus/");
|
||||
}
|
||||
|
||||
if(i == 2) {
|
||||
@@ -378,6 +380,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
||||
|
||||
if(guibutton.id == 101) {
|
||||
(this.getTextField(2)).setText(NoppesStringUtils.getClipboardContents());
|
||||
this.setScript();
|
||||
}
|
||||
|
||||
ScriptContainer container;
|
||||
@@ -425,7 +428,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
||||
container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
|
||||
if(container != null) {
|
||||
this.setScript();
|
||||
this.AWTWindow = new GuiJTextArea(container.script).setListener(this);
|
||||
AWTWindow = new GuiJTextArea(container.script).setListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ public class GuiNpcTextArea extends GuiNpcTextField implements IGui{
|
||||
private int startClick = -1;
|
||||
private boolean clickVerticalBar = false;
|
||||
private boolean wrapLine = true;
|
||||
|
||||
private List<String> lines = new ArrayList<>();
|
||||
|
||||
public GuiNpcTextArea(int id,GuiScreen guiscreen, int i, int j, int k, int l, String s) {
|
||||
super(id,guiscreen, i, j, k, l, s);
|
||||
posX = i;
|
||||
@@ -39,34 +40,57 @@ public class GuiNpcTextArea extends GuiNpcTextField implements IGui{
|
||||
this.setText(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
super.setText(text);
|
||||
|
||||
updateLineList();
|
||||
}
|
||||
|
||||
public void updateLineList() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
StringBuilder line = new StringBuilder();
|
||||
for(char c : getText().toCharArray()){
|
||||
if(c == '\r' || c == '\n'){
|
||||
list.add(line.toString());
|
||||
line = new StringBuilder();
|
||||
}
|
||||
else
|
||||
line.append(c);
|
||||
}
|
||||
list.add(line.toString());
|
||||
lines = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCursorCounter(){
|
||||
cursorCounter++;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean textboxKeyTyped(char c, int i){
|
||||
if (isFocused() && canEdit){
|
||||
String originalText = getText();
|
||||
this.setText(originalText);
|
||||
if(c == '\r' || c == '\n'){
|
||||
this.setText(originalText.substring(0, cursorPosition) + c + originalText.substring(cursorPosition));
|
||||
}
|
||||
this.setCursorPositionZero();
|
||||
this.moveCursorBy(cursorPosition);
|
||||
boolean bo = super.textboxKeyTyped(c, i);
|
||||
String newText = getText();
|
||||
if(i != Keyboard.KEY_DELETE)
|
||||
cursorPosition += newText.length() - originalText.length();
|
||||
if(i == Keyboard.KEY_LEFT && cursorPosition > 0)
|
||||
cursorPosition--;
|
||||
if(i == Keyboard.KEY_RIGHT && cursorPosition < newText.length())
|
||||
cursorPosition++;
|
||||
return bo;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public boolean textboxKeyTyped(char c, int i){
|
||||
if (isFocused() && canEdit){
|
||||
String originalText = getText();
|
||||
this.setText(originalText);
|
||||
if(c == '\r' || c == '\n'){
|
||||
this.setText(originalText.substring(0, cursorPosition) + c + originalText.substring(cursorPosition));
|
||||
}
|
||||
this.setCursorPositionZero();
|
||||
this.moveCursorBy(cursorPosition);
|
||||
boolean bo = super.textboxKeyTyped(c, i);
|
||||
updateLineList();
|
||||
String newText = getText();
|
||||
if(i != Keyboard.KEY_DELETE)
|
||||
cursorPosition += newText.length() - originalText.length();
|
||||
if(i == Keyboard.KEY_LEFT && cursorPosition > 0)
|
||||
cursorPosition--;
|
||||
if(i == Keyboard.KEY_RIGHT && cursorPosition < newText.length())
|
||||
cursorPosition++;
|
||||
return bo;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int i, int j, int k){
|
||||
@@ -84,7 +108,6 @@ public class GuiNpcTextArea extends GuiNpcTextField implements IGui{
|
||||
int x = i - posX;
|
||||
int y = (j - posY - 4) / font.height() + getStartLineY();
|
||||
cursorPosition = 0;
|
||||
List<String> lines = getLines();
|
||||
int charCount = 0;
|
||||
int lineCount = 0;
|
||||
int maxSize = width - (isScrolling()?14:4);
|
||||
@@ -153,8 +176,7 @@ public class GuiNpcTextArea extends GuiNpcTextField implements IGui{
|
||||
int startLine = getStartLineY();
|
||||
|
||||
int maxLine = height / font.height() + startLine;
|
||||
|
||||
List<String> lines = getLines();
|
||||
|
||||
int charCount = 0;
|
||||
int lineCount = 0;
|
||||
int maxSize = width - (isScrolling()?14:4);
|
||||
|
||||
@@ -14,19 +14,20 @@ import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.ModelPartConfig;
|
||||
import noppes.npcs.ModelPartData;
|
||||
import noppes.npcs.client.ClientProxy;
|
||||
import noppes.npcs.client.model.animation.AniCrawling;
|
||||
import noppes.npcs.client.model.animation.AniHug;
|
||||
import noppes.npcs.client.model.part.*;
|
||||
import noppes.npcs.client.model.util.ModelPartInterface;
|
||||
import noppes.npcs.client.model.util.ModelScaleRenderer;
|
||||
import noppes.npcs.client.renderer.RenderNPCInterface;
|
||||
import noppes.npcs.constants.EnumAnimation;
|
||||
import noppes.npcs.constants.EnumJobType;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.roles.JobPuppet;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.ISkinOverlay;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import static noppes.npcs.client.ClientProxy.bindTexture;
|
||||
|
||||
@@ -352,9 +353,77 @@ public class ModelMPM extends ModelNPCMale{
|
||||
biped.isSneak = isSneak;
|
||||
}
|
||||
entityModel.render(entity, par2, par3, par4, par5, par6, par7);
|
||||
|
||||
if (!npc.display.skinOverlayData.overlayList.isEmpty()) {
|
||||
for (ISkinOverlay overlayData : npc.display.skinOverlayData.overlayList.values()) {
|
||||
try {
|
||||
if (overlayData.getTexture().isEmpty())
|
||||
continue;
|
||||
|
||||
if (((SkinOverlay)overlayData).getLocation() == null) {
|
||||
((SkinOverlay)overlayData).setLocation(new ResourceLocation(overlayData.getTexture()));
|
||||
} else {
|
||||
String str = ((SkinOverlay)npc.display.skinOverlayData.overlayList.get(0)).getLocation().getResourceDomain()+":"+((SkinOverlay)npc.display.skinOverlayData.overlayList.get(0)).getLocation().getResourcePath();
|
||||
if (!str.equals(overlayData.getTexture())) {
|
||||
((SkinOverlay)overlayData).setLocation(new ResourceLocation(overlayData.getTexture()));
|
||||
}
|
||||
}
|
||||
|
||||
if (((SkinOverlay)overlayData).getLocation().getResourcePath().isEmpty())
|
||||
continue;
|
||||
|
||||
try {
|
||||
RenderNPCInterface.staticRenderManager.renderEngine.bindTexture(((SkinOverlay)overlayData).getLocation());
|
||||
} catch (Exception e) { continue; }
|
||||
|
||||
// Overlay & Glow
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
if (overlayData.getBlend()) {
|
||||
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
|
||||
} else {
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
|
||||
|
||||
if (overlayData.getGlow()) {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0);
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.getAlpha());
|
||||
|
||||
GL11.glDepthMask(!npc.isInvisible());
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glTranslatef(npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedX(), npc.display.overlayRenderTicks * 0.001F * overlayData.getSpeedY(), 0.0F);
|
||||
GL11.glScalef(overlayData.getTextureScaleX(), overlayData.getTextureScaleY(), 1.0F);
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
float scale = 1.005f * overlayData.getSize();
|
||||
GL11.glTranslatef(overlayData.getOffsetX(), overlayData.getOffsetY(), overlayData.getOffsetZ());
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
entityModel.render(entity, par2, par3, par4, par5, par6, par7);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
|
||||
Minecraft.getMinecraft().entityRenderer.enableLightmap((double) 0);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
npc.display.overlayRenderTicks++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
alpha = npc.isInvisible() && !npc.isInvisibleToPlayer(player) ? 0.15f : 1;
|
||||
|
||||
setPlayerData(npc);
|
||||
|
||||
@@ -138,7 +138,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
|
||||
overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY,
|
||||
overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ
|
||||
))
|
||||
return;
|
||||
continue;;
|
||||
this.modelBipedMain.render(p_77036_1_, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, p_77036_7_);
|
||||
postRenderOverlay();
|
||||
}
|
||||
@@ -342,7 +342,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
|
||||
overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY,
|
||||
overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ
|
||||
))
|
||||
return;
|
||||
continue;;
|
||||
|
||||
if (gender >= 2.0F) {
|
||||
GL11.glRotatef(7F, 0, 0, 1);
|
||||
@@ -366,19 +366,33 @@ public class RenderCNPCPlayer extends RenderPlayer {
|
||||
Class<?> ModelBipedBody = Class.forName("JinRyuu.JRMCore.entity.ModelBipedBody");
|
||||
|
||||
Object m = RenderPlayerJBRA.getField("modelMain").get(event.renderer);
|
||||
ModelBipedBody.getField("onGround").set(m, (int) player.getSwingProgress(event.partialRenderTick));
|
||||
ModelBipedBody.getField("isRiding").set(m, player.isRiding());
|
||||
ModelBipedBody.getField("isChild").set(m, player.isChild());
|
||||
ModelBipedBody.getField("isSneak").set(m, player.isSneaking());
|
||||
ModelBipedBody.getField("y").set(null, ModelBipedDBC.getField("y").get(null));
|
||||
|
||||
ModelRenderer bipedHead = (ModelRenderer) ModelBipedBody.getField("bipedHead").get(m);
|
||||
ModelRenderer bipedBody = (ModelRenderer) ModelBipedBody.getField("bipedBody").get(m);
|
||||
ModelRenderer bipedRA = (ModelRenderer) ModelBipedBody.getField("bipedRightArm").get(m);
|
||||
ModelRenderer bipedLA = (ModelRenderer) ModelBipedBody.getField("bipedLeftArm").get(m);
|
||||
ModelRenderer bipedRL = (ModelRenderer) ModelBipedBody.getField("bipedRightLeg").get(m);
|
||||
ModelRenderer bipedLL = (ModelRenderer) ModelBipedBody.getField("bipedLeftLeg").get(m);
|
||||
float childScl = (float) RenderPlayerJBRA.getMethod("childSclGet").invoke(null);
|
||||
|
||||
ModelBipedBody.getField("onGround").set(m, (int) player.getSwingProgress(event.partialRenderTick));
|
||||
ModelBipedBody.getField("isRiding").set(m, player.isRiding());
|
||||
ModelBipedBody.getField("isChild").set(m, player.isChild());
|
||||
ModelBipedBody.getField("isSneak").set(m, player.isSneaking());
|
||||
ModelBipedBody.getField("y").set(null, ModelBipedDBC.getField("y").get(null));
|
||||
|
||||
ModelRenderer Brightarm = (ModelRenderer) ModelBipedBody.getField("Brightarm").get(m);
|
||||
ModelRenderer Bleftarm = (ModelRenderer) ModelBipedBody.getField("Bleftarm").get(m);
|
||||
ModelRenderer rightleg = (ModelRenderer) ModelBipedBody.getField("rightleg").get(m);
|
||||
ModelRenderer leftleg = (ModelRenderer) ModelBipedBody.getField("leftleg").get(m);
|
||||
ModelRenderer body = (ModelRenderer) ModelBipedBody.getField("body").get(m);
|
||||
ModelRenderer hip = (ModelRenderer) ModelBipedBody.getField("hip").get(m);
|
||||
ModelRenderer waist = (ModelRenderer) ModelBipedBody.getField("waist").get(m);
|
||||
ModelRenderer bottom = (ModelRenderer) ModelBipedBody.getField("bottom").get(m);
|
||||
ModelRenderer Bbreast = (ModelRenderer) ModelBipedBody.getField("Bbreast").get(m);
|
||||
ModelRenderer Bbreast2 = (ModelRenderer) ModelBipedBody.getField("Bbreast2").get(m);
|
||||
ModelRenderer breast = (ModelRenderer) ModelBipedBody.getField("breast").get(m);
|
||||
ModelRenderer breast2 = (ModelRenderer) ModelBipedBody.getField("breast2").get(m);
|
||||
float childScl = (float) RenderPlayerJBRA.getMethod("childSclGet").invoke(null);
|
||||
|
||||
Method renderDBC = ModelBipedBody.getMethod("render",Entity.class,float.class,float.class,float.class,float.class,float.class,float.class);
|
||||
Field rot1 = ModelBipedDBC.getField("rot1");
|
||||
@@ -388,64 +402,89 @@ public class RenderCNPCPlayer extends RenderPlayer {
|
||||
Field rot5 = ModelBipedDBC.getField("rot5");
|
||||
Field rot6 = ModelBipedDBC.getField("rot6");
|
||||
|
||||
if (!player.isInvisible()) {
|
||||
if (Client.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
for (SkinOverlay overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) {
|
||||
if (overlayData.texture.isEmpty())
|
||||
continue;
|
||||
if (Client.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
for (SkinOverlay overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) {
|
||||
if (overlayData.texture.isEmpty())
|
||||
continue;
|
||||
|
||||
if (overlayData.location == null) {
|
||||
if (overlayData.location == null) {
|
||||
overlayData.location = new ResourceLocation(overlayData.texture);
|
||||
} else {
|
||||
String str = overlayData.location.getResourceDomain() + ":" + overlayData.location.getResourcePath();
|
||||
if (!str.equals(overlayData.texture)) {
|
||||
overlayData.location = new ResourceLocation(overlayData.texture);
|
||||
} else {
|
||||
String str = overlayData.location.getResourceDomain() + ":" + overlayData.location.getResourcePath();
|
||||
if (!str.equals(overlayData.texture)) {
|
||||
overlayData.location = new ResourceLocation(overlayData.texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.blend, overlayData.alpha, overlayData.size,
|
||||
overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY,
|
||||
overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ
|
||||
))
|
||||
return;
|
||||
if (!preRenderOverlay(player, overlayData.location, overlayData.glow, overlayData.blend, overlayData.alpha, overlayData.size,
|
||||
overlayData.speedX, overlayData.speedY, overlayData.scaleX, overlayData.scaleY,
|
||||
overlayData.offsetX, overlayData.offsetY, overlayData.offsetZ
|
||||
))
|
||||
continue;
|
||||
bipedHead.isHidden = true;
|
||||
renderDBC.invoke(m, player,
|
||||
(float) rot1.get(m), (float) rot2.get(m), (float) rot3.get(m),
|
||||
(float) rot4.get(m), (float) rot5.get(m), (float) rot6.get(m)
|
||||
);
|
||||
bipedHead.isHidden = false;
|
||||
|
||||
bipedHead.isHidden = true;
|
||||
renderDBC.invoke(m, player,
|
||||
(float) rot1.get(m), (float) rot2.get(m), (float) rot3.get(m),
|
||||
(float) rot4.get(m), (float) rot5.get(m), (float) rot6.get(m)
|
||||
);
|
||||
bipedHead.isHidden = false;
|
||||
|
||||
bipedBody.isHidden = true;
|
||||
bipedRA.isHidden = true;
|
||||
bipedLA.isHidden = true;
|
||||
bipedRL.isHidden = true;
|
||||
bipedLL.isHidden = true;
|
||||
|
||||
if (childScl > 1.5F) {
|
||||
GL11.glTranslatef(0, -0.015F, 0);
|
||||
bipedBody.isHidden = true;
|
||||
bipedRA.isHidden = true;
|
||||
bipedLA.isHidden = true;
|
||||
bipedRL.isHidden = true;
|
||||
bipedLL.isHidden = true;
|
||||
//Female render
|
||||
Brightarm.isHidden = true;
|
||||
Bleftarm.isHidden = true;
|
||||
rightleg.isHidden = true;
|
||||
leftleg.isHidden = true;
|
||||
body.isHidden = true;
|
||||
hip.isHidden = true;
|
||||
waist.isHidden = true;
|
||||
bottom.isHidden = true;
|
||||
Bbreast.isHidden = true;
|
||||
Bbreast2.isHidden = true;
|
||||
breast.isHidden = true;
|
||||
breast2.isHidden = true;
|
||||
if (player.isSneaking()) {
|
||||
GL11.glTranslatef(0, 0.06F, 0);
|
||||
}
|
||||
if (childScl > 1.5F) {
|
||||
GL11.glTranslatef(0, -0.015F, 0);
|
||||
GL11.glScalef(1.025F, 1.025F, 1.025F);
|
||||
} else {
|
||||
if (childScl > 1) {
|
||||
GL11.glTranslatef(0, -0.01F, 0);
|
||||
GL11.glScalef(1.025F, 1.025F, 1.025F);
|
||||
} else {
|
||||
if (childScl > 1) {
|
||||
GL11.glTranslatef(0, -0.01F, 0);
|
||||
GL11.glScalef(1.025F, 1.025F, 1.025F);
|
||||
} else {
|
||||
GL11.glTranslatef(0, 0.0025F, 0);
|
||||
GL11.glScalef(1.02F, 1.02F, 1.02F);
|
||||
}
|
||||
GL11.glTranslatef(0, 0.0025F, 0);
|
||||
GL11.glScalef(1.02F, 1.02F, 1.02F);
|
||||
}
|
||||
renderDBC.invoke(m, player,
|
||||
(float) rot1.get(m), (float) rot2.get(m), (float) rot3.get(m),
|
||||
(float) rot4.get(m), (float) rot5.get(m), (float) rot6.get(m)
|
||||
);
|
||||
bipedBody.isHidden = false;
|
||||
bipedRA.isHidden = false;
|
||||
bipedLA.isHidden = false;
|
||||
bipedRL.isHidden = false;
|
||||
bipedLL.isHidden = false;
|
||||
|
||||
postRenderOverlay();
|
||||
}
|
||||
renderDBC.invoke(m, player,
|
||||
(float) rot1.get(m), (float) rot2.get(m), (float) rot3.get(m),
|
||||
(float) rot4.get(m), (float) rot5.get(m), (float) rot6.get(m)
|
||||
);
|
||||
bipedBody.isHidden = false;
|
||||
bipedRA.isHidden = false;
|
||||
bipedLA.isHidden = false;
|
||||
bipedRL.isHidden = false;
|
||||
bipedLL.isHidden = false;
|
||||
//Female render
|
||||
Brightarm.isHidden = false;
|
||||
Bleftarm.isHidden = false;
|
||||
rightleg.isHidden = false;
|
||||
leftleg.isHidden = false;
|
||||
body.isHidden = false;
|
||||
hip.isHidden = false;
|
||||
waist.isHidden = false;
|
||||
bottom.isHidden = false;
|
||||
Bbreast.isHidden = false;
|
||||
Bbreast2.isHidden = false;
|
||||
breast.isHidden = false;
|
||||
breast2.isHidden = false;
|
||||
|
||||
postRenderOverlay();
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
@@ -42,6 +43,7 @@ import javax.imageio.ImageIO;
|
||||
|
||||
public class RenderNPCInterface extends RenderLiving{
|
||||
public static long LastTextureTick = 0;
|
||||
public static RenderManager staticRenderManager;
|
||||
public ModelBase originalModel;
|
||||
|
||||
public RenderNPCInterface(ModelBase model, float f){
|
||||
@@ -212,6 +214,8 @@ public class RenderNPCInterface extends RenderLiving{
|
||||
if(npc.ai.standingType == EnumStandingType.HeadRotation && !npc.isWalking() && !npc.isInteracting()){
|
||||
npc.prevRenderYawOffset = npc.renderYawOffset = npc.ai.orientation;
|
||||
}
|
||||
|
||||
staticRenderManager = this.renderManager;
|
||||
super.doRender(entityliving, d, d1, d2, f, f1);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,5 +40,10 @@ public enum EnumPacketClient {
|
||||
UPDATE_ITEM,
|
||||
PLAYER_UPDATE_SKIN_OVERLAYS,
|
||||
OVERLAY_QUEST_TRACKING,
|
||||
DISABLE_MOUSE_INPUT
|
||||
DISABLE_MOUSE_INPUT,
|
||||
PLAY_SOUND_TO,
|
||||
STOP_SOUND_FOR,
|
||||
PAUSE_SOUNDS,
|
||||
CONTINUE_SOUNDS,
|
||||
STOP_SOUNDS
|
||||
}
|
||||
@@ -14,6 +14,7 @@ public enum EnumScriptType {
|
||||
DIALOG_CLOSE("dialogClose"),
|
||||
TIMER("timer"),
|
||||
|
||||
ATTACKED("attacked"),
|
||||
ATTACK_MELEE("meleeAttack"),
|
||||
TARGET_LOST("targetLost"),
|
||||
ROLE("role"),
|
||||
|
||||
@@ -47,6 +47,13 @@ public class ScriptContainer {
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
this.script = compound.getString("Script");
|
||||
for (int i = 0; i < CustomNpcs.ExpandedScriptLimit; i++) {
|
||||
if (compound.hasKey("ExpandedScript"+i)) {
|
||||
this.script += compound.getString("ExpandedScript"+i);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//this.type = compound.getString("Type");
|
||||
this.console = NBTTags.GetLongStringMap(compound.getTagList("Console", 10));
|
||||
this.scripts = NBTTags.getStringList(compound.getTagList("ScriptList", 10));
|
||||
@@ -54,7 +61,29 @@ public class ScriptContainer {
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setString("Script", this.script);
|
||||
if (this.script.length() < 65535) {
|
||||
compound.setString("Script", this.script);
|
||||
} else {
|
||||
if (CustomNpcs.ExpandedScriptLimit > 0) {
|
||||
int i = 0;
|
||||
int length = this.script.length();
|
||||
while (length > 0 && i <= CustomNpcs.ExpandedScriptLimit) {
|
||||
String str = "";
|
||||
if (i == 0) {
|
||||
compound.setString("Script", this.script.substring(0, 65535));
|
||||
str = this.script.substring(0, 65535);
|
||||
} else {
|
||||
int end = (length - 65535) >= 0 ? 65535 * (i + 1) : 65535 * i + length;
|
||||
str = this.script.substring(65535 * i, end);
|
||||
compound.setString("ExpandedScript" + (i - 1), str);
|
||||
}
|
||||
i++;
|
||||
length -= str.length();
|
||||
}
|
||||
} else {
|
||||
compound.setString("Script", this.script.substring(0, 65535));
|
||||
}
|
||||
}
|
||||
//compound.setString("Type", this.type);
|
||||
compound.setTag("Console", NBTTags.NBTLongStringMap(this.console));
|
||||
compound.setTag("ScriptList", NBTTags.nbtStringList(this.scripts));
|
||||
|
||||
@@ -194,16 +194,25 @@ public class ServerCloneController implements ICloneHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public IEntity spawn(double x, double y, double z, int tab, String name, IWorld world) {
|
||||
public IEntity spawn(double x, double y, double z, int tab, String name, IWorld world, boolean ignoreProtection) {
|
||||
NBTTagCompound compound = this.getCloneData((ICommandSender)null, name, tab);
|
||||
if (compound == null) {
|
||||
throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name, new Object[0]);
|
||||
} else {
|
||||
Entity entity = NoppesUtilServer.spawnClone(compound, (int)x, (int)y, (int)z, world.getMCWorld());
|
||||
Entity entity;
|
||||
if (!ignoreProtection) {
|
||||
entity = NoppesUtilServer.spawnCloneWithProtection(compound, (int) x, (int) y, (int) z, world.getMCWorld());
|
||||
} else {
|
||||
entity = NoppesUtilServer.spawnClone(compound, (int) x, (int) y, (int) z, world.getMCWorld());
|
||||
}
|
||||
return entity == null ? null : NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public IEntity spawn(double x, double y, double z, int tab, String name, IWorld world) {
|
||||
return spawn(x, y, z, tab, name, world, true);
|
||||
}
|
||||
|
||||
public IEntity[] getTab(int tab, IWorld world) {
|
||||
File dir = new File(getDir(), tab + "");
|
||||
if (!dir.exists() || !dir.isDirectory() || dir.listFiles() == null) {
|
||||
|
||||
@@ -164,11 +164,7 @@ public class Faction implements IFaction {
|
||||
}
|
||||
|
||||
public void addEnemyFaction(IFaction faction) {
|
||||
if (this.attackFactions.contains(faction.getId())) {
|
||||
throw new CustomNPCsException("Faction " + this.id + " is already hostile to " + id, new Object[0]);
|
||||
} else {
|
||||
this.attackFactions.add(faction.getId());
|
||||
}
|
||||
this.attackFactions.add(faction.getId());
|
||||
}
|
||||
|
||||
public void removeEnemyFaction(IFaction faction) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -114,7 +115,9 @@ public class PlayerQuestData implements IPlayerQuestData {
|
||||
public boolean checkQuestCompletion(PlayerData playerData,EnumQuestType type) {
|
||||
boolean bo = false;
|
||||
EntityPlayer player = playerData.player;
|
||||
for(QuestData data : this.activeQuests.values()){
|
||||
|
||||
ArrayList<QuestData> activeQuestValues = new ArrayList<>(this.activeQuests.values());
|
||||
for(QuestData data : activeQuestValues){
|
||||
if(data.quest.type != type && type != null)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -613,7 +613,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
}
|
||||
tasks.taskEntries = new ArrayList<EntityAITaskEntry>();
|
||||
}
|
||||
private void updateTasks() {
|
||||
public void updateTasks() {
|
||||
if (worldObj == null || worldObj.isRemote)
|
||||
return;
|
||||
aiLeap = aiAttackTarget = aiResponse = aiSprint = aiRange = null;
|
||||
@@ -770,8 +770,8 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
* Add immutable task entries.
|
||||
*/
|
||||
public void addRegularEntries() {
|
||||
this.tasks.addTask(this.taskCount++, new EntityAIReturn(this));
|
||||
this.tasks.addTask(this.taskCount++, new EntityAIFollow(this));
|
||||
this.tasks.addTask(this.taskCount++, new EntityAIReturn(this));
|
||||
if (this.ai.standingType != EnumStandingType.NoRotation && this.ai.standingType != EnumStandingType.HeadRotation)
|
||||
this.tasks.addTask(this.taskCount++, new EntityAIWatchClosest(this, EntityLivingBase.class, 5.0F));
|
||||
this.tasks.addTask(this.taskCount++, new EntityAILook(this));
|
||||
@@ -1429,6 +1429,15 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
this.motionY = 0.4000000059604645D;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void addVelocity(double p_70024_1_, double p_70024_3_, double p_70024_5_) {
|
||||
if (this.attackingPlayer != null) {
|
||||
float f2 = 0.5F * (2 - stats.resistances.knockback);
|
||||
super.addVelocity(p_70024_1_ * (double)f2,p_70024_3_ * (double)f2,p_70024_5_ * (double)f2);
|
||||
} else {
|
||||
super.addVelocity(p_70024_1_,p_70024_3_,p_70024_5_);
|
||||
}
|
||||
}
|
||||
|
||||
public Faction getFaction() {
|
||||
String[] split = dataWatcher.getWatchableObjectString(13).split(":");
|
||||
|
||||
@@ -49,12 +49,14 @@ public class DataSkinOverlays implements IOverlayHandler {
|
||||
}
|
||||
|
||||
public void updateClient() {
|
||||
if (parent instanceof PlayerData) {
|
||||
NBTTagCompound compound = this.writeToNBT(new NBTTagCompound());
|
||||
((PlayerData) parent).player.getEntityData().setTag("SkinOverlayData", compound.getTagList("SkinOverlayData",10));
|
||||
Server.sendToAll(EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, ((PlayerData) parent).player.getCommandSenderName(), compound);
|
||||
} else if (parent instanceof EntityNPCInterface) {
|
||||
((EntityNPCInterface) parent).updateClient = true;
|
||||
if (parent != null) {
|
||||
if (parent instanceof PlayerData && ((PlayerData) parent).player != null) {
|
||||
NBTTagCompound compound = this.writeToNBT(new NBTTagCompound());
|
||||
((PlayerData) parent).player.getEntityData().setTag("SkinOverlayData", compound.getTagList("SkinOverlayData", 10));
|
||||
Server.sendToAll(EnumPacketClient.PLAYER_UPDATE_SKIN_OVERLAYS, ((PlayerData) parent).player.getCommandSenderName(), compound);
|
||||
} else if (parent instanceof EntityNPCInterface) {
|
||||
((EntityNPCInterface) parent).updateClient = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ package noppes.npcs.entity.data;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.EventHooks;
|
||||
@@ -19,48 +19,47 @@ import noppes.npcs.scripted.CustomNPCsException;
|
||||
|
||||
public class DataTimers implements ITimers {
|
||||
private final Object parent;
|
||||
private Map<Integer, DataTimers.Timer> timers = new HashMap();
|
||||
private HashMap<Integer, Timer> timers = new HashMap<>();
|
||||
|
||||
public DataTimers(Object parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void start(int id, int ticks, boolean repeat) {
|
||||
if(this.timers.containsKey(Integer.valueOf(id))) {
|
||||
throw new CustomNPCsException("There is already a timer with id: " + id, new Object[0]);
|
||||
if(this.timers.containsKey(id)) {
|
||||
throw new CustomNPCsException("There is already a timer with id: " + id);
|
||||
} else {
|
||||
this.timers.put(Integer.valueOf(id), new DataTimers.Timer(id, ticks, repeat));
|
||||
this.timers.put(id, new DataTimers.Timer(id, ticks, repeat));
|
||||
}
|
||||
}
|
||||
|
||||
public void forceStart(int id, int ticks, boolean repeat) {
|
||||
this.timers.put(Integer.valueOf(id), new DataTimers.Timer(id, ticks, repeat));
|
||||
this.timers.put(id, new DataTimers.Timer(id, ticks, repeat));
|
||||
}
|
||||
|
||||
public boolean has(int id) {
|
||||
return this.timers.containsKey(Integer.valueOf(id));
|
||||
return this.timers.containsKey(id);
|
||||
}
|
||||
|
||||
public boolean stop(int id) {
|
||||
boolean remove = this.timers.remove(Integer.valueOf(id)) != null;
|
||||
return remove;
|
||||
return this.timers.remove(id) != null;
|
||||
}
|
||||
|
||||
public void reset(int id) {
|
||||
DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id));
|
||||
if(timer == null) {
|
||||
throw new CustomNPCsException("There is no timer with id: " + id, new Object[0]);
|
||||
} else {
|
||||
timer.ticks = 0;
|
||||
}
|
||||
this.timerException(id);
|
||||
DataTimers.Timer timer = this.timers.get(id);
|
||||
timer.ticks = 0;
|
||||
}
|
||||
|
||||
public int ticks(int id){
|
||||
return this.timers.get(Integer.valueOf(id)).ticks;
|
||||
this.timerException(id);
|
||||
return this.timers.get(id).ticks;
|
||||
}
|
||||
|
||||
public void setTicks(int id, int ticks){
|
||||
DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id));
|
||||
this.timerException(id);
|
||||
|
||||
DataTimers.Timer timer = this.timers.get(id);
|
||||
if(ticks < 0)
|
||||
ticks = 0;
|
||||
if(ticks > timer.timerTicks)
|
||||
@@ -70,11 +69,14 @@ public class DataTimers implements ITimers {
|
||||
}
|
||||
|
||||
public int maxTicks(int id){
|
||||
return this.timers.get(Integer.valueOf(id)).timerTicks;
|
||||
this.timerException(id);
|
||||
return this.timers.get(id).timerTicks;
|
||||
}
|
||||
|
||||
public void setMaxTicks(int id, int maxTicks){
|
||||
DataTimers.Timer timer = (DataTimers.Timer)this.timers.get(Integer.valueOf(id));
|
||||
this.timerException(id);
|
||||
|
||||
DataTimers.Timer timer = this.timers.get(id);
|
||||
if(maxTicks < 0)
|
||||
maxTicks = 0;
|
||||
if(timer.ticks > maxTicks)
|
||||
@@ -84,11 +86,13 @@ public class DataTimers implements ITimers {
|
||||
}
|
||||
|
||||
public boolean repeats(int id){
|
||||
return this.timers.get(Integer.valueOf(id)).repeat;
|
||||
this.timerException(id);
|
||||
return this.timers.get(id).repeat;
|
||||
}
|
||||
|
||||
public void setRepeats(int id, boolean repeat){
|
||||
this.timers.get(Integer.valueOf(id)).repeat = repeat;
|
||||
this.timerException(id);
|
||||
this.timers.get(id).repeat = repeat;
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
@@ -108,8 +112,14 @@ public class DataTimers implements ITimers {
|
||||
compound.setTag("NpcsTimers", list);
|
||||
}
|
||||
|
||||
private void timerException(int id) {
|
||||
if (!this.timers.containsKey(id)) {
|
||||
throw new CustomNPCsException("There is no timer with id: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
Map<Integer, DataTimers.Timer> timers = new HashMap();
|
||||
HashMap<Integer, DataTimers.Timer> timers = new HashMap<>();
|
||||
NBTTagList list = compound.getTagList("NpcsTimers", 10);
|
||||
|
||||
if(list != null) {
|
||||
@@ -125,16 +135,16 @@ public class DataTimers implements ITimers {
|
||||
}
|
||||
|
||||
public void update() {
|
||||
Iterator var1 = (new ArrayList(this.timers.values())).iterator();
|
||||
Iterator<DataTimers.Timer> var1 = (new ArrayList<>(this.timers.values())).iterator();
|
||||
|
||||
while(var1.hasNext()) {
|
||||
DataTimers.Timer timer = (DataTimers.Timer)var1.next();
|
||||
while (var1.hasNext()) {
|
||||
DataTimers.Timer timer = var1.next();
|
||||
timer.update();
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.timers = new HashMap();
|
||||
this.timers = new HashMap<>();
|
||||
}
|
||||
|
||||
public int size() { return this.timers.size(); }
|
||||
@@ -143,7 +153,7 @@ public class DataTimers implements ITimers {
|
||||
public int id;
|
||||
private boolean repeat;
|
||||
private int timerTicks;
|
||||
private int ticks = 0;
|
||||
private int ticks;
|
||||
|
||||
public Timer(int id, int ticks, boolean repeat) {
|
||||
this.id = id;
|
||||
|
||||
@@ -5,6 +5,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -31,11 +33,15 @@ public class ItemNpcScripter extends Item{
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){
|
||||
if(!par2World.isRemote)
|
||||
return par1ItemStack;
|
||||
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.ScriptEvent, par3EntityPlayer);
|
||||
return par1ItemStack;
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player){
|
||||
if(!world.isRemote)
|
||||
return itemStack;
|
||||
if(!CustomNpcs.isScriptDev(player)){
|
||||
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
||||
} else {
|
||||
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.ScriptEvent, player);
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -13,6 +13,8 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
@@ -60,12 +62,16 @@ public class ItemScripted extends Item implements ItemRenderInterface {
|
||||
return super.setUnlocalizedName(name);
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer entityPlayer)
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if(entityPlayer.isSneaking() && entityPlayer.capabilities.isCreativeMode) {
|
||||
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.ScriptItem, entityPlayer);
|
||||
if(player.isSneaking() && player.capabilities.isCreativeMode) {
|
||||
if(!CustomNpcs.isScriptDev(player)){
|
||||
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
||||
} else {
|
||||
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.ScriptItem, player);
|
||||
}
|
||||
}
|
||||
entityPlayer.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ import net.minecraft.world.biome.BiomeGenBase;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.controllers.*;
|
||||
import noppes.npcs.controllers.data.Faction;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.items.ItemScripted;
|
||||
import noppes.npcs.containers.ContainerNpcInterface;
|
||||
@@ -50,6 +49,7 @@ import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IFaction;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ISound;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.interfaces.AbstractNpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay;
|
||||
@@ -334,6 +334,13 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
return arr;
|
||||
}
|
||||
|
||||
public String[] getPlayerNames() {
|
||||
IPlayer[] players = getAllServerPlayers();
|
||||
String[] names = new String[players.length];
|
||||
for (int i = 0; i < names.length; ++i) names[i] = players[i].getDisplayName();
|
||||
return names;
|
||||
}
|
||||
|
||||
public void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch){
|
||||
entity.getWorld().getMCWorld().playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch);
|
||||
}
|
||||
@@ -361,6 +368,30 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
return new ScriptParticle(directory);
|
||||
}
|
||||
|
||||
public ISound createSound(String directory) {
|
||||
return new ScriptSound(directory);
|
||||
}
|
||||
|
||||
public void playSound(int id, ISound sound) {
|
||||
NoppesUtilServer.playSound(id, (ScriptSound) sound);
|
||||
}
|
||||
|
||||
public void stopSound(int id) {
|
||||
NoppesUtilServer.stopSound(id);
|
||||
}
|
||||
|
||||
public void pauseSounds() {
|
||||
NoppesUtilServer.pauseSounds();
|
||||
}
|
||||
|
||||
public void continueSounds() {
|
||||
NoppesUtilServer.continueSounds();
|
||||
}
|
||||
|
||||
public void stopSounds() {
|
||||
NoppesUtilServer.stopSounds();
|
||||
}
|
||||
|
||||
public int getServerTime() {
|
||||
return MinecraftServer.getServer().getTickCounter();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -131,4 +132,19 @@ public class ScriptBlock implements IBlock {
|
||||
this.tile.writeToNBT(compound);
|
||||
return NpcAPI.Instance().getINbt(compound);
|
||||
}
|
||||
|
||||
public boolean canCollide(double maxVolume) {
|
||||
AxisAlignedBB alignedBB = block.getCollisionBoundingBoxFromPool(world.getMCWorld(),getX(),getY(),getZ());
|
||||
if (alignedBB == null) {
|
||||
return false;
|
||||
}
|
||||
double xEdge = alignedBB.maxX - alignedBB.minX;
|
||||
double yEdge = alignedBB.maxY - alignedBB.minY;
|
||||
double zEdge = alignedBB.maxZ - alignedBB.minZ;
|
||||
return Math.abs(xEdge * yEdge * zEdge) > maxVolume;
|
||||
}
|
||||
|
||||
public boolean canCollide() {
|
||||
return canCollide(0);
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class ScriptBlockPos implements IPos {
|
||||
}
|
||||
|
||||
public IPos add(IPos pos) {
|
||||
return new ScriptBlockPos(this.blockPos.add(pos.getMCBlockPos()));
|
||||
return new ScriptBlockPos(this.blockPos.add(this.blockPos));
|
||||
}
|
||||
|
||||
public IPos subtract(int x, int y, int z) {
|
||||
@@ -100,10 +100,6 @@ public class ScriptBlockPos implements IPos {
|
||||
return new ScriptBlockPos(this.blockPos.offset(EnumFacing.values()[direction], n));
|
||||
}
|
||||
|
||||
public BlockPos getMCBlockPos() {
|
||||
return this.blockPos;
|
||||
}
|
||||
|
||||
public double[] normalize() {
|
||||
double d = Math.sqrt((double)(this.blockPos.getX() * this.blockPos.getX() + this.blockPos.getY() * this.blockPos.getY() + this.blockPos.getZ() * this.blockPos.getZ()));
|
||||
return new double[]{(double)this.getX() / d, (double)this.getY() / d, (double)this.getZ() / d};
|
||||
|
||||
@@ -3,6 +3,7 @@ package noppes.npcs.scripted;
|
||||
import net.minecraft.nbt.*;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.scripted.interfaces.IParticle;
|
||||
import noppes.npcs.scripted.interfaces.IWorld;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -128,7 +129,7 @@ public class ScriptParticle implements IParticle {
|
||||
return particle;
|
||||
}
|
||||
|
||||
public void spawnOnEntity(IEntity entity){
|
||||
public void spawn(IEntity entity){
|
||||
int entityID = entity.getMCEntity().getEntityId();
|
||||
|
||||
NBTTagCompound compound = this.writeToNBT();
|
||||
@@ -137,16 +138,28 @@ public class ScriptParticle implements IParticle {
|
||||
NoppesUtilServer.spawnScriptedParticle(compound, entity.getWorld().getDimensionID());
|
||||
}
|
||||
|
||||
public void spawnInWorld(ScriptWorld world){
|
||||
public void spawn(IWorld world){
|
||||
NBTTagCompound compound = this.writeToNBT();
|
||||
NoppesUtilServer.spawnScriptedParticle(compound, world.getDimensionID());
|
||||
}
|
||||
|
||||
public void spawnInWorld(ScriptWorld world, double x, double y, double z){
|
||||
public void spawn(IWorld world, double x, double y, double z){
|
||||
NBTTagCompound compound = this.writeToNBT();
|
||||
NoppesUtilServer.spawnScriptedParticle(compound, world.getDimensionID());
|
||||
}
|
||||
|
||||
public void spawnOnEntity(IEntity entity) {
|
||||
spawn(entity);
|
||||
}
|
||||
|
||||
public void spawnInWorld(IWorld world) {
|
||||
spawn(world);
|
||||
}
|
||||
|
||||
public void spawnInWorld(IWorld world, double x, double y, double z){
|
||||
spawn(world, x, y, z);
|
||||
}
|
||||
|
||||
public void setGlows(boolean glows) { this.glows = glows; }
|
||||
public boolean getGlows() { return this.glows; }
|
||||
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import noppes.npcs.scripted.interfaces.IPos;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ISound;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class ScriptSound implements ISound {
|
||||
public IEntity sourceEntity;
|
||||
public String directory;
|
||||
public float volume = 1.0F;
|
||||
public float pitch = 1.0F;
|
||||
public float xPosF;
|
||||
public float yPosF;
|
||||
public float zPosF;
|
||||
public boolean repeat = false;
|
||||
public int repeatDelay = 0;
|
||||
|
||||
public ScriptSound(String location) {
|
||||
this.directory = location;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
ScriptSound newSound = new ScriptSound("");
|
||||
|
||||
//Iterate through fields, check if they're not equal to a new object, write to NBT
|
||||
for (Field field : ScriptSound.class.getDeclaredFields()) {
|
||||
try {
|
||||
if (field.getName().equals("sourceEntity") && this.sourceEntity != null) {
|
||||
compound.setInteger("EntityID",this.sourceEntity.getEntityId());
|
||||
} else if (!field.get(this).equals(field.get(newSound))) {
|
||||
compound = writeNBTTag(compound, field.getType(), field.getName(), field.get(this));
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeNBTTag(NBTTagCompound compound, Class<?> c, String key, Object value) {
|
||||
if (c == boolean.class) {
|
||||
compound.setBoolean(key, (Boolean) value);
|
||||
}
|
||||
if (c == int.class) {
|
||||
compound.setInteger(key, (Integer) value);
|
||||
}
|
||||
if (c == double.class) {
|
||||
compound.setDouble(key, (Double) value);
|
||||
}
|
||||
if (c == float.class) {
|
||||
compound.setFloat(key, (Float) value);
|
||||
}
|
||||
if (c == String.class) {
|
||||
compound.setString(key, (String) value);
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
private static Object readNBTTag(NBTTagCompound compound, String key) {
|
||||
if (compound.getTag(key) instanceof NBTTagByte) {
|
||||
return compound.getBoolean(key);
|
||||
}
|
||||
if (compound.getTag(key) instanceof NBTTagInt) {
|
||||
return compound.getInteger(key);
|
||||
}
|
||||
if (compound.getTag(key) instanceof NBTTagDouble) {
|
||||
return compound.getDouble(key);
|
||||
}
|
||||
if (compound.getTag(key) instanceof NBTTagFloat) {
|
||||
return compound.getFloat(key);
|
||||
}
|
||||
if (compound.getTag(key) instanceof NBTTagString) {
|
||||
return compound.getString(key);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ScriptSound fromNBT(NBTTagCompound compound) {
|
||||
ScriptSound particle = new ScriptSound(compound.getString("directory"));
|
||||
|
||||
//Iterate through fields, check if compound has a key equal to the field's name, and if so set the field equal to that value from NBT.
|
||||
for (Field field : ScriptSound.class.getDeclaredFields()) {
|
||||
try {
|
||||
if (compound.hasKey(field.getName())) {
|
||||
if (!field.getName().equals("sourceEntity")) {
|
||||
Object val = ScriptSound.readNBTTag(compound, field.getName());
|
||||
if (val != null) {
|
||||
field.set(particle, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
return particle;
|
||||
}
|
||||
|
||||
public void setEntity(IEntity entity) {
|
||||
this.sourceEntity = entity;
|
||||
}
|
||||
|
||||
public IEntity getEntity() {
|
||||
return sourceEntity;
|
||||
}
|
||||
|
||||
public void setRepeat(boolean repeat) {
|
||||
this.repeat = repeat;
|
||||
}
|
||||
|
||||
public boolean repeats() {
|
||||
return this.repeat;
|
||||
}
|
||||
|
||||
public void setRepeatDelay(int delay) {
|
||||
this.repeatDelay = delay;
|
||||
}
|
||||
|
||||
public int getRepeatDelay() {
|
||||
return this.repeatDelay;
|
||||
}
|
||||
|
||||
public void setVolume(float volume) {
|
||||
this.volume = volume;
|
||||
}
|
||||
|
||||
public float getVolume()
|
||||
{
|
||||
return this.volume;
|
||||
}
|
||||
|
||||
public void setPitch(float pitch) {
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public float getPitch()
|
||||
{
|
||||
return this.pitch;
|
||||
}
|
||||
|
||||
public void setPosition(IPos pos) {
|
||||
this.xPosF = pos.getX();
|
||||
this.yPosF = pos.getY();
|
||||
this.zPosF = pos.getZ();
|
||||
}
|
||||
|
||||
public void setPosition(float x, float y, float z) {
|
||||
this.xPosF = x;
|
||||
this.yPosF = y;
|
||||
this.zPosF = z;
|
||||
}
|
||||
|
||||
public IPos getPos() {
|
||||
return new ScriptBlockPos(new BlockPos(xPosF,yPosF,zPosF));
|
||||
}
|
||||
|
||||
public float getX() {
|
||||
return this.xPosF;
|
||||
}
|
||||
|
||||
public float getY() {
|
||||
return this.yPosF;
|
||||
}
|
||||
|
||||
public float getZ() {
|
||||
return this.zPosF;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package noppes.npcs.scripted;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -15,6 +16,7 @@ import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntitySign;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
@@ -29,6 +31,7 @@ import noppes.npcs.scripted.interfaces.IParticle;
|
||||
import noppes.npcs.scripted.interfaces.ITileEntity;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ISound;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.interfaces.IWorld;
|
||||
|
||||
@@ -150,6 +153,51 @@ public class ScriptWorld implements IWorld {
|
||||
world.playSoundToNearExcept((EntityPlayerMP) player.getMCEntity(), sound, volume, pitch);
|
||||
}
|
||||
|
||||
public void playSound(int id, ISound sound) {
|
||||
IPlayer[] players = getAllServerPlayers();
|
||||
for (IPlayer player : players) {
|
||||
if (player.getDimension() == this.getDimensionID()) {
|
||||
player.playSound(id, sound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopSound(int id) {
|
||||
IPlayer[] players = getAllServerPlayers();
|
||||
for (IPlayer player : players) {
|
||||
if (player.getDimension() == this.getDimensionID()) {
|
||||
player.stopSound(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void pauseSounds() {
|
||||
IPlayer[] players = getAllServerPlayers();
|
||||
for (IPlayer player : players) {
|
||||
if (player.getDimension() == this.getDimensionID()) {
|
||||
player.pauseSounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void continueSounds() {
|
||||
IPlayer[] players = getAllServerPlayers();
|
||||
for (IPlayer player : players) {
|
||||
if (player.getDimension() == this.getDimensionID()) {
|
||||
player.continueSounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopSounds() {
|
||||
IPlayer[] players = getAllServerPlayers();
|
||||
for (IPlayer player : players) {
|
||||
if (player.getDimension() == this.getDimensionID()) {
|
||||
player.stopSounds();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEntity getEntityByID(int id){
|
||||
return NpcAPI.Instance().getIEntity(world.getEntityByID(id));
|
||||
}
|
||||
@@ -187,6 +235,35 @@ public class ScriptWorld implements IWorld {
|
||||
return list.toArray(new IEntity[0]);
|
||||
}
|
||||
|
||||
public IEntity[] getEntitiesNear(IPos position, double range) {
|
||||
ArrayList<IEntity> list = new ArrayList<>();
|
||||
|
||||
List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(
|
||||
position.getX() - range, position.getY() - range, position.getZ() - range,
|
||||
position.getX() + range, position.getY() + range, position.getZ() + range));
|
||||
for(Entity entity : entities){
|
||||
list.add(NpcAPI.Instance().getIEntity(entity));
|
||||
}
|
||||
|
||||
list.sort((e1, e2) -> {
|
||||
double dist1 = e1.getPos().distanceTo(position);
|
||||
double dist2 = e2.getPos().distanceTo(position);
|
||||
|
||||
if (dist1 > dist2) {
|
||||
return 1;
|
||||
} else if (dist1 < dist2) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
return list.toArray(new IEntity[0]);
|
||||
}
|
||||
|
||||
public IEntity[] getEntitiesNear(double x, double y, double z, double range) {
|
||||
return getEntitiesNear(new ScriptBlockPos(new BlockPos(x,y,z)), range);
|
||||
}
|
||||
|
||||
public void setTileEntity(int x, int y, int z, ITileEntity tileEntity){
|
||||
world.setTileEntity(x,y,z,tileEntity.getMCTileEntity());
|
||||
}
|
||||
@@ -281,42 +358,63 @@ public class ScriptWorld implements IWorld {
|
||||
public void removeBlock(int x, int y, int z){
|
||||
world.setBlock(x, y, z, Blocks.air);
|
||||
}
|
||||
|
||||
/**
|
||||
* starting at the start position, draw a line in the lookVector direction until a block is detected
|
||||
* @param startPos
|
||||
* @param lookVector should be a normalized direction vector
|
||||
* @param maxDistance
|
||||
* @return the first detected block but null if maxDistance is reached
|
||||
*/
|
||||
public IBlock rayCastBlock(double[] startPos, double[] lookVector, int maxDistance) {
|
||||
if (startPos.length != 3 || lookVector.length != 3) 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;
|
||||
|
||||
while (rep++ < maxDistance + 10) {
|
||||
currentPos = currentPos.addVector(lookVector[0], lookVector[1], lookVector[2]);
|
||||
pos = new ScriptBlockPos(new BlockPos(currentPos.xCoord, currentPos.yCoord, currentPos.zCoord));
|
||||
|
||||
IBlock block = getBlock((int)currentPos.xCoord, (int)currentPos.yCoord, (int)currentPos.zCoord);
|
||||
//System.out.println("Checking block at ["+(int)currentPos.xCoord+","+(int)currentPos.yCoord+","+(int)currentPos.zCoord+"]");
|
||||
if (block == null) continue;
|
||||
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)
|
||||
+Math.pow(currentPos.yCoord-startPos[1],2)
|
||||
+Math.pow(currentPos.zCoord-startPos[2],2)
|
||||
, 0.5);
|
||||
//System.out.println("current distance check: "+distance+" on rep "+rep);
|
||||
if (distance > maxDistance) return null;
|
||||
return block;
|
||||
if (distance > maxDistance) {
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
//System.out.println("ScriptWorld:WARNING: Repeated a ray cast to many times");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* starting at the start position, draw a line in the lookVector direction until a block is detected
|
||||
* @param startPos
|
||||
* @param lookVector will normalize x, y, z to get a direction vector
|
||||
* @param maxDistance
|
||||
* @return the first detected block but null if maxDistance is reached
|
||||
*/
|
||||
public IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance) {
|
||||
return rayCastPos(startPos,lookVector,maxDistance,true, false, false);
|
||||
}
|
||||
|
||||
public IPos rayCastPos(IPos startPos, IPos lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
|
||||
return rayCastPos(new double[] {startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalize(), maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision);
|
||||
}
|
||||
|
||||
public IPos rayCastPos(IPos startPos, IPos lookVector, int maxDistance) {
|
||||
return rayCastPos(new double[] {startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalize(), maxDistance, true, false, false);
|
||||
}
|
||||
|
||||
public IBlock rayCastBlock(double[] startPos, double[] lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
|
||||
return getBlock(rayCastPos(startPos,lookVector,maxDistance,stopOnBlock,stopOnLiquid,stopOnCollision));
|
||||
}
|
||||
|
||||
public IBlock rayCastBlock(double[] startPos, double[] lookVector, int maxDistance) {
|
||||
return rayCastBlock(startPos, lookVector, maxDistance, true, false, false);
|
||||
}
|
||||
|
||||
public IBlock rayCastBlock(IPos startPos, IPos lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
|
||||
return rayCastBlock(new double[] {startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalize(), maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision);
|
||||
}
|
||||
|
||||
public IBlock rayCastBlock(IPos startPos, IPos lookVector, int maxDistance) {
|
||||
return rayCastBlock(new double[] {startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalize(), maxDistance);
|
||||
}
|
||||
@@ -350,6 +448,61 @@ public class ScriptWorld implements IWorld {
|
||||
return currentPos;
|
||||
}
|
||||
|
||||
public IEntity[] rayCastEntities(double[] startPos, double[] lookVector,
|
||||
int maxDistance, double offset, double range,
|
||||
boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
|
||||
ArrayList<IEntity> entities = new ArrayList<>();
|
||||
|
||||
Vec3 currentPos = Vec3.createVectorHelper(startPos[0], startPos[1], startPos[2]); int rep = 0;
|
||||
currentPos = currentPos.addVector(lookVector[0]*offset, lookVector[1]*offset, lookVector[2]*offset);
|
||||
|
||||
while (rep++ < maxDistance + 10) {
|
||||
currentPos = currentPos.addVector(lookVector[0], lookVector[1], lookVector[2]);
|
||||
IPos pos = new ScriptBlockPos(new BlockPos(currentPos.xCoord, currentPos.yCoord, currentPos.zCoord));
|
||||
IBlock block = getBlock(pos);
|
||||
|
||||
if (block != null && stopOnBlock) {
|
||||
if ((!stopOnLiquid || block.getMCBlock() instanceof BlockLiquid)
|
||||
&& (!stopOnCollision || block.canCollide()))
|
||||
return entities.toArray(new IEntity[0]);
|
||||
}
|
||||
|
||||
IEntity[] entitiesNear = getEntitiesNear(pos,range);
|
||||
for (IEntity entity : entitiesNear) {
|
||||
if (!entities.contains(entity)) {
|
||||
entities.add(entity);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return entities.toArray(new IEntity[0]);
|
||||
}
|
||||
|
||||
public IEntity[] rayCastEntities(IPos startPos, IPos lookVector,
|
||||
int maxDistance, double offset, double range,
|
||||
boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
|
||||
return rayCastEntities(new double[] {startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalize(), maxDistance, offset, range, stopOnBlock, stopOnLiquid, stopOnCollision);
|
||||
}
|
||||
|
||||
public IEntity[] rayCastEntities(double[] startPos, double[] lookVector,
|
||||
int maxDistance, double offset, double range) {
|
||||
return rayCastEntities(startPos, lookVector, maxDistance, offset, range, true, false, true);
|
||||
}
|
||||
|
||||
public IEntity[] rayCastEntities(IPos startPos, IPos lookVector,
|
||||
int maxDistance, double offset, double range) {
|
||||
return rayCastEntities(new double[] {startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalize(), maxDistance, offset, range, true, false, true);
|
||||
}
|
||||
|
||||
public boolean canSeeSky(int x, int y, int z) {
|
||||
return world.canBlockSeeTheSky(x, y, z);
|
||||
}
|
||||
@@ -547,7 +700,8 @@ public class ScriptWorld implements IWorld {
|
||||
public void explode(double x, double y, double z, float range, boolean fire, boolean grief){
|
||||
world.newExplosion(null, x, y, z, range, fire, grief);
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public IPlayer[] getAllServerPlayers(){
|
||||
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
IPlayer[] arr = new IPlayer[list.size()];
|
||||
@@ -558,6 +712,7 @@ public class ScriptWorld implements IWorld {
|
||||
return arr;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String[] getPlayerNames() {
|
||||
IPlayer[] players = getAllServerPlayers();
|
||||
String[] names = new String[players.length];
|
||||
@@ -584,24 +739,27 @@ public class ScriptWorld implements IWorld {
|
||||
* @param name Name of the cloned entity
|
||||
* @return Returns the entity which was spawned
|
||||
*/
|
||||
public IEntity spawnClone(int x, int y, int z, int tab, String name){
|
||||
public IEntity spawnClone(int x, int y, int z, int tab, String name, boolean ignoreProtection){
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(null, name, tab);
|
||||
if(compound == null)
|
||||
return null;
|
||||
Entity entity = NoppesUtilServer.spawnClone(compound, x, y, z, world);
|
||||
if(entity == null)
|
||||
return null;
|
||||
return NpcAPI.Instance().getIEntity(entity);
|
||||
Entity entity;
|
||||
if (!ignoreProtection) {
|
||||
entity = NoppesUtilServer.spawnCloneWithProtection(compound, x, y, z, world);
|
||||
} else {
|
||||
entity = NoppesUtilServer.spawnClone(compound, x, y, z, world);
|
||||
}
|
||||
return entity == null ? null : NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
|
||||
public IEntity spawnClone(int x, int y, int z, int tab, String name) {
|
||||
return this.spawnClone(x,y,z,tab,name,true);
|
||||
}
|
||||
|
||||
public ScriptScoreboard getScoreboard(){
|
||||
return new ScriptScoreboard();
|
||||
}
|
||||
|
||||
public BlockPos getMCBlockPos(int x, int y, int z){
|
||||
return new BlockPos(x,y,z);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* Expert use only
|
||||
|
||||
@@ -248,7 +248,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
NoppesUtilServer.spawnScriptedParticle(compound, this.getWorld().getDimensionID());
|
||||
}
|
||||
|
||||
public void spawnParticle(IParticle entityParticle) { entityParticle.spawnOnEntity(this); }
|
||||
public void spawnParticle(IParticle entityParticle) { entityParticle.spawn(this); }
|
||||
|
||||
public int getEntityId(){
|
||||
return entity.getEntityId();
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package noppes.npcs.scripted.entity;
|
||||
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EntityDamageSource;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import noppes.npcs.scripted.ScriptBlockPos;
|
||||
import noppes.npcs.scripted.interfaces.IBlock;
|
||||
import noppes.npcs.scripted.interfaces.IPos;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
@@ -13,6 +19,8 @@ import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptDamageSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T> implements IEntityLivingBase {
|
||||
protected T entity;
|
||||
|
||||
@@ -97,6 +105,47 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
||||
public boolean canSeeEntity(IEntity entity){
|
||||
return this.entity.canEntityBeSeen(entity.getMCEntity());
|
||||
}
|
||||
|
||||
public IPos getLookVector() {
|
||||
Vec3 lookVec = entity.getLookVec();
|
||||
return new ScriptBlockPos(new BlockPos(lookVec.xCoord,lookVec.yCoord,lookVec.zCoord));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public IBlock getLookingAtBlock(int maxDistance) {
|
||||
return getLookingAtBlock(maxDistance, true, false, false);
|
||||
}
|
||||
|
||||
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[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord},
|
||||
maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision);
|
||||
}
|
||||
|
||||
public IPos getLookingAtPos(int maxDistance) {
|
||||
return getLookingAtPos(maxDistance, true, false, false);
|
||||
}
|
||||
|
||||
public IEntity[] getLookingAtEntities(int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
|
||||
Vec3 lookVec = entity.getLookVec();
|
||||
double[] startPos = new double[] {entity.posX, entity.posY+entity.getEyeHeight(), entity.posZ};
|
||||
double[] lookVector = new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord};
|
||||
|
||||
return getWorld().rayCastEntities(startPos,lookVector,maxDistance,offset,range,stopOnBlock,stopOnLiquid,stopOnCollision);
|
||||
}
|
||||
|
||||
public IEntity[] getLookingAtEntities(int maxDistance, double offset, double range) {
|
||||
return getLookingAtEntities(maxDistance,offset,range,true,false,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expert use only
|
||||
@@ -116,10 +165,6 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
||||
public void swingHand(){
|
||||
entity.swingItem();
|
||||
}
|
||||
|
||||
public String getLookVec(){
|
||||
return entity.getLookVec().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Works the same as the <a href="http://minecraft.gamepedia.com/Commands#effect">/effect command</a>
|
||||
|
||||
@@ -452,12 +452,14 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
return npc.stats.maxDelay;
|
||||
}
|
||||
|
||||
public void setRangedRage(int rangedRange) {
|
||||
public void setRangedRange(int rangedRange) {
|
||||
npc.stats.rangedRange = rangedRange;
|
||||
}
|
||||
public int getRangedRage() {
|
||||
public int getRangedRange() {
|
||||
return npc.stats.rangedRange;
|
||||
}
|
||||
public void setRangedRage(int rangedRage) { this.setRangedRange(rangedRage); }
|
||||
public int getRangedRage() { return this.getRangedRange(); }
|
||||
|
||||
public void setFireRate(int rate) {
|
||||
npc.stats.fireRate = rate;
|
||||
@@ -1006,8 +1008,13 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
* @param type Retaliation type. 0:normal, 1:panic, 2:retreat, 3:nothing
|
||||
*/
|
||||
public void setRetaliateType(int type){
|
||||
if (type < 0)
|
||||
type = 0;
|
||||
if (type > 3)
|
||||
type = 3;
|
||||
|
||||
npc.ai.onAttack = type;
|
||||
npc.setResponse();
|
||||
npc.updateTasks();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package noppes.npcs.scripted.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -17,13 +14,8 @@ import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.NoppesStringUtils;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.*;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.containers.ContainerCustomGui;
|
||||
@@ -41,17 +33,16 @@ import noppes.npcs.controllers.data.QuestData;
|
||||
import noppes.npcs.entity.EntityDialogNpc;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptPixelmonPlayerData;
|
||||
import noppes.npcs.scripted.ScriptSound;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.gui.ScriptGui;
|
||||
import noppes.npcs.scripted.interfaces.IParticle;
|
||||
import noppes.npcs.scripted.interfaces.handler.IPlayerData;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IDialog;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
|
||||
import noppes.npcs.scripted.interfaces.IBlock;
|
||||
import noppes.npcs.scripted.interfaces.IContainer;
|
||||
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ISound;
|
||||
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.ITimers;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.handler.IOverlayHandler;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
@@ -81,6 +72,10 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
return player.getCommandSenderName();
|
||||
}
|
||||
|
||||
public void kick(String reason) {
|
||||
player.playerNetServerHandler.kickPlayerFromServer(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle(IParticle entityParticle) {
|
||||
entityParticle.spawnOnEntity(this);
|
||||
@@ -121,15 +116,30 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
|
||||
player.getFoodStats().addStats(0,saturation-prevSaturation);
|
||||
}
|
||||
|
||||
public boolean hasFinishedQuest(int id){
|
||||
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
return data.finishedQuests.containsKey(id);
|
||||
|
||||
public void showDialog(IDialog dialog) {
|
||||
if (dialog != null) {
|
||||
showDialog(dialog.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasActiveQuest(int id){
|
||||
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
return data.activeQuests.containsKey(id);
|
||||
|
||||
public boolean hasReadDialog(IDialog dialog) {
|
||||
if (dialog != null) {
|
||||
return hasReadDialog(dialog.getId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void readDialog(IDialog dialog) {
|
||||
if (dialog != null) {
|
||||
this.readDialog(dialog.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public void unreadDialog(IDialog dialog) {
|
||||
if (dialog != null) {
|
||||
this.unreadDialog(dialog.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public void showDialog(int id){
|
||||
@@ -139,7 +149,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
|
||||
NoppesUtilServer.openDialog(player, new EntityDialogNpc(this.player.worldObj), dialog, 0);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasReadDialog(int id){
|
||||
PlayerDialogData data = PlayerDataController.instance.getPlayerData(player).dialogData;
|
||||
return data.dialogsRead.contains(id);
|
||||
@@ -153,6 +163,52 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
PlayerDataController.instance.getPlayerData(player).dialogData.dialogsRead.remove(id);
|
||||
}
|
||||
|
||||
public boolean hasFinishedQuest(IQuest quest) {
|
||||
if (quest == null)
|
||||
return false;
|
||||
return hasFinishedQuest(quest.getId());
|
||||
}
|
||||
|
||||
public boolean hasActiveQuest(IQuest quest) {
|
||||
if (quest == null)
|
||||
return false;
|
||||
return hasActiveQuest(quest.getId());
|
||||
}
|
||||
|
||||
public void startQuest(IQuest quest) {
|
||||
if (quest == null)
|
||||
return;
|
||||
startQuest(quest.getId());
|
||||
}
|
||||
|
||||
public void finishQuest(IQuest quest) {
|
||||
if (quest == null)
|
||||
return;
|
||||
finishQuest(quest.getId());
|
||||
}
|
||||
|
||||
public void stopQuest(IQuest quest) {
|
||||
if (quest == null)
|
||||
return;
|
||||
stopQuest(quest.getId());
|
||||
}
|
||||
|
||||
public void removeQuest(IQuest quest) {
|
||||
if (quest == null)
|
||||
return;
|
||||
removeQuest(quest.getId());
|
||||
}
|
||||
|
||||
public boolean hasFinishedQuest(int id){
|
||||
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
return data.finishedQuests.containsKey(id);
|
||||
}
|
||||
|
||||
public boolean hasActiveQuest(int id){
|
||||
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
return data.activeQuests.containsKey(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the quest from active quest list
|
||||
* @param id The Quest ID
|
||||
@@ -487,6 +543,26 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
player.playSound(name, volume, pitch);
|
||||
}
|
||||
|
||||
public void playSound(int id, ISound sound) {
|
||||
NoppesUtilPlayer.playSoundTo(player, id, (ScriptSound) sound);
|
||||
}
|
||||
|
||||
public void stopSound(int id) {
|
||||
NoppesUtilPlayer.stopSoundFor(player, id);
|
||||
}
|
||||
|
||||
public void pauseSounds() {
|
||||
NoppesUtilPlayer.pauseSoundsFor(player);
|
||||
}
|
||||
|
||||
public void continueSounds() {
|
||||
NoppesUtilPlayer.continueSoundsFor(player);
|
||||
}
|
||||
|
||||
public void stopSounds() {
|
||||
NoppesUtilPlayer.stopSoundsFor(player);
|
||||
}
|
||||
|
||||
public void mountEntity(Entity ridingEntity){
|
||||
player.mountEntity(ridingEntity);
|
||||
}
|
||||
@@ -550,14 +626,6 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
return new ScriptPixelmonPlayerData(player);
|
||||
}
|
||||
|
||||
public IBlock getLookingAtBlock(int maxDistance) {
|
||||
Vec3 lookVec = player.getLookVec();
|
||||
return getWorld().rayCastBlock(
|
||||
new double[] {player.posX, player.posY+player.getEyeHeight(), player.posZ},
|
||||
new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord},
|
||||
maxDistance);
|
||||
}
|
||||
|
||||
public ITimers getTimers() {
|
||||
return PlayerDataController.instance.getPlayerData(player).timers;
|
||||
}
|
||||
@@ -601,6 +669,10 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public boolean isScriptingDev() {
|
||||
return CustomNpcs.isScriptDev(player);
|
||||
}
|
||||
|
||||
public IQuest[] getActiveQuests() {
|
||||
PlayerQuestData data = (PlayerQuestData) this.getData().getQuestData();
|
||||
List<IQuest> quests = new ArrayList();
|
||||
|
||||
@@ -58,15 +58,26 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
}
|
||||
|
||||
public static class MouseClickedEvent extends PlayerEvent {
|
||||
public final boolean isCtrlPressed;
|
||||
public final boolean isAltPressed;
|
||||
public final boolean isShiftPressed;
|
||||
public final boolean isMetaPressed;
|
||||
public final int[] keysDown;
|
||||
|
||||
public final int button;
|
||||
public final int mouseWheel;
|
||||
public final boolean buttonDown;
|
||||
|
||||
public MouseClickedEvent(IPlayer player, int button, int mouseWheel, boolean buttonDown){
|
||||
public MouseClickedEvent(IPlayer player, int button, int mouseWheel, boolean buttonDown, boolean isCtrlPressed, boolean isAltPressed, boolean isShiftPressed, boolean isMetaPressed, int[] heldKeys){
|
||||
super(player);
|
||||
this.button = button;
|
||||
this.mouseWheel = mouseWheel;
|
||||
this.buttonDown = buttonDown;
|
||||
this.isCtrlPressed = isCtrlPressed;
|
||||
this.isAltPressed = isAltPressed;
|
||||
this.isShiftPressed = isShiftPressed;
|
||||
this.isMetaPressed = isMetaPressed;
|
||||
this.keysDown = heldKeys;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +137,20 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class AttackedEvent extends PlayerEvent {
|
||||
public final IDamageSource damageSource;
|
||||
public final IEntity source;
|
||||
public final float damage;
|
||||
|
||||
public AttackedEvent(IPlayer player, Entity source, float damage, DamageSource damagesource) {
|
||||
super(player);
|
||||
this.source = NpcAPI.Instance().getIEntity(source);
|
||||
this.damage = damage;
|
||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class DamagedEvent extends PlayerEvent {
|
||||
public final IDamageSource damageSource;
|
||||
@@ -212,6 +237,20 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class AttackEvent extends PlayerEvent {
|
||||
public final IDamageSource damageSource;
|
||||
public final IEntity target;
|
||||
public float damage;
|
||||
|
||||
public AttackEvent(IPlayer player, Entity target, float damage, DamageSource damagesource) {
|
||||
super(player);
|
||||
this.target = NpcAPI.Instance().getIEntity(target);
|
||||
this.damage = damage;
|
||||
this.damageSource = NpcAPI.Instance().getIDamageSource(damagesource);
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class DamagedEntityEvent extends PlayerEvent {
|
||||
public final IDamageSource damageSource;
|
||||
@@ -274,18 +313,6 @@ public class PlayerEvent extends CustomNPCsEvent {
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class AttackEvent extends PlayerEvent {
|
||||
public final int type;
|
||||
public final Object target;
|
||||
|
||||
public AttackEvent(IPlayer player, int type, Object target) {
|
||||
super(player);
|
||||
this.type = type;
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class InteractEvent extends PlayerEvent {
|
||||
public final int type;
|
||||
|
||||
@@ -22,13 +22,16 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.controllers.*;
|
||||
import noppes.npcs.scripted.ScriptSound;
|
||||
import noppes.npcs.scripted.gui.ScriptGui;
|
||||
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
|
||||
import noppes.npcs.scripted.interfaces.handler.*;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ISound;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay;
|
||||
import noppes.npcs.scripted.overlay.ScriptOverlay;
|
||||
@@ -153,6 +156,8 @@ public abstract class AbstractNpcAPI {
|
||||
|
||||
public abstract IPlayer[] getAllServerPlayers();
|
||||
|
||||
public abstract String[] getPlayerNames();
|
||||
|
||||
public abstract IItemStack createItem(String id, int damage, int size);
|
||||
|
||||
public abstract void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch);
|
||||
@@ -179,6 +184,18 @@ public abstract class AbstractNpcAPI {
|
||||
@Deprecated
|
||||
public abstract IParticle createEntityParticle(String directory);
|
||||
|
||||
public abstract ISound createSound(String directory);
|
||||
|
||||
public abstract void playSound(int id, ISound sound);
|
||||
|
||||
public abstract void stopSound(int id);
|
||||
|
||||
public abstract void pauseSounds();
|
||||
|
||||
public abstract void continueSounds();
|
||||
|
||||
public abstract void stopSounds();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The uptime of the server in MC ticks.
|
||||
|
||||
@@ -103,4 +103,13 @@ public interface IBlock {
|
||||
* @return An INbt object which can modify the block's tile entity's NBT data.
|
||||
*/
|
||||
INbt getTileEntityNBT();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param maxVolume The volume threshold to determine whether this block's bounding box collides, if it has one.
|
||||
* @return Whether this block can be collided with
|
||||
*/
|
||||
boolean canCollide(double maxVolume);
|
||||
|
||||
boolean canCollide();
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
import noppes.npcs.scripted.ScriptWorld;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
|
||||
/**
|
||||
@@ -24,13 +23,13 @@ public interface IParticle {
|
||||
*
|
||||
* @param entity Spawns this particle object on the given entity. When spawned this way, the particle will always have its origin at the entity.
|
||||
*/
|
||||
void spawnOnEntity(IEntity entity);
|
||||
void spawn(IEntity entity);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param world Spawns the particle in the given world, at a position corresponding to this particle's position variables.
|
||||
*/
|
||||
void spawnInWorld(ScriptWorld world);
|
||||
void spawn(IWorld world);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -39,7 +38,16 @@ public interface IParticle {
|
||||
* @param y The Y position the particle will spawn in the world.
|
||||
* @param z The Z position the particle will spawn in the world.
|
||||
*/
|
||||
void spawnInWorld(ScriptWorld world, double x, double y, double z);
|
||||
void spawn(IWorld world, double x, double y, double z);
|
||||
|
||||
@Deprecated
|
||||
void spawnOnEntity(IEntity entity);
|
||||
|
||||
@Deprecated
|
||||
void spawnInWorld(IWorld world);
|
||||
|
||||
@Deprecated
|
||||
void spawnInWorld(IWorld world, double x, double y, double z);
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IPos {
|
||||
int getX();
|
||||
|
||||
@@ -140,12 +138,6 @@ public interface IPos {
|
||||
*/
|
||||
double[] normalize();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return An obfuscated MC BlockPos object.
|
||||
*/
|
||||
BlockPos getMCBlockPos();
|
||||
|
||||
/**
|
||||
* Offsets the block by 1 block in the given direction and returns the resulting IPos object
|
||||
*
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import noppes.npcs.scripted.ScriptBlock;
|
||||
import noppes.npcs.scripted.ScriptWorld;
|
||||
|
||||
public interface ITileEntity {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.scripted.ScriptScoreboard;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ISound;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
|
||||
public interface IWorld {
|
||||
@@ -79,6 +79,16 @@ public interface IWorld {
|
||||
|
||||
void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch);
|
||||
|
||||
void playSound(int id, ISound sound);
|
||||
|
||||
void stopSound(int id);
|
||||
|
||||
void pauseSounds();
|
||||
|
||||
void continueSounds();
|
||||
|
||||
void stopSounds();
|
||||
|
||||
IEntity getEntityByID(int id);
|
||||
|
||||
boolean spawnEntityInWorld(IEntity entity);
|
||||
@@ -100,6 +110,10 @@ public interface IWorld {
|
||||
|
||||
IEntity[] getLoadedEntities();
|
||||
|
||||
IEntity[] getEntitiesNear(IPos position, double range);
|
||||
|
||||
IEntity[] getEntitiesNear(double x, double y, double z, double range);
|
||||
|
||||
/**
|
||||
* Sets the block's tile entity at the given position.
|
||||
*/
|
||||
@@ -156,23 +170,28 @@ public interface IWorld {
|
||||
*/
|
||||
public void removeBlock(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* starting at the start position, draw a line in the lookVector direction until a block is detected
|
||||
* @param startPos
|
||||
* @param lookVector should be a normalized direction vector
|
||||
* @param maxDistance
|
||||
* @return the first detected block but null if maxDistance is reached
|
||||
*/
|
||||
public IBlock rayCastBlock(double[] startPos, double[] lookVector, int maxDistance);
|
||||
IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance);
|
||||
|
||||
IPos rayCastPos(IPos startPos, IPos lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IPos rayCastPos(IPos startPos, IPos lookVector, int maxDistance);
|
||||
|
||||
/**
|
||||
* starting at the start position, draw a line in the lookVector direction until a block is detected
|
||||
* @param startPos
|
||||
* @param lookVector will normalize x, y, z to get a direction vector
|
||||
* @param maxDistance
|
||||
* @return the first detected block but null if maxDistance is reached
|
||||
*/
|
||||
public IBlock rayCastBlock(IPos startPos, IPos lookVector, int maxDistance);
|
||||
* starting at the start position, draw a line in the lookVector direction until a block is detected
|
||||
* @param startPos
|
||||
* @param lookVector should be a normalized direction vector
|
||||
* @param maxDistance
|
||||
* @return the first detected block but null if maxDistance is reached
|
||||
*/
|
||||
IBlock rayCastBlock(double[] startPos, double[] lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IBlock rayCastBlock(double[] startPos, double[] lookVector, int maxDistance);
|
||||
|
||||
IBlock rayCastBlock(IPos startPos, IPos lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IBlock rayCastBlock(IPos startPos, IPos lookVector, int maxDistance);
|
||||
|
||||
/**
|
||||
* @param startPos
|
||||
@@ -181,6 +200,14 @@ public interface IWorld {
|
||||
*/
|
||||
public IPos getNearestAir(IPos startPos, int maxHeight);
|
||||
|
||||
IEntity[] rayCastEntities(double[] startPos, double[] lookVector, int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IEntity[] rayCastEntities(IPos startPos, IPos lookVector, int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IEntity[] rayCastEntities(double[] startPos, double[] lookVector, int maxDistance, double offset, double range);
|
||||
|
||||
IEntity[] rayCastEntities(IPos startPos, IPos lookVector, int maxDistance, double offset, double range);
|
||||
|
||||
/**
|
||||
* @param x
|
||||
* @param y
|
||||
@@ -346,18 +373,15 @@ public interface IWorld {
|
||||
* @param z The z position the clone will be spawned at
|
||||
* @param tab The tab in which the clone is
|
||||
* @param name Name of the cloned entity
|
||||
* @param ignoreProtection Whether the spawning of this clone skips protection checks.
|
||||
* @return Returns the entity which was spawned
|
||||
*/
|
||||
IEntity spawnClone(int x, int y, int z, int tab, String name, boolean ignoreProtection);
|
||||
|
||||
IEntity spawnClone(int x, int y, int z, int tab, String name);
|
||||
|
||||
ScriptScoreboard getScoreboard();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return An obfuscated MC BlockPos object.
|
||||
*/
|
||||
BlockPos getMCBlockPos(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* Expert use only
|
||||
|
||||
@@ -254,8 +254,8 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
|
||||
void setMaxProjectileDelay(int maxDelay);
|
||||
int getMaxProjectileDelay();
|
||||
|
||||
void setRangedRage(int rangedRange);
|
||||
int getRangedRage();
|
||||
void setRangedRange(int rangedRange);
|
||||
int getRangedRange();
|
||||
|
||||
void setFireRate(int rate);
|
||||
int getFireRate();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package noppes.npcs.scripted.interfaces.entity;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.scripted.interfaces.IBlock;
|
||||
import noppes.npcs.scripted.interfaces.IPos;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.ScriptDamageSource;
|
||||
|
||||
@@ -50,6 +52,40 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
|
||||
*/
|
||||
boolean canSeeEntity(IEntity entity);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Returns the look vector of this entity as an IPos object.
|
||||
*/
|
||||
IPos getLookVector();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param maxDistance The max distance to perform checks before stopping
|
||||
* @return The first block found by following along the entity's look vector.
|
||||
*/
|
||||
IBlock getLookingAtBlock(int maxDistance);
|
||||
|
||||
/**
|
||||
* Returns an IPos object corresponding to the final obstructed point following along the
|
||||
* entity's look vector. If no obstructions are found (entity is looking in a straight path of
|
||||
* air with no blocks in the way), the final position is returned.
|
||||
*
|
||||
* @param maxDistance The max distance to perform checks before stopping
|
||||
* @return The position the entity is looking at.
|
||||
*/
|
||||
IPos getLookingAtPos(int maxDistance);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param maxDistance The max distance to perform checks before stopping
|
||||
* @param range The radius to check for surrounding entities at every point on the vector
|
||||
* @return A list of entities, sorted first by closest to the entity along the look vector, then by which
|
||||
* entities are closest to the vector.
|
||||
*/
|
||||
IEntity[] getLookingAtEntities(int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
|
||||
|
||||
IEntity[] getLookingAtEntities(int maxDistance, double offset, double range);
|
||||
|
||||
/**
|
||||
* Expert use only
|
||||
* @return Returns the minecraft entity object
|
||||
|
||||
@@ -6,9 +6,11 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
import noppes.npcs.scripted.entity.ScriptDBCPlayer;
|
||||
import noppes.npcs.scripted.interfaces.handler.IOverlayHandler;
|
||||
import noppes.npcs.scripted.interfaces.handler.IPlayerData;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IDialog;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
|
||||
import noppes.npcs.scripted.interfaces.handler.data.ISound;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay;
|
||||
import noppes.npcs.scripted.ScriptPixelmonPlayerData;
|
||||
@@ -24,6 +26,8 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
|
||||
*/
|
||||
String getName();
|
||||
|
||||
void kick(String reason);
|
||||
|
||||
void setPosition(double x, double y, double z);
|
||||
|
||||
void setPosition(double x, double y, double z, int dimensionId);
|
||||
@@ -36,36 +40,69 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
|
||||
|
||||
void setSaturation(float saturation);
|
||||
|
||||
public boolean hasReadDialog(int id);
|
||||
void showDialog(IDialog dialog);
|
||||
|
||||
public void readDialog(int id);
|
||||
boolean hasReadDialog(IDialog dialog);
|
||||
|
||||
public void unreadDialog(int id);
|
||||
void readDialog(IDialog dialog);
|
||||
|
||||
void unreadDialog(IDialog dialog);
|
||||
|
||||
void showDialog(int id);
|
||||
|
||||
boolean hasReadDialog(int id);
|
||||
|
||||
void readDialog(int id);
|
||||
|
||||
void unreadDialog(int id);
|
||||
|
||||
boolean hasFinishedQuest(IQuest quest);
|
||||
|
||||
boolean hasActiveQuest(IQuest quest);
|
||||
|
||||
/**
|
||||
* Add the quest from active quest list
|
||||
* @param quest The quest
|
||||
*/
|
||||
void startQuest(IQuest quest);
|
||||
|
||||
/**
|
||||
* Add the quest from finished quest list
|
||||
* @param quest The quest
|
||||
*/
|
||||
void finishQuest(IQuest quest);
|
||||
/**
|
||||
* Removes the quest from active quest list
|
||||
* @param quest The quest
|
||||
*/
|
||||
void stopQuest(IQuest quest);
|
||||
|
||||
/**
|
||||
* Removes the quest from active and finished quest list
|
||||
* @param quest The quest
|
||||
*/
|
||||
void removeQuest(IQuest quest);
|
||||
|
||||
boolean hasFinishedQuest(int id);
|
||||
|
||||
boolean hasActiveQuest(int id);
|
||||
|
||||
/**
|
||||
* Add the quest from active quest list
|
||||
* @param id The Quest ID
|
||||
* @param id The quest ID
|
||||
*/
|
||||
void startQuest(int id);
|
||||
|
||||
/**
|
||||
* Add the quest from finished quest list
|
||||
* @param id The Quest ID
|
||||
* @param id The quest ID
|
||||
*/
|
||||
void finishQuest(int id);
|
||||
/**
|
||||
* Removes the quest from active quest list
|
||||
* @param id The Quest ID
|
||||
* @param id The quest ID
|
||||
*/
|
||||
void stopQuest(int id);
|
||||
|
||||
/**
|
||||
* Removes the quest from active and finished quest list
|
||||
* @param id The Quest ID
|
||||
* @param id The quest ID
|
||||
*/
|
||||
void removeQuest(int id);
|
||||
|
||||
@@ -188,6 +225,16 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
|
||||
|
||||
void playSound(String name, float volume, float pitch);
|
||||
|
||||
void playSound(int id, ISound sound);
|
||||
|
||||
void stopSound(int id);
|
||||
|
||||
void pauseSounds();
|
||||
|
||||
void continueSounds();
|
||||
|
||||
void stopSounds();
|
||||
|
||||
void mountEntity(Entity ridingEntity);
|
||||
|
||||
IEntity dropOneItem(boolean dropStack);
|
||||
@@ -226,8 +273,6 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
|
||||
*/
|
||||
ScriptPixelmonPlayerData getPixelmonData();
|
||||
|
||||
IBlock getLookingAtBlock(int maxDistance);
|
||||
|
||||
ITimers getTimers();
|
||||
|
||||
void updatePlayerInventory();
|
||||
@@ -238,6 +283,8 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
|
||||
|
||||
public IPlayerData getData();
|
||||
|
||||
boolean isScriptingDev();
|
||||
|
||||
IQuest[] getActiveQuests();
|
||||
|
||||
IContainer getOpenContainer();
|
||||
|
||||
@@ -9,6 +9,9 @@ import noppes.npcs.scripted.interfaces.IWorld;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
|
||||
public interface ICloneHandler {
|
||||
|
||||
IEntity spawn(double x, double y, double z, int tab, String name, IWorld world, boolean ignoreProtection);
|
||||
|
||||
IEntity spawn(double x, double y, double z, int tab, String name, IWorld world);
|
||||
|
||||
IEntity[] getTab(int tab, IWorld world);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package noppes.npcs.scripted.interfaces.handler.data;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.IPos;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
|
||||
public interface ISound {
|
||||
|
||||
void setEntity(IEntity entity);
|
||||
|
||||
IEntity getEntity();
|
||||
|
||||
void setRepeat(boolean repeat);
|
||||
|
||||
boolean repeats();
|
||||
|
||||
void setRepeatDelay(int delay);
|
||||
|
||||
int getRepeatDelay();
|
||||
|
||||
void setVolume(float volume);
|
||||
|
||||
float getVolume();
|
||||
|
||||
void setPitch(float pitch);
|
||||
|
||||
float getPitch();
|
||||
|
||||
void setPosition(IPos pos);
|
||||
|
||||
void setPosition(float x, float y, float z);
|
||||
|
||||
float getX();
|
||||
|
||||
float getY();
|
||||
|
||||
float getZ();
|
||||
}
|
||||
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 3.9 KiB |