mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 10:19:08 +00:00
1.7.10 Files
Files added
This commit is contained in:
1 parent
393ea9b463
commit
a31efb2dc3
1768 files changed
+84831
No files matched your search
@@ -0,0 +1,286 @@
|
||||
package foxz.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import foxz.commandhelper.ChMcLogger;
|
||||
import foxz.commandhelper.annotations.Command;
|
||||
import foxz.commandhelper.annotations.SubCommand;
|
||||
import foxz.commandhelper.permissions.OpOnly;
|
||||
import foxz.commandhelper.permissions.ParamCheck;
|
||||
import foxz.commandhelper.permissions.PlayerOnly;
|
||||
import foxz.utils.Utils;
|
||||
|
||||
@Command(
|
||||
name = "clone",
|
||||
desc = "Clone operation (server side)"
|
||||
)
|
||||
public class CmdClone extends ChMcLogger {
|
||||
|
||||
public CmdClone(Object sender) {
|
||||
super(sender);
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Add NPC(s) to clone storage",
|
||||
usage = "<npc> <tab> [clonedname]",
|
||||
permissions = {OpOnly.class ,PlayerOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean add(String[] args) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) pcParam;
|
||||
int tab = 0;
|
||||
try{
|
||||
tab = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
|
||||
}
|
||||
List<EntityNPCInterface> list = Utils.getNearbeEntityFromPlayer(EntityNPCInterface.class, player, 80);
|
||||
for (EntityNPCInterface npc : list) {
|
||||
if (npc.display.name.equalsIgnoreCase(args[0])) {
|
||||
String name = npc.display.name;
|
||||
if (args.length > 2) {
|
||||
name = args[2];
|
||||
}
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(!npc.writeToNBTOptional(compound))
|
||||
return false;
|
||||
ServerCloneController.Instance.addClone(compound, name, tab);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(desc = "List NPC from clone storage", usage = "<tab>", permissions={OpOnly.class ,ParamCheck.class})
|
||||
public Boolean list(String[] args) {
|
||||
sendmessage("--- Stored NPCs --- (server side)");
|
||||
int tab = 0;
|
||||
try{
|
||||
tab = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
|
||||
}
|
||||
for (String name : ServerCloneController.Instance.getClones(tab)) {
|
||||
sendmessage(name);
|
||||
}
|
||||
sendmessage("------------------------------------");
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(desc = "Remove NPC from clone storage", usage = "<name> <tab>", permissions={OpOnly.class ,ParamCheck.class})
|
||||
public Boolean del(String[] args) {
|
||||
String nametodel = args[0];
|
||||
int tab = 0;
|
||||
try{
|
||||
tab = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
|
||||
}
|
||||
boolean deleted = false;
|
||||
for(String name : ServerCloneController.Instance.getClones(tab)){
|
||||
if(nametodel.equalsIgnoreCase(name)){
|
||||
ServerCloneController.Instance.removeClone(name, tab);
|
||||
deleted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ServerCloneController.Instance.removeClone(nametodel, tab)) {
|
||||
sendmessage(String.format("Npc '%s' wasn't found", nametodel));
|
||||
return false;
|
||||
}
|
||||
;
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Spawn cloned NPC",
|
||||
usage = "<name> <tab> [[world:]x,y,z]] [newname]",
|
||||
permissions={OpOnly.class ,ParamCheck.class})
|
||||
public boolean spawn(String[] args) {
|
||||
String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space
|
||||
int tab = 0;
|
||||
try{
|
||||
tab = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
|
||||
}
|
||||
String newname=null;
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(this.pcParam, name, tab);
|
||||
if(compound == null){
|
||||
sendmessage("Unknown npc");
|
||||
return false;
|
||||
}
|
||||
World world = pcParam.getEntityWorld();
|
||||
double posX = pcParam.getPlayerCoordinates().posX;
|
||||
double posY = pcParam.getPlayerCoordinates().posY;
|
||||
double posZ = pcParam.getPlayerCoordinates().posZ;
|
||||
|
||||
if(args.length > 2){
|
||||
String location = args[2];
|
||||
String[] par;
|
||||
if (location.contains(":")){
|
||||
par = location.split(":");
|
||||
location = par[1];
|
||||
world = Utils.getWorld(par[0]);
|
||||
if (world == null){
|
||||
sendmessage (String.format("'%s' is an unknown world",par[0]));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (location.contains(",")){
|
||||
par = location.split(",");
|
||||
if (par.length != 3){
|
||||
sendmessage("Location need be x,y,z");
|
||||
return false;
|
||||
}
|
||||
try{
|
||||
posX = CommandBase.func_110666_a(pcParam, posX, par[0]);
|
||||
posY = CommandBase.func_110665_a(pcParam, posY, par[1].trim(), 0, 0);
|
||||
posZ = CommandBase.func_110666_a(pcParam, posZ, par[2]);
|
||||
} catch(NumberFormatException ex){
|
||||
sendmessage("Location should be in numbers");
|
||||
return false;
|
||||
}
|
||||
if (args.length > 3){
|
||||
newname = args[3];
|
||||
}
|
||||
} else {
|
||||
newname = location;
|
||||
}
|
||||
}
|
||||
|
||||
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
||||
sendmessage ("Location needed");
|
||||
return false;
|
||||
}
|
||||
|
||||
Entity entity = EntityList.createEntityFromNBT(compound, world);
|
||||
entity.setPosition(posX + 0.5, posY + 1, posZ + 0.5);
|
||||
if(entity instanceof EntityNPCInterface){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
npc.ai.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)};
|
||||
if(newname != null && !newname.isEmpty())
|
||||
npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way
|
||||
}
|
||||
world.spawnEntityInWorld(entity);
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Spawn cloned NPC",
|
||||
usage = "<name> <tab> <lenght> <width> [[world:]x,y,z]] [newname]",
|
||||
permissions={OpOnly.class ,ParamCheck.class})
|
||||
public boolean grid(String[] args) {
|
||||
String name = args[0].replaceAll("%", " "); // if name of npc separed by space, user must use % in place of space
|
||||
int tab = 0;
|
||||
try{
|
||||
tab = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
|
||||
}
|
||||
|
||||
int width, height;
|
||||
try{
|
||||
width = Integer.parseInt(args[2]);
|
||||
height = Integer.parseInt(args[3]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
sendmessage("lenght or width wasnt a number");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
String newname=null;
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(this.pcParam, name, tab);
|
||||
if(compound == null){
|
||||
sendmessage("Unknown npc");
|
||||
return false;
|
||||
}
|
||||
World world = pcParam.getEntityWorld();
|
||||
double posX = pcParam.getPlayerCoordinates().posX;
|
||||
double posY = pcParam.getPlayerCoordinates().posY;
|
||||
double posZ = pcParam.getPlayerCoordinates().posZ;
|
||||
|
||||
if(args.length > 4){
|
||||
String location = args[4];
|
||||
String[] par;
|
||||
if (location.contains(":")){
|
||||
par = location.split(":");
|
||||
location = par[1];
|
||||
world = Utils.getWorld(par[0]);
|
||||
if (world == null){
|
||||
sendmessage (String.format("'%s' is an unknown world",par[0]));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (location.contains(",")){
|
||||
par = location.split(",");
|
||||
if (par.length != 3){
|
||||
sendmessage("Location need be x,y,z");
|
||||
return false;
|
||||
}
|
||||
try{
|
||||
posX = CommandBase.func_110666_a(pcParam, posX, par[0]);
|
||||
posY = CommandBase.func_110665_a(pcParam, posY, par[1].trim(), 0, 0);
|
||||
posZ = CommandBase.func_110666_a(pcParam, posZ, par[2]);
|
||||
} catch(NumberFormatException ex){
|
||||
sendmessage("Location should be in numbers");
|
||||
return false;
|
||||
}
|
||||
if (args.length > 5){
|
||||
newname = args[5];
|
||||
}
|
||||
} else {
|
||||
newname = location;
|
||||
}
|
||||
}
|
||||
|
||||
if (posX == 0 && posY == 0 && posZ == 0){//incase it was called from the console and not pos was given
|
||||
sendmessage ("Location needed");
|
||||
return false;
|
||||
}
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int z = 0; z < height; z++){
|
||||
Entity entity = EntityList.createEntityFromNBT(compound, world);
|
||||
int xx = MathHelper.floor_double(posX) + x;
|
||||
int yy = Math.max(MathHelper.floor_double(posY) - 2, 1);
|
||||
int zz = MathHelper.floor_double(posZ) + z;
|
||||
|
||||
for(int y = 0; y < 10; y++){
|
||||
Block b = world.getBlock(xx, yy + y, zz);
|
||||
Block b2 = world.getBlock(xx, yy + y + 1, zz);
|
||||
if(b != null && (b2 == null || b2.getCollisionBoundingBoxFromPool(world, xx, yy + y + 1, zz) == null)){
|
||||
yy += y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
entity.setPosition(posX + 0.5 + x, yy + 1, posZ + 0.5 + z);
|
||||
if(entity instanceof EntityNPCInterface){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
npc.ai.startPos = new int[]{xx, yy, zz};
|
||||
if(newname != null && !newname.isEmpty())
|
||||
npc.display.name = newname.replaceAll("%", " "); // like name, newname must use % in place of space to keep a logical way
|
||||
}
|
||||
world.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
package foxz.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockIce;
|
||||
import net.minecraft.block.BlockLeavesBase;
|
||||
import net.minecraft.block.BlockVine;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.controllers.ChunkController;
|
||||
import foxz.commandhelper.ChMcLogger;
|
||||
import foxz.commandhelper.annotations.Command;
|
||||
import foxz.commandhelper.annotations.SubCommand;
|
||||
import foxz.commandhelper.permissions.OpOnly;
|
||||
import foxz.commandhelper.permissions.PlayerOnly;
|
||||
|
||||
@Command(
|
||||
name="config",
|
||||
desc="Some config things you can set ",
|
||||
usage=""
|
||||
)
|
||||
public class CmdConfig extends ChMcLogger {
|
||||
|
||||
public CmdConfig(Object sender) {
|
||||
super (sender);
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Disable/Enable the natural leaves decay",
|
||||
usage="<true/false>",
|
||||
permissions={OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public boolean leavesdecay(String[] args){
|
||||
if(args.length == 0){
|
||||
sendmessage("LeavesDecay: " + CustomNpcs.LeavesDecayEnabled);
|
||||
}
|
||||
else{
|
||||
CustomNpcs.LeavesDecayEnabled = Boolean.parseBoolean(args[0]);
|
||||
CustomNpcs.Config.updateConfig();
|
||||
Set<String> names = Block.blockRegistry.getKeys();
|
||||
for(String name : names){
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if(block instanceof BlockLeavesBase){
|
||||
block.setTickRandomly(CustomNpcs.LeavesDecayEnabled);
|
||||
}
|
||||
}
|
||||
sendmessage("LeavesDecay is now " + CustomNpcs.LeavesDecayEnabled);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Disable/Enable the vines growing",
|
||||
usage="<true/false>",
|
||||
permissions={OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public boolean vinegrowth(String[] args){
|
||||
if(args.length == 0){
|
||||
sendmessage("VineGrowth: " + CustomNpcs.VineGrowthEnabled);
|
||||
}
|
||||
else{
|
||||
CustomNpcs.VineGrowthEnabled = Boolean.parseBoolean(args[0]);
|
||||
CustomNpcs.Config.updateConfig();
|
||||
Set<String> names = Block.blockRegistry.getKeys();
|
||||
for(String name : names){
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if(block instanceof BlockVine){
|
||||
block.setTickRandomly(CustomNpcs.VineGrowthEnabled);
|
||||
}
|
||||
}
|
||||
sendmessage("VineGrowth is now " + CustomNpcs.VineGrowthEnabled);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Disable/Enable the ice melting",
|
||||
usage="<true/false>",
|
||||
permissions={OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public boolean icemelts(String[] args){
|
||||
if(args.length == 0){
|
||||
sendmessage("IceMelts: " + CustomNpcs.IceMeltsEnabled);
|
||||
}
|
||||
else{
|
||||
CustomNpcs.IceMeltsEnabled = Boolean.parseBoolean(args[0]);
|
||||
CustomNpcs.Config.updateConfig();
|
||||
Set<String> names = Block.blockRegistry.getKeys();
|
||||
for(String name : names){
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if(block instanceof BlockIce){
|
||||
block.setTickRandomly(CustomNpcs.IceMeltsEnabled);
|
||||
}
|
||||
}
|
||||
sendmessage("IceMelts is now " + CustomNpcs.IceMeltsEnabled);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Disable/Enable guns shooting",
|
||||
usage="<true/false>",
|
||||
permissions={OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public boolean guns(String[] args){
|
||||
if(args.length == 0){
|
||||
sendmessage("GunsEnabled: " + CustomNpcs.GunsEnabled);
|
||||
}
|
||||
else{
|
||||
CustomNpcs.GunsEnabled = Boolean.parseBoolean(args[0]);
|
||||
CustomNpcs.Config.updateConfig();
|
||||
sendmessage("GunsEnabled is now " + CustomNpcs.GunsEnabled);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Freezes/Unfreezes npcs",
|
||||
usage="<true/false>",
|
||||
permissions={OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public boolean freezenpcs(String[] args){
|
||||
if(args.length == 0){
|
||||
sendmessage("Frozen NPCs: " + CustomNpcs.FreezeNPCs);
|
||||
}
|
||||
else{
|
||||
CustomNpcs.FreezeNPCs = Boolean.parseBoolean(args[0]);
|
||||
sendmessage("FrozenNPCs is now " + CustomNpcs.FreezeNPCs);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Set how many active chunkloaders you can have",
|
||||
usage="<number>",
|
||||
permissions={OpOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public boolean chunkloaders(String[] args){
|
||||
if(args.length == 0){
|
||||
sendmessage("ChunkLoaders: " + ChunkController.instance.size() + "/" + CustomNpcs.ChuckLoaders);
|
||||
}
|
||||
else{
|
||||
try{
|
||||
CustomNpcs.ChuckLoaders = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
sendmessage("Didnt get a number");
|
||||
return false;
|
||||
}
|
||||
CustomNpcs.Config.updateConfig();
|
||||
|
||||
int size = ChunkController.instance.size();
|
||||
if(size > CustomNpcs.ChuckLoaders){
|
||||
ChunkController.instance.unload(size - CustomNpcs.ChuckLoaders);
|
||||
sendmessage(size - CustomNpcs.ChuckLoaders + " chunksloaders unloaded");
|
||||
}
|
||||
sendmessage("ChunkLoaders: " + ChunkController.instance.size() + "/" + CustomNpcs.ChuckLoaders);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc="Get/Set font",
|
||||
usage="[type] [size]",
|
||||
permissions={PlayerOnly.class},
|
||||
hasEmptyCall = true
|
||||
)
|
||||
public void font(String[] args){
|
||||
int size = 18;
|
||||
if(args.length > 1){
|
||||
try{
|
||||
size = Integer.parseInt(args[args.length - 1]);
|
||||
args = Arrays.copyOfRange(args, 0, args.length - 1);
|
||||
}
|
||||
catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
String font = "";
|
||||
for(int i = 0; i < args.length; i++){
|
||||
font += " " + args[i];
|
||||
}
|
||||
Server.sendData((EntityPlayerMP)this.pcParam, EnumPacketClient.CONFIG, 0, font.trim(), size);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package foxz.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.client.EntityUtil;
|
||||
import noppes.npcs.controllers.Dialog;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.DialogOption;
|
||||
import noppes.npcs.controllers.PlayerData;
|
||||
import noppes.npcs.entity.EntityDialogNpc;
|
||||
import foxz.commandhelper.ChMcLogger;
|
||||
import foxz.commandhelper.annotations.Command;
|
||||
import foxz.commandhelper.annotations.SubCommand;
|
||||
import foxz.commandhelper.permissions.OpOnly;
|
||||
import foxz.commandhelper.permissions.ParamCheck;
|
||||
|
||||
@Command(
|
||||
name="dialog",
|
||||
desc="dialog operations",
|
||||
usage="help"
|
||||
)
|
||||
public class CmdDialog extends ChMcLogger {
|
||||
|
||||
public CmdDialog(Object sender) {
|
||||
super(sender);
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc="force read",
|
||||
usage="<player> <dialog>",
|
||||
permissions={OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public boolean read(String args[]){
|
||||
String playername=args[0];
|
||||
int diagid;
|
||||
try {
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("DialogID must be an integer");
|
||||
return false;
|
||||
}
|
||||
List<PlayerData> data = getPlayersData(playername);
|
||||
if (data.isEmpty()) {
|
||||
sendmessage(String.format("Unknow player '%s'", playername));
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.dialogData.dialogsRead.add(diagid);
|
||||
playerdata.saveNBTData(null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="force unread dialog",
|
||||
usage="<player> <dialog>",
|
||||
permissions={OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public boolean unread(String args[]){
|
||||
String playername=args[0];
|
||||
int diagid;
|
||||
try {
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("DialogID must be an integer");
|
||||
return false;
|
||||
}
|
||||
List<PlayerData> data = getPlayersData(playername);
|
||||
if (data.isEmpty()) {
|
||||
sendmessage(String.format("Unknow player '%s'", playername));
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.dialogData.dialogsRead.remove(diagid);
|
||||
playerdata.saveNBTData(null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@SubCommand(
|
||||
desc="reload dialogs from disk",
|
||||
permissions={OpOnly.class}
|
||||
)
|
||||
public boolean reload(String args[]){
|
||||
new DialogController();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc="show dialog",
|
||||
usage="<player> <dialog> <name>",
|
||||
permissions={OpOnly.class}
|
||||
)
|
||||
public void show(String args[]){
|
||||
EntityPlayer player = CommandBase.getPlayer(pcParam, args[0]);
|
||||
if(player == null){
|
||||
sendmessage(String.format("Unknow player '%s'", args[0]));
|
||||
return;
|
||||
}
|
||||
|
||||
int diagid;
|
||||
try {
|
||||
diagid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("DialogID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
Dialog dialog = DialogController.instance.dialogs.get(diagid);
|
||||
if(dialog == null){
|
||||
sendmessage("Unknown dialog id: " + args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
EntityDialogNpc npc = new EntityDialogNpc(this.pcParam.getEntityWorld());
|
||||
npc.display.name = args[2];
|
||||
EntityUtil.Copy(player, npc);
|
||||
DialogOption option = new DialogOption();
|
||||
option.dialogId = diagid;
|
||||
option.title = dialog.title;
|
||||
npc.dialogs.put(0, option);
|
||||
NoppesUtilServer.openDialog(player, npc, dialog);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package foxz.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import noppes.npcs.controllers.Faction;
|
||||
import noppes.npcs.controllers.PlayerData;
|
||||
import noppes.npcs.controllers.PlayerFactionData;
|
||||
import foxz.commandhelper.ChMcLogger;
|
||||
import foxz.commandhelper.annotations.Command;
|
||||
import foxz.commandhelper.annotations.SubCommand;
|
||||
import foxz.commandhelper.permissions.OpOnly;
|
||||
import foxz.commandhelper.permissions.ParamCheck;
|
||||
|
||||
@Command(
|
||||
name = "faction",
|
||||
desc = "operations about relationship between player and faction"
|
||||
)
|
||||
public class CmdFaction extends ChMcLogger {
|
||||
|
||||
public String playername;
|
||||
|
||||
public Faction selectedFaction;
|
||||
public List<PlayerData> data;
|
||||
|
||||
public CmdFaction(Object sender) {
|
||||
super(sender);
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Add points",
|
||||
usage = "<points>",
|
||||
permissions={OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean add(String[] args) {
|
||||
int points;
|
||||
try {
|
||||
points = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("Must be an integer");
|
||||
return false;
|
||||
}
|
||||
int factionid = this.selectedFaction.id;
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.increasePoints(factionid, points);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Substract points",
|
||||
usage = "<points>",
|
||||
permissions={OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean subtract(String[] args) {
|
||||
int points;
|
||||
try {
|
||||
points = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("Must be an integer");
|
||||
return false;
|
||||
}
|
||||
int factionid = this.selectedFaction.id;
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.increasePoints(factionid, -points);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Reset points to default",
|
||||
usage = "",
|
||||
permissions={OpOnly.class}
|
||||
)
|
||||
public Boolean reset(String[] args) {
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set points",
|
||||
usage = "<points>",
|
||||
permissions={OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean set(String[] args) {
|
||||
int points;
|
||||
try {
|
||||
points = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("Must be an integer");
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.factionData.put(this.selectedFaction.id,points);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Drop relationship",
|
||||
usage="",
|
||||
permissions={OpOnly.class}
|
||||
)
|
||||
public Boolean drop(String[] args){
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.factionData.factionData.remove(this.selectedFaction.id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
package foxz.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityXPOrb;
|
||||
import net.minecraft.entity.monster.EntityGhast;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.entity.passive.EntityHorse;
|
||||
import net.minecraft.entity.passive.EntityTameable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import noppes.npcs.controllers.FactionController;
|
||||
import noppes.npcs.controllers.PlayerData;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import foxz.commandhelper.ChMcLogger;
|
||||
import foxz.commandhelper.annotations.Command;
|
||||
import foxz.commandhelper.annotations.SubCommand;
|
||||
import foxz.commandhelper.permissions.OpOnly;
|
||||
import foxz.commandhelper.permissions.ParamCheck;
|
||||
import foxz.commandhelper.permissions.PlayerOnly;
|
||||
import foxz.utils.Utils;
|
||||
|
||||
@Command(
|
||||
name = "noppes",
|
||||
desc = "noppes root command",
|
||||
sub = {CmdClone.class, CmdScript.class, CmdQuest.class, CmdDialog.class, CmdConfig.class}
|
||||
)
|
||||
public class CmdNoppes extends ChMcLogger {
|
||||
|
||||
public CmdFaction cmdfaction = new CmdFaction(ctorParm);
|
||||
public CmdNpc cmdnpc= new CmdNpc(ctorParm);
|
||||
public static Map<String,Class<?>> SlayMap = new LinkedHashMap<String,Class<?>>();
|
||||
|
||||
public CmdNoppes(Object sender) {
|
||||
super(sender);
|
||||
|
||||
SlayMap.clear();
|
||||
|
||||
SlayMap.put("all",EntityLivingBase.class);
|
||||
SlayMap.put("mobs",EntityMob.class);
|
||||
SlayMap.put("animals", EntityAnimal.class);
|
||||
SlayMap.put("items", EntityItem.class);
|
||||
SlayMap.put("xporbs", EntityXPOrb.class);
|
||||
SlayMap.put("npcs", EntityNPCInterface.class);
|
||||
|
||||
HashMap<String,Class<?>> list = new HashMap<String,Class<?>>(EntityList.stringToClassMapping);
|
||||
for(String name : list.keySet()){
|
||||
Class<?> cls = list.get(name);
|
||||
if(EntityNPCInterface.class.isAssignableFrom(cls))
|
||||
continue;
|
||||
if(!EntityLivingBase.class.isAssignableFrom(cls))
|
||||
continue;
|
||||
SlayMap.put(name.toLowerCase(), list.get(name));
|
||||
}
|
||||
|
||||
SlayMap.remove("monster");
|
||||
SlayMap.remove("mob");
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
name = "faction",
|
||||
desc = "Faction operations",
|
||||
usage = "<player> <faction> <command>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean faction(String[] args) {
|
||||
String playername = args[0];
|
||||
String factionname = args[1];
|
||||
|
||||
cmdfaction.data = getPlayersData(playername);
|
||||
if (cmdfaction.data.isEmpty()) {
|
||||
sendmessage(String.format("Unknow player '%s'", playername));
|
||||
return false;
|
||||
}
|
||||
try{
|
||||
cmdfaction.selectedFaction = FactionController.getInstance().getFaction(Integer.parseInt(factionname));
|
||||
}
|
||||
catch(NumberFormatException e){
|
||||
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
|
||||
}
|
||||
if (cmdfaction.selectedFaction == null) {
|
||||
sendmessage(String.format("Unknow facion '%s", factionname));
|
||||
return false;
|
||||
}
|
||||
args = Arrays.copyOfRange(args, 2, args.length);
|
||||
cmdfaction.processCommand(this.pcParam, args);
|
||||
|
||||
for(PlayerData playerdata : cmdfaction.data){
|
||||
playerdata.saveNBTData(null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="NPC manipulations",
|
||||
usage="<npc> <command>",
|
||||
permissions={OpOnly.class,ParamCheck.class}
|
||||
)
|
||||
public boolean npc(String[] args){
|
||||
String npcname=args[0].replace("%", " ");
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
if(args[0].equalsIgnoreCase("create")){
|
||||
cmdnpc.processCommand(this.pcParam, new String[]{args[0], npcname});
|
||||
return true;
|
||||
}
|
||||
int x = pcParam.getPlayerCoordinates().posX;
|
||||
int y = pcParam.getPlayerCoordinates().posY;
|
||||
int z = pcParam.getPlayerCoordinates().posZ;
|
||||
List<EntityNPCInterface> list = getNearbeEntityFromPlayer(EntityNPCInterface.class, pcParam.getEntityWorld(), x, y, z, 80);
|
||||
EntityNPCInterface closest = null;
|
||||
for (EntityNPCInterface npc : list) {
|
||||
String name = npc.display.name.replace(" ", "_");
|
||||
if (name.equalsIgnoreCase(npcname)){
|
||||
if(closest == null || closest.getDistanceSq(x, y, z) > npc.getDistanceSq(x, y, z))
|
||||
closest = npc;
|
||||
}
|
||||
}
|
||||
if(closest != null){
|
||||
cmdnpc.selectedNpc=closest;
|
||||
cmdnpc.processCommand(this.pcParam, args);
|
||||
cmdnpc.selectedNpc = null;
|
||||
}
|
||||
else
|
||||
sendmessage(String.format("NPC '%s' was not found",npcname));
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
name = "slay",
|
||||
desc = "Kills given entity within range. Also has all, mobs, animal options. Can have multiple types",
|
||||
usage = "<type>.. [range]",
|
||||
permissions = {PlayerOnly.class, OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean slay(String[] args) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) pcParam;
|
||||
ArrayList<Class<?>> toDelete = new ArrayList<Class<?>>();
|
||||
boolean deleteNPCs = false;
|
||||
for(String delete : args){
|
||||
delete = delete.toLowerCase();
|
||||
Class<?> cls = SlayMap.get(delete);
|
||||
if(cls != null)
|
||||
toDelete.add(cls);
|
||||
if(delete.equals("mobs")){
|
||||
toDelete.add(EntityGhast.class);
|
||||
toDelete.add(EntityDragon.class);
|
||||
}
|
||||
if(delete.equals("npcs"))
|
||||
deleteNPCs = true;
|
||||
}
|
||||
int count = 0;
|
||||
int range = 120;
|
||||
try{
|
||||
range = Integer.parseInt(args[args.length - 1]);
|
||||
}
|
||||
catch(NumberFormatException ex){
|
||||
|
||||
}
|
||||
AxisAlignedBB box = player.boundingBox.expand(range, range, range);
|
||||
List<Entity> list = player.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, box);
|
||||
|
||||
for(Entity entity : list){
|
||||
if(entity instanceof EntityPlayer)
|
||||
continue;
|
||||
if(entity instanceof EntityTameable && ((EntityTameable)entity).isTamed())
|
||||
continue;
|
||||
if(entity instanceof EntityNPCInterface && !deleteNPCs)
|
||||
continue;
|
||||
if(delete(entity,toDelete))
|
||||
count++;
|
||||
}
|
||||
if(toDelete.contains(EntityXPOrb.class)){
|
||||
list = player.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, box);
|
||||
for(Entity entity : list){
|
||||
entity.isDead = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if(toDelete.contains(EntityItem.class)){
|
||||
list = player.worldObj.getEntitiesWithinAABB(EntityItem.class, box);
|
||||
for(Entity entity : list){
|
||||
entity.isDead = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
player.addChatMessage(new ChatComponentTranslation(count + " entities deleted"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean delete(Entity entity, ArrayList<Class<?>> toDelete) {
|
||||
for(Class<?> delete : toDelete){
|
||||
if(delete == EntityAnimal.class && (entity instanceof EntityHorse)){
|
||||
continue;
|
||||
}
|
||||
if(delete.isAssignableFrom(entity.getClass())){
|
||||
entity.isDead = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
if(args[0].equalsIgnoreCase("slay")){
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, SlayMap.keySet().toArray(new String[SlayMap.size()]));
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("npc") && args.length == 3){
|
||||
return cmdnpc.addTabCompletion(par1, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("faction") && args.length == 4){
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"add", "subtract", "set", "reset", "drop", "create"});
|
||||
}
|
||||
return super.addTabCompletion(par1, args);
|
||||
}
|
||||
//<editor-fold desc="--- FoxZ fork (keep it pls)">
|
||||
// @SubCommand(
|
||||
// desc = "Save AltPlayerInv",
|
||||
// usage = "{player} {inv}",
|
||||
// permissions={OpOnly.class}
|
||||
// )
|
||||
// public boolean sapi(String[] args) {
|
||||
// EntityPlayer p = getOnlinePlayer(args[0]);
|
||||
// sendmessage(String.format("noppes.sapi:%s %s", args[0], args[1]));
|
||||
// if (p == null) {
|
||||
// sendmessage("noppes.sapi:unkow " + args[0]);
|
||||
// return false;
|
||||
// }
|
||||
// savePlayerAltInv(p, args[1]);
|
||||
// sendmessage("noppes.sapi:saved");
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @SubCommand(
|
||||
// desc = "Load AltPlayerInv",
|
||||
// usage = "{player} {inv}",
|
||||
// permissions={OpOnly.class}
|
||||
// )
|
||||
// public boolean lapi(String[] args) {
|
||||
// EntityPlayer p = getOnlinePlayer(args[0]);
|
||||
// sendmessage(String.format("noppes.lapi:%s %s", args[0], args[1]));
|
||||
// if (p == null) {
|
||||
// sendmessage("noppes.sapi:unknow " + args[0]);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// loadPlayerAltInv(p, args[1]);
|
||||
// sendmessage("noppes.lapi:loaded");
|
||||
// return true;
|
||||
// }
|
||||
//</editor-fold>
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package foxz.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import scala.actors.threadpool.Arrays;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.PlayerSelector;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleCompanion;
|
||||
import noppes.npcs.roles.RoleFollower;
|
||||
import foxz.commandhelper.ChMcLogger;
|
||||
import foxz.commandhelper.annotations.Command;
|
||||
import foxz.commandhelper.annotations.SubCommand;
|
||||
import foxz.commandhelper.permissions.OpOnly;
|
||||
import foxz.commandhelper.permissions.PlayerOnly;
|
||||
|
||||
@Command(
|
||||
name="npc",
|
||||
desc="NPC manipulation",
|
||||
usage="<name> <command>"
|
||||
)
|
||||
public class CmdNpc extends ChMcLogger {
|
||||
|
||||
CmdNpc(Object ctorParm) {
|
||||
super (ctorParm);
|
||||
}
|
||||
|
||||
public EntityNPCInterface selectedNpc;
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc="Set Home (respawn place)",
|
||||
usage=""
|
||||
)
|
||||
public void home(String[] args){
|
||||
double posX = pcParam.getPlayerCoordinates().posX;
|
||||
double posY = pcParam.getPlayerCoordinates().posY;
|
||||
double posZ = pcParam.getPlayerCoordinates().posZ;
|
||||
|
||||
if(args.length == 3){
|
||||
posX = CommandBase.func_110666_a(pcParam, selectedNpc.posX, args[0]);
|
||||
posY = CommandBase.func_110665_a(pcParam, selectedNpc.posY, args[1].trim(), 0, 0);
|
||||
posZ = CommandBase.func_110666_a(pcParam, selectedNpc.posZ, args[2]);
|
||||
}
|
||||
|
||||
selectedNpc.ai.startPos = new int[]{MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)};
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Set npc visibility",
|
||||
usage=""
|
||||
)
|
||||
public void visible(String[] args){
|
||||
if(args.length < 1)
|
||||
return;
|
||||
boolean bo = args[0].equalsIgnoreCase("true");
|
||||
boolean semi = args[0].equalsIgnoreCase("semi");
|
||||
|
||||
int current = selectedNpc.display.visible;
|
||||
if(semi)
|
||||
selectedNpc.display.visible = 2;
|
||||
else if(bo)
|
||||
selectedNpc.display.visible = 0;
|
||||
else
|
||||
selectedNpc.display.visible = 1;
|
||||
|
||||
if(current != selectedNpc.display.visible)
|
||||
selectedNpc.updateClient = true;
|
||||
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Delete an NPC",
|
||||
usage=""
|
||||
)
|
||||
public void delete(String[] args){
|
||||
selectedNpc.delete();
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc="Owner",
|
||||
usage=""
|
||||
)
|
||||
public void owner(String[] args){
|
||||
if(args.length < 1){
|
||||
EntityPlayer player = null;
|
||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||
player = ((RoleFollower)selectedNpc.roleInterface).owner;
|
||||
|
||||
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
||||
player = ((RoleCompanion)selectedNpc.roleInterface).owner;
|
||||
|
||||
if(player == null)
|
||||
sendmessage("No owner");
|
||||
else
|
||||
sendmessage("Owner is: " + player.getCommandSenderName());
|
||||
}
|
||||
else{
|
||||
EntityPlayerMP player = CommandBase.getPlayer(pcParam, args[0]);
|
||||
if(selectedNpc.roleInterface instanceof RoleFollower)
|
||||
((RoleFollower)selectedNpc.roleInterface).setOwner(player);
|
||||
|
||||
if(selectedNpc.roleInterface instanceof RoleCompanion)
|
||||
((RoleCompanion)selectedNpc.roleInterface).setOwner(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubCommand(
|
||||
desc="Set npc name",
|
||||
usage=""
|
||||
)
|
||||
public void name(String[] args){
|
||||
if(args.length < 1)
|
||||
return;
|
||||
|
||||
String name = args[0];
|
||||
for(int i = 1; i < args.length; i++){
|
||||
name += " " + args[i];
|
||||
}
|
||||
|
||||
if(!selectedNpc.display.name.equals(name)){
|
||||
selectedNpc.display.name = name;
|
||||
selectedNpc.updateClient = true;
|
||||
}
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Creates an NPC",
|
||||
usage = "[name]",
|
||||
permissions = {PlayerOnly.class, OpOnly.class}
|
||||
)
|
||||
public void create(String[] args) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) pcParam;
|
||||
World pw = player.getEntityWorld();
|
||||
EntityCustomNpc npc = new EntityCustomNpc(pw);
|
||||
if(args.length > 0)
|
||||
npc.display.name = args[0];
|
||||
npc.setPositionAndRotation(player.posX, player.posY, player.posZ, player.cameraYaw, player.cameraPitch);
|
||||
npc.ai.startPos = new int[]{MathHelper.floor_double(player.posX),MathHelper.floor_double(player.posY),MathHelper.floor_double(player.posZ)};
|
||||
pw.spawnEntityInWorld(npc);
|
||||
npc.setHealth(npc.getMaxHealth());
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
if(args.length == 2){
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, new String[]{"create", "home", "visible", "delete", "owner", "name"});
|
||||
}
|
||||
if(args.length == 3 && args[1].equalsIgnoreCase("owner")){
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
||||
}
|
||||
|
||||
return super.addTabCompletion(par1, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
package foxz.command;
|
||||
|
||||
import static foxz.utils.Utils.getOnlinePlayer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.PlayerSelector;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.PlayerData;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.Quest;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.QuestData;
|
||||
import foxz.commandhelper.ChMcLogger;
|
||||
import foxz.commandhelper.annotations.Command;
|
||||
import foxz.commandhelper.annotations.SubCommand;
|
||||
import foxz.commandhelper.permissions.OpOnly;
|
||||
import foxz.commandhelper.permissions.ParamCheck;
|
||||
|
||||
@Command(
|
||||
name = "quest",
|
||||
usage = "help",
|
||||
desc = "Quest operations"
|
||||
)
|
||||
public class CmdQuest extends ChMcLogger{
|
||||
|
||||
public CmdQuest(Object sender) {
|
||||
super(sender);
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Start a quest",
|
||||
usage = "<player> <quest>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean start(String[] args) {
|
||||
String playername=args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("QuestID must be an integer");
|
||||
return false;
|
||||
}
|
||||
List<PlayerData> data = getPlayersData(playername);
|
||||
if (data.isEmpty()) {
|
||||
sendmessage(String.format("Unknow player '%s'", playername));
|
||||
return false;
|
||||
}
|
||||
Quest quest = QuestController.instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
sendmessage("Unknown QuestID");
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
if(playerdata.questData.activeQuests.containsKey(questid))
|
||||
continue;
|
||||
QuestData questdata = new QuestData(quest);
|
||||
playerdata.questData.activeQuests.put(questid, questdata);
|
||||
playerdata.saveNBTData(null);
|
||||
if(playerdata.player != null){
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Finish a quest",
|
||||
usage = "<player> <quest>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean finish(String args[]){
|
||||
String playername=args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
sendmessage("QuestID must be an integer");
|
||||
return false;
|
||||
}
|
||||
List<PlayerData> data = getPlayersData(playername);
|
||||
if (data.isEmpty()) {
|
||||
sendmessage(String.format("Unknow player '%s'", playername));
|
||||
return false;
|
||||
}
|
||||
|
||||
Quest quest = QuestController.instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
sendmessage("Unknown QuestID");
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
|
||||
playerdata.saveNBTData(null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Stop a started quest",
|
||||
usage = "<player> <quest>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean stop(String[] args) {
|
||||
String playername=args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("QuestID must be an integer");
|
||||
return false;
|
||||
}
|
||||
List<PlayerData> data = getPlayersData(playername);
|
||||
if (data.isEmpty()) {
|
||||
sendmessage(String.format("Unknow player '%s'", playername));
|
||||
return false;
|
||||
}
|
||||
Quest quest = QuestController.instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
sendmessage("Unknown QuestID");
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.saveNBTData(null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Removes a quest from finished and active quests",
|
||||
usage = "<player> <quest>",
|
||||
permissions = {OpOnly.class, ParamCheck.class}
|
||||
)
|
||||
public Boolean remove(String[] args) {
|
||||
String playername=args[0];
|
||||
int questid;
|
||||
try {
|
||||
questid = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
sendmessage("QuestID must be an integer");
|
||||
return false;
|
||||
}
|
||||
List<PlayerData> data = getPlayersData(playername);
|
||||
if (data.isEmpty()) {
|
||||
sendmessage(String.format("Unknow player '%s'", playername));
|
||||
return false;
|
||||
}
|
||||
Quest quest = QuestController.instance.quests.get(questid);
|
||||
if (quest == null){
|
||||
sendmessage("Unknown QuestID");
|
||||
return false;
|
||||
}
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.questData.finishedQuests.remove(questid);
|
||||
playerdata.saveNBTData(null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@SubCommand(
|
||||
desc="reload quests from disk",
|
||||
permissions={OpOnly.class}
|
||||
)
|
||||
public boolean reload(String args[]){
|
||||
new DialogController();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package foxz.command;
|
||||
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import foxz.commandhelper.ChMcLogger;
|
||||
import foxz.commandhelper.annotations.Command;
|
||||
import foxz.commandhelper.annotations.SubCommand;
|
||||
import foxz.commandhelper.permissions.OpOnly;
|
||||
|
||||
@Command(
|
||||
name = "script",
|
||||
desc = "Script operation"
|
||||
)
|
||||
public class CmdScript extends ChMcLogger {
|
||||
|
||||
public CmdScript(Object sender) {
|
||||
super(sender);
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Reload scripts and saved data from disks script folder.",
|
||||
permissions={OpOnly.class}
|
||||
)
|
||||
public Boolean reload(String args[]) {
|
||||
if(ScriptController.Instance.loadStoredData())
|
||||
sendmessage("Reload succesful");
|
||||
else
|
||||
sendmessage("Failed reloading stored data");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package foxz.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
|
||||
public class CommandNoppes extends CommandBase {
|
||||
|
||||
public CmdNoppes noppes = new CmdNoppes(this);
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return noppes.commandHelper.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return noppes.commandHelper.usage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender var1, String[] var2) {
|
||||
noppes.processCommand(var1, var2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender par1, String[] par2){
|
||||
return noppes.addTabCompletion(par1, par2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel(){
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
// (c)SJFN@ CommandHelper v14.03.21 by [email protected]
|
||||
// licence : cc-by-nc+no gov,mil usage
|
||||
package foxz.commandhelper;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.PlayerSelector;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.controllers.PlayerData;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import foxz.commandhelper.annotations.Command;
|
||||
import foxz.commandhelper.annotations.SubCommand;
|
||||
import foxz.commandhelper.permissions.AbstractPermission;
|
||||
|
||||
public abstract class AbstractCommandHelper extends CommandHelper {
|
||||
|
||||
public Object ctorParm;
|
||||
public ICommandSender pcParam;
|
||||
public Object xParam;
|
||||
public AbstractCommandHelper parentCmdHelper;
|
||||
public AbstractCommandHelper rootCmdHelper;
|
||||
|
||||
public AbstractCommandHelper(Object sender) {
|
||||
this.ctorParm = sender;
|
||||
ctor();
|
||||
}
|
||||
|
||||
public void ctor() {
|
||||
this.commandHelper.name = ((Command) this.getClass().getAnnotation(Command.class)).name();
|
||||
this.commandHelper.usage = ((Command) this.getClass().getAnnotation(Command.class)).usage();
|
||||
this.commandHelper.desc = ((Command) this.getClass().getAnnotation(Command.class)).desc();
|
||||
// sub
|
||||
for (Class c : this.getClass().getAnnotation(Command.class).sub()) {
|
||||
try {
|
||||
String name = ((Command) c.getAnnotation(Command.class)).name().toUpperCase();
|
||||
Constructor<AbstractCommandHelper> ctor = c.getConstructor(Object.class);
|
||||
ctor.setAccessible(true);
|
||||
AbstractCommandHelper sc = (AbstractCommandHelper) ctor.newInstance(ctorParm);
|
||||
commands.put(name, sc);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AbstractCommandHelper.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
// intern
|
||||
for (Method m : this.getClass().getDeclaredMethods()) {
|
||||
SubCommand sc = m.getAnnotation(SubCommand.class);
|
||||
if (sc != null) {
|
||||
String name = sc.name();
|
||||
if (name.equals("")) {
|
||||
name = m.getName();
|
||||
}
|
||||
commands.put(name.toUpperCase(), new MethodSubCmd(this, m));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, CommandHelper> commands = new HashMap<String, CommandHelper>();
|
||||
|
||||
public abstract void help(String cmd, String desc, String usa);
|
||||
|
||||
public abstract void cmdError(String cmd);
|
||||
|
||||
public abstract void error(String err);
|
||||
|
||||
protected class MethodSubCmd extends CommandHelper {
|
||||
|
||||
public List<AbstractPermission> permissions = new ArrayList<AbstractPermission>();
|
||||
|
||||
public MethodSubCmd(AbstractCommandHelper ch, Method m) {
|
||||
SubCommand s = m.getAnnotation(SubCommand.class);
|
||||
commandHelper.name = s.name();
|
||||
if (commandHelper.name.equals("")) {
|
||||
commandHelper.name = m.getName();
|
||||
}
|
||||
commandHelper.usage = s.usage();
|
||||
commandHelper.desc = s.desc();
|
||||
commandHelper.hasEmptyCall = s.hasEmptyCall();
|
||||
|
||||
method = m;
|
||||
for (Class c : s.permissions()) {
|
||||
try {
|
||||
Constructor<AbstractPermission> ctor = c.getDeclaredConstructor();
|
||||
ctor.setAccessible(true);
|
||||
AbstractPermission i = ctor.newInstance();
|
||||
permissions.add(i);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AbstractCommandHelper.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
String[] np = currentHelper.usage.split(" ");
|
||||
if(np.length < args.length)
|
||||
return null;
|
||||
String parameter = np[args.length - 1];
|
||||
if(parameter.equals("<player>"))
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Method method;
|
||||
|
||||
}
|
||||
|
||||
public void allHelp() {
|
||||
for (CommandHelper cur : commands.values()) {
|
||||
help(cur.commandHelper.name, cur.commandHelper.desc, "");
|
||||
}
|
||||
}
|
||||
|
||||
public Helper currentHelper;
|
||||
|
||||
public Boolean processCommand(ICommandSender param, String[] args) {
|
||||
pcParam = param;
|
||||
if (parentCmdHelper == null) {
|
||||
rootCmdHelper = this;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
allHelp();
|
||||
return true;
|
||||
}
|
||||
|
||||
String cmd = args[0].toUpperCase();
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
if ((cmd.equals("HELP") || args.length == 0) && doHelp(param, args, cmd)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CommandHelper ch = commands.get(cmd);
|
||||
if (ch == null) {
|
||||
cmdError(cmd);
|
||||
return false;
|
||||
}
|
||||
if (ch instanceof AbstractCommandHelper) {
|
||||
AbstractCommandHelper f = (AbstractCommandHelper) ch;
|
||||
f.parentCmdHelper = this;
|
||||
f.rootCmdHelper = this.rootCmdHelper;
|
||||
return f.processCommand(param, args);
|
||||
}
|
||||
else if (ch instanceof MethodSubCmd) {
|
||||
MethodSubCmd m = (MethodSubCmd) ch;
|
||||
m.method.setAccessible(true);
|
||||
currentHelper = ch.commandHelper;
|
||||
try {
|
||||
for (AbstractPermission p : m.permissions) {
|
||||
if (!p.delegate(this, args)) {
|
||||
error(p.errorMsg());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return (Boolean) m.method.invoke(this, (Object) args);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AbstractCommandHelper.class.getName()).log(Level.SEVERE, m.commandHelper.name, ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
cmdError(cmd);
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean doHelp(ICommandSender param, String[] args, String cmd){
|
||||
boolean isHelp = cmd.equals("HELP");
|
||||
if(args.length > 0){
|
||||
cmd = args[0];
|
||||
}
|
||||
CommandHelper ch = commands.get(cmd.toUpperCase());
|
||||
if(ch != null){
|
||||
if(ch.commandHelper.hasEmptyCall && !isHelp)
|
||||
return false;
|
||||
if(ch instanceof AbstractCommandHelper){
|
||||
((AbstractCommandHelper)ch).pcParam = param;
|
||||
((AbstractCommandHelper)ch).allHelp();
|
||||
}
|
||||
else if(ch instanceof MethodSubCmd && ((MethodSubCmd)ch).commandHelper.usage.isEmpty())
|
||||
return false;
|
||||
else
|
||||
help(ch.commandHelper.name, ch.commandHelper.desc, ch.commandHelper.usage);
|
||||
}
|
||||
else
|
||||
allHelp();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
if(args.length <= 1){
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(String command : commands.keySet())
|
||||
list.add(command.toLowerCase());
|
||||
list.add("help");
|
||||
return CommandBase.getListOfStringsMatchingLastWord(args, list.toArray(new String[list.size()]));
|
||||
}
|
||||
CommandHelper ch = commands.get(args[0].toUpperCase());
|
||||
if(ch == null)
|
||||
return null;
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
currentHelper = ch.commandHelper;
|
||||
return ch.addTabCompletion(par1, args);
|
||||
}
|
||||
|
||||
public List<PlayerData> getPlayersData(String username){
|
||||
ArrayList<PlayerData> list = new ArrayList<PlayerData>();
|
||||
EntityPlayerMP[] players = PlayerSelector.matchPlayers(pcParam, username);
|
||||
if(players == null || players.length == 0){
|
||||
PlayerData data = PlayerDataController.instance.getDataFromUsername(username);
|
||||
if(data != null)
|
||||
list.add(data);
|
||||
}
|
||||
else{
|
||||
for(EntityPlayer player : players){
|
||||
list.add(PlayerDataController.instance.getPlayerData(player));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public <T> List<T> getNearbeEntityFromPlayer(Class<? extends T> cls, World world, int x, int y, int z, int range) {
|
||||
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(range, range, range);
|
||||
List<T> list = world.getEntitiesWithinAABB(cls, bb);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package foxz.commandhelper;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
|
||||
public class ChMcLogger extends AbstractCommandHelper {
|
||||
|
||||
public ChMcLogger(Object sender) {
|
||||
super(sender);
|
||||
}
|
||||
|
||||
public void sendmessage(String msg) {
|
||||
ICommandSender sender = (ICommandSender) pcParam;
|
||||
sender.addChatMessage(new ChatComponentText(msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void help(String cmd, String desc, String usa) {
|
||||
if(usa.isEmpty())
|
||||
sendmessage(String.format("%s = %s", cmd, desc));
|
||||
else
|
||||
sendmessage(String.format("%s %s = %s", cmd, usa, desc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cmdError(String cmd) {
|
||||
sendmessage(String.format("Unknow command '%s'", cmd));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String err) {
|
||||
sendmessage(String.format("Error: %s", err));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package foxz.commandhelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
|
||||
public abstract class CommandHelper {
|
||||
|
||||
public class Helper {
|
||||
|
||||
public String name;
|
||||
public String usage;
|
||||
public String desc;
|
||||
public boolean hasEmptyCall;
|
||||
}
|
||||
public Helper commandHelper = new Helper();
|
||||
public List addTabCompletion(ICommandSender par1, String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package foxz.commandhelper.annotations;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Documented
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
public @interface Command {
|
||||
|
||||
String name();
|
||||
|
||||
String desc();
|
||||
|
||||
String usage() default "";
|
||||
|
||||
Class[] sub() default {};
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package foxz.commandhelper.annotations;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Documented
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface SubCommand {
|
||||
|
||||
String name() default "";
|
||||
|
||||
String usage() default "";
|
||||
|
||||
boolean hasEmptyCall() default false;
|
||||
|
||||
String desc();
|
||||
|
||||
Class[] permissions() default {};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package foxz.commandhelper.permissions;
|
||||
|
||||
import foxz.commandhelper.AbstractCommandHelper;
|
||||
|
||||
public abstract class AbstractPermission {
|
||||
|
||||
abstract public String errorMsg();
|
||||
|
||||
abstract public boolean delegate(AbstractCommandHelper parent, String args[]);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package foxz.commandhelper.permissions;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import foxz.commandhelper.AbstractCommandHelper;
|
||||
|
||||
public class OpOnly extends AbstractPermission {
|
||||
|
||||
@Override
|
||||
public String errorMsg() {
|
||||
return "Op Only";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delegate(AbstractCommandHelper parent, String[] args) {
|
||||
if(!(parent.pcParam instanceof EntityPlayer))
|
||||
return true;
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152596_g(((EntityPlayer)parent.pcParam).getGameProfile());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package foxz.commandhelper.permissions;
|
||||
|
||||
import foxz.commandhelper.AbstractCommandHelper;
|
||||
|
||||
public class ParamCheck extends AbstractPermission {
|
||||
|
||||
String err;
|
||||
|
||||
@Override
|
||||
public String errorMsg() {
|
||||
return err;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delegate(AbstractCommandHelper parent, String[] args) {
|
||||
String[] np = parent.currentHelper.usage.split(" ");
|
||||
int countRequired = 0;
|
||||
for(String command : np){
|
||||
if(command.startsWith("<"))
|
||||
countRequired++;
|
||||
}
|
||||
if (args.length < countRequired) {
|
||||
err = np[args.length] + " missing";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package foxz.commandhelper.permissions;
|
||||
|
||||
import foxz.commandhelper.AbstractCommandHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author foxz
|
||||
*/
|
||||
public class PlayerOnly extends AbstractPermission {
|
||||
|
||||
@Override
|
||||
public String errorMsg() {
|
||||
return "Player Only";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delegate(AbstractCommandHelper parent, String[] args) {
|
||||
return parent.pcParam instanceof EntityPlayer;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package foxz.utils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleTrader;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
public class Market {
|
||||
|
||||
static public void save(RoleTrader r, String name) {
|
||||
if(name.isEmpty())
|
||||
return;
|
||||
File file = getFile(name + "_new");
|
||||
File file1 = getFile(name);
|
||||
|
||||
try {
|
||||
NBTJsonUtil.SaveFile(file, r.writeNBT(new NBTTagCompound()));
|
||||
if(file1.exists()){
|
||||
file1.delete();
|
||||
}
|
||||
file.renameTo(file1);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public void load(RoleTrader role, String name){
|
||||
if(role.npc.worldObj.isRemote)
|
||||
return;
|
||||
File file = getFile(name);
|
||||
if(!file.exists())
|
||||
return;
|
||||
|
||||
try {
|
||||
role.readNBT(NBTJsonUtil.LoadFile(file));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
private static File getFile(String name){
|
||||
File dir = new File(CustomNpcs.getWorldSaveDirectory(), "markets");
|
||||
if(!dir.exists())
|
||||
dir.mkdir();
|
||||
return new File(dir, name.toLowerCase() + ".json");
|
||||
}
|
||||
|
||||
static public void setMarket(EntityNPCInterface npc, String marketName) {
|
||||
if(marketName.isEmpty())
|
||||
return;
|
||||
if(!getFile(marketName).exists())
|
||||
Market.save((RoleTrader) npc.roleInterface, marketName);
|
||||
|
||||
Market.load((RoleTrader) npc.roleInterface, marketName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package foxz.utils;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
public class Utils {
|
||||
|
||||
static public <T> List<T> getNearbeEntityFromPlayer(Class<? extends T> cls,EntityPlayerMP player, int dis) {
|
||||
AxisAlignedBB range = player.boundingBox.expand(dis, dis, dis);
|
||||
List<T> list = player.worldObj.getEntitiesWithinAABB(cls, range);
|
||||
return list;
|
||||
}
|
||||
|
||||
static public EntityPlayer getOnlinePlayer(String playername){
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152612_a(playername);
|
||||
}
|
||||
|
||||
static public World getWorld(String t){
|
||||
WorldServer[] ws=MinecraftServer.getServer().worldServers;
|
||||
for (WorldServer w:ws){
|
||||
if (w!=null){
|
||||
if ((w.provider.dimensionId + "").equalsIgnoreCase(t)){
|
||||
return w;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// <editor-fold desc="--- Foxz fork (pls keep it)">
|
||||
// static public void savePlayerAltInv(EntityPlayer p,String n){
|
||||
// NBTTagList tag=p.inventory.writeToNBT(new NBTTagList());
|
||||
// p.getEntityData().setTag("AltInv_"+n, tag);
|
||||
// }
|
||||
//
|
||||
// static public void loadPlayerAltInv(EntityPlayer p,String n){
|
||||
// p.inventory.readFromNBT((NBTTagList) p.getEntityData().getTag("AltInv_"+n));
|
||||
// }
|
||||
// </editor-fold>
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.minecraft.client.gui.inventory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
||||
|
||||
public class NPCGuiContainerHelper {
|
||||
|
||||
public static int getLeft(GuiContainer gui) {
|
||||
return gui.guiLeft;
|
||||
}
|
||||
|
||||
public static int getTop(GuiContainer gui) {
|
||||
return gui.guiTop;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.minecraft.client.renderer.entity;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class NPCRendererHelper {
|
||||
|
||||
public static ModelBase getMainModel(RendererLivingEntity render){
|
||||
return render.mainModel;
|
||||
}
|
||||
|
||||
public static String getTexture(RendererLivingEntity render, Entity entity){
|
||||
ResourceLocation location = render.getEntityTexture(entity);
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
public static int shouldRenderPass(EntityLivingBase entity, int par2, float par3, RendererLivingEntity renderEntity) {
|
||||
return renderEntity.shouldRenderPass(entity, par2, par3);
|
||||
}
|
||||
|
||||
public static void preRenderCallback(EntityLivingBase entity, float f,
|
||||
RendererLivingEntity renderEntity) {
|
||||
renderEntity.preRenderCallback(entity, f);
|
||||
}
|
||||
|
||||
public static ModelBase getPassModel(RendererLivingEntity render) {
|
||||
return render.renderPassModel;
|
||||
}
|
||||
|
||||
public static float handleRotationFloat(EntityLivingBase entity,
|
||||
float par2, RendererLivingEntity renderEntity) {
|
||||
return renderEntity.handleRotationFloat(entity, par2);
|
||||
}
|
||||
|
||||
public static void renderEquippedItems(EntityLivingBase entity, float f,
|
||||
RendererLivingEntity renderEntity) {
|
||||
renderEntity.renderEquippedItems(entity, f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.minecraft.client.resources;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class NPCResourceHelper {
|
||||
|
||||
public static File getPackFile(AbstractResourcePack pack){
|
||||
return pack.resourcePackFile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.minecraft.entity;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class NPCEntityHelper {
|
||||
|
||||
public static Item getDropItem(EntityLiving entity){
|
||||
return entity.getDropItem();
|
||||
}
|
||||
|
||||
public static void setRecentlyHit(EntityLivingBase entity){
|
||||
entity.recentlyHit = 100;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.blocks.tiles.TileNpcContainer;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.containers.ContainerCarpentryBench;
|
||||
import noppes.npcs.containers.ContainerCrate;
|
||||
import noppes.npcs.containers.ContainerMail;
|
||||
import noppes.npcs.containers.ContainerManageBanks;
|
||||
import noppes.npcs.containers.ContainerManageRecipes;
|
||||
import noppes.npcs.containers.ContainerMerchantAdd;
|
||||
import noppes.npcs.containers.ContainerNPCBankLarge;
|
||||
import noppes.npcs.containers.ContainerNPCBankSmall;
|
||||
import noppes.npcs.containers.ContainerNPCBankUnlock;
|
||||
import noppes.npcs.containers.ContainerNPCBankUpgrade;
|
||||
import noppes.npcs.containers.ContainerNPCCompanion;
|
||||
import noppes.npcs.containers.ContainerNPCFollower;
|
||||
import noppes.npcs.containers.ContainerNPCFollowerHire;
|
||||
import noppes.npcs.containers.ContainerNPCFollowerSetup;
|
||||
import noppes.npcs.containers.ContainerNPCInv;
|
||||
import noppes.npcs.containers.ContainerNPCTrader;
|
||||
import noppes.npcs.containers.ContainerNPCTraderSetup;
|
||||
import noppes.npcs.containers.ContainerNpcItemGiver;
|
||||
import noppes.npcs.containers.ContainerNpcQuestReward;
|
||||
import noppes.npcs.containers.ContainerNpcQuestTypeItem;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
public class CommonProxy implements IGuiHandler {
|
||||
|
||||
public boolean newVersionAvailable = false;
|
||||
public int revision = 4;
|
||||
|
||||
public void load() {
|
||||
CustomNpcs.Channel.register(new PacketHandlerServer());
|
||||
CustomNpcs.ChannelPlayer.register(new PacketHandlerPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if(ID > EnumGuiType.values().length)
|
||||
return null;
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
EnumGuiType gui = EnumGuiType.values()[ID];
|
||||
return getContainer(gui, player, x, y, z, npc);
|
||||
}
|
||||
public Container getContainer(EnumGuiType gui,EntityPlayer player, int x, int y, int z,EntityNPCInterface npc){
|
||||
if(gui == EnumGuiType.MainMenuInv)
|
||||
return new ContainerNPCInv(npc, player);
|
||||
|
||||
if(gui == EnumGuiType.PlayerBankSmall)
|
||||
return new ContainerNPCBankSmall(player, x , y);
|
||||
|
||||
if(gui == EnumGuiType.PlayerBankUnlock)
|
||||
return new ContainerNPCBankUnlock(player, x , y);
|
||||
|
||||
if(gui == EnumGuiType.PlayerBankUprade)
|
||||
return new ContainerNPCBankUpgrade(player, x , y);
|
||||
|
||||
if(gui == EnumGuiType.PlayerBankLarge)
|
||||
return new ContainerNPCBankLarge(player, x , y);
|
||||
|
||||
if(gui == EnumGuiType.PlayerFollowerHire)
|
||||
return new ContainerNPCFollowerHire(npc, player);
|
||||
|
||||
if(gui == EnumGuiType.PlayerFollower)
|
||||
return new ContainerNPCFollower(npc, player);
|
||||
|
||||
if(gui == EnumGuiType.PlayerTrader)
|
||||
return new ContainerNPCTrader(npc, player);
|
||||
|
||||
if(gui == EnumGuiType.PlayerAnvil)
|
||||
return new ContainerCarpentryBench(player.inventory, player.worldObj, x, y, z);
|
||||
|
||||
if(gui == EnumGuiType.SetupItemGiver)
|
||||
return new ContainerNpcItemGiver(npc, player);
|
||||
|
||||
if(gui == EnumGuiType.SetupTrader)
|
||||
return new ContainerNPCTraderSetup(npc, player);
|
||||
|
||||
if(gui == EnumGuiType.SetupFollower)
|
||||
return new ContainerNPCFollowerSetup(npc, player);
|
||||
|
||||
if(gui == EnumGuiType.QuestReward)
|
||||
return new ContainerNpcQuestReward(player);
|
||||
|
||||
if(gui == EnumGuiType.QuestItem)
|
||||
return new ContainerNpcQuestTypeItem(player);
|
||||
|
||||
if(gui == EnumGuiType.ManageRecipes)
|
||||
return new ContainerManageRecipes(player,x);
|
||||
|
||||
if(gui == EnumGuiType.ManageBanks)
|
||||
return new ContainerManageBanks(player);
|
||||
|
||||
if(gui == EnumGuiType.MerchantAdd)
|
||||
return new ContainerMerchantAdd(player, ServerEventsHandler.Merchant, player.worldObj);
|
||||
|
||||
if(gui == EnumGuiType.Crate)
|
||||
return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z));
|
||||
|
||||
if(gui == EnumGuiType.PlayerMailman)
|
||||
return new ContainerMail(player, x == 1, y == 1);
|
||||
|
||||
if(gui == EnumGuiType.CompanionInv)
|
||||
return new ContainerNPCCompanion(npc, player);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void openGui(EntityNPCInterface npc, EnumGuiType gui) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public void openGui(EntityNPCInterface npc, EnumGuiType gui, int x, int y, int z) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
|
||||
public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) {
|
||||
|
||||
}
|
||||
|
||||
public void openGui(EntityPlayer player, Object guiscreen) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void spawnParticle(EntityLivingBase player, String string, Object... ob) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public boolean hasClient() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void registerItem(Item item) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public ModelBiped getSkirtModel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void spawnParticle(String particle, double x, double y, double z,
|
||||
double motionX, double motionY, double motionZ, float scale) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class CreativeTabNpcs extends CreativeTabs{
|
||||
public Item item = Items.bowl;
|
||||
public int meta = 0;
|
||||
|
||||
public CreativeTabNpcs(String label) {
|
||||
super(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getTabIconItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int func_151243_f(){
|
||||
return meta;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,896 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||
import net.minecraft.dispenser.IBlockSource;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Item.ToolMaterial;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemArmor.ArmorMaterial;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemFlintAndSteel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import noppes.npcs.blocks.BlockBanner;
|
||||
import noppes.npcs.blocks.BlockBarrel;
|
||||
import noppes.npcs.blocks.BlockBeam;
|
||||
import noppes.npcs.blocks.BlockBigSign;
|
||||
import noppes.npcs.blocks.BlockBlood;
|
||||
import noppes.npcs.blocks.BlockBook;
|
||||
import noppes.npcs.blocks.BlockBorder;
|
||||
import noppes.npcs.blocks.BlockCampfire;
|
||||
import noppes.npcs.blocks.BlockCandle;
|
||||
import noppes.npcs.blocks.BlockCarpentryBench;
|
||||
import noppes.npcs.blocks.BlockChair;
|
||||
import noppes.npcs.blocks.BlockCouchWood;
|
||||
import noppes.npcs.blocks.BlockCouchWool;
|
||||
import noppes.npcs.blocks.BlockCrate;
|
||||
import noppes.npcs.blocks.BlockCrystal;
|
||||
import noppes.npcs.blocks.BlockLamp;
|
||||
import noppes.npcs.blocks.BlockMailbox;
|
||||
import noppes.npcs.blocks.BlockNpcRedstone;
|
||||
import noppes.npcs.blocks.BlockPedestal;
|
||||
import noppes.npcs.blocks.BlockPlaceholder;
|
||||
import noppes.npcs.blocks.BlockShelf;
|
||||
import noppes.npcs.blocks.BlockSign;
|
||||
import noppes.npcs.blocks.BlockStool;
|
||||
import noppes.npcs.blocks.BlockTable;
|
||||
import noppes.npcs.blocks.BlockTallLamp;
|
||||
import noppes.npcs.blocks.BlockTombstone;
|
||||
import noppes.npcs.blocks.BlockWallBanner;
|
||||
import noppes.npcs.blocks.BlockWaypoint;
|
||||
import noppes.npcs.blocks.BlockWeaponRack;
|
||||
import noppes.npcs.blocks.tiles.TileBanner;
|
||||
import noppes.npcs.blocks.tiles.TileBarrel;
|
||||
import noppes.npcs.blocks.tiles.TileBeam;
|
||||
import noppes.npcs.blocks.tiles.TileBigSign;
|
||||
import noppes.npcs.blocks.tiles.TileBlockAnvil;
|
||||
import noppes.npcs.blocks.tiles.TileBook;
|
||||
import noppes.npcs.blocks.tiles.TileBorder;
|
||||
import noppes.npcs.blocks.tiles.TileCampfire;
|
||||
import noppes.npcs.blocks.tiles.TileCandle;
|
||||
import noppes.npcs.blocks.tiles.TileChair;
|
||||
import noppes.npcs.blocks.tiles.TileCouchWood;
|
||||
import noppes.npcs.blocks.tiles.TileCouchWool;
|
||||
import noppes.npcs.blocks.tiles.TileCrate;
|
||||
import noppes.npcs.blocks.tiles.TileLamp;
|
||||
import noppes.npcs.blocks.tiles.TileMailbox;
|
||||
import noppes.npcs.blocks.tiles.TilePedestal;
|
||||
import noppes.npcs.blocks.tiles.TileRedstoneBlock;
|
||||
import noppes.npcs.blocks.tiles.TileShelf;
|
||||
import noppes.npcs.blocks.tiles.TileSign;
|
||||
import noppes.npcs.blocks.tiles.TileStool;
|
||||
import noppes.npcs.blocks.tiles.TileTable;
|
||||
import noppes.npcs.blocks.tiles.TileTallLamp;
|
||||
import noppes.npcs.blocks.tiles.TileTombstone;
|
||||
import noppes.npcs.blocks.tiles.TileWallBanner;
|
||||
import noppes.npcs.blocks.tiles.TileWaypoint;
|
||||
import noppes.npcs.blocks.tiles.TileWeaponRack;
|
||||
import noppes.npcs.constants.EnumNpcToolMaterial;
|
||||
import noppes.npcs.items.ItemBattleAxe;
|
||||
import noppes.npcs.items.ItemBroadSword;
|
||||
import noppes.npcs.items.ItemBullet;
|
||||
import noppes.npcs.items.ItemClaw;
|
||||
import noppes.npcs.items.ItemCrossbow;
|
||||
import noppes.npcs.items.ItemDagger;
|
||||
import noppes.npcs.items.ItemDaggerReversed;
|
||||
import noppes.npcs.items.ItemElementalStaff;
|
||||
import noppes.npcs.items.ItemExcalibur;
|
||||
import noppes.npcs.items.ItemGlaive;
|
||||
import noppes.npcs.items.ItemGun;
|
||||
import noppes.npcs.items.ItemGunChainsaw;
|
||||
import noppes.npcs.items.ItemKunai;
|
||||
import noppes.npcs.items.ItemKunaiReversed;
|
||||
import noppes.npcs.items.ItemLeafBlade;
|
||||
import noppes.npcs.items.ItemMachineGun;
|
||||
import noppes.npcs.items.ItemMounter;
|
||||
import noppes.npcs.items.ItemMusic;
|
||||
import noppes.npcs.items.ItemMusicBanjo;
|
||||
import noppes.npcs.items.ItemMusicClarinet;
|
||||
import noppes.npcs.items.ItemMusicOracina;
|
||||
import noppes.npcs.items.ItemMusicViolin;
|
||||
import noppes.npcs.items.ItemMusket;
|
||||
import noppes.npcs.items.ItemNpcArmor;
|
||||
import noppes.npcs.items.ItemNpcArmorColorable;
|
||||
import noppes.npcs.items.ItemNpcBlock;
|
||||
import noppes.npcs.items.ItemNpcCloner;
|
||||
import noppes.npcs.items.ItemNpcColored;
|
||||
import noppes.npcs.items.ItemNpcInterface;
|
||||
import noppes.npcs.items.ItemNpcMovingPath;
|
||||
import noppes.npcs.items.ItemNpcScripter;
|
||||
import noppes.npcs.items.ItemNpcWand;
|
||||
import noppes.npcs.items.ItemNpcWeaponInterface;
|
||||
import noppes.npcs.items.ItemOrb;
|
||||
import noppes.npcs.items.ItemPlaceholder;
|
||||
import noppes.npcs.items.ItemRotatedShield;
|
||||
import noppes.npcs.items.ItemScythe;
|
||||
import noppes.npcs.items.ItemShield;
|
||||
import noppes.npcs.items.ItemSkirt;
|
||||
import noppes.npcs.items.ItemSlingshot;
|
||||
import noppes.npcs.items.ItemSoulstoneEmpty;
|
||||
import noppes.npcs.items.ItemSoulstoneFilled;
|
||||
import noppes.npcs.items.ItemSpear;
|
||||
import noppes.npcs.items.ItemStaff;
|
||||
import noppes.npcs.items.ItemTeleporter;
|
||||
import noppes.npcs.items.ItemThrowingShuriken;
|
||||
import noppes.npcs.items.ItemThrowingWeapon;
|
||||
import noppes.npcs.items.ItemWand;
|
||||
import noppes.npcs.items.ItemWarhammer;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class CustomItems {
|
||||
|
||||
public static Item wand;
|
||||
public static Item cloner;
|
||||
public static Item scripter;
|
||||
public static Item moving;
|
||||
public static Item mount;
|
||||
public static Item teleporter;
|
||||
|
||||
public static Item soulstoneEmpty;
|
||||
public static Item soulstoneFull;
|
||||
|
||||
public static Item banjo;
|
||||
public static Item violin;
|
||||
public static Item violinbow;
|
||||
public static Item harp;
|
||||
public static Item guitar;
|
||||
public static Item frenchHorn;
|
||||
public static Item clarinet;
|
||||
public static Item ocarina;
|
||||
|
||||
public static Item coinWood;
|
||||
public static Item coinStone;
|
||||
public static Item coinIron;
|
||||
public static Item coinGold;
|
||||
public static Item coinDiamond;
|
||||
public static Item coinBronze;
|
||||
public static Item coinEmerald;
|
||||
public static Item moneyBag;
|
||||
|
||||
public static Item bulletWood;
|
||||
public static Item bulletStone;
|
||||
public static Item bulletIron;
|
||||
public static Item bulletGold;
|
||||
public static Item bulletDiamond;
|
||||
public static Item bulletBronze;
|
||||
public static Item bulletEmerald;
|
||||
public static Item bulletBlack;
|
||||
|
||||
public static Item gunWood;
|
||||
public static Item gunStone;
|
||||
public static Item gunIron;
|
||||
public static Item gunGold;
|
||||
public static Item gunDiamond;
|
||||
public static Item gunBronze;
|
||||
public static Item gunEmerald;
|
||||
public static Item gunMachine;
|
||||
|
||||
public static Item halberdWood;
|
||||
public static Item halberdStone;
|
||||
public static Item halberdIron;
|
||||
public static Item halberdGold;
|
||||
public static Item halberdDiamond;
|
||||
public static Item halberdBronze;
|
||||
public static Item halberdEmerald;
|
||||
public static Item halberdDemonic;
|
||||
public static Item halberdFrost;
|
||||
public static Item halberdMithril;
|
||||
|
||||
public static Item tridentWood;
|
||||
public static Item tridentStone;
|
||||
public static Item tridentIron;
|
||||
public static Item tridentGold;
|
||||
public static Item tridentDiamond;
|
||||
public static Item tridentBronze;
|
||||
public static Item tridentEmerald;
|
||||
public static Item tridentCurse;
|
||||
public static Item tridentDemonic;
|
||||
public static Item tridentFrost;
|
||||
public static Item tridentMithril;
|
||||
|
||||
public static Item glaiveWood;
|
||||
public static Item glaiveStone;
|
||||
public static Item glaiveIron;
|
||||
public static Item glaiveGold;
|
||||
public static Item glaiveDiamond;
|
||||
public static Item glaiveBronze;
|
||||
public static Item glaiveEmerald;
|
||||
public static Item glaiveDemonic;
|
||||
public static Item glaiveFrost;
|
||||
public static Item glaiveMithril;
|
||||
|
||||
public static Item battleAxeWood;
|
||||
public static Item battleAxeStone;
|
||||
public static Item battleAxeIron;
|
||||
public static Item battleAxeGold;
|
||||
public static Item battleAxeDiamond;
|
||||
public static Item battleAxeBronze;
|
||||
public static Item battleAxeEmerald;
|
||||
public static Item battleAxeCurse;
|
||||
public static Item battleAxeDemonic;
|
||||
public static Item battleAxeFrost;
|
||||
public static Item battleAxeMithril;
|
||||
|
||||
public static Item spellNature;
|
||||
public static Item spellArcane;
|
||||
public static Item spellItem;
|
||||
public static Item spellLightning;
|
||||
public static Item spellIce;
|
||||
public static Item spellFire;
|
||||
public static Item spellDark;
|
||||
public static Item spellHoly;
|
||||
|
||||
public static Item staffWood;
|
||||
public static Item staffStone;
|
||||
public static Item staffIron;
|
||||
public static Item staffGold;
|
||||
public static Item staffDiamond;
|
||||
public static Item staffBronze;
|
||||
public static Item staffEmerald;
|
||||
public static Item staffDemonic;
|
||||
public static Item staffFrost;
|
||||
public static Item staffMithril;
|
||||
public static Item staffElemental;
|
||||
public static Item orb;
|
||||
public static Item mana;
|
||||
|
||||
public static Item swordBronze;
|
||||
public static Item swordEmerald;
|
||||
public static Item swordDemonic;
|
||||
public static Item swordFrost;
|
||||
public static Item swordMithril;
|
||||
|
||||
public static Item bronze_ingot;
|
||||
public static Item demonic_ingot;
|
||||
public static Item mithril_ingot;
|
||||
|
||||
public static Item kunai;
|
||||
public static Item shuriken;
|
||||
|
||||
public static Item excalibur;
|
||||
public static Item letter;
|
||||
public static Item bag;
|
||||
public static Item satchel;
|
||||
|
||||
public static Block redstoneBlock;
|
||||
public static Block carpentyBench;
|
||||
public static Block mailbox;
|
||||
public static Block waypoint;
|
||||
public static Block border;
|
||||
|
||||
public static Block banner;
|
||||
public static Block wallBanner;
|
||||
public static Block tallLamp;
|
||||
public static Block blood;
|
||||
public static Block book;
|
||||
public static Block chair;
|
||||
public static Block crate;
|
||||
public static Block weaponsRack;
|
||||
public static Block pedestal;
|
||||
public static Block couchWool;
|
||||
public static Block couchWood;
|
||||
public static Block table;
|
||||
public static Block stool;
|
||||
public static Block bigsign;
|
||||
public static Block barrel;
|
||||
public static Block tombstone;
|
||||
public static Block shelf;
|
||||
public static Block sign;
|
||||
public static Block beam;
|
||||
public static Block crystal;
|
||||
|
||||
public static Block lamp;
|
||||
public static Block campfire;
|
||||
public static Block candle;
|
||||
|
||||
public static Block lamp_unlit;
|
||||
public static Block campfire_unlit;
|
||||
public static Block candle_unlit;
|
||||
|
||||
public static Item crossbowBolt;
|
||||
|
||||
public static CreativeTabNpcs tab = new CreativeTabNpcs("cnpcs");
|
||||
public static CreativeTabNpcs tabArmor;
|
||||
public static CreativeTabNpcs tabWeapon;
|
||||
public static CreativeTabNpcs tabBlocks = new CreativeTabNpcs("cnpcsb");
|
||||
public static CreativeTabNpcs tabMisc = new CreativeTabNpcs("cnpcsm");
|
||||
|
||||
|
||||
public static void load(){
|
||||
GameRegistry.registerTileEntity(TileRedstoneBlock.class, "TileRedstoneBlock");
|
||||
GameRegistry.registerTileEntity(TileBlockAnvil.class, "TileBlockAnvil");
|
||||
GameRegistry.registerTileEntity(TileMailbox.class, "TileMailbox");
|
||||
GameRegistry.registerTileEntity(TileWaypoint.class, "TileWaypoint");
|
||||
GameRegistry.registerTileEntity(TileBanner.class, "TileNPCBanner");
|
||||
|
||||
if(!CustomNpcs.DisableExtraBlock){
|
||||
GameRegistry.registerTileEntity(TileWallBanner.class, "TileNPCWallBanner");
|
||||
GameRegistry.registerTileEntity(TileTallLamp.class, "TileNPCTallLamp");
|
||||
GameRegistry.registerTileEntity(TileChair.class, "TileNPCChair");
|
||||
GameRegistry.registerTileEntity(TileCrate.class, "TileNPCCrate");
|
||||
GameRegistry.registerTileEntity(TileWeaponRack.class, "TileNPCWeaponRack");
|
||||
GameRegistry.registerTileEntity(TileCouchWool.class, "TileNPCCouchWool");
|
||||
GameRegistry.registerTileEntity(TileCouchWood.class, "TileNPCCouchWood");
|
||||
GameRegistry.registerTileEntity(TileTable.class, "TileNPCTable");
|
||||
GameRegistry.registerTileEntity(TileLamp.class, "TileNPCLamp");
|
||||
GameRegistry.registerTileEntity(TileCandle.class, "TileNPCCandle");
|
||||
GameRegistry.registerTileEntity(TileBorder.class, "TileNPCBorder");
|
||||
GameRegistry.registerTileEntity(TileStool.class, "TileNPCStool");
|
||||
GameRegistry.registerTileEntity(TileBigSign.class, "TileNPCBigSign");
|
||||
GameRegistry.registerTileEntity(TileBarrel.class, "TileNPCBarrel");
|
||||
GameRegistry.registerTileEntity(TileCampfire.class, "TileNPCCampfire");
|
||||
GameRegistry.registerTileEntity(TileTombstone.class, "TileNPCTombstone");
|
||||
GameRegistry.registerTileEntity(TileShelf.class, "TileNPCShelf");
|
||||
GameRegistry.registerTileEntity(TileSign.class, "TileNPCSign");
|
||||
GameRegistry.registerTileEntity(TileBeam.class, "TileNPCBeam");
|
||||
GameRegistry.registerTileEntity(TileBook.class, "TileNPCBook");
|
||||
GameRegistry.registerTileEntity(TilePedestal.class, "TileNPCPedestal");
|
||||
}
|
||||
wand = new ItemNpcWand().setUnlocalizedName("npcWand").setFull3D();
|
||||
cloner = new ItemNpcCloner().setUnlocalizedName("npcMobCloner").setFull3D();
|
||||
scripter = new ItemNpcScripter().setUnlocalizedName("npcScripter").setFull3D();
|
||||
moving = new ItemNpcMovingPath().setUnlocalizedName("npcMovingPath").setFull3D();
|
||||
mount = new ItemMounter().setUnlocalizedName("npcMounter").setFull3D();
|
||||
teleporter = new ItemTeleporter().setUnlocalizedName("npcTeleporter").setFull3D();
|
||||
|
||||
redstoneBlock = new BlockNpcRedstone().setHardness(50.0F).setResistance(2000).setBlockName("npcRedstoneBlock").setBlockTextureName("customnpcs:npcRedstoneBlock").setCreativeTab(tab);
|
||||
carpentyBench = new BlockCarpentryBench().setBlockName("npcCarpentyBench").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
mailbox = new BlockMailbox().setBlockName("npcMailbox").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks);
|
||||
waypoint = new BlockWaypoint().setBlockName("npcLocationBlock").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setBlockTextureName("customnpcs:npcWaypoint").setCreativeTab(tab);
|
||||
border = new BlockBorder().setBlockName("npcBorder").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tab).setBlockTextureName("customnpcs:npcBorder");
|
||||
|
||||
soulstoneEmpty = new ItemSoulstoneEmpty().setUnlocalizedName("npcSoulstoneEmpty").setTextureName("customnpcs:npcSoulstoneEmpty").setCreativeTab(tab);
|
||||
soulstoneFull = new ItemSoulstoneFilled().setUnlocalizedName("npcSoulstoneFilled").setTextureName("customnpcs:npcSoulstoneFilled");
|
||||
|
||||
BlockDispenser.dispenseBehaviorRegistry.putObject(soulstoneFull, new BehaviorDefaultDispenseItem(){
|
||||
|
||||
@Override
|
||||
public ItemStack dispenseStack(IBlockSource source, ItemStack item){
|
||||
EnumFacing enumfacing = BlockDispenser.func_149937_b(source.getBlockMetadata());
|
||||
int x = source.getXInt() + enumfacing.getFrontOffsetX();
|
||||
int z = source.getZInt() + enumfacing.getFrontOffsetZ();
|
||||
((ItemSoulstoneFilled)soulstoneFull).spawn(null, item, source.getWorld(), x, source.getYInt(), z);
|
||||
item.splitStack(1);
|
||||
return item;
|
||||
}
|
||||
});
|
||||
GameRegistry.registerBlock(redstoneBlock, "npcRedstoneBlock");
|
||||
GameRegistry.registerBlock(carpentyBench, ItemNpcBlock.class, "npcCarpentyBench");
|
||||
GameRegistry.registerBlock(mailbox, ItemBlock.class, "npcMailbox");
|
||||
GameRegistry.registerBlock(waypoint, "npcWaypoint");
|
||||
GameRegistry.registerBlock(border, "npcBorder");
|
||||
|
||||
Item.getItemFromBlock(mailbox).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(carpentyBench).setHasSubtypes(true);
|
||||
|
||||
((ItemNpcBlock)Item.getItemFromBlock(carpentyBench)).names = new String[]{"tile.npcCarpentyBench", "tile.anvil"};
|
||||
|
||||
if(!CustomNpcs.DisableExtraBlock){
|
||||
blood = new BlockBlood().setBlockName("npcBloodBlock").setBlockTextureName("customnpcs:npcBloodBlock").setCreativeTab(tabBlocks);
|
||||
banner = new BlockBanner().setBlockName("npcBanner").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks);
|
||||
wallBanner = new BlockWallBanner().setBlockName("npcWallBanner").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks);
|
||||
tallLamp = new BlockTallLamp().setBlockName("npcTallLamp").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setCreativeTab(tabBlocks);
|
||||
chair = new BlockChair().setBlockName("npcChair").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
crate = new BlockCrate().setBlockName("npcCrate").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
weaponsRack = new BlockWeaponRack().setBlockName("npcWeaponRack").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
couchWool = new BlockCouchWool().setBlockName("npcCouchWool").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
table = new BlockTable().setBlockName("npcTable").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
couchWood = new BlockCouchWood().setBlockName("npcCouchWood").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
lamp = new BlockLamp(true).setBlockName("npcLamp").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
candle = new BlockCandle(true).setBlockName("npcCandle").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
stool = new BlockStool().setBlockName("npcStool").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
Block placeholder = new BlockPlaceholder().setBlockName("npcPlaceholder").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabMisc);
|
||||
bigsign = new BlockBigSign().setBlockName("npcBigSign").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
barrel = new BlockBarrel().setBlockName("npcBarrel").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
campfire = new BlockCampfire(true).setBlockName("npcCampfire").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone).setCreativeTab(tabBlocks);
|
||||
tombstone = new BlockTombstone().setBlockName("npcTombstone").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone).setCreativeTab(tabBlocks);
|
||||
shelf = new BlockShelf().setBlockName("npcShelf").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
sign = new BlockSign().setBlockName("npcSign").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
beam = new BlockBeam().setBlockName("npcBeam").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
book = new BlockBook().setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
pedestal = new BlockPedestal().setBlockName("npcPedestal").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood).setCreativeTab(tabBlocks);
|
||||
crystal = new BlockCrystal().setBlockName("npcCrystal").setBlockTextureName("customnpcs:npcCrystal").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeGlass).setCreativeTab(tabBlocks);
|
||||
|
||||
campfire_unlit = new BlockCampfire(false).setBlockName("npcCampfire").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone);
|
||||
lamp_unlit = new BlockLamp(false).setBlockName("npcLamp").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood);
|
||||
candle_unlit = new BlockCandle(false).setBlockName("npcCandle").setHardness(5.0F).setResistance(10.0F).setStepSound(Block.soundTypeWood);
|
||||
|
||||
GameRegistry.registerBlock(blood, "npcBloodBlock");
|
||||
GameRegistry.registerBlock(banner, ItemBlock.class, "npcBanner");
|
||||
GameRegistry.registerBlock(wallBanner, ItemBlock.class, "npcWallBanner");
|
||||
GameRegistry.registerBlock(tallLamp, ItemBlock.class, "npcTallLamp");
|
||||
GameRegistry.registerBlock(chair, ItemBlock.class, "npcChair");
|
||||
GameRegistry.registerBlock(crate, ItemBlock.class, "npcCrate");
|
||||
GameRegistry.registerBlock(weaponsRack, ItemBlock.class, "npcWeaponRack");
|
||||
GameRegistry.registerBlock(couchWool, ItemBlock.class, "npcCouchWool");
|
||||
GameRegistry.registerBlock(couchWood, ItemBlock.class, "npcCouchWood");
|
||||
GameRegistry.registerBlock(table, ItemBlock.class, "npcTable");
|
||||
GameRegistry.registerBlock(stool, ItemBlock.class, "npcStool");
|
||||
GameRegistry.registerBlock(placeholder, ItemPlaceholder.class, "npcPlaceholder");
|
||||
GameRegistry.registerBlock(bigsign, "npcBigSign");
|
||||
GameRegistry.registerBlock(barrel, ItemBlock.class, "npcBarrel");
|
||||
GameRegistry.registerBlock(tombstone, ItemBlock.class, "npcTombstone");
|
||||
GameRegistry.registerBlock(shelf, ItemBlock.class, "npcShelf");
|
||||
GameRegistry.registerBlock(sign, ItemBlock.class, "npcSign");
|
||||
GameRegistry.registerBlock(beam, ItemBlock.class, "npcBeam");
|
||||
GameRegistry.registerBlock(book, "npcBook");
|
||||
GameRegistry.registerBlock(pedestal, ItemBlock.class, "npcPedestal");
|
||||
GameRegistry.registerBlock(crystal, ItemNpcColored.class, "npcCrystalBlock");
|
||||
GameRegistry.registerBlock(campfire, "npcCampfire");
|
||||
GameRegistry.registerBlock(lamp, "npcLamp");
|
||||
GameRegistry.registerBlock(candle, "npcCandle");
|
||||
GameRegistry.registerBlock(campfire_unlit, "npcCampfireUnlit");
|
||||
GameRegistry.registerBlock(candle_unlit, "npcLampUnlit");
|
||||
GameRegistry.registerBlock(lamp_unlit, "npcCandleUnlit");
|
||||
|
||||
Item.getItemFromBlock(banner).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(wallBanner).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(tallLamp).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(chair).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(crate).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(weaponsRack).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(couchWool).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(couchWood).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(table).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(stool).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(barrel).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(tombstone).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(shelf).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(sign).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(beam).setHasSubtypes(true);
|
||||
Item.getItemFromBlock(pedestal).setHasSubtypes(true);
|
||||
}
|
||||
|
||||
banjo = new ItemMusicBanjo().setUnlocalizedName("npcBanjo").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBanjo");
|
||||
violin = new ItemMusicViolin().setUnlocalizedName("npcViolin").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcViolin");
|
||||
violinbow = new ItemNpcInterface().setUnlocalizedName("npcViolinBow").setFull3D().setMaxStackSize(1).setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcViolinBow");
|
||||
harp = new ItemMusicViolin().setUnlocalizedName("npcHarp").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcHarp");
|
||||
guitar = new ItemMusicBanjo().setUnlocalizedName("npcGuitar").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGuitar");
|
||||
frenchHorn = new ItemMusic().setRotated().setUnlocalizedName("npcFrenchHorn").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrenchHorn");
|
||||
ocarina = new ItemMusicOracina().setUnlocalizedName("npcOcarina").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcOcarina");
|
||||
clarinet = new ItemMusicClarinet().setUnlocalizedName("npcClarinet").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcClarinet");
|
||||
|
||||
|
||||
if(!CustomNpcs.DisableExtraItems){
|
||||
tabArmor = new CreativeTabNpcs("cnpcsa");
|
||||
tabWeapon = new CreativeTabNpcs("cnpcsw");
|
||||
|
||||
gunWood = new ItemGun(26820,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcWoodenGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenGun");
|
||||
bulletWood = new ItemBullet(26821,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcWoodenBullet").setMaxStackSize(64).setTextureName("customnpcs:npcWoodenBullet");
|
||||
|
||||
gunStone = new ItemGun(26822,EnumNpcToolMaterial.STONE).setUnlocalizedName("npcStoneGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneGun");
|
||||
bulletStone = new ItemBullet(26823,EnumNpcToolMaterial.STONE).setUnlocalizedName("npcStoneBullet").setMaxStackSize(64).setTextureName("customnpcs:npcStoneBullet");
|
||||
|
||||
gunIron = new ItemGun(26824,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcIronGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronGun");
|
||||
bulletIron = new ItemBullet(26825,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcIronBullet").setMaxStackSize(64).setTextureName("customnpcs:npcIronBullet");
|
||||
|
||||
gunGold = new ItemGun(26826,EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcGoldGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldGun");
|
||||
bulletGold = new ItemBullet(26827,EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcGoldenBullet").setMaxStackSize(64).setTextureName("customnpcs:npcGoldenBullet");
|
||||
|
||||
gunDiamond = new ItemGun(26828,EnumNpcToolMaterial.DIA).setUnlocalizedName("npcDiamondGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondGun");
|
||||
bulletDiamond = new ItemBullet(26829,EnumNpcToolMaterial.DIA).setUnlocalizedName("npcDiamondBullet").setMaxStackSize(64).setTextureName("customnpcs:npcDiamondBullet");
|
||||
|
||||
gunBronze = new ItemGun(26830,EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcBronzeGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeGun");
|
||||
bulletBronze = new ItemBullet(26831,EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcBronzeBullet").setMaxStackSize(64).setTextureName("customnpcs:npcBronzeBullet");
|
||||
|
||||
gunEmerald = new ItemGun(26832,EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcEmeraldGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldGun");
|
||||
bulletEmerald = new ItemBullet(26833,EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcEmeraldBullet").setMaxStackSize(64).setTextureName("customnpcs:npcEmeraldBullet");
|
||||
|
||||
gunMachine = new ItemMachineGun(26834).setUnlocalizedName("npcMachineGun").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMachineGun");
|
||||
bulletBlack = new ItemBullet(26835,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcBlackBullet").setMaxStackSize(64).setTextureName("customnpcs:npcBlackBullet");
|
||||
|
||||
ToolMaterial bronze = EnumHelper.addToolMaterial("BRONZE", 2, 170, 5.0F, 2, 15);
|
||||
ToolMaterial emerald = EnumHelper.addToolMaterial("REALEMERALD", 3, 1000, 8.0F, 4, 10);
|
||||
ToolMaterial demonic = EnumHelper.addToolMaterial("DEMONIC", 3, 100, 8.0F, 6, 22);
|
||||
ToolMaterial frost = EnumHelper.addToolMaterial("FROST", 2, 59, 6.0F, 3, 5);
|
||||
ToolMaterial mithril = EnumHelper.addToolMaterial("MITHRIL", 3, 3000, 8.0F, 3.0F, 10);
|
||||
|
||||
tridentWood = new ItemSpear(26840,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenTrident");
|
||||
tridentStone = new ItemSpear(26841,ToolMaterial.STONE).setUnlocalizedName("npcStoneTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneTrident");
|
||||
tridentIron = new ItemSpear(26842,ToolMaterial.IRON).setUnlocalizedName("npcIronTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronTrident");
|
||||
tridentGold = new ItemSpear(26843,ToolMaterial.GOLD).setUnlocalizedName("npcGoldTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldTrident");
|
||||
tridentDiamond = new ItemSpear(26844,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondTrident");
|
||||
tridentBronze = new ItemSpear(26845,bronze).setUnlocalizedName("npcBronzeTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeTrident");
|
||||
tridentEmerald = new ItemSpear(26846,emerald).setUnlocalizedName("npcEmeraldTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldTrident");
|
||||
tridentCurse = new ItemSpear(26847,emerald).setUnlocalizedName("npcCursedTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCursedTrident");
|
||||
tridentDemonic = new ItemSpear(26847,demonic).setUnlocalizedName("npcDemonicTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicTrident");
|
||||
tridentFrost = new ItemSpear(26847,frost).setUnlocalizedName("npcFrostTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostTrident");
|
||||
tridentMithril = new ItemSpear(26847,mithril).setUnlocalizedName("npcMithrilTrident").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilTrident");
|
||||
|
||||
spellNature = new ItemNpcInterface(26930).setUnlocalizedName("npcNatureSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcNatureSpell");
|
||||
spellArcane = new ItemNpcInterface(26931).setUnlocalizedName("npcArcaneSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcArcaneSpell");
|
||||
spellLightning = new ItemNpcInterface(26932).setUnlocalizedName("npcLightningSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcLightningSpell");
|
||||
spellIce = new ItemNpcInterface(26933).setUnlocalizedName("npcIceSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcIceSpell");
|
||||
spellFire = new ItemNpcInterface(26934).setUnlocalizedName("npcFireSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcFireSpell");
|
||||
spellDark = new ItemNpcInterface(26935).setUnlocalizedName("npcDarkSpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcDarkSpell");
|
||||
spellHoly = new ItemNpcInterface(26936).setUnlocalizedName("npcHolySpell").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcHolySpell");
|
||||
|
||||
orb = new ItemOrb(26937).setUnlocalizedName("npcOrb").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcOrb");
|
||||
mana = new ItemNpcInterface(26938).setUnlocalizedName("npcMana").setCreativeTab(CustomItems.tabWeapon).setTextureName("customnpcs:npcMana");
|
||||
Item brokenOrb = new ItemOrb(26939).setUnlocalizedName("npcBrokenOrb").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBrokenOrb");
|
||||
|
||||
kunai = new ItemKunai(26910,ToolMaterial.IRON).setUnlocalizedName("npcKunai").setMaxStackSize(1).setFull3D().setTextureName("customnpcs:npcKunai");
|
||||
Item kunai = new ItemKunaiReversed(26911,ToolMaterial.IRON).setUnlocalizedName("npcReverseKunai").setMaxStackSize(1).setFull3D().setTextureName("customnpcs:npcReverseKunai");
|
||||
kunai = new ItemThrowingShuriken(26912).setRotating().setDropItem().setUnlocalizedName("npcShuriken").setFull3D().setTextureName("customnpcs:npcShuriken");
|
||||
shuriken = new ItemThrowingWeapon(26913).setDamage(4).setRotating().setDropItem().setUnlocalizedName("npcGiantShuriken").setFull3D().setTextureName("customnpcs:npcGiantShuriken");
|
||||
Item katana = new ItemNpcWeaponInterface(26914,ToolMaterial.IRON).setUnlocalizedName("npcKatana").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcKatana");
|
||||
Item knive = new ItemDagger(26915,ToolMaterial.IRON).setUnlocalizedName("npcKukri").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcKukri");
|
||||
|
||||
swordBronze = new ItemNpcWeaponInterface(bronze).setUnlocalizedName("npcBronzeSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeSword");
|
||||
swordEmerald = new ItemNpcWeaponInterface(emerald).setUnlocalizedName("npcEmeraldSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldSword");
|
||||
swordDemonic = new ItemNpcWeaponInterface(demonic).setUnlocalizedName("npcDemonicSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicSword");
|
||||
swordFrost = new ItemNpcWeaponInterface(frost).setUnlocalizedName("npcFrostSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostSword");
|
||||
swordMithril = new ItemNpcWeaponInterface(mithril).setUnlocalizedName("npcMithrilSword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilSword");
|
||||
|
||||
Item golf = new ItemSpear(26800,ToolMaterial.IRON).setUnlocalizedName("npcGolfClub").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGolfClub");
|
||||
Item magicwand = new ItemWand(26801).setUnlocalizedName("npcMagicWand").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMagicWand");
|
||||
Item chickenSword = new ItemNpcInterface(26802).setUnlocalizedName("npcChickenSword").setFull3D().setMaxStackSize(1).setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcChickenSword");
|
||||
Item handcuffs = new ItemNpcInterface(26803).setUnlocalizedName("npcHandCuffs").setFull3D().setMaxStackSize(1).setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcHandCuffs");
|
||||
Item hammer = new ItemNpcWeaponInterface(26804,ToolMaterial.STONE).setUnlocalizedName("npcHammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcHammer");
|
||||
Item baseballbat = new ItemNpcWeaponInterface(26805,ToolMaterial.IRON).setUnlocalizedName("npcBaseballBat").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBaseballBat");
|
||||
Item leadpipe = new ItemNpcWeaponInterface(26806,ToolMaterial.IRON).setUnlocalizedName("npcLeadPipe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcLeadPipe");
|
||||
Item cleaver = new ItemNpcWeaponInterface(26807,ToolMaterial.IRON).setUnlocalizedName("npcCleaver").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCleaver");
|
||||
Item saber = new ItemNpcWeaponInterface(26808,ToolMaterial.IRON).setUnlocalizedName("npcSaber").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSaber");
|
||||
Item hockey = new ItemSpear(26809,ToolMaterial.IRON).setUnlocalizedName("npcHockeyStick").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcHockeyStick");
|
||||
hammer = new ItemSpear(26810,ToolMaterial.IRON).setUnlocalizedName("npcSledgeHammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSledgeHammer");
|
||||
Item bottle = new ItemNpcWeaponInterface(26811,ToolMaterial.IRON).setUnlocalizedName("npcBrokenBottle").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBrokenBottle");
|
||||
knive = new ItemDagger(26812,ToolMaterial.STONE).setUnlocalizedName("npcCombatKnive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCombatKnive");
|
||||
Item lighter = new ItemFlintAndSteel().setUnlocalizedName("npcLighter").setMaxStackSize(1).setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcLighter");
|
||||
Item macuahuitl = new ItemNpcWeaponInterface(26714,ToolMaterial.IRON).setUnlocalizedName("npcMacuahuitl").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMacuahuitl");
|
||||
Item bowstaff = new ItemGlaive(26715,ToolMaterial.IRON).setUnlocalizedName("npcBoStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBoStaff");
|
||||
Item sai = new ItemDagger(26757,ToolMaterial.IRON).setUnlocalizedName("npcSaiBlade").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSaiBlade");
|
||||
Item slingshot = new ItemSlingshot(26767).setUnlocalizedName("npcSlingshot").setFull3D().setTextureName("customnpcs:npcSlingshot");
|
||||
Item musket = new ItemMusket(26758).setUnlocalizedName("npcMusket").setFull3D().setTextureName("customnpcs:npcMusket").setMaxStackSize(1);
|
||||
Item leaf = new ItemLeafBlade(26758,ToolMaterial.IRON).setUnlocalizedName("npcLeafBlade").setFull3D().setTextureName("customnpcs:npcLeafBlade").setMaxStackSize(1);
|
||||
|
||||
Item crossbow = new ItemCrossbow(26768).setUnlocalizedName("npcCrossbow").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCrossbow");
|
||||
crossbowBolt = new ItemBullet(26769,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcCrossBolt").setMaxStackSize(64).setTextureName("customnpcs:npcCrossBolt");
|
||||
|
||||
Item batton = new ItemNpcWeaponInterface(26814,ToolMaterial.STONE).setUnlocalizedName("npcBatton").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBatton");
|
||||
Item chainsaw = new ItemGunChainsaw(26815,ToolMaterial.EMERALD).setUnlocalizedName("npcGunChainsaw").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGunChainsaw");
|
||||
Item rapier = new ItemNpcWeaponInterface(26816,ToolMaterial.IRON).setUnlocalizedName("npcRapier").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcRapier");
|
||||
Item crowbar = new ItemNpcWeaponInterface(26817,ToolMaterial.IRON).setUnlocalizedName("npcCrowbar").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCrowbar");
|
||||
Item pipewrench = new ItemNpcWeaponInterface(26818,ToolMaterial.IRON).setUnlocalizedName("npcPipeWrench").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcPipeWrench");
|
||||
Item swiss = new ItemDagger(26819,ToolMaterial.IRON).setUnlocalizedName("npcSwissArmyKnife").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSwissArmyKnife");
|
||||
Item wrench = new ItemNpcWeaponInterface(26836,ToolMaterial.IRON).setUnlocalizedName("npcWrench").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWrench");
|
||||
excalibur = new ItemExcalibur(26799,ToolMaterial.EMERALD).setUnlocalizedName("npcExcalibur").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcExcalibur");
|
||||
|
||||
Item shield = new ItemShield(26729,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcWoodenShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenShield");
|
||||
shield = new ItemShield(26730,EnumNpcToolMaterial.STONE).setUnlocalizedName("npcStoneShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneShield");
|
||||
shield = new ItemShield(26736,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcIronShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronShield");
|
||||
shield = new ItemShield(26737,EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcGoldenShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenShield");
|
||||
shield = new ItemShield(26738,EnumNpcToolMaterial.DIA).setUnlocalizedName("npcDiaShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiaShield");
|
||||
shield = new ItemShield(26739,EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcBronzeShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeShield");
|
||||
shield = new ItemShield(26728,EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcEmeraldShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldShield");
|
||||
shield = new ItemShield(26739,EnumNpcToolMaterial.DEMONIC).setUnlocalizedName("npcDemonicShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicShield");
|
||||
shield = new ItemRotatedShield(26739,EnumNpcToolMaterial.FROST).setUnlocalizedName("npcFrostShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostShield");
|
||||
shield = new ItemRotatedShield(26739,EnumNpcToolMaterial.MITHRIL).setUnlocalizedName("npcMithrilShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilShield");
|
||||
|
||||
shield = new ItemRotatedShield(26740,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcFullWoodenShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenShield");
|
||||
shield = new ItemRotatedShield(26741,EnumNpcToolMaterial.STONE).setUnlocalizedName("npcFullStoneShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullStoneShield");
|
||||
shield = new ItemRotatedShield(26742,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcFullIronShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullIronShield");
|
||||
shield = new ItemRotatedShield(26743,EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcFullGoldenShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullGoldenShield");
|
||||
shield = new ItemRotatedShield(26744,EnumNpcToolMaterial.DIA).setUnlocalizedName("npcFullDiaShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullDiaShield");
|
||||
shield = new ItemRotatedShield(26745,EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcFullBronzeShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeShield");
|
||||
shield = new ItemRotatedShield(26727,EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcFullEmeraldShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldShield");
|
||||
|
||||
shield = new ItemShield(26746,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcHeaterShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcHeaterShield");
|
||||
shield = new ItemShield(26747,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcCryscentShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcCryscentShield");
|
||||
shield = new ItemShield(26748,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcScutumShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcScutumShield");
|
||||
shield = new ItemRotatedShield(26749,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcTowerShield").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcTowerShield");
|
||||
|
||||
Item spear = new ItemSpear(26750,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenSpear");
|
||||
spear = new ItemSpear(26751,ToolMaterial.STONE).setUnlocalizedName("npcStoneSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneSpear");
|
||||
spear = new ItemSpear(26752,ToolMaterial.IRON).setUnlocalizedName("npcIronSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronSpear");
|
||||
spear = new ItemSpear(26753,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenSpear");
|
||||
spear = new ItemSpear(26754,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondSpear");
|
||||
spear = new ItemSpear(26755,bronze).setUnlocalizedName("npcBronzeSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeSpear");
|
||||
spear = new ItemSpear(26756,emerald).setUnlocalizedName("npcEmeraldSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldSpear");
|
||||
spear = new ItemSpear(26756,demonic).setUnlocalizedName("npcDemonicSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicSpear");
|
||||
spear = new ItemSpear(26756,frost).setUnlocalizedName("npcFrostSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostSpear");
|
||||
spear = new ItemSpear(26756,mithril).setUnlocalizedName("npcMithrilSpear").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilSpear");
|
||||
|
||||
halberdWood = new ItemSpear(26750,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenHalberd");
|
||||
halberdStone = new ItemSpear(26751,ToolMaterial.STONE).setUnlocalizedName("npcStoneHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneHalberd");
|
||||
halberdIron = new ItemSpear(26752,ToolMaterial.IRON).setUnlocalizedName("npcIronHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronHalberd");
|
||||
halberdGold = new ItemSpear(26753,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenHalberd");
|
||||
halberdDiamond = new ItemSpear(26754,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondHalberd");
|
||||
halberdBronze = new ItemSpear(26755,bronze).setUnlocalizedName("npcBronzeHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeHalberd");
|
||||
halberdEmerald = new ItemSpear(26756,emerald).setUnlocalizedName("npcEmeraldHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldHalberd");
|
||||
halberdDemonic = new ItemSpear(26756,demonic).setUnlocalizedName("npcDemonicHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicHalberd");
|
||||
halberdFrost = new ItemSpear(26756,frost).setUnlocalizedName("npcFrostHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostHalberd");
|
||||
halberdMithril = new ItemSpear(26756,mithril).setUnlocalizedName("npcMithrilHalberd").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilHalberd");
|
||||
|
||||
battleAxeWood = new ItemBattleAxe(26760,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenBattleAxe");
|
||||
battleAxeStone = new ItemBattleAxe(26761,ToolMaterial.STONE).setUnlocalizedName("npcStoneBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneBattleAxe");
|
||||
battleAxeIron = new ItemBattleAxe(26762,ToolMaterial.IRON).setUnlocalizedName("npcIronBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronBattleAxe");
|
||||
battleAxeGold = new ItemBattleAxe(26763,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenBattleAxe");
|
||||
battleAxeDiamond = new ItemBattleAxe(26764,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondBattleAxe");
|
||||
battleAxeBronze = new ItemBattleAxe(26765,bronze).setUnlocalizedName("npcBronzeBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeBattleAxe");
|
||||
battleAxeEmerald = new ItemBattleAxe(26766,emerald).setUnlocalizedName("npcEmeraldBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldBattleAxe");
|
||||
battleAxeDemonic = new ItemBattleAxe(26766,demonic).setUnlocalizedName("npcDemonicBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicBattleAxe");
|
||||
battleAxeFrost = new ItemBattleAxe(26766,frost).setUnlocalizedName("npcFrostBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostBattleAxe");
|
||||
battleAxeMithril = new ItemBattleAxe(26766,mithril).setUnlocalizedName("npcMithrilBattleAxe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilBattleAxe");
|
||||
|
||||
Item warhammer = new ItemWarhammer(26760,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenWarhammer");
|
||||
warhammer = new ItemWarhammer(26761,ToolMaterial.STONE).setUnlocalizedName("npcStoneWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneWarhammer");
|
||||
warhammer = new ItemWarhammer(26762,ToolMaterial.IRON).setUnlocalizedName("npcIronWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronWarhammer");
|
||||
warhammer = new ItemWarhammer(26763,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenWarhammer");
|
||||
warhammer = new ItemWarhammer(26764,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondWarhammer");
|
||||
warhammer = new ItemWarhammer(26765,bronze).setUnlocalizedName("npcBronzeWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeWarhammer");
|
||||
warhammer = new ItemWarhammer(26766,emerald).setUnlocalizedName("npcEmeraldWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldWarhammer");
|
||||
warhammer = new ItemWarhammer(26766,demonic).setUnlocalizedName("npcDemonicWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicWarhammer");
|
||||
warhammer = new ItemWarhammer(26766,frost).setUnlocalizedName("npcFrostWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostWarhammer");
|
||||
warhammer = new ItemWarhammer(26766,mithril).setUnlocalizedName("npcMithrilWarhammer").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilWarhammer");
|
||||
|
||||
Item mace = new ItemNpcWeaponInterface(26770,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenMace");
|
||||
mace = new ItemNpcWeaponInterface(26771,ToolMaterial.STONE).setUnlocalizedName("npcStoneMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneMace");
|
||||
mace = new ItemNpcWeaponInterface(26772,ToolMaterial.IRON).setUnlocalizedName("npcIronMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronMace");
|
||||
mace = new ItemNpcWeaponInterface(26773,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenMace");
|
||||
mace = new ItemNpcWeaponInterface(26774,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondMace");
|
||||
mace = new ItemNpcWeaponInterface(26775,bronze).setUnlocalizedName("npcBronzeMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeMace");
|
||||
mace = new ItemNpcWeaponInterface(26776,emerald).setUnlocalizedName("npcEmeraldMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldMace");
|
||||
mace = new ItemNpcWeaponInterface(26776,demonic).setUnlocalizedName("npcDemonicMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicMace");
|
||||
mace = new ItemNpcWeaponInterface(26776,frost).setUnlocalizedName("npcFrostMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostMace");
|
||||
mace = new ItemNpcWeaponInterface(26776,mithril).setUnlocalizedName("npcMithrilMace").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilMace");
|
||||
|
||||
Item dagger = new ItemDagger(26700,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenDagger");
|
||||
dagger = new ItemDaggerReversed(26701, (ItemDagger) dagger, ToolMaterial.WOOD).setUnlocalizedName("npcWoodenReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenDagger");
|
||||
dagger = new ItemDagger(26702,ToolMaterial.STONE).setUnlocalizedName("npcStoneDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneDagger");
|
||||
dagger = new ItemDaggerReversed(26703, (ItemDagger) dagger,ToolMaterial.STONE).setUnlocalizedName("npcStoneReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneDagger");
|
||||
dagger = new ItemDagger(26704,ToolMaterial.IRON).setUnlocalizedName("npcIronDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronDagger");
|
||||
dagger = new ItemDaggerReversed(26705, (ItemDagger) dagger,ToolMaterial.IRON).setUnlocalizedName("npcIronReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronDagger");
|
||||
dagger = new ItemDagger(26706,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenDagger");
|
||||
dagger = new ItemDaggerReversed(26707, (ItemDagger) dagger,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenDagger");
|
||||
dagger = new ItemDagger(26708,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondDagger");
|
||||
dagger = new ItemDaggerReversed(26709, (ItemDagger) dagger,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondDagger");
|
||||
dagger = new ItemDagger(26710,bronze).setUnlocalizedName("npcBronzeDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeDagger");
|
||||
dagger = new ItemDaggerReversed(26711, (ItemDagger) dagger,bronze).setUnlocalizedName("npcBronzeReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeDagger");
|
||||
dagger = new ItemDagger(26712,emerald).setUnlocalizedName("npcEmeraldDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldDagger");
|
||||
dagger = new ItemDaggerReversed(26713, (ItemDagger) dagger,emerald).setUnlocalizedName("npcEmeraldReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldDagger");
|
||||
dagger = new ItemDagger(26712,demonic).setUnlocalizedName("npcDemonicDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicDagger");
|
||||
dagger = new ItemDaggerReversed(26713, (ItemDagger) dagger,demonic).setUnlocalizedName("npcDemonicReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicDagger");
|
||||
dagger = new ItemDagger(26712,frost).setUnlocalizedName("npcFrostDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostDagger");
|
||||
dagger = new ItemDaggerReversed(26713, (ItemDagger) dagger,frost).setUnlocalizedName("npcFrostReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostDagger");
|
||||
dagger = new ItemDagger(26712,mithril).setUnlocalizedName("npcMithrilDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilDagger");
|
||||
dagger = new ItemDaggerReversed(26713, (ItemDagger) dagger,frost).setUnlocalizedName("npcMithrilReversedDagger").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilDagger");
|
||||
|
||||
Item claw = new ItemClaw(26850,ToolMaterial.IRON).setUnlocalizedName("npcNinjaClaw").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcNinjaClaw");
|
||||
claw = new ItemClaw(26851,ToolMaterial.IRON).setUnlocalizedName("npcSteelClaw").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcSteelClaw");
|
||||
claw = new ItemClaw(26852,ToolMaterial.IRON).setUnlocalizedName("npcBearClaw").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBearClaw");
|
||||
claw = new ItemClaw(26853,ToolMaterial.IRON).setUnlocalizedName("npcKatar").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcKatar");
|
||||
|
||||
staffWood = new ItemStaff(26777,EnumNpcToolMaterial.WOOD).setUnlocalizedName("npcWoodenStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenStaff");
|
||||
staffStone = new ItemStaff(26778,EnumNpcToolMaterial.STONE).setUnlocalizedName("npcStoneStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneStaff");
|
||||
staffIron = new ItemStaff(26779,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcIronStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronStaff");
|
||||
staffGold = new ItemStaff(26780,EnumNpcToolMaterial.GOLD).setUnlocalizedName("npcGoldenStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenStaff");
|
||||
staffDiamond = new ItemStaff(26781,EnumNpcToolMaterial.DIA).setUnlocalizedName("npcDiamondStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondStaff");
|
||||
staffBronze = new ItemStaff(26782,EnumNpcToolMaterial.BRONZE).setUnlocalizedName("npcBronzeStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeStaff");
|
||||
staffEmerald = new ItemStaff(26783,EnumNpcToolMaterial.EMERALD).setUnlocalizedName("npcEmeraldStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldStaff");
|
||||
staffDemonic = new ItemStaff(26783,EnumNpcToolMaterial.DEMONIC).setUnlocalizedName("npcDemonicStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicStaff");
|
||||
staffFrost = new ItemStaff(26783,EnumNpcToolMaterial.FROST).setUnlocalizedName("npcFrostStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostStaff");
|
||||
staffMithril = new ItemStaff(26783,EnumNpcToolMaterial.MITHRIL).setUnlocalizedName("npcMithrilStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilStaff");
|
||||
staffElemental = new ItemElementalStaff(26784,EnumNpcToolMaterial.IRON).setUnlocalizedName("npcElementalStaff").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcElementalStaff");
|
||||
|
||||
Item scythe = new ItemScythe(26785,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenScythe");
|
||||
scythe = new ItemScythe(26786,ToolMaterial.STONE).setUnlocalizedName("npcStoneScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneScythe");
|
||||
scythe = new ItemScythe(26787,ToolMaterial.IRON).setUnlocalizedName("npcIronScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronScythe");
|
||||
scythe = new ItemScythe(26788,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenScythe");
|
||||
scythe = new ItemScythe(26789,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondScythe");
|
||||
scythe = new ItemScythe(26798,emerald).setUnlocalizedName("npcEmeraldScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldScythe");
|
||||
scythe = new ItemScythe(26797,bronze).setUnlocalizedName("npcBronzeScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeScythe");
|
||||
scythe = new ItemScythe(26797,demonic).setUnlocalizedName("npcDemonicScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicScythe");
|
||||
scythe = new ItemScythe(26797,frost).setUnlocalizedName("npcFrostScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostScythe");
|
||||
scythe = new ItemScythe(26797,mithril).setUnlocalizedName("npcMithrilScythe").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilScythe");
|
||||
|
||||
glaiveWood = new ItemGlaive(26790,ToolMaterial.WOOD).setUnlocalizedName("npcWoodenGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenGlaive");
|
||||
glaiveStone = new ItemGlaive(26791,ToolMaterial.STONE).setUnlocalizedName("npcStoneGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneGlaive");
|
||||
glaiveIron = new ItemGlaive(26792,ToolMaterial.IRON).setUnlocalizedName("npcIronGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronGlaive");
|
||||
glaiveGold = new ItemGlaive(26793,ToolMaterial.GOLD).setUnlocalizedName("npcGoldenGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenGlaive");
|
||||
glaiveDiamond = new ItemGlaive(26794,ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondGlaive");
|
||||
glaiveBronze = new ItemGlaive(26795,bronze).setUnlocalizedName("npcBronzeGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeGlaive");
|
||||
glaiveEmerald = new ItemGlaive(26796,emerald).setUnlocalizedName("npcEmeraldGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldGlaive");
|
||||
glaiveDemonic = new ItemGlaive(26796,demonic).setUnlocalizedName("npcDemonicGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicGlaive");
|
||||
glaiveFrost = new ItemGlaive(26796,frost).setUnlocalizedName("npcFrostGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostGlaive");
|
||||
glaiveMithril = new ItemGlaive(26796,mithril).setUnlocalizedName("npcMithrilGlaive").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilGlaive");
|
||||
|
||||
new ItemBroadSword(ToolMaterial.WOOD).setUnlocalizedName("npcWoodenBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcWoodenBroadsword");
|
||||
new ItemBroadSword(ToolMaterial.STONE).setUnlocalizedName("npcStoneBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcStoneBroadsword");
|
||||
new ItemBroadSword(ToolMaterial.IRON).setUnlocalizedName("npcIronBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcIronBroadsword");
|
||||
new ItemBroadSword(ToolMaterial.GOLD).setUnlocalizedName("npcGoldenBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcGoldenBroadsword");
|
||||
new ItemBroadSword(ToolMaterial.EMERALD).setUnlocalizedName("npcDiamondBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDiamondBroadsword");
|
||||
new ItemBroadSword(bronze).setUnlocalizedName("npcBronzeBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcBronzeBroadsword");
|
||||
new ItemBroadSword(emerald).setUnlocalizedName("npcEmeraldBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcEmeraldBroadsword");
|
||||
new ItemBroadSword(demonic).setUnlocalizedName("npcDemonicBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcDemonicBroadsword");
|
||||
new ItemBroadSword(frost).setUnlocalizedName("npcFrostBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcFrostBroadsword");
|
||||
new ItemBroadSword(mithril).setUnlocalizedName("npcMithrilBroadsword").setFull3D().setMaxStackSize(1).setTextureName("customnpcs:npcMithrilBroadsword");
|
||||
|
||||
ItemArmor.ArmorMaterial armorMithril = EnumHelper.addArmorMaterial("MITHRIL", 40, new int[]{3, 8, 6, 3}, 20);
|
||||
ItemArmor.ArmorMaterial armorBronze = EnumHelper.addArmorMaterial("BRONZE", 7, new int[]{2, 6, 5, 2}, 20);
|
||||
ItemArmor.ArmorMaterial armorEmerald = EnumHelper.addArmorMaterial("EMERALD", 35, new int[]{5, 7, 4, 5}, 5);
|
||||
|
||||
Item cowarmor = new ItemNpcArmor(26860, ArmorMaterial.CHAIN,0,"cowleather").setUnlocalizedName("npcCowleatherHead").setMaxStackSize(1).setTextureName("customnpcs:npcCowleatherHead");
|
||||
Item armor = new ItemNpcArmor(26861,ArmorMaterial.CHAIN,1,"cowleather").setUnlocalizedName("npcCowleatherChest").setMaxStackSize(1).setTextureName("customnpcs:npcCowleatherChest");
|
||||
armor = new ItemNpcArmor(26862,ArmorMaterial.CHAIN,2,"cowleather").setUnlocalizedName("npcCowleatherLegs").setMaxStackSize(1).setTextureName("customnpcs:npcCowleatherLegs");
|
||||
armor = new ItemNpcArmor(26863,ArmorMaterial.CHAIN,3,"cowleather").setUnlocalizedName("npcCowleatherBoots").setMaxStackSize(1).setTextureName("customnpcs:npcCowleatherBoots");
|
||||
|
||||
armor = new ItemNpcArmor(26864,ArmorMaterial.IRON,0,"nanorum").setUnlocalizedName("npcNanorumHead").setMaxStackSize(1).setTextureName("customnpcs:npcNanorumHead");
|
||||
armor = new ItemNpcArmor(26865,ArmorMaterial.IRON,1,"nanorum").setUnlocalizedName("npcNanorumChest").setMaxStackSize(1).setTextureName("customnpcs:npcNanorumChest");
|
||||
armor = new ItemNpcArmor(26866,ArmorMaterial.IRON,2,"nanorum").setUnlocalizedName("npcNanorumLegs").setMaxStackSize(1).setTextureName("customnpcs:npcNanorumLegs");
|
||||
armor = new ItemNpcArmor(26867,ArmorMaterial.IRON,3,"nanorum").setUnlocalizedName("npcNanorumBoots").setMaxStackSize(1).setTextureName("customnpcs:npcNanorumBoots");
|
||||
|
||||
armor = new ItemNpcArmor(26868,ArmorMaterial.IRON,0,"tactical").setUnlocalizedName("npcTacticalHead").setMaxStackSize(1).setTextureName("customnpcs:npcTacticalHead");
|
||||
armor = new ItemNpcArmor(26869,ArmorMaterial.IRON,1,"tactical").setUnlocalizedName("npcTacticalChest").setMaxStackSize(1).setTextureName("customnpcs:npcTacticalChest");
|
||||
|
||||
armor = new ItemNpcArmor(26919,ArmorMaterial.IRON,0,"fullcloth").setUnlocalizedName("npcFullLeatherHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullLeatherHead");
|
||||
armor = new ItemNpcArmor(26920,ArmorMaterial.IRON,1,"fullcloth").setUnlocalizedName("npcFullLeatherChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullLeatherChest");
|
||||
|
||||
armor = new ItemNpcArmor(26870,ArmorMaterial.IRON,0,"fulliron").setUnlocalizedName("npcFullIronHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullIronHead");
|
||||
armor = new ItemNpcArmor(26871,ArmorMaterial.IRON,1,"fulliron").setUnlocalizedName("npcFullIronChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullIronChest");
|
||||
|
||||
armor = new ItemNpcArmor(26872,ArmorMaterial.GOLD,0,"fullgold").setUnlocalizedName("npcFullGoldHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullGoldHead");
|
||||
armor = new ItemNpcArmor(26873,ArmorMaterial.GOLD,1,"fullgold").setUnlocalizedName("npcFullGoldChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullGoldChest");
|
||||
|
||||
armor = new ItemNpcArmor(26874,ArmorMaterial.DIAMOND,0,"fulldiamond").setUnlocalizedName("npcFullDiamondHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullDiamondHead");
|
||||
armor = new ItemNpcArmor(26875,ArmorMaterial.DIAMOND,1,"fulldiamond").setUnlocalizedName("npcFullDiamondChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullDiamondChest");
|
||||
|
||||
armor = new ItemNpcArmor(26876, armorBronze,0,"fullbronze").setUnlocalizedName("npcFullBronzeHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeHead");
|
||||
armor = new ItemNpcArmor(26877, armorBronze,1,"fullbronze").setUnlocalizedName("npcFullBronzeChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeChest");
|
||||
armor = new ItemNpcArmor(26878, armorBronze,2,"fullbronze").setUnlocalizedName("npcFullBronzeLeggings").setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeLeggings");
|
||||
armor = new ItemNpcArmor(26879, armorBronze,3,"fullbronze").setUnlocalizedName("npcFullBronzeBoots").setMaxStackSize(1).setTextureName("customnpcs:npcFullBronzeBoots");
|
||||
|
||||
armor = new ItemNpcArmor(26921, armorEmerald,0,"fullemerald").setUnlocalizedName("npcFullEmeraldHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldHead");
|
||||
armor = new ItemNpcArmor(26922, armorEmerald,1,"fullemerald").setUnlocalizedName("npcFullEmeraldChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldChest");
|
||||
armor = new ItemNpcArmor(26923, armorEmerald,2,"fullemerald").setUnlocalizedName("npcFullEmeraldLeggings").setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldLeggings");
|
||||
armor = new ItemNpcArmor(26924, armorEmerald,3,"fullemerald").setUnlocalizedName("npcFullEmeraldBoots").setMaxStackSize(1).setTextureName("customnpcs:npcFullEmeraldBoots");
|
||||
|
||||
armor = new ItemNpcArmor(26880,ArmorMaterial.CLOTH,0,"fullwood").setUnlocalizedName("npcFullWoodenHead").setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenHead");
|
||||
armor = new ItemNpcArmor(26881,ArmorMaterial.CLOTH,1,"fullwood").setUnlocalizedName("npcFullWoodenChest").setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenChest");
|
||||
armor = new ItemNpcArmor(26882,ArmorMaterial.CLOTH,2,"fullwood").setUnlocalizedName("npcFullWoodenLeggings").setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenLeggings");
|
||||
armor = new ItemNpcArmor(26883,ArmorMaterial.CLOTH,3,"fullwood").setUnlocalizedName("npcFullWoodenBoots").setMaxStackSize(1).setTextureName("customnpcs:npcFullWoodenBoots");
|
||||
|
||||
armor = new ItemNpcArmor(26884,ArmorMaterial.CHAIN,1,"tuxido").setUnlocalizedName("npcTuxedoChest").setMaxStackSize(1).setTextureName("customnpcs:npcTuxedoChest");
|
||||
armor = new ItemNpcArmor(26885,ArmorMaterial.CHAIN,2,"tuxido").setUnlocalizedName("npcTuxedoPants").setMaxStackSize(1).setTextureName("customnpcs:npcTuxedoPants");
|
||||
armor = new ItemNpcArmor(26886,ArmorMaterial.CHAIN,3,"tuxido").setUnlocalizedName("npcTuxedoBottom").setMaxStackSize(1).setTextureName("customnpcs:npcTuxedoBottom");
|
||||
|
||||
armor = new ItemNpcArmor(26887,ArmorMaterial.CHAIN,0,"wizard").setUnlocalizedName("npcWizardHead").setMaxStackSize(1).setTextureName("customnpcs:npcWizardHead");
|
||||
armor = new ItemNpcArmor(26888,ArmorMaterial.CHAIN,1,"wizard").setUnlocalizedName("npcWizardChest").setMaxStackSize(1).setTextureName("customnpcs:npcWizardChest");
|
||||
armor = new ItemNpcArmor(26889,ArmorMaterial.CHAIN,2,"wizard").setUnlocalizedName("npcWizardPants").setMaxStackSize(1).setTextureName("customnpcs:npcWizardPants");
|
||||
|
||||
armor = new ItemNpcArmor(26890,ArmorMaterial.IRON,0,"assassin").setUnlocalizedName("npcAssassinHead").setMaxStackSize(1).setTextureName("customnpcs:npcAssassinHead");
|
||||
armor = new ItemNpcArmor(26891,ArmorMaterial.IRON,1,"assassin").setUnlocalizedName("npcAssassinChest").setMaxStackSize(1).setTextureName("customnpcs:npcAssassinChest");
|
||||
armor = new ItemNpcArmor(26892,ArmorMaterial.IRON,2,"assassin").setUnlocalizedName("npcAssassinLeggings").setMaxStackSize(1).setTextureName("customnpcs:npcAssassinLeggings");
|
||||
armor = new ItemNpcArmor(26893,ArmorMaterial.IRON,3,"assassin").setUnlocalizedName("npcAssassinBoots").setMaxStackSize(1).setTextureName("customnpcs:npcAssassinBoots");
|
||||
|
||||
armor = new ItemNpcArmor(26894,ArmorMaterial.IRON,0,"soldier").setUnlocalizedName("npcSoldierHead").setMaxStackSize(1).setTextureName("customnpcs:npcSoldierHead");
|
||||
armor = new ItemNpcArmor(26895,ArmorMaterial.IRON,1,"soldier").setUnlocalizedName("npcSoldierChest").setMaxStackSize(1).setTextureName("customnpcs:npcSoldierChest");
|
||||
armor = new ItemNpcArmor(26896,ArmorMaterial.IRON,2,"soldier").setUnlocalizedName("npcSoldierLegs").setMaxStackSize(1).setTextureName("customnpcs:npcSoldierLegs");
|
||||
armor = new ItemNpcArmor(26897,ArmorMaterial.IRON,3,"soldier").setUnlocalizedName("npcSoldierBottom").setMaxStackSize(1).setTextureName("customnpcs:npcSoldierBottom");
|
||||
|
||||
armor = new ItemNpcArmor(26898,ArmorMaterial.DIAMOND,0,"x407").setUnlocalizedName("npcX407Head").setMaxStackSize(1).setTextureName("customnpcs:npcX407Head");
|
||||
armor = new ItemNpcArmor(26899,ArmorMaterial.DIAMOND,1,"x407").setUnlocalizedName("npcX407Chest").setMaxStackSize(1).setTextureName("customnpcs:npcX407Chest");
|
||||
armor = new ItemNpcArmor(26900,ArmorMaterial.DIAMOND,2,"x407").setUnlocalizedName("npcX407Legs").setMaxStackSize(1).setTextureName("customnpcs:npcX407Legs");
|
||||
armor = new ItemNpcArmor(26901,ArmorMaterial.DIAMOND,3,"x407").setUnlocalizedName("npcX407Boots").setMaxStackSize(1).setTextureName("customnpcs:npcX407Boots");
|
||||
|
||||
armor = new ItemNpcArmor(26898,armorMithril,0,"mithril").setUnlocalizedName("npcMithrilHead").setMaxStackSize(1).setTextureName("customnpcs:npcMithrilHead");
|
||||
armor = new ItemNpcArmor(26899,armorMithril,1,"mithril").setUnlocalizedName("npcMithrilChest").setMaxStackSize(1).setTextureName("customnpcs:npcMithrilChest");
|
||||
armor = new ItemNpcArmor(26900,armorMithril,2,"mithril").setUnlocalizedName("npcMithrilLegs").setMaxStackSize(1).setTextureName("customnpcs:npcMithrilLegs");
|
||||
armor = new ItemNpcArmor(26901,armorMithril,3,"mithril").setUnlocalizedName("npcMithrilBoots").setMaxStackSize(1).setTextureName("customnpcs:npcMithrilBoots");
|
||||
|
||||
armor = new ItemNpcArmor(26898,ArmorMaterial.DIAMOND,0,"demonic").setUnlocalizedName("npcDemonicHead").setMaxStackSize(1).setTextureName("customnpcs:npcDemonicHead");
|
||||
armor = new ItemNpcArmor(26899,ArmorMaterial.DIAMOND,1,"demonic").setUnlocalizedName("npcDemonicChest").setMaxStackSize(1).setTextureName("customnpcs:npcDemonicChest");
|
||||
armor = new ItemNpcArmor(26900,ArmorMaterial.DIAMOND,2,"demonic").setUnlocalizedName("npcDemonicLegs").setMaxStackSize(1).setTextureName("customnpcs:npcDemonicLegs");
|
||||
armor = new ItemNpcArmor(26901,ArmorMaterial.DIAMOND,3,"demonic").setUnlocalizedName("npcDemonicBoots").setMaxStackSize(1).setTextureName("customnpcs:npcDemonicBoots");
|
||||
|
||||
armor = new ItemNpcArmor(26902,ArmorMaterial.GOLD,0,"commissar").setUnlocalizedName("npcCommissarHead").setMaxStackSize(1).setTextureName("customnpcs:npcCommissarHead");
|
||||
armor = new ItemNpcArmor(26903,ArmorMaterial.GOLD,1,"commissar").setUnlocalizedName("npcCommissarChest").setMaxStackSize(1).setTextureName("customnpcs:npcCommissarChest");
|
||||
armor = new ItemNpcArmor(26904,ArmorMaterial.GOLD,2,"commissar").setUnlocalizedName("npcCommissarLegs").setMaxStackSize(1).setTextureName("customnpcs:npcCommissarLegs");
|
||||
armor = new ItemNpcArmor(26905,ArmorMaterial.GOLD,3,"commissar").setUnlocalizedName("npcCommissarBottom").setMaxStackSize(1).setTextureName("customnpcs:npcCommissarBottom");
|
||||
|
||||
armor = new ItemNpcArmor(26906,ArmorMaterial.IRON,0,"infantry").setUnlocalizedName("npcInfantryHelmet").setMaxStackSize(1).setTextureName("customnpcs:npcInfantryHelmet");
|
||||
armor = new ItemNpcArmor(26907,ArmorMaterial.DIAMOND,1,"officer").setUnlocalizedName("npcOfficerChest").setMaxStackSize(1).setTextureName("customnpcs:npcOfficerChest");
|
||||
|
||||
armor = new ItemNpcArmor(26908,ArmorMaterial.DIAMOND,0,"crown1").setUnlocalizedName("npcCrown2").setMaxStackSize(1).setTextureName("customnpcs:npcCrown2");
|
||||
armor = new ItemNpcArmor(26909,ArmorMaterial.DIAMOND,0,"crown2").setUnlocalizedName("npcCrown").setMaxStackSize(1).setTextureName("customnpcs:npcCrown");
|
||||
armor = new ItemNpcArmorColorable(26909,ArmorMaterial.CLOTH,0,"papercrown").setUnlocalizedName("npcPaperCrown").setMaxStackSize(1).setTextureName("customnpcs:npcPaperCrown");
|
||||
|
||||
armor = new ItemNpcArmor(26916,ArmorMaterial.IRON,0,"ninja").setUnlocalizedName("npcNinjaHead").setMaxStackSize(1).setTextureName("customnpcs:npcNinjaHead");
|
||||
armor = new ItemNpcArmor(26917,ArmorMaterial.IRON,1,"ninja").setUnlocalizedName("npcNinjaChest").setMaxStackSize(1).setTextureName("customnpcs:npcNinjaChest");
|
||||
armor = new ItemNpcArmor(26918,ArmorMaterial.IRON,2,"ninja").setUnlocalizedName("npcNinjaPants").setMaxStackSize(1).setTextureName("customnpcs:npcNinjaPants");
|
||||
|
||||
armor = new ItemSkirt(ArmorMaterial.CHAIN,"textures/models/armor/chainmail_layer_2.png").setUnlocalizedName("npcChainSkirt").setTextureName("customnpcs:npcChainSkirt");
|
||||
armor = new ItemSkirt(ArmorMaterial.CLOTH,"textures/models/armor/leather_layer_2.png").setUnlocalizedName("npcLeatherSkirt").setTextureName("customnpcs:npcLeatherSkirt");
|
||||
armor = new ItemSkirt(ArmorMaterial.GOLD,"textures/models/armor/gold_layer_2.png").setUnlocalizedName("npcGoldSkirt").setTextureName("customnpcs:npcGoldSkirt");
|
||||
armor = new ItemSkirt(ArmorMaterial.IRON,"textures/models/armor/iron_layer_2.png").setUnlocalizedName("npcIronSkirt").setTextureName("customnpcs:npcIronSkirt");
|
||||
armor = new ItemSkirt(ArmorMaterial.DIAMOND,"textures/models/armor/diamond_layer_2.png").setUnlocalizedName("npcDiamondSkirt").setTextureName("customnpcs:npcDiamondSkirt");
|
||||
armor = new ItemSkirt(armorEmerald,"customnpcs:textures/armor/fullemerald_2.png").setUnlocalizedName("npcEmeraldSkirt").setTextureName("customnpcs:npcEmeraldSkirt");
|
||||
armor = new ItemSkirt(armorBronze,"customnpcs:textures/armor/fullbronze_2.png").setUnlocalizedName("npcBronzeSkirt").setTextureName("customnpcs:npcBronzeSkirt");
|
||||
armor = new ItemSkirt(ArmorMaterial.DIAMOND,"customnpcs:textures/armor/demonic_2.png").setUnlocalizedName("npcDemonicSkirt").setTextureName("customnpcs:npcDemonicSkirt");
|
||||
armor = new ItemSkirt(armorMithril,"customnpcs:textures/armor/mithril_2.png").setUnlocalizedName("npcMithrilSkirt").setTextureName("customnpcs:npcMithrilSkirt");
|
||||
|
||||
|
||||
coinWood = new ItemNpcInterface(26717).setUnlocalizedName("npcCoinWooden").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinWooden");
|
||||
coinStone = new ItemNpcInterface(26718).setUnlocalizedName("npcCoinStone").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinStone");
|
||||
coinBronze = new ItemNpcInterface(26719).setUnlocalizedName("npcCoinBronze").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinBronze");
|
||||
coinIron = new ItemNpcInterface(26720).setUnlocalizedName("npcCoinIron").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinIron");
|
||||
coinGold = new ItemNpcInterface(26721).setUnlocalizedName("npcCoinGold").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinGold");
|
||||
coinDiamond = new ItemNpcInterface(26722).setUnlocalizedName("npcCoinDiamond").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinDiamond");
|
||||
coinEmerald = new ItemNpcInterface(26723).setUnlocalizedName("npcCoinEmerald").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCoinEmerald");
|
||||
Item quest = new ItemNpcInterface().setUnlocalizedName("npcAncientCoin").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAncientCoin");
|
||||
|
||||
letter = new ItemNpcInterface(26950).setUnlocalizedName("npcLetter").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcLetter");
|
||||
quest = new ItemNpcInterface(26951).setUnlocalizedName("npcPlans").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcPlans");
|
||||
satchel = new ItemNpcInterface(26952).setUnlocalizedName("npcSatchel").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSatchel");
|
||||
bag = new ItemNpcInterface(26953).setUnlocalizedName("npcBag").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBag");
|
||||
|
||||
quest = new ItemNpcInterface(26954).setUnlocalizedName("npcCrystal").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCrystal");
|
||||
quest = new ItemNpcInterface(26955).setUnlocalizedName("npcSeveredEar").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSeveredEar");
|
||||
quest = new ItemNpcInterface(26956).setUnlocalizedName("npcPhone").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcPhone");
|
||||
|
||||
quest = new ItemNpcArmor(26957,ArmorMaterial.IRON,0,"mask").setMaxStackSize(64).setUnlocalizedName("npcBanditMask").setCreativeTab(CustomItems.tabArmor).setTextureName("customnpcs:npcBanditMask");
|
||||
quest = new ItemNpcInterface(26958).setUnlocalizedName("npcBrokenArrow").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBrokenArrow");
|
||||
quest = new ItemNpcInterface(26959).setUnlocalizedName("npcEarthElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcEarthElement");
|
||||
quest = new ItemNpcInterface(26960).setUnlocalizedName("npcWaterElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcWaterElement");
|
||||
quest = new ItemNpcInterface(26961).setUnlocalizedName("npcFireElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcFireElement");
|
||||
quest = new ItemNpcInterface(26962).setUnlocalizedName("npcAirElement").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAirElement");
|
||||
|
||||
quest = new ItemNpcInterface(26963).setUnlocalizedName("npcCarKey").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcCarKey");
|
||||
quest = new ItemNpcInterface(26964).setUnlocalizedName("npcKey").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcKey");
|
||||
quest = new ItemNpcInterface(26965).setUnlocalizedName("npcKey2").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcKey2");
|
||||
quest = new ItemNpcInterface(26966).setUnlocalizedName("npcPendant").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcPendant");
|
||||
quest = new ItemNpcInterface(26967).setUnlocalizedName("npcBlueprint").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBlueprint");
|
||||
quest = new ItemNpcInterface(26968).setUnlocalizedName("npcRing").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcRing");
|
||||
quest = new ItemNpcInterface(26969).setUnlocalizedName("npcSkull").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSkull");
|
||||
|
||||
Item sapphire = new ItemNpcInterface(26970).setUnlocalizedName("npcSaphire").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSaphire");
|
||||
Item ruby = new ItemNpcInterface(26971).setUnlocalizedName("npcRuby").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcRuby");
|
||||
Item amethyst = new ItemNpcInterface(26972).setUnlocalizedName("npcAmethyst").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAmethyst");
|
||||
|
||||
OreDictionary.registerOre("gemSaphire", sapphire);
|
||||
OreDictionary.registerOre("gemRuby", ruby);
|
||||
OreDictionary.registerOre("gemAmethyst", amethyst);
|
||||
|
||||
bronze_ingot = new ItemNpcInterface(26973).setUnlocalizedName("npcBronzeIngot").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcBronzeIngot");
|
||||
demonic_ingot = new ItemNpcInterface(26973).setUnlocalizedName("npcDemonicIngot").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcDemonicIngot");
|
||||
mithril_ingot = new ItemNpcInterface(26973).setUnlocalizedName("npcMithrilIngot").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcMithrilIngot");
|
||||
|
||||
armorMithril.customCraftingMaterial = mithril_ingot;
|
||||
|
||||
bronze.customCraftingMaterial = bronze_ingot;
|
||||
emerald.customCraftingMaterial = Items.emerald;
|
||||
demonic.customCraftingMaterial = demonic_ingot;
|
||||
frost.customCraftingMaterial = Item.getItemFromBlock(Blocks.ice);
|
||||
mithril.customCraftingMaterial = mithril_ingot;
|
||||
|
||||
OreDictionary.registerOre("ingotBronze", bronze_ingot);
|
||||
OreDictionary.registerOre("ingotDemonic", demonic_ingot);
|
||||
OreDictionary.registerOre("ingotMithril", mithril_ingot);
|
||||
|
||||
quest = new ItemNpcInterface().setUnlocalizedName("npcAncientScroll").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcAncientScroll");
|
||||
quest = new ItemNpcInterface().setUnlocalizedName("npcArtifact").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcArtifact");
|
||||
quest = new ItemNpcInterface().setUnlocalizedName("npcLocket").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcLocket");
|
||||
quest = new ItemNpcInterface().setUnlocalizedName("npcSilk").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcSilk");
|
||||
quest = new ItemNpcInterface().setUnlocalizedName("npcStatuette").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcStatuette");
|
||||
quest = new ItemNpcInterface().setUnlocalizedName("npcTablet").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcTablet");
|
||||
|
||||
quest = new ItemNpcInterface().setUnlocalizedName("npcHeart").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcHeart");
|
||||
quest = new ItemNpcInterface().setUnlocalizedName("npcMoney").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcMoney");
|
||||
quest = new ItemNpcInterface().setUnlocalizedName("npcNecklace").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcNecklace");
|
||||
quest = new ItemNpcInterface().setUnlocalizedName("npcUsbStick").setCreativeTab(CustomItems.tabMisc).setTextureName("customnpcs:npcUsbStick");
|
||||
|
||||
tabArmor.item = cowarmor;
|
||||
tabWeapon.item = CustomItems.shuriken;
|
||||
tabMisc.item = CustomItems.coinGold;
|
||||
tabBlocks.item = Item.getItemFromBlock(couchWool);
|
||||
tabBlocks.meta = 1;
|
||||
}
|
||||
|
||||
tab.item = wand;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartedEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
|
||||
import cpw.mods.fml.common.network.FMLEventChannel;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import foxz.command.CommandNoppes;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockIce;
|
||||
import net.minecraft.block.BlockLeavesBase;
|
||||
import net.minecraft.block.BlockVine;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import noppes.npcs.config.ConfigLoader;
|
||||
import noppes.npcs.config.ConfigProp;
|
||||
import noppes.npcs.controllers.BankController;
|
||||
import noppes.npcs.controllers.ChunkController;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.FactionController;
|
||||
import noppes.npcs.controllers.GlobalDataController;
|
||||
import noppes.npcs.controllers.LinkedNpcController;
|
||||
import noppes.npcs.controllers.PixelmonHelper;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.RecipeController;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.controllers.SpawnController;
|
||||
import noppes.npcs.controllers.TransportController;
|
||||
import noppes.npcs.enchants.EnchantInterface;
|
||||
import noppes.npcs.entity.EntityChairMount;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityMagicProjectile;
|
||||
import noppes.npcs.entity.EntityNPCGolem;
|
||||
import noppes.npcs.entity.EntityNpcCrystal;
|
||||
import noppes.npcs.entity.EntityNpcDragon;
|
||||
import noppes.npcs.entity.EntityNpcPony;
|
||||
import noppes.npcs.entity.EntityNpcSlime;
|
||||
import noppes.npcs.entity.EntityProjectile;
|
||||
import noppes.npcs.entity.old.EntityNPCDwarfFemale;
|
||||
import noppes.npcs.entity.old.EntityNPCDwarfMale;
|
||||
import noppes.npcs.entity.old.EntityNPCElfFemale;
|
||||
import noppes.npcs.entity.old.EntityNPCElfMale;
|
||||
import noppes.npcs.entity.old.EntityNPCEnderman;
|
||||
import noppes.npcs.entity.old.EntityNPCFurryFemale;
|
||||
import noppes.npcs.entity.old.EntityNPCFurryMale;
|
||||
import noppes.npcs.entity.old.EntityNPCHumanFemale;
|
||||
import noppes.npcs.entity.old.EntityNPCHumanMale;
|
||||
import noppes.npcs.entity.old.EntityNPCOrcFemale;
|
||||
import noppes.npcs.entity.old.EntityNPCOrcMale;
|
||||
import noppes.npcs.entity.old.EntityNPCVillager;
|
||||
import noppes.npcs.entity.old.EntityNpcEnderchibi;
|
||||
import noppes.npcs.entity.old.EntityNpcMonsterFemale;
|
||||
import noppes.npcs.entity.old.EntityNpcMonsterMale;
|
||||
import noppes.npcs.entity.old.EntityNpcNagaFemale;
|
||||
import noppes.npcs.entity.old.EntityNpcNagaMale;
|
||||
import noppes.npcs.entity.old.EntityNpcSkeleton;
|
||||
|
||||
@Mod(modid = "customnpcs", name = "CustomNpcs", version = "1.7.10d")
|
||||
public class CustomNpcs {
|
||||
|
||||
@ConfigProp(info = "Disable Chat Bubbles")
|
||||
public static boolean EnableChatBubbles = true;
|
||||
|
||||
private static int NewEntityStartId = 0;
|
||||
|
||||
@ConfigProp(info = "Navigation search range for NPCs. Not recommended to increase if you have a slow pc or on a server")
|
||||
public static int NpcNavRange = 32;
|
||||
|
||||
@ConfigProp(info = "Set to true if you want the dialog command option to be able to use op commands like tp etc")
|
||||
public static boolean NpcUseOpCommands = false;
|
||||
|
||||
@ConfigProp
|
||||
public static boolean InventoryGuiEnabled = true;
|
||||
|
||||
@ConfigProp
|
||||
public static boolean DisableExtraItems = false;
|
||||
@ConfigProp
|
||||
public static boolean DisableExtraBlock = false;
|
||||
|
||||
public static long ticks;
|
||||
|
||||
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@ConfigProp(info = "Enables CustomNpcs startup update message")
|
||||
public static boolean EnableUpdateChecker = true;
|
||||
|
||||
public static CustomNpcs instance;
|
||||
|
||||
public static boolean FreezeNPCs = false;
|
||||
|
||||
@ConfigProp(info = "Only ops can create and edit npcs")
|
||||
public static boolean OpsOnly = false;
|
||||
|
||||
@ConfigProp(info = "Default interact line. Leave empty to not have one")
|
||||
public static String DefaultInteractLine = "Hello @p";
|
||||
|
||||
@ConfigProp
|
||||
public static boolean DisableEnchants = false;
|
||||
@ConfigProp(info = "Start Id for enchants. IDs can only range from 0-256")
|
||||
public static int EnchantStartId = 100;
|
||||
|
||||
@ConfigProp(info = "Number of chunk loading npcs that can be active at the same time")
|
||||
public static int ChuckLoaders = 20;
|
||||
|
||||
public static File Dir;
|
||||
|
||||
@ConfigProp(info = "Set to false if you want to disable guns")
|
||||
public static boolean GunsEnabled = true;
|
||||
|
||||
@ConfigProp(info = "Enables leaves decay")
|
||||
public static boolean LeavesDecayEnabled = true;
|
||||
|
||||
@ConfigProp(info = "Enables Vine Growth")
|
||||
public static boolean VineGrowthEnabled = true;
|
||||
|
||||
@ConfigProp(info = "Enables Ice Melting")
|
||||
public static boolean IceMeltsEnabled = true;
|
||||
|
||||
@ConfigProp(info = "Normal players can use soulstone on animals")
|
||||
public static boolean SoulStoneAnimals = true;
|
||||
|
||||
@ConfigProp(info = "Normal players can use soulstone on all npcs")
|
||||
public static boolean SoulStoneNPCs = false;
|
||||
|
||||
@ConfigProp(info="When set to Minecraft it will use minecrafts font, when Default it will use OpenSans. Can only use fonts installed on your PC")
|
||||
public static String FontType = "Default";
|
||||
|
||||
@ConfigProp(info="Font size for custom fonts (doesn't work with minecrafts font)")
|
||||
public static int FontSize = 18;
|
||||
|
||||
public static FMLEventChannel Channel;
|
||||
public static FMLEventChannel ChannelPlayer;
|
||||
|
||||
public static ConfigLoader Config;
|
||||
|
||||
public CustomNpcs() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void load(FMLPreInitializationEvent ev) {
|
||||
Channel = NetworkRegistry.INSTANCE.newEventDrivenChannel("CustomNPCs");
|
||||
ChannelPlayer = NetworkRegistry.INSTANCE.newEventDrivenChannel("CustomNPCsPlayer");
|
||||
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
String dir = "";
|
||||
if (server != null) {
|
||||
dir = new File(".").getAbsolutePath();
|
||||
} else {
|
||||
dir = Minecraft.getMinecraft().mcDataDir.getAbsolutePath();
|
||||
}
|
||||
Dir = new File(dir, "customnpcs");
|
||||
Dir.mkdir();
|
||||
|
||||
Config = new ConfigLoader(this.getClass(), new File(dir, "config"), "CustomNpcs");
|
||||
Config.loadConfig();
|
||||
|
||||
if (NpcNavRange < 16) {
|
||||
NpcNavRange = 16;
|
||||
}
|
||||
EnchantInterface.load();
|
||||
CustomItems.load();
|
||||
|
||||
proxy.load();
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(this, proxy);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new ServerEventsHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new ScriptController());
|
||||
|
||||
FMLCommonHandler.instance().bus().register(new ServerTickHandler());
|
||||
|
||||
registerNpc(EntityNPCHumanMale.class, "npchumanmale");
|
||||
registerNpc(EntityNPCVillager.class, "npcvillager");
|
||||
registerNpc(EntityNpcPony.class, "npcpony");
|
||||
registerNpc(EntityNPCHumanFemale.class, "npchumanfemale");
|
||||
registerNpc(EntityNPCDwarfMale.class, "npcdwarfmale");
|
||||
registerNpc(EntityNPCFurryMale.class, "npcfurrymale");
|
||||
registerNpc(EntityNpcMonsterMale.class, "npczombiemale");
|
||||
registerNpc(EntityNpcMonsterFemale.class, "npczombiefemale");
|
||||
registerNpc(EntityNpcSkeleton.class, "npcskeleton");
|
||||
registerNpc(EntityNPCDwarfFemale.class, "npcdwarffemale");
|
||||
registerNpc(EntityNPCFurryFemale.class, "npcfurryfemale");
|
||||
registerNpc(EntityNPCOrcMale.class, "npcorcfmale");
|
||||
registerNpc(EntityNPCOrcFemale.class, "npcorcfemale");
|
||||
registerNpc(EntityNPCElfMale.class, "npcelfmale");
|
||||
registerNpc(EntityNPCElfFemale.class, "npcelffemale");
|
||||
registerNpc(EntityNpcCrystal.class, "npccrystal");
|
||||
registerNpc(EntityNpcEnderchibi.class, "npcenderchibi");
|
||||
registerNpc(EntityNpcNagaMale.class, "npcnagamale");
|
||||
registerNpc(EntityNpcNagaFemale.class, "npcnagafemale");
|
||||
registerNpc(EntityNpcSlime.class, "NpcSlime");
|
||||
registerNpc(EntityNpcDragon.class, "NpcDragon");
|
||||
registerNpc(EntityNPCEnderman.class, "npcEnderman");
|
||||
registerNpc(EntityNPCGolem.class, "npcGolem");
|
||||
registerNpc(EntityCustomNpc.class, "CustomNpc");
|
||||
|
||||
registerNewEntity(EntityChairMount.class, "CustomNpcChairMount", 64, 10, false);
|
||||
registerNewEntity(EntityProjectile.class, "throwableitem", 64, 3, true);
|
||||
registerNewEntity(EntityMagicProjectile.class, "magicprojectile", 64, 3, true);
|
||||
|
||||
new RecipeController();
|
||||
|
||||
ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkController());
|
||||
|
||||
new CustomNpcsPermissions();
|
||||
|
||||
PixelmonHelper.load();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void setAboutToStart(FMLServerAboutToStartEvent event) {
|
||||
ChunkController.instance.clear();
|
||||
new QuestController();
|
||||
new PlayerDataController();
|
||||
new FactionController();
|
||||
new TransportController();
|
||||
new GlobalDataController();
|
||||
new SpawnController();
|
||||
new LinkedNpcController();
|
||||
ScriptController.Instance.loadStoredData();
|
||||
ScriptController.HasStart = false;
|
||||
|
||||
Set<String> names = Block.blockRegistry.getKeys();
|
||||
for(String name : names){
|
||||
Block block = (Block) Block.blockRegistry.getObject(name);
|
||||
if(block instanceof BlockLeavesBase){
|
||||
block.setTickRandomly(LeavesDecayEnabled);
|
||||
}
|
||||
if(block instanceof BlockVine){
|
||||
block.setTickRandomly(VineGrowthEnabled);
|
||||
}
|
||||
if(block instanceof BlockIce){
|
||||
block.setTickRandomly(IceMeltsEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Loading items in the about to start event was corrupting items with a damage value
|
||||
@EventHandler
|
||||
public void started(FMLServerStartedEvent event) {
|
||||
RecipeController.instance.load();
|
||||
new DialogController();
|
||||
new BankController();
|
||||
QuestController.instance.load();
|
||||
ScriptController.HasStart = true;
|
||||
ServerCloneController.Instance = new ServerCloneController();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void stopped(FMLServerStoppedEvent event){
|
||||
ServerCloneController.Instance = null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverstart(FMLServerStartingEvent event) {
|
||||
event.registerServerCommand(new CommandNoppes());
|
||||
}
|
||||
|
||||
private void registerNpc(Class<? extends Entity> cl, String name) {
|
||||
EntityRegistry.registerModEntity(cl, name, NewEntityStartId++, this, 64, 3, true);
|
||||
EntityList.stringToClassMapping.put(name, cl);
|
||||
}
|
||||
|
||||
private void registerNewEntity(Class<? extends Entity> cl, String name, int range, int update, boolean velocity) {
|
||||
EntityRegistry.registerModEntity(cl, name, NewEntityStartId++, this, range, update, velocity);
|
||||
}
|
||||
|
||||
|
||||
public static File getWorldSaveDirectory() {
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
File saves = new File(".");
|
||||
if (server != null && !server.isDedicatedServer()) {
|
||||
saves = new File(Minecraft.getMinecraft().mcDataDir, "saves");
|
||||
}
|
||||
if (server != null) {
|
||||
File savedir = new File(new File(saves, server.getFolderName()), "customnpcs");
|
||||
if (!savedir.exists()) {
|
||||
savedir.mkdir();
|
||||
}
|
||||
return savedir;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import noppes.npcs.CustomNpcsPermissions.Permission;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
|
||||
public class CustomNpcsPermissions{
|
||||
public static final Permission NPC_DELETE = new Permission("customnpcs.npc.delete");
|
||||
public static final Permission NPC_CREATE = new Permission("customnpcs.npc.create");
|
||||
public static final Permission NPC_GUI = new Permission("customnpcs.npc.gui");
|
||||
public static final Permission NPC_FREEZE = new Permission("customnpcs.npc.freeze");
|
||||
public static final Permission NPC_RESET = new Permission("customnpcs.npc.reset");
|
||||
public static final Permission NPC_AI = new Permission("customnpcs.npc.ai");
|
||||
public static final Permission NPC_ADVANCED = new Permission("customnpcs.npc.advanced");
|
||||
public static final Permission NPC_DISPLAY = new Permission("customnpcs.npc.display");
|
||||
public static final Permission NPC_INVENTORY = new Permission("customnpcs.npc.inventory");
|
||||
public static final Permission NPC_STATS = new Permission("customnpcs.npc.stats");
|
||||
public static final Permission NPC_CLONE = new Permission("customnpcs.npc.clone");
|
||||
|
||||
public static final Permission GLOBAL_LINKED = new Permission("customnpcs.global.linked");
|
||||
public static final Permission GLOBAL_PLAYERDATA = new Permission("customnpcs.global.playerdata");
|
||||
public static final Permission GLOBAL_BANK = new Permission("customnpcs.global.bank");
|
||||
public static final Permission GLOBAL_DIALOG = new Permission("customnpcs.global.dialog");
|
||||
public static final Permission GLOBAL_QUEST = new Permission("customnpcs.global.quest");
|
||||
public static final Permission GLOBAL_FACTION = new Permission("customnpcs.global.faction");
|
||||
public static final Permission GLOBAL_TRANSPORT = new Permission("customnpcs.global.transport");
|
||||
public static final Permission GLOBAL_RECIPE = new Permission("customnpcs.global.recipe");
|
||||
public static final Permission GLOBAL_NATURALSPAWN = new Permission("customnpcs.global.naturalspawn");
|
||||
|
||||
public static final Permission SPAWNER_MOB = new Permission("customnpcs.spawner.mob");
|
||||
public static final Permission SPAWNER_CREATE = new Permission("customnpcs.spawner.create");
|
||||
|
||||
public static final Permission TOOL_MOUNTER = new Permission("customnpcs.tool.mounter");
|
||||
public static final Permission TOOL_PATHER = new Permission("customnpcs.tool.pather");
|
||||
public static final Permission TOOL_SCRIPTER = new Permission("customnpcs.tool.scripter");
|
||||
|
||||
public static final Permission EDIT_VILLAGER = new Permission("customnpcs.edit.villager");
|
||||
public static final Permission EDIT_BLOCKS = new Permission("customnpcs.edit.blocks");
|
||||
|
||||
public static final Permission SOULSTONE_ALL = new Permission("customnpcs.soulstone.all");
|
||||
|
||||
public static CustomNpcsPermissions Instance;
|
||||
private Class<?> bukkit;
|
||||
private Method getPlayer;
|
||||
private Method hasPermission;
|
||||
|
||||
public CustomNpcsPermissions(){
|
||||
Instance = this;
|
||||
try {
|
||||
bukkit = Class.forName("org.bukkit.Bukkit");
|
||||
getPlayer = bukkit.getMethod("getPlayer", String.class);
|
||||
hasPermission = Class.forName("org.bukkit.entity.Player").getMethod("hasPermission", String.class);
|
||||
LogManager.getLogger(CustomNpcs.class).info("Bukkit permissions enabled");
|
||||
LogManager.getLogger(CustomNpcs.class).info("Permissions available:");
|
||||
Collections.sort(Permission.permissions, String.CASE_INSENSITIVE_ORDER);
|
||||
for(String p : Permission.permissions){
|
||||
LogManager.getLogger(CustomNpcs.class).info(p);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
// bukkit/mcpc+ is not loaded
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasPermission(EntityPlayer player, Permission permission){
|
||||
if(Instance.bukkit != null){
|
||||
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean bukkitPermission(String username, String permission) {
|
||||
try {
|
||||
Object player = getPlayer.invoke(null, username);
|
||||
return (Boolean) hasPermission.invoke(player, permission);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static class Permission{
|
||||
private static final List<String> permissions = new ArrayList<String>();
|
||||
public String name;
|
||||
public Permission(String name){
|
||||
this.name = name;
|
||||
if(!permissions.contains(name))
|
||||
permissions.add(name);
|
||||
}
|
||||
}
|
||||
public static boolean hasPermissionString(EntityPlayerMP player, String permission) {
|
||||
if(Instance.bukkit != null){
|
||||
return Instance.bukkitPermission(player.getCommandSenderName(), permission);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean enabled() {
|
||||
return Instance.bukkit != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.Teleporter;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
public class CustomTeleporter extends Teleporter{
|
||||
|
||||
public CustomTeleporter(WorldServer par1WorldServer) {
|
||||
super(par1WorldServer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import noppes.npcs.constants.EnumAnimation;
|
||||
import noppes.npcs.constants.EnumMovingType;
|
||||
import noppes.npcs.constants.EnumNavType;
|
||||
import noppes.npcs.constants.EnumStandingType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class DataAI {
|
||||
private EntityNPCInterface npc;
|
||||
|
||||
public int onAttack = 0; //0:fight 1:panic 2:retreat 3:nothing
|
||||
public int doorInteract = 2;
|
||||
public int findShelter = 2;
|
||||
public int distanceToMelee = 4;
|
||||
public int canFireIndirect = 0;
|
||||
public boolean canSwim = true;
|
||||
public boolean reactsToFire = false;
|
||||
public boolean avoidsWater = false;
|
||||
public boolean avoidsSun = false;
|
||||
public boolean returnToStart = true;
|
||||
public boolean directLOS = true;
|
||||
public boolean canLeap = false;
|
||||
public boolean canSprint = false;
|
||||
public boolean stopAndInteract = true;
|
||||
public EnumNavType tacticalVariant = EnumNavType.Default;
|
||||
public int useRangeMelee = 0;
|
||||
public int tacticalRadius = 8;
|
||||
|
||||
public EnumAnimation animationType = EnumAnimation.NONE;
|
||||
public EnumStandingType standingType = EnumStandingType.RotateBody;
|
||||
public EnumMovingType movingType = EnumMovingType.Standing;
|
||||
public boolean npcInteracting = true;
|
||||
|
||||
public int orientation = 0;
|
||||
public float bodyOffsetX = 5, bodyOffsetY = 5, bodyOffsetZ = 5;
|
||||
public int walkingRange = 10;
|
||||
private int moveSpeed = 5;
|
||||
|
||||
private List<int[]> movingPath = new ArrayList<int[]>();
|
||||
public int[] startPos;
|
||||
public int movingPos = 0;
|
||||
public int movingPattern = 0; // 0:Looping 1:Backtracking
|
||||
|
||||
public boolean movingPause = true;
|
||||
|
||||
public boolean ignoreCobweb = false;
|
||||
|
||||
public DataAI(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
public void readToNBT(NBTTagCompound compound) {
|
||||
canSwim = compound.getBoolean("CanSwim");
|
||||
reactsToFire = compound.getBoolean("ReactsToFire");
|
||||
avoidsWater = compound.getBoolean("AvoidsWater");
|
||||
avoidsSun = compound.getBoolean("AvoidsSun");
|
||||
returnToStart = compound.getBoolean("ReturnToStart");
|
||||
onAttack = compound.getInteger("OnAttack");
|
||||
doorInteract = compound.getInteger("DoorInteract");
|
||||
findShelter = compound.getInteger("FindShelter");
|
||||
directLOS = compound.getBoolean("DirectLOS");
|
||||
canLeap = compound.getBoolean("CanLeap");
|
||||
canSprint = compound.getBoolean("CanSprint");
|
||||
canFireIndirect = compound.getInteger("FireIndirect");
|
||||
useRangeMelee = compound.getInteger("RangeAndMelee");
|
||||
distanceToMelee = compound.getInteger("DistanceToMelee");
|
||||
tacticalRadius = compound.getInteger("TacticalRadius");
|
||||
movingPause = compound.getBoolean("MovingPause");
|
||||
ignoreCobweb = compound.getBoolean("IgnoreCobweb");
|
||||
npcInteracting = compound.getBoolean("npcInteracting");
|
||||
stopAndInteract = compound.getBoolean("stopAndInteract");
|
||||
|
||||
|
||||
animationType = EnumAnimation.values()[compound.getInteger("MoveState") % EnumAnimation.values().length];
|
||||
standingType = EnumStandingType.values()[compound.getInteger("StandingState") % EnumStandingType.values().length];
|
||||
movingType = EnumMovingType.values()[compound.getInteger("MovingState") % EnumMovingType.values().length];
|
||||
tacticalVariant = EnumNavType.values()[compound.getInteger("TacticalVariant") % EnumNavType.values().length];
|
||||
|
||||
orientation = compound.getInteger("Orientation");
|
||||
bodyOffsetY = compound.getFloat("PositionOffsetY");
|
||||
bodyOffsetZ = compound.getFloat("PositionOffsetZ");
|
||||
bodyOffsetX = compound.getFloat("PositionOffsetX");
|
||||
walkingRange = compound.getInteger("WalkingRange");
|
||||
setWalkingSpeed(compound.getInteger("MoveSpeed"));
|
||||
|
||||
setMovingPath(NBTTags.getIntegerArraySet(compound.getTagList("MovingPathNew",10)));
|
||||
movingPos = compound.getInteger("MovingPos");
|
||||
movingPattern = compound.getInteger("MovingPatern");
|
||||
|
||||
startPos = compound.getIntArray("StartPosNew");
|
||||
if (startPos == null || startPos.length != 3){
|
||||
startPos = new int[] {
|
||||
MathHelper.floor_double(npc.posX),
|
||||
MathHelper.floor_double(npc.posY),
|
||||
MathHelper.floor_double(npc.posZ) };
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setBoolean("CanSwim", canSwim);
|
||||
compound.setBoolean("ReactsToFire", reactsToFire);
|
||||
compound.setBoolean("AvoidsWater", avoidsWater );
|
||||
compound.setBoolean("AvoidsSun", avoidsSun);
|
||||
compound.setBoolean("ReturnToStart", returnToStart);
|
||||
compound.setInteger("OnAttack", onAttack);
|
||||
compound.setInteger("DoorInteract", doorInteract);
|
||||
compound.setInteger("FindShelter", findShelter);
|
||||
compound.setBoolean("DirectLOS", directLOS);
|
||||
compound.setBoolean("CanLeap", canLeap);
|
||||
compound.setBoolean("CanSprint", canSprint);
|
||||
compound.setInteger("FireIndirect", canFireIndirect);
|
||||
compound.setInteger("RangeAndMelee", useRangeMelee);
|
||||
compound.setInteger("DistanceToMelee", distanceToMelee);
|
||||
compound.setInteger("TacticalRadius", tacticalRadius);
|
||||
compound.setBoolean("MovingPause", movingPause);
|
||||
compound.setBoolean("IgnoreCobweb", ignoreCobweb);
|
||||
compound.setBoolean("npcInteracting", npcInteracting);
|
||||
compound.setBoolean("stopAndInteract", stopAndInteract);
|
||||
|
||||
compound.setInteger("MoveState", animationType.ordinal());
|
||||
compound.setInteger("StandingState", standingType.ordinal());
|
||||
compound.setInteger("MovingState", movingType.ordinal());
|
||||
compound.setInteger("TacticalVariant", tacticalVariant.ordinal());
|
||||
|
||||
compound.setInteger("Orientation", orientation);
|
||||
compound.setFloat("PositionOffsetX", bodyOffsetX);
|
||||
compound.setFloat("PositionOffsetY", bodyOffsetY);
|
||||
compound.setFloat("PositionOffsetZ", bodyOffsetZ);
|
||||
compound.setInteger("WalkingRange", walkingRange);
|
||||
compound.setInteger("MoveSpeed", moveSpeed);
|
||||
|
||||
compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(movingPath));
|
||||
compound.setInteger("MovingPos", movingPos);
|
||||
compound.setInteger("MovingPatern", movingPattern);
|
||||
|
||||
npc.setAvoidWater(avoidsWater);
|
||||
|
||||
compound.setIntArray("StartPosNew", npc.getStartPos());
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public List<int[]> getMovingPath() {
|
||||
if(movingPath.isEmpty() && startPos != null)
|
||||
movingPath.add(startPos);
|
||||
return movingPath;
|
||||
}
|
||||
|
||||
public void setMovingPath(List<int[]> list) {
|
||||
movingPath = list;
|
||||
if(!movingPath.isEmpty())
|
||||
startPos = movingPath.get(0);
|
||||
}
|
||||
|
||||
public int[] getCurrentMovingPath(){
|
||||
List<int[]> list = getMovingPath();
|
||||
if(list.size() == 1){
|
||||
movingPos = 0;
|
||||
}
|
||||
else if(movingPos >= list.size()){
|
||||
if(movingPattern == 0)
|
||||
movingPos = 0;
|
||||
else{
|
||||
int size = list.size() * 2 - 2;
|
||||
if(movingPos >= size){
|
||||
movingPos = 0;
|
||||
}
|
||||
else if(movingPos >= list.size()){
|
||||
return list.get(list.size() - (movingPos % list.size()) - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return list.get(movingPos);
|
||||
}
|
||||
|
||||
public void incrementMovingPath(){
|
||||
List<int[]> list = getMovingPath();
|
||||
if(list.size() == 1){
|
||||
movingPos = 0;
|
||||
}
|
||||
else if(movingPattern == 0){
|
||||
movingPos++;
|
||||
movingPos = movingPos % list.size();
|
||||
}
|
||||
else if(movingPattern == 1){
|
||||
movingPos++;
|
||||
int size = list.size() * 2 - 2;
|
||||
movingPos = movingPos % size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void decreaseMovingPath() {
|
||||
List<int[]> list = getMovingPath();
|
||||
if(list.size() == 1){
|
||||
movingPos = 0;
|
||||
}
|
||||
else if(movingPattern == 0){
|
||||
movingPos--;
|
||||
if(movingPos < 0)
|
||||
movingPos += list.size();
|
||||
}
|
||||
else if(movingPattern == 1){
|
||||
movingPos--;
|
||||
if(movingPos < 0){
|
||||
int size = list.size() * 2 - 2;
|
||||
movingPos += size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getDistanceSqToPathPoint() {
|
||||
int[] pos = getCurrentMovingPath();
|
||||
return npc.getDistanceSq(pos[0] + 0.5, pos[1], pos[2] + 0.5);
|
||||
}
|
||||
|
||||
public void setWalkingSpeed(int speed){
|
||||
this.moveSpeed = speed;
|
||||
npc.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(npc.getSpeed());
|
||||
}
|
||||
|
||||
public int getWalkingSpeed(){
|
||||
return this.moveSpeed;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.constants.EnumJobType;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.controllers.DialogOption;
|
||||
import noppes.npcs.controllers.FactionOptions;
|
||||
import noppes.npcs.controllers.Line;
|
||||
import noppes.npcs.controllers.Lines;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobBard;
|
||||
import noppes.npcs.roles.JobChunkLoader;
|
||||
import noppes.npcs.roles.JobConversation;
|
||||
import noppes.npcs.roles.JobFollower;
|
||||
import noppes.npcs.roles.JobGuard;
|
||||
import noppes.npcs.roles.JobHealer;
|
||||
import noppes.npcs.roles.JobItemGiver;
|
||||
import noppes.npcs.roles.JobPuppet;
|
||||
import noppes.npcs.roles.JobSpawner;
|
||||
import noppes.npcs.roles.RoleBank;
|
||||
import noppes.npcs.roles.RoleCompanion;
|
||||
import noppes.npcs.roles.RoleFollower;
|
||||
import noppes.npcs.roles.RolePostman;
|
||||
import noppes.npcs.roles.RoleTrader;
|
||||
import noppes.npcs.roles.RoleTransporter;
|
||||
|
||||
public class DataAdvanced {
|
||||
|
||||
public Lines interactLines = new Lines();
|
||||
public Lines worldLines = new Lines();
|
||||
public Lines attackLines = new Lines();
|
||||
public Lines killedLines = new Lines();
|
||||
public Lines killLines = new Lines();
|
||||
|
||||
public boolean orderedLines = false;
|
||||
|
||||
public String idleSound = "";
|
||||
public String angrySound = "";
|
||||
public String hurtSound = "minecraft:game.player.hurt";
|
||||
public String deathSound = "minecraft:game.player.hurt";
|
||||
public String stepSound = "";
|
||||
|
||||
private EntityNPCInterface npc;
|
||||
public FactionOptions factions = new FactionOptions();
|
||||
|
||||
public EnumRoleType role = EnumRoleType.None;
|
||||
public EnumJobType job = EnumJobType.None;
|
||||
|
||||
public boolean attackOtherFactions = false;
|
||||
public boolean defendFaction = false;
|
||||
public boolean disablePitch = false;
|
||||
|
||||
public DataAdvanced(EntityNPCInterface npc) {
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setTag("NpcLines", worldLines.writeToNBT());
|
||||
compound.setTag("NpcKilledLines", killedLines.writeToNBT());
|
||||
compound.setTag("NpcInteractLines", interactLines.writeToNBT());
|
||||
compound.setTag("NpcAttackLines", attackLines.writeToNBT());
|
||||
compound.setTag("NpcKillLines", killLines.writeToNBT());
|
||||
|
||||
compound.setString("NpcIdleSound", idleSound);
|
||||
compound.setString("NpcAngrySound", angrySound);
|
||||
compound.setString("NpcHurtSound", hurtSound);
|
||||
compound.setString("NpcDeathSound", deathSound);
|
||||
compound.setString("NpcStepSound", stepSound);
|
||||
|
||||
compound.setBoolean("OrderedLines", orderedLines);
|
||||
|
||||
compound.setInteger("FactionID", npc.getFaction().id);
|
||||
compound.setBoolean("AttackOtherFactions", attackOtherFactions);
|
||||
compound.setBoolean("DefendFaction", defendFaction);
|
||||
compound.setBoolean("DisablePitch", disablePitch);
|
||||
|
||||
compound.setInteger("Role", role.ordinal());
|
||||
compound.setInteger("NpcJob", job.ordinal());
|
||||
compound.setTag("FactionPoints", factions.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
compound.setTag("NPCDialogOptions", nbtDialogs(npc.dialogs));
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void readToNBT(NBTTagCompound compound) {
|
||||
interactLines.readNBT(compound.getCompoundTag("NpcInteractLines"));
|
||||
worldLines.readNBT(compound.getCompoundTag("NpcLines"));
|
||||
attackLines.readNBT(compound.getCompoundTag("NpcAttackLines"));
|
||||
killedLines.readNBT(compound.getCompoundTag("NpcKilledLines"));
|
||||
killLines.readNBT(compound.getCompoundTag("NpcKillLines"));
|
||||
|
||||
idleSound = compound.getString("NpcIdleSound");
|
||||
angrySound = compound.getString("NpcAngrySound");
|
||||
hurtSound = compound.getString("NpcHurtSound");
|
||||
deathSound = compound.getString("NpcDeathSound");
|
||||
stepSound = compound.getString("NpcStepSound");
|
||||
|
||||
orderedLines = compound.getBoolean("OrderedLines");
|
||||
|
||||
npc.setFaction(compound.getInteger("FactionID"));
|
||||
npc.faction = npc.getFaction();
|
||||
attackOtherFactions = compound.getBoolean("AttackOtherFactions");
|
||||
defendFaction = compound.getBoolean("DefendFaction");
|
||||
disablePitch = compound.getBoolean("DisablePitch");
|
||||
|
||||
setRole(compound.getInteger("Role"));
|
||||
setJob(compound.getInteger("NpcJob"));
|
||||
|
||||
factions.readFromNBT(compound.getCompoundTag("FactionPoints"));
|
||||
|
||||
npc.dialogs = getDialogs(compound.getTagList("NPCDialogOptions", 10));
|
||||
}
|
||||
|
||||
private HashMap<Integer, DialogOption> getDialogs(NBTTagList tagList) {
|
||||
HashMap<Integer, DialogOption> map = new HashMap<Integer, DialogOption>();
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
int slot = nbttagcompound.getInteger("DialogSlot");
|
||||
DialogOption option = new DialogOption();
|
||||
option.readNBT(nbttagcompound.getCompoundTag("NPCDialog"));
|
||||
map.put(slot, option);
|
||||
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
private NBTTagList nbtDialogs(HashMap<Integer, DialogOption> dialogs2) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
for (int slot : dialogs2.keySet()) {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setInteger("DialogSlot", slot);
|
||||
nbttagcompound.setTag("NPCDialog", dialogs2.get(slot)
|
||||
.writeNBT());
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public Line getInteractLine() {
|
||||
return interactLines.getLine(!orderedLines);
|
||||
}
|
||||
|
||||
public Line getAttackLine() {
|
||||
return attackLines.getLine(!orderedLines);
|
||||
}
|
||||
|
||||
public Line getKilledLine() {
|
||||
return killedLines.getLine(!orderedLines);
|
||||
}
|
||||
|
||||
public Line getKillLine() {
|
||||
return killLines.getLine(!orderedLines);
|
||||
}
|
||||
|
||||
public Line getWorldLine() {
|
||||
return worldLines.getLine(!orderedLines);
|
||||
}
|
||||
|
||||
public void setRole(int i) {
|
||||
if (EnumRoleType.values().length <= i) {
|
||||
i -= 2;
|
||||
}
|
||||
role = EnumRoleType.values()[i];
|
||||
if(role == EnumRoleType.None)
|
||||
npc.roleInterface = null;
|
||||
else if(role == EnumRoleType.Bank && !(npc.roleInterface instanceof RoleBank))
|
||||
npc.roleInterface = new RoleBank(npc);
|
||||
else if(role == EnumRoleType.Follower && !(npc.roleInterface instanceof RoleFollower))
|
||||
npc.roleInterface = new RoleFollower(npc);
|
||||
else if(role == EnumRoleType.Postman && !(npc.roleInterface instanceof RolePostman))
|
||||
npc.roleInterface = new RolePostman(npc);
|
||||
else if(role == EnumRoleType.Trader && !(npc.roleInterface instanceof RoleTrader))
|
||||
npc.roleInterface = new RoleTrader(npc);
|
||||
else if(role == EnumRoleType.Transporter && !(npc.roleInterface instanceof RoleTransporter))
|
||||
npc.roleInterface = new RoleTransporter(npc);
|
||||
else if(role == EnumRoleType.Companion && !(npc.roleInterface instanceof RoleCompanion))
|
||||
npc.roleInterface = new RoleCompanion(npc);
|
||||
}
|
||||
|
||||
public void setJob(int i) {
|
||||
if(npc.jobInterface != null && !npc.worldObj.isRemote)
|
||||
npc.jobInterface.reset();
|
||||
|
||||
job = EnumJobType.values()[i % EnumJobType.values().length];
|
||||
if (job == EnumJobType.None)
|
||||
npc.jobInterface = null;
|
||||
else if (job == EnumJobType.Bard && !(npc.jobInterface instanceof JobBard))
|
||||
npc.jobInterface = new JobBard(npc);
|
||||
else if (job == EnumJobType.Healer && !(npc.jobInterface instanceof JobHealer))
|
||||
npc.jobInterface = new JobHealer(npc);
|
||||
else if (job == EnumJobType.Guard && !(npc.jobInterface instanceof JobGuard))
|
||||
npc.jobInterface = new JobGuard(npc);
|
||||
else if (job == EnumJobType.ItemGiver && !(npc.jobInterface instanceof JobItemGiver))
|
||||
npc.jobInterface = new JobItemGiver(npc);
|
||||
else if (job == EnumJobType.Follower && !(npc.jobInterface instanceof JobFollower))
|
||||
npc.jobInterface = new JobFollower(npc);
|
||||
else if (job == EnumJobType.Spawner && !(npc.jobInterface instanceof JobSpawner))
|
||||
npc.jobInterface = new JobSpawner(npc);
|
||||
else if (job == EnumJobType.Conversation && !(npc.jobInterface instanceof JobConversation))
|
||||
npc.jobInterface = new JobConversation(npc);
|
||||
else if (job == EnumJobType.ChunkLoader && !(npc.jobInterface instanceof JobChunkLoader))
|
||||
npc.jobInterface = new JobChunkLoader(npc);
|
||||
else if (job == EnumJobType.Puppet && !(npc.jobInterface instanceof JobPuppet))
|
||||
npc.jobInterface = new JobPuppet(npc);
|
||||
}
|
||||
|
||||
public boolean hasWorldLines() {
|
||||
return !worldLines.isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.StringUtils;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
public class DataDisplay {
|
||||
EntityNPCInterface npc;
|
||||
|
||||
public String name;
|
||||
public String title = "";
|
||||
|
||||
public byte skinType = 0; //0:normal, 1:player, 2:url
|
||||
public String url = "";
|
||||
public GameProfile playerProfile;
|
||||
public String texture = "customnpcs:textures/entity/humanmale/Steve.png";;
|
||||
public String cloakTexture = "";
|
||||
public String glowTexture = "";
|
||||
|
||||
public int visible = 0;//0:visible 1:Invisible 2:semi-invisible
|
||||
|
||||
public int modelSize = 5;
|
||||
|
||||
public int showName = 0;
|
||||
|
||||
public boolean disableLivingAnimation = false;
|
||||
|
||||
public byte showBossBar = 0;
|
||||
|
||||
public DataDisplay(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
String[] names = { "Noppes", "Noppes", "Noppes", "Noppes", "Atesson",
|
||||
"Rothcersul", "Achdranys", "Pegato", "Chald", "Gareld",
|
||||
"Nalworche", "Ineald", "Tia'kim", "Torerod", "Turturdar",
|
||||
"Ranler", "Dyntan", "Oldrake", "Gharis", "Elmn", "Tanal",
|
||||
"Waran-ess", "Ach-aldhat", "Athi", "Itageray", "Tasr",
|
||||
"Ightech", "Gakih", "Adkal", "Qua'an", "Sieq", "Urnp", "Rods",
|
||||
"Vorbani", "Smaik", "Fian", "Hir", "Ristai", "Kineth", "Naif",
|
||||
"Issraya", "Arisotura", "Honf", "Rilfom", "Estz", "Ghatroth",
|
||||
"Yosil", "Darage", "Aldny", "Tyltran", "Armos", "Loxiku",
|
||||
"Burhat", "Tinlt", "Ightyd", "Mia",
|
||||
"Ken", "Karla", "Lily", "Carina", "Daniel", "Slater", "Zidane", "Valentine", "Eirina",
|
||||
"Carnow", "Grave", "Shadow", "Drakken", "Kaoz", "Silk", "Drake", "Oldam", "Lynxx", "Lenyx",
|
||||
"Winter", "Seth", "Apolitho", "Amethyst", "Ankin", "Seinkan", "Ayumu", "Sakamoto", "Divina",
|
||||
"Div", "Magia", "Magnus", "Tiakono", "Ruin", "Hailinx", "Ethan", "Wate", "Carter", "William",
|
||||
"Brion", "Sparrow", "Basrrelen", "Gyaku", "Claire", "Crowfeather", "Blackwell", "Raven", "Farcri",
|
||||
"Lucas", "Bangheart", "Kamoku", "Kyoukan", "Blaze", "Benjamin", "Larianne", "Kakaragon",
|
||||
"Melancholy", "Epodyno", "Thanato", "Mika", "Dacks", "Ylander", "Neve", "Meadow", "Cuero",
|
||||
"Embrera", "Eldamore", "Faolan", "Chim", "Nasu", "Kathrine", "Ariel", "Arei", "Demytrix",
|
||||
"Kora", "Ava", "Larson", "Leonardo", "Wyrl", "Sakiama", "Lambton", "Kederath", "Malus", "Riplette",
|
||||
"Andern", "Ezall", "Lucien", "Droco", "Cray", "Tymen", "Zenix", "Entranger",
|
||||
"Saenorath", "Chris", "Christine", "Marble", "Mable", "Ross", "Rose", "Xalgan ", "Kennet"
|
||||
};
|
||||
name = names[new Random().nextInt(names.length)];
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setString("Name", name);
|
||||
nbttagcompound.setString("Title", title);
|
||||
nbttagcompound.setString("SkinUrl", url);
|
||||
nbttagcompound.setString("Texture", texture);
|
||||
nbttagcompound.setString("CloakTexture", cloakTexture);
|
||||
nbttagcompound.setString("GlowTexture", glowTexture);
|
||||
nbttagcompound.setByte("UsingSkinUrl", skinType);
|
||||
|
||||
if (this.playerProfile != null)
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
NBTUtil.func_152460_a(nbttagcompound1, this.playerProfile);
|
||||
nbttagcompound.setTag("SkinUsername", nbttagcompound1);
|
||||
}
|
||||
|
||||
nbttagcompound.setInteger("Size", modelSize);
|
||||
|
||||
nbttagcompound.setInteger("ShowName", showName);
|
||||
nbttagcompound.setInteger("NpcVisible", visible);
|
||||
|
||||
nbttagcompound.setBoolean("NoLivingAnimation", disableLivingAnimation);
|
||||
nbttagcompound.setByte("BossBar", showBossBar);
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
public void readToNBT(NBTTagCompound nbttagcompound) {
|
||||
name = nbttagcompound.getString("Name");
|
||||
title = nbttagcompound.getString("Title");
|
||||
|
||||
url = nbttagcompound.getString("SkinUrl");
|
||||
int prevSkinType = skinType;
|
||||
skinType = nbttagcompound.getByte("UsingSkinUrl");
|
||||
|
||||
this.playerProfile = null;
|
||||
if(skinType == 1){
|
||||
if (nbttagcompound.hasKey("SkinUsername", 10)){
|
||||
this.playerProfile = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("SkinUsername"));
|
||||
}
|
||||
else if (nbttagcompound.hasKey("SkinUsername", 8) && !StringUtils.isNullOrEmpty(nbttagcompound.getString("SkinUsername"))){
|
||||
this.playerProfile = new GameProfile(null, nbttagcompound.getString("SkinUsername"));
|
||||
}
|
||||
this.loadProfile();
|
||||
}
|
||||
|
||||
String prevTexture = texture;
|
||||
|
||||
texture = nbttagcompound.getString("Texture");
|
||||
cloakTexture = nbttagcompound.getString("CloakTexture");
|
||||
glowTexture = nbttagcompound.getString("GlowTexture");
|
||||
|
||||
modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, 30);
|
||||
|
||||
showName = nbttagcompound.getInteger("ShowName");
|
||||
visible = nbttagcompound.getInteger("NpcVisible");
|
||||
|
||||
disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation");
|
||||
showBossBar = nbttagcompound.getByte("BossBar");
|
||||
|
||||
if(prevSkinType != skinType || !texture.equals(prevTexture))
|
||||
npc.textureLocation = null;
|
||||
npc.textureGlowLocation = null;
|
||||
npc.textureCloakLocation = null;
|
||||
npc.updateHitbox();
|
||||
}
|
||||
|
||||
public void loadProfile(){
|
||||
if (this.playerProfile != null && !StringUtils.isNullOrEmpty(this.playerProfile.getName()) && MinecraftServer.getServer() != null){
|
||||
if (!this.playerProfile.isComplete() || !this.playerProfile.getProperties().containsKey("textures")){
|
||||
GameProfile gameprofile = MinecraftServer.getServer().func_152358_ax().func_152655_a(this.playerProfile.getName());
|
||||
|
||||
if (gameprofile != null){
|
||||
Property property = (Property)Iterables.getFirst(gameprofile.getProperties().get("textures"), (Object)null);
|
||||
|
||||
if (property == null){
|
||||
gameprofile = MinecraftServer.getServer().func_147130_as().fillProfileProperties(gameprofile, false);
|
||||
}
|
||||
|
||||
this.playerProfile = gameprofile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean showName() {
|
||||
if(npc.isKilled())
|
||||
return false;
|
||||
return showName == 0 || (showName == 2 && npc.isAttacking());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,331 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityXPOrb;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class DataInventory implements IInventory{
|
||||
public HashMap<Integer,ItemStack> items = new HashMap<Integer,ItemStack>();
|
||||
public HashMap<Integer,Integer> dropchance = new HashMap<Integer,Integer>();
|
||||
public HashMap<Integer, ItemStack> weapons = new HashMap<Integer, ItemStack>();
|
||||
public HashMap<Integer, ItemStack> armor = new HashMap<Integer, ItemStack>();
|
||||
|
||||
public int minExp = 0;
|
||||
public int maxExp = 0;
|
||||
|
||||
public int lootMode = 0;
|
||||
|
||||
private EntityNPCInterface npc;
|
||||
|
||||
public DataInventory(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
}
|
||||
public NBTTagCompound writeEntityToNBT(NBTTagCompound nbttagcompound){
|
||||
nbttagcompound.setInteger("MinExp", minExp);
|
||||
nbttagcompound.setInteger("MaxExp", maxExp);
|
||||
nbttagcompound.setTag("NpcInv", NBTTags.nbtItemStackList(items));
|
||||
nbttagcompound.setTag("Armor", NBTTags.nbtItemStackList(getArmor()));
|
||||
nbttagcompound.setTag("Weapons", NBTTags.nbtItemStackList(getWeapons()));
|
||||
nbttagcompound.setTag("DropChance", NBTTags.nbtIntegerIntegerMap(dropchance));
|
||||
nbttagcompound.setInteger("LootMode", lootMode);
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
public void readEntityFromNBT(NBTTagCompound nbttagcompound){
|
||||
minExp = nbttagcompound.getInteger("MinExp");
|
||||
maxExp = nbttagcompound.getInteger("MaxExp");
|
||||
items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcInv", 10));
|
||||
setArmor(NBTTags.getItemStackList(nbttagcompound.getTagList("Armor", 10)));
|
||||
setWeapons(NBTTags.getItemStackList(nbttagcompound.getTagList("Weapons", 10)));
|
||||
dropchance = NBTTags.getIntegerIntegerMap(nbttagcompound.getTagList("DropChance", 10));
|
||||
lootMode = nbttagcompound.getInteger("LootMode");
|
||||
}
|
||||
public HashMap<Integer, ItemStack> getWeapons() {
|
||||
return weapons;
|
||||
}
|
||||
public void setWeapons(HashMap<Integer, ItemStack> list) {
|
||||
weapons = list;
|
||||
}
|
||||
public HashMap<Integer, ItemStack> getArmor() {
|
||||
return armor;
|
||||
}
|
||||
public void setArmor(HashMap<Integer, ItemStack> list) {
|
||||
armor = list;
|
||||
}
|
||||
public ItemStack getWeapon(){
|
||||
return weapons.get(0);
|
||||
}
|
||||
public void setWeapon(ItemStack item){
|
||||
weapons.put(0, item);
|
||||
}
|
||||
public ItemStack getProjectile(){
|
||||
return weapons.get(1);
|
||||
}
|
||||
public void setProjectile(ItemStack item){
|
||||
weapons.put(1, item);
|
||||
}
|
||||
public ItemStack getOffHand(){
|
||||
return weapons.get(2);
|
||||
}
|
||||
public void setOffHand(ItemStack item){
|
||||
weapons.put(2, item);
|
||||
}
|
||||
|
||||
public void dropStuff(Entity entity, DamageSource damagesource) {
|
||||
ArrayList<EntityItem> list = new ArrayList<EntityItem>();
|
||||
for (int i : items.keySet()) {
|
||||
ItemStack item = items.get(i);
|
||||
if(item == null)
|
||||
continue;
|
||||
int dchance = 100;
|
||||
if(dropchance.containsKey(i))
|
||||
dchance = dropchance.get(i);
|
||||
int chance = npc.worldObj.rand.nextInt(100) + dchance;
|
||||
if(chance >= 100){
|
||||
EntityItem e = getEntityItem(item.copy());
|
||||
if(e != null)
|
||||
list.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
int enchant = 0;
|
||||
if (damagesource.getEntity() instanceof EntityPlayer){
|
||||
enchant = EnchantmentHelper.getLootingModifier((EntityLivingBase)damagesource.getEntity());
|
||||
}
|
||||
|
||||
if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(npc, damagesource, list, enchant, true, 0)){
|
||||
for (EntityItem item : list){
|
||||
if(lootMode == 1 && entity instanceof EntityPlayer){
|
||||
EntityPlayer player = (EntityPlayer)entity;
|
||||
item.delayBeforeCanPickup = 2;
|
||||
npc.worldObj.spawnEntityInWorld(item);
|
||||
ItemStack stack = item.getEntityItem();
|
||||
int i = stack.stackSize;
|
||||
|
||||
if (player.inventory.addItemStackToInventory(stack)) {
|
||||
npc.worldObj.playSoundAtEntity(item,
|
||||
"random.pop",
|
||||
0.2F,
|
||||
((npc.getRNG().nextFloat() - npc.getRNG().nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
player.onItemPickup(item, i);
|
||||
|
||||
if (stack.stackSize <= 0) {
|
||||
item.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
npc.worldObj.spawnEntityInWorld(item);
|
||||
}
|
||||
}
|
||||
|
||||
int var1 = minExp;
|
||||
if (maxExp - minExp > 0)
|
||||
var1 += npc.worldObj.rand.nextInt(maxExp - minExp);
|
||||
|
||||
while (var1 > 0){
|
||||
int var2 = EntityXPOrb.getXPSplit(var1);
|
||||
var1 -= var2;
|
||||
if(lootMode == 1 && entity instanceof EntityPlayer){
|
||||
npc.worldObj.spawnEntityInWorld(new EntityXPOrb(entity.worldObj, entity.posX, entity.posY, entity.posZ, var2));
|
||||
}
|
||||
else{
|
||||
npc.worldObj.spawnEntityInWorld(new EntityXPOrb(npc.worldObj, npc.posX, npc.posY, npc.posZ, var2));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public EntityItem getEntityItem(ItemStack itemstack) {
|
||||
if (itemstack == null) {
|
||||
return null;
|
||||
}
|
||||
EntityItem entityitem = new EntityItem(npc.worldObj, npc.posX,
|
||||
(npc.posY - 0.30000001192092896D) + (double) npc.getEyeHeight(), npc.posZ,
|
||||
itemstack);
|
||||
entityitem.delayBeforeCanPickup = 40;
|
||||
|
||||
float f2 = npc.getRNG().nextFloat() * 0.5F;
|
||||
float f4 = npc.getRNG().nextFloat() * 3.141593F * 2.0F;
|
||||
entityitem.motionX = -MathHelper.sin(f4) * f2;
|
||||
entityitem.motionZ = MathHelper.cos(f4) * f2;
|
||||
entityitem.motionY = 0.20000000298023224D;
|
||||
|
||||
return entityitem;
|
||||
}
|
||||
|
||||
public ItemStack armorItemInSlot(int i) {
|
||||
return getArmor().get(i);
|
||||
}
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
// TODO Auto-generated method stub
|
||||
return 15;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
if(i < 4)
|
||||
return armorItemInSlot(i);
|
||||
else if(i < 7)
|
||||
return getWeapons().get(i-4);
|
||||
else
|
||||
return items.get(i-7);
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1, int par2) {
|
||||
int i =0;
|
||||
HashMap<Integer,ItemStack> var3;
|
||||
|
||||
if (par1 >= 7)
|
||||
{
|
||||
var3 = items;
|
||||
par1 -= 7;
|
||||
}
|
||||
else if (par1 >= 4)
|
||||
{
|
||||
var3 = getWeapons();
|
||||
par1 -= 4;
|
||||
i = 1;
|
||||
}
|
||||
else{
|
||||
var3 = getArmor();
|
||||
i = 2;
|
||||
}
|
||||
|
||||
ItemStack var4 = null;
|
||||
if (var3.get(par1) != null)
|
||||
{
|
||||
|
||||
if (var3.get(par1).stackSize <= par2)
|
||||
{
|
||||
var4 = var3.get(par1);
|
||||
var3.put(par1,null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var4 = var3.get(par1).splitStack(par2);
|
||||
|
||||
if (var3.get(par1).stackSize == 0)
|
||||
{
|
||||
var3.put(par1,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(i == 1)
|
||||
setWeapons(var3);
|
||||
if(i == 2)
|
||||
setArmor(var3);
|
||||
return var4;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int par1) {
|
||||
int i = 0;
|
||||
HashMap<Integer,ItemStack> var2;;
|
||||
|
||||
if (par1 >= 7)
|
||||
{
|
||||
var2 = items;
|
||||
par1 -= 7;
|
||||
}
|
||||
else if (par1 >= 4)
|
||||
{
|
||||
var2 = getWeapons();
|
||||
par1 -= 4;
|
||||
i = 1;
|
||||
}
|
||||
else{
|
||||
var2 = getArmor();
|
||||
i = 2;
|
||||
}
|
||||
|
||||
if (var2.get(par1) != null)
|
||||
{
|
||||
ItemStack var3 = var2.get(par1);
|
||||
var2.put(par1,null);
|
||||
if(i == 1)
|
||||
setWeapons(var2);
|
||||
if(i == 2)
|
||||
setArmor(var2);
|
||||
return var3;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
|
||||
{
|
||||
int i = 0;
|
||||
HashMap<Integer,ItemStack> var3;
|
||||
|
||||
if (par1 >= 7)
|
||||
{
|
||||
var3 = items;
|
||||
par1 -= 7;
|
||||
}
|
||||
else if (par1 >= 4)
|
||||
{
|
||||
var3 = getWeapons();
|
||||
par1 -= 4;
|
||||
i = 1;
|
||||
}
|
||||
else{
|
||||
var3 = getArmor();
|
||||
i = 2;
|
||||
}
|
||||
|
||||
var3.put(par1,par2ItemStack);
|
||||
if(i == 1)
|
||||
setWeapons(var3);
|
||||
if(i == 2)
|
||||
setArmor(var3);
|
||||
}
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "NPC Inventory";
|
||||
}
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void markDirty() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public void openInventory() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.ScriptEvent;
|
||||
import noppes.npcs.scripted.ScriptNpc;
|
||||
import noppes.npcs.scripted.ScriptWorld;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
|
||||
public class DataScript {
|
||||
public Map<Integer,ScriptContainer> scripts = new HashMap<Integer,ScriptContainer>();
|
||||
private final static EntityType entities = new EntityType();
|
||||
private final static JobType jobs = new JobType();
|
||||
private final static RoleType roles = new RoleType();
|
||||
|
||||
public String scriptLanguage = "ECMAScript";
|
||||
private EntityNPCInterface npc;
|
||||
public boolean enabled = false;
|
||||
|
||||
public ScriptNpc dummyNpc;
|
||||
public ScriptWorld dummyWorld;
|
||||
public boolean clientNeedsUpdate = false;
|
||||
public boolean aiNeedsUpdate = false;
|
||||
public boolean hasInited = false;
|
||||
|
||||
public DataScript(EntityNPCInterface npc) {
|
||||
this.npc = npc;
|
||||
if(npc instanceof EntityCustomNpc)
|
||||
dummyNpc = new ScriptNpc((EntityCustomNpc) npc);
|
||||
if(npc.worldObj instanceof WorldServer)
|
||||
dummyWorld = new ScriptWorld((WorldServer) npc.worldObj);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
scripts = readScript(compound.getTagList("ScriptsContainers", 10));
|
||||
scriptLanguage = compound.getString("ScriptLanguage");
|
||||
enabled = compound.getBoolean("ScriptEnabled");
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
compound.setTag("ScriptsContainers", writeScript(scripts));
|
||||
compound.setString("ScriptLanguage", scriptLanguage);
|
||||
compound.setBoolean("ScriptEnabled", enabled);
|
||||
return compound;
|
||||
}
|
||||
|
||||
private Map<Integer,ScriptContainer> readScript(NBTTagList list){
|
||||
Map<Integer,ScriptContainer> scripts = new HashMap<Integer,ScriptContainer>();
|
||||
for(int i = 0; i < list.tagCount(); i++){
|
||||
NBTTagCompound compoundd = list.getCompoundTagAt(i);
|
||||
ScriptContainer script = new ScriptContainer();
|
||||
script.readFromNBT(compoundd);
|
||||
if(script.hasCode() || npc.isRemote())
|
||||
scripts.put(compoundd.getInteger("Type"), script);
|
||||
}
|
||||
return scripts;
|
||||
}
|
||||
|
||||
private NBTTagList writeScript(Map<Integer,ScriptContainer> scripts){
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(Integer type : scripts.keySet()){
|
||||
NBTTagCompound compoundd = new NBTTagCompound();
|
||||
compoundd.setInteger("Type", type);
|
||||
ScriptContainer script = scripts.get(type);
|
||||
script.writeToNBT(compoundd);
|
||||
list.appendTag(compoundd);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean callScript(EnumScriptType type, Object... obs){
|
||||
if(aiNeedsUpdate){
|
||||
npc.updateAI = true;
|
||||
aiNeedsUpdate = false;
|
||||
}
|
||||
if(clientNeedsUpdate){
|
||||
npc.updateClient = true;
|
||||
clientNeedsUpdate = false;
|
||||
}
|
||||
if(!isEnabled())
|
||||
return false;
|
||||
if(!hasInited){
|
||||
hasInited = true;
|
||||
callScript(EnumScriptType.INIT);
|
||||
}
|
||||
ScriptContainer script = scripts.get(type.ordinal());
|
||||
if(script == null || script.errored || !script.hasCode())
|
||||
return false;
|
||||
script.setEngine(scriptLanguage);
|
||||
if(script.engine == null)
|
||||
return false;
|
||||
for(int i = 0; i + 1 < obs.length; i += 2){
|
||||
Object ob = obs[i + 1];
|
||||
if(ob instanceof Entity)
|
||||
ob = ScriptController.Instance.getScriptForEntity((Entity)ob);
|
||||
script.engine.put(obs[i].toString(), ob);
|
||||
}
|
||||
|
||||
return callScript(script);
|
||||
}
|
||||
|
||||
public boolean isEnabled(){
|
||||
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty();
|
||||
}
|
||||
|
||||
private boolean callScript(ScriptContainer script){
|
||||
ScriptEngine engine = script.engine;
|
||||
engine.put("npc", dummyNpc);
|
||||
engine.put("world", dummyWorld);
|
||||
ScriptEvent result = (ScriptEvent) engine.get("event");
|
||||
if(result == null)
|
||||
engine.put("event", result = new ScriptEvent());
|
||||
engine.put("EntityType", entities);
|
||||
engine.put("RoleType", roles);
|
||||
engine.put("JobType", jobs);
|
||||
script.run(engine);
|
||||
|
||||
if(clientNeedsUpdate){
|
||||
npc.updateClient = true;
|
||||
clientNeedsUpdate = false;
|
||||
}
|
||||
if(aiNeedsUpdate){
|
||||
npc.updateAI = true;
|
||||
aiNeedsUpdate = false;
|
||||
}
|
||||
return result.isCancelled();
|
||||
}
|
||||
|
||||
public void setWorld(World world) {
|
||||
if(world instanceof WorldServer)
|
||||
dummyWorld = new ScriptWorld((WorldServer) world);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import net.minecraft.entity.EnumCreatureAttribute;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.constants.EnumParticleType;
|
||||
import noppes.npcs.constants.EnumPotionType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
public class DataStats {
|
||||
|
||||
private int attackStrength = 5;
|
||||
public int attackSpeed = 20, attackRange = 2, knockback = 0;
|
||||
public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60;
|
||||
public int aggroRange = 16;
|
||||
|
||||
public EnumPotionType potionType = EnumPotionType.None;
|
||||
public int potionDuration = 5; //20 = 1 second
|
||||
public int potionAmp = 0;
|
||||
|
||||
public int maxHealth = 20;
|
||||
public int respawnTime = 20;
|
||||
public int spawnCycle = 0;
|
||||
public boolean hideKilledBody = false;
|
||||
public boolean canDespawn = false;
|
||||
|
||||
public Resistances resistances = new Resistances();
|
||||
|
||||
public boolean immuneToFire = false;
|
||||
public boolean potionImmune = false;
|
||||
public boolean canDrown = true;
|
||||
public boolean burnInSun = false;
|
||||
public boolean noFallDamage = false;
|
||||
public int healthRegen = 1;
|
||||
public int combatRegen = 0;
|
||||
|
||||
public int pDamage = 4, pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5;
|
||||
public boolean pPhysics = true, pXlr8 = false, pGlows = false, pExplode = false;
|
||||
public boolean pRender3D = false, pSpin = false, pStick = false;
|
||||
public EnumPotionType pEffect = EnumPotionType.None;
|
||||
public EnumParticleType pTrail = EnumParticleType.None;
|
||||
public int pEffAmp = 0;
|
||||
public String fireSound = "random.bow";
|
||||
public boolean aimWhileShooting = false;
|
||||
|
||||
public EnumCreatureAttribute creatureType = EnumCreatureAttribute.UNDEFINED;
|
||||
|
||||
private EntityNPCInterface npc;
|
||||
public boolean attackInvisible = false;
|
||||
|
||||
public DataStats(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
}
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound)
|
||||
{
|
||||
compound.setTag("Resistances", resistances.writeToNBT());
|
||||
compound.setInteger("MaxHealth", maxHealth);
|
||||
compound.setInteger("AggroRange", aggroRange);
|
||||
compound.setBoolean("HideBodyWhenKilled", hideKilledBody);
|
||||
compound.setInteger("RespawnTime", respawnTime);
|
||||
compound.setInteger("SpawnCycle", spawnCycle);
|
||||
compound.setInteger("CreatureType", creatureType.ordinal());
|
||||
compound.setInteger("HealthRegen", healthRegen);
|
||||
compound.setInteger("CombatRegen", combatRegen);
|
||||
|
||||
compound.setInteger("AttackStrenght", attackStrength);
|
||||
compound.setInteger("AttackRange", attackRange);
|
||||
compound.setInteger("AttackSpeed", attackSpeed);
|
||||
compound.setInteger("KnockBack", knockback);
|
||||
compound.setInteger("PotionEffect", potionType.ordinal());
|
||||
compound.setInteger("PotionDuration", potionDuration);
|
||||
compound.setInteger("PotionAmp", potionAmp);
|
||||
|
||||
compound.setInteger("MaxFiringRange", rangedRange);
|
||||
compound.setInteger("FireRate", fireRate);
|
||||
compound.setInteger("minDelay", minDelay);
|
||||
compound.setInteger("maxDelay", maxDelay);
|
||||
compound.setInteger("BurstCount", burstCount);
|
||||
compound.setInteger("ShotCount", shotCount);
|
||||
compound.setInteger("Accuracy", accuracy);
|
||||
|
||||
compound.setInteger("pDamage", pDamage);
|
||||
compound.setInteger("pImpact", pImpact);
|
||||
compound.setInteger("pSize", pSize);
|
||||
compound.setInteger("pSpeed", pSpeed);
|
||||
compound.setInteger("pArea", pArea);
|
||||
compound.setInteger("pDur", pDur);
|
||||
compound.setBoolean("pPhysics", pPhysics);
|
||||
compound.setBoolean("pXlr8", pXlr8);
|
||||
compound.setBoolean("pGlows", pGlows);
|
||||
compound.setBoolean("pExplode", pExplode);
|
||||
compound.setBoolean("pRender3D", pRender3D);
|
||||
compound.setBoolean("pSpin", pSpin);
|
||||
compound.setBoolean("pStick", pStick);
|
||||
compound.setInteger("pEffect", pEffect.ordinal());
|
||||
compound.setInteger("pTrail", pTrail.ordinal());
|
||||
compound.setInteger("pEffAmp", pEffAmp);
|
||||
compound.setString("FiringSound", fireSound);
|
||||
compound.setBoolean("AimWhileShooting", aimWhileShooting);
|
||||
|
||||
compound.setBoolean("ImmuneToFire", immuneToFire);
|
||||
compound.setBoolean("PotionImmune", potionImmune);
|
||||
compound.setBoolean("CanDrown", canDrown);
|
||||
compound.setBoolean("BurnInSun", burnInSun);
|
||||
compound.setBoolean("NoFallDamage", noFallDamage);
|
||||
compound.setBoolean("CanDespawn", canDespawn);
|
||||
compound.setBoolean("AttackInvisible", attackInvisible);
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void readToNBT(NBTTagCompound compound)
|
||||
{
|
||||
resistances.readToNBT(compound.getCompoundTag("Resistances"));
|
||||
setMaxHealth(compound.getInteger("MaxHealth"));
|
||||
hideKilledBody = compound.getBoolean("HideBodyWhenKilled");
|
||||
aggroRange = compound.getInteger("AggroRange");
|
||||
respawnTime = compound.getInteger("RespawnTime");
|
||||
spawnCycle = compound.getInteger("SpawnCycle");
|
||||
creatureType = EnumCreatureAttribute.values()[compound.getInteger("CreatureType") % EnumPotionType.values().length];
|
||||
healthRegen = compound.getInteger("HealthRegen");
|
||||
combatRegen = compound.getInteger("CombatRegen");
|
||||
|
||||
setAttackStrength(compound.getInteger("AttackStrenght"));
|
||||
attackSpeed = compound.getInteger("AttackSpeed");
|
||||
attackRange = compound.getInteger("AttackRange");
|
||||
knockback = compound.getInteger("KnockBack");
|
||||
potionType = EnumPotionType.values()[compound.getInteger("PotionEffect") % EnumPotionType.values().length];
|
||||
potionDuration = compound.getInteger("PotionDuration");
|
||||
potionAmp = compound.getInteger("PotionAmp");
|
||||
|
||||
rangedRange = compound.getInteger("MaxFiringRange");
|
||||
fireRate = compound.getInteger("FireRate");
|
||||
minDelay = ValueUtil.CorrectInt(compound.getInteger("minDelay"), 1, 9999);
|
||||
maxDelay = ValueUtil.CorrectInt(compound.getInteger("maxDelay"), 1, 9999);
|
||||
burstCount = compound.getInteger("BurstCount");
|
||||
shotCount = ValueUtil.CorrectInt(compound.getInteger("ShotCount"), 1, 10);
|
||||
accuracy = compound.getInteger("Accuracy");
|
||||
|
||||
pDamage = compound.getInteger("pDamage");
|
||||
pImpact = compound.getInteger("pImpact");
|
||||
pSize = compound.getInteger("pSize");
|
||||
pSpeed = compound.getInteger("pSpeed");
|
||||
pArea = compound.getInteger("pArea");
|
||||
pDur = compound.getInteger("pDur");
|
||||
pPhysics = compound.getBoolean("pPhysics");
|
||||
pXlr8 = compound.getBoolean("pXlr8");
|
||||
pGlows = compound.getBoolean("pGlows");
|
||||
pExplode = compound.getBoolean("pExplode");
|
||||
pRender3D = compound.getBoolean("pRender3D");
|
||||
pSpin = compound.getBoolean("pSpin");
|
||||
pStick = compound.getBoolean("pStick");
|
||||
pEffect = EnumPotionType.values()[compound.getInteger("pEffect") % EnumPotionType.values().length];
|
||||
pTrail = EnumParticleType.values()[compound.getInteger("pTrail") % EnumParticleType.values().length];
|
||||
pEffAmp = compound.getInteger("pEffAmp");
|
||||
fireSound = compound.getString("FiringSound");
|
||||
aimWhileShooting = compound.getBoolean("AimWhileShooting");
|
||||
|
||||
immuneToFire = compound.getBoolean("ImmuneToFire");
|
||||
potionImmune = compound.getBoolean("PotionImmune");
|
||||
canDrown = compound.getBoolean("CanDrown");
|
||||
burnInSun = compound.getBoolean("BurnInSun");
|
||||
noFallDamage = compound.getBoolean("NoFallDamage");
|
||||
canDespawn = compound.getBoolean("CanDespawn");
|
||||
attackInvisible = compound.getBoolean("AttackInvisible");
|
||||
|
||||
npc.setImmuneToFire(immuneToFire);
|
||||
}
|
||||
|
||||
public int getAttackStrength(){
|
||||
return attackStrength;
|
||||
}
|
||||
public void setAttackStrength(int strength){
|
||||
attackStrength = strength;
|
||||
npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength);
|
||||
}
|
||||
|
||||
public void setMaxHealth(int maxHealth) {
|
||||
this.maxHealth = maxHealth;
|
||||
npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public interface IChatMessages {
|
||||
|
||||
public void addMessage(String message, EntityNPCInterface npc);
|
||||
public void renderMessages(double par3, double par5, double par7, float scale);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface ICompatibilty {
|
||||
public int getVersion();
|
||||
public void setVersion(int version);
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound);
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.StreamHandler;
|
||||
|
||||
public class LogWriter {
|
||||
private final static String name = "CustomNPCs";
|
||||
private final static Logger logger = Logger.getLogger(name);
|
||||
private final static SimpleDateFormat dateformat = new SimpleDateFormat("HH:mm:ss");
|
||||
private static Handler handler;
|
||||
static {
|
||||
try {
|
||||
File dir = new File("logs");
|
||||
if(!dir.exists())
|
||||
dir.mkdir();
|
||||
File file = new File(dir, name + "-latest.log");
|
||||
File lock = new File(dir, name + "-latest.log.lck");
|
||||
File file1 = new File(dir, name + "-1.log");
|
||||
File file2 = new File(dir, name + "-2.log");
|
||||
File file3 = new File(dir, name + "-3.log");
|
||||
|
||||
if(lock.exists())
|
||||
lock.delete();
|
||||
|
||||
if(file3.exists())
|
||||
file3.delete();
|
||||
if(file2.exists())
|
||||
file2.renameTo(file3);
|
||||
if(file1.exists())
|
||||
file1.renameTo(file2);
|
||||
if(file.exists())
|
||||
file.renameTo(file1);
|
||||
|
||||
handler = new StreamHandler(new FileOutputStream(file), new Formatter() {
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
StackTraceElement element = Thread.currentThread().getStackTrace()[8];
|
||||
String line = "[" + element.getClassName() + ":" + element.getLineNumber() + "] ";
|
||||
String time = "[" + dateformat.format(new Date(record.getMillis())) + "][" + record.getLevel() + "]" + line;
|
||||
if(record.getThrown() != null){
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
record.getThrown().printStackTrace(pw);
|
||||
return time + sw.toString();
|
||||
}
|
||||
return time + record.getMessage() + System.getProperty("line.separator");
|
||||
}
|
||||
});
|
||||
handler.setLevel(Level.ALL);
|
||||
logger.addHandler(handler);
|
||||
logger.setUseParentHandlers(false);
|
||||
Handler consoleHandler = new ConsoleHandler();
|
||||
consoleHandler.setFormatter(handler.getFormatter());
|
||||
consoleHandler.setLevel(Level.ALL);
|
||||
logger.addHandler(consoleHandler);
|
||||
|
||||
logger.setLevel(Level.ALL);
|
||||
info(new Date().toString());
|
||||
} catch (SecurityException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void info(Object msg) {
|
||||
logger.log(Level.FINE, msg.toString());
|
||||
handler.flush();
|
||||
}
|
||||
|
||||
public static void error(Object msg) {
|
||||
logger.log(Level.SEVERE, msg.toString());
|
||||
handler.flush();
|
||||
}
|
||||
|
||||
public static void error(Object msg, Exception e) {
|
||||
logger.log(Level.SEVERE, msg.toString());
|
||||
logger.log(Level.SEVERE, e.getMessage(), e);
|
||||
handler.flush();
|
||||
}
|
||||
|
||||
public static void except(Exception e) {
|
||||
logger.log(Level.SEVERE, e.getMessage(), e);
|
||||
handler.flush();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.controllers.PixelmonHelper;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class ModelData extends ModelDataShared{
|
||||
|
||||
public EntityLivingBase getEntity(EntityNPCInterface npc){
|
||||
if(entityClass == null)
|
||||
return null;
|
||||
if(entity == null){
|
||||
try {
|
||||
entity = entityClass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {npc.worldObj});
|
||||
|
||||
entity.readEntityFromNBT(extra);
|
||||
|
||||
if(entity instanceof EntityLiving){
|
||||
EntityLiving living = (EntityLiving)entity;
|
||||
living.setCurrentItemOrArmor(0, npc.getHeldItem() != null?npc.getHeldItem():npc.getOffHand());
|
||||
living.setCurrentItemOrArmor(1, npc.inventory.armorItemInSlot(3));
|
||||
living.setCurrentItemOrArmor(2, npc.inventory.armorItemInSlot(2));
|
||||
living.setCurrentItemOrArmor(3, npc.inventory.armorItemInSlot(1));
|
||||
living.setCurrentItemOrArmor(4, npc.inventory.armorItemInSlot(0));
|
||||
}
|
||||
if(PixelmonHelper.isPixelmon(entity) && npc.worldObj.isRemote){
|
||||
if(extra.hasKey("Name"))
|
||||
PixelmonHelper.setName(entity, extra.getString("Name"));
|
||||
else
|
||||
PixelmonHelper.setName(entity, "Abra");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
public ModelData copy(){
|
||||
ModelData data = new ModelData();
|
||||
data.readFromNBT(this.writeToNBT());
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.entity.EntityAgeable;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.passive.EntityBat;
|
||||
import net.minecraft.entity.passive.EntityHorse;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
public class ModelDataShared{
|
||||
public ModelPartConfig arms = new ModelPartConfig();
|
||||
public ModelPartConfig body = new ModelPartConfig();
|
||||
public ModelPartConfig legs = new ModelPartConfig();
|
||||
public ModelPartConfig head = new ModelPartConfig();
|
||||
|
||||
public ModelPartData legParts = new ModelPartData();
|
||||
|
||||
public Class<? extends EntityLivingBase> entityClass;
|
||||
public EntityLivingBase entity;
|
||||
|
||||
public NBTTagCompound extra = new NBTTagCompound();
|
||||
|
||||
private HashMap<String,ModelPartData> parts = new HashMap<String,ModelPartData>();
|
||||
public byte breasts = 0;
|
||||
|
||||
public byte headwear = 2;
|
||||
|
||||
public NBTTagCompound writeToNBT(){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
|
||||
if(entityClass != null)
|
||||
compound.setString("EntityClass", entityClass.getCanonicalName());
|
||||
|
||||
compound.setTag("ArmsConfig", arms.writeToNBT());
|
||||
compound.setTag("BodyConfig", body.writeToNBT());
|
||||
compound.setTag("LegsConfig", legs.writeToNBT());
|
||||
compound.setTag("HeadConfig", head.writeToNBT());
|
||||
|
||||
compound.setTag("LegParts", legParts.writeToNBT());
|
||||
|
||||
compound.setByte("Headwear", headwear);
|
||||
compound.setByte("Breasts", breasts);
|
||||
compound.setTag("ExtraData", extra);
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(String name : parts.keySet()){
|
||||
NBTTagCompound item = parts.get(name).writeToNBT();
|
||||
item.setString("PartName", name);
|
||||
list.appendTag(item);
|
||||
}
|
||||
compound.setTag("Parts", list);
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
setEntityClass(compound.getString("EntityClass"));
|
||||
|
||||
arms.readFromNBT(compound.getCompoundTag("ArmsConfig"));
|
||||
body.readFromNBT(compound.getCompoundTag("BodyConfig"));
|
||||
legs.readFromNBT(compound.getCompoundTag("LegsConfig"));
|
||||
head.readFromNBT(compound.getCompoundTag("HeadConfig"));
|
||||
|
||||
legParts.readFromNBT(compound.getCompoundTag("LegParts"));
|
||||
|
||||
headwear = compound.getByte("Headwear");
|
||||
breasts = compound.getByte("Breasts");
|
||||
extra = compound.getCompoundTag("ExtraData");
|
||||
|
||||
HashMap<String,ModelPartData> parts = new HashMap<String,ModelPartData>();
|
||||
NBTTagList list = compound.getTagList("Parts", 10);
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
NBTTagCompound item = list.getCompoundTagAt(i);
|
||||
ModelPartData part = new ModelPartData();
|
||||
part.readFromNBT(item);
|
||||
parts.put(item.getString("PartName"), part);
|
||||
}
|
||||
this.parts = parts;
|
||||
|
||||
}
|
||||
|
||||
private void setEntityClass(String string) {
|
||||
entityClass = null;
|
||||
entity = null;
|
||||
try {
|
||||
Class<?> cls = Class.forName(string);
|
||||
if (EntityLivingBase.class.isAssignableFrom(cls))
|
||||
entityClass = cls.asSubclass(EntityLivingBase.class);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void setEntityClass(Class<? extends EntityLivingBase> entityClass){
|
||||
this.entityClass = entityClass;
|
||||
entity = null;
|
||||
extra = new NBTTagCompound();
|
||||
if(entityClass == EntityHorse.class)
|
||||
extra.setInteger("Type", -1);
|
||||
}
|
||||
|
||||
public Class<? extends EntityLivingBase> getEntityClass(){
|
||||
return entityClass;
|
||||
}
|
||||
|
||||
public float offsetY() {
|
||||
if(entity == null)
|
||||
return -getBodyY();
|
||||
return entity.height - 1.8f;
|
||||
}
|
||||
|
||||
public void clearEntity() {
|
||||
entity = null;
|
||||
}
|
||||
|
||||
|
||||
public ModelPartData getPartData(String type){
|
||||
return parts.get(type);
|
||||
}
|
||||
|
||||
public void removePart(String type) {
|
||||
parts.remove(type);
|
||||
}
|
||||
|
||||
public ModelPartData getOrCreatePart(String type) {
|
||||
ModelPartData part = parts.get(type);
|
||||
if(part == null)
|
||||
parts.put(type, part = new ModelPartData());
|
||||
return part;
|
||||
}
|
||||
|
||||
public float getBodyY(){
|
||||
if(legParts.type == 3)
|
||||
return (0.9f - body.scaleY) * 0.75f + getLegsY();
|
||||
if(legParts.type == 3)
|
||||
return (0.5f - body.scaleY) * 0.75f + getLegsY();
|
||||
return (1 - body.scaleY) * 0.75f + getLegsY();
|
||||
}
|
||||
|
||||
public float getLegsY() {
|
||||
if(legParts.type == 3)
|
||||
return (0.87f - legs.scaleY) * 1f;
|
||||
return (1 - legs.scaleY) * 0.75f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
public class ModelPartConfig {
|
||||
public float scaleX = 1, scaleY = 1, scaleZ = 1;
|
||||
public float transX = 0, transY = 0, transZ = 0;
|
||||
|
||||
|
||||
public NBTTagCompound writeToNBT(){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setFloat("ScaleX", scaleX);
|
||||
compound.setFloat("ScaleY", scaleY);
|
||||
compound.setFloat("ScaleZ", scaleZ);
|
||||
|
||||
compound.setFloat("TransX", transX);
|
||||
compound.setFloat("TransY", transY);
|
||||
compound.setFloat("TransZ", transZ);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
scaleX = ValueUtil.correctFloat(compound.getFloat("ScaleX"), 0.5f, 1.5f);
|
||||
scaleY = ValueUtil.correctFloat(compound.getFloat("ScaleY"), 0.5f, 1.5f);
|
||||
scaleZ = ValueUtil.correctFloat(compound.getFloat("ScaleZ"), 0.5f, 1.5f);
|
||||
|
||||
transX = compound.getFloat("TransX");
|
||||
transY = compound.getFloat("TransY");
|
||||
transZ = compound.getFloat("TransZ");
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "ScaleX: " + scaleX + " - ScaleY: " + scaleY + " - ScaleZ: " + scaleZ;
|
||||
}
|
||||
|
||||
public void setScale(float x, float y, float z) {
|
||||
scaleX = x;
|
||||
scaleY = y;
|
||||
scaleZ = z;
|
||||
}
|
||||
public void setScale(float x, float y) {
|
||||
scaleZ = scaleX = x;
|
||||
scaleY = y;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class ModelPartData {
|
||||
public int color = 0xFFFFFF;
|
||||
public String texture;
|
||||
public byte type = 0;
|
||||
public boolean playerTexture;
|
||||
|
||||
private ResourceLocation location;
|
||||
|
||||
public ModelPartData(){
|
||||
playerTexture = true;
|
||||
}
|
||||
|
||||
public ModelPartData(String texture) {
|
||||
this.texture = texture;
|
||||
playerTexture = false;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setByte("Type", type);
|
||||
compound.setInteger("Color", color);
|
||||
if(texture != null && !texture.isEmpty())
|
||||
compound.setString("Texture", texture);
|
||||
compound.setBoolean("PlayerTexture", playerTexture);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
type = compound.getByte("Type");
|
||||
color = compound.getInteger("Color");
|
||||
texture = compound.getString("Texture");
|
||||
playerTexture = compound.getBoolean("PlayerTexture");
|
||||
location = null;
|
||||
}
|
||||
|
||||
public ResourceLocation getResource(){
|
||||
if(texture.isEmpty())
|
||||
return null;
|
||||
if(location != null)
|
||||
return location;
|
||||
location = new ResourceLocation(texture);
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setTexture(String texture, int type) {
|
||||
this.type = (byte) type;
|
||||
this.location = null;
|
||||
if(texture.isEmpty()){
|
||||
playerTexture = true;
|
||||
this.texture = texture;
|
||||
}
|
||||
else{
|
||||
this.texture = "moreplayermodels:textures/"+ texture + ".png";
|
||||
playerTexture = false;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "Color: " + color + " Type: " + type;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
String str = Integer.toHexString(color);
|
||||
|
||||
while(str.length() < 6)
|
||||
str = "0" + str;
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,386 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagDouble;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class NBTTags {
|
||||
|
||||
public static HashMap<Integer, ItemStack> getItemStackList(
|
||||
NBTTagList tagList) {
|
||||
HashMap<Integer, ItemStack> list = new HashMap<Integer, ItemStack>();
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
try{
|
||||
list.put(nbttagcompound.getByte("Slot") & 0xff, NoppesUtilServer.readItem(nbttagcompound));
|
||||
}
|
||||
catch(ClassCastException e){
|
||||
list.put(nbttagcompound.getInteger("Slot"), NoppesUtilServer.readItem(nbttagcompound));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static ItemStack[] getItemStackArray(
|
||||
NBTTagList tagList) {
|
||||
ItemStack[] list = new ItemStack[tagList.tagCount()];
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
list[nbttagcompound.getByte("Slot") & 0xff] = NoppesUtilServer.readItem(nbttagcompound);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static ArrayList<int[]> getIntegerArraySet(NBTTagList tagList) {
|
||||
ArrayList<int[]> set = new ArrayList<int[]>();
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound compound = tagList.getCompoundTagAt(i);
|
||||
set.add(compound.getIntArray("Array"));
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
public static HashMap<Integer, Boolean> getBooleanList(NBTTagList tagList) {
|
||||
HashMap<Integer, Boolean> list = new HashMap<Integer, Boolean>();
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getBoolean("Boolean"));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static HashMap<Integer, Integer> getIntegerIntegerMap(
|
||||
NBTTagList tagList) {
|
||||
HashMap<Integer, Integer> list = new HashMap<Integer, Integer>();
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getInteger("Integer"));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static HashMap<Integer, Long> getIntegerLongMap(
|
||||
NBTTagList tagList) {
|
||||
HashMap<Integer, Long> list = new HashMap<Integer, Long>();
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getLong("Long"));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static HashSet<Integer> getIntegerSet(NBTTagList tagList) {
|
||||
HashSet<Integer> list = new HashSet<Integer>();
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
list.add(nbttagcompound.getInteger("Integer"));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static HashMap<String, String> getStringStringMap(NBTTagList tagList) {
|
||||
HashMap<String, String> list = new HashMap<String, String>();
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
list.put(nbttagcompound.getString("Slot"), nbttagcompound.getString("Value"));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static HashMap<Integer, String> getIntegerStringMap(NBTTagList tagList) {
|
||||
HashMap<Integer, String> list = new HashMap<Integer, String>();
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getString("Value"));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static HashMap<String, Integer> getStringIntegerMap(NBTTagList tagList) {
|
||||
HashMap<String, Integer> list = new HashMap<String, Integer>();
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
list.put(nbttagcompound.getString("Slot"), nbttagcompound.getInteger("Value"));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public static HashMap<String, Vector<String>> getVectorMap(NBTTagList tagList) {
|
||||
HashMap<String, Vector<String>> map = new HashMap<String, Vector<String>>();
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
Vector<String> values = new Vector<String>();
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
NBTTagList list = nbttagcompound.getTagList("Values", 10);
|
||||
for(int j = 0; j < list.tagCount(); j++)
|
||||
{
|
||||
NBTTagCompound value = list.getCompoundTagAt(j);
|
||||
values.add(value.getString("Value"));
|
||||
}
|
||||
|
||||
map.put(nbttagcompound.getString("Key"), values);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
public static List<String> getStringList(NBTTagList tagList) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
String line = nbttagcompound.getString("Line");
|
||||
list.add(line);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String[] getStringArray(NBTTagList tagList, int size) {
|
||||
String[] arr = new String[size];
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
String line = nbttagcompound.getString("Value");
|
||||
int slot = nbttagcompound.getInteger("Slot");
|
||||
arr[slot] = line;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtIntegerArraySet(List<int[]> set) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
if(set == null)
|
||||
return nbttaglist;
|
||||
for(int[] arr : set)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setIntArray("Array", arr);
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtItemStackList(HashMap<Integer,ItemStack>inventory) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
if(inventory == null)
|
||||
return nbttaglist;
|
||||
for(int slot : inventory.keySet())
|
||||
{
|
||||
ItemStack item = inventory.get(slot);
|
||||
if(item == null)
|
||||
continue;
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setByte("Slot", (byte)slot);
|
||||
|
||||
NoppesUtilServer.writeItem(item, nbttagcompound);
|
||||
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtItemStackArray(ItemStack[] inventory) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
if(inventory == null)
|
||||
return nbttaglist;
|
||||
for(int slot = 0 ; slot < inventory.length; slot++)
|
||||
{
|
||||
ItemStack item = inventory[slot];
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setByte("Slot", (byte)slot);
|
||||
|
||||
if(item != null)
|
||||
NoppesUtilServer.writeItem(item, nbttagcompound);
|
||||
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtBooleanList(HashMap<Integer, Boolean> updatedSlots) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
if(updatedSlots == null)
|
||||
return nbttaglist;
|
||||
HashMap<Integer,Boolean> inventory2 = updatedSlots;
|
||||
for(Integer slot : inventory2.keySet())
|
||||
{
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setInteger("Slot", slot);
|
||||
nbttagcompound.setBoolean("Boolean", inventory2.get(slot));
|
||||
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtIntegerIntegerMap(HashMap<Integer, Integer> lines) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
if(lines == null)
|
||||
return nbttaglist;
|
||||
for (int slot : lines.keySet()) {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setInteger("Slot", slot);
|
||||
nbttagcompound.setInteger("Integer", lines.get(slot));
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtIntegerLongMap(HashMap<Integer, Long> lines) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
if(lines == null)
|
||||
return nbttaglist;
|
||||
for (int slot : lines.keySet()) {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setInteger("Slot", slot);
|
||||
nbttagcompound.setLong("Long", lines.get(slot));
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtIntegerSet(HashSet<Integer> set) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
if(set == null)
|
||||
return nbttaglist;
|
||||
for (int slot : set) {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setInteger("Integer", slot);
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtVectorMap(HashMap<String, Vector<String>> map) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
if(map == null)
|
||||
return list;
|
||||
for(String key : map.keySet()){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setString("Key", key);
|
||||
NBTTagList values = new NBTTagList();
|
||||
for(String value : map.get(key)){
|
||||
NBTTagCompound comp = new NBTTagCompound();
|
||||
comp.setString("Value", value);
|
||||
values.appendTag(comp);
|
||||
}
|
||||
compound.setTag("Values", values);
|
||||
list.appendTag(compound);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtStringStringMap(HashMap<String, String> map) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
if(map == null)
|
||||
return nbttaglist;
|
||||
for(String slot : map.keySet())
|
||||
{
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setString("Slot", slot);
|
||||
nbttagcompound.setString("Value", map.get(slot));
|
||||
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtStringIntegerMap(HashMap<String, Integer> map) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
if(map == null)
|
||||
return nbttaglist;
|
||||
for(String slot : map.keySet())
|
||||
{
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setString("Slot", slot);
|
||||
nbttagcompound.setInteger("Value", map.get(slot));
|
||||
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTBase nbtIntegerStringMap(HashMap<Integer, String> map) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
if(map == null)
|
||||
return nbttaglist;
|
||||
for(int slot : map.keySet())
|
||||
{
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setInteger("Slot", slot);
|
||||
nbttagcompound.setString("Value", map.get(slot));
|
||||
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtStringArray(String[] list) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
if(list == null)
|
||||
return nbttaglist;
|
||||
for(int i = 0; i < list.length; i++){
|
||||
if(list[i] == null)
|
||||
continue;
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setString("Value", list[i]);
|
||||
nbttagcompound.setInteger("Slot", i);
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtStringList(List<String> list) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
for (String s : list) {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setString("Line", s);
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtDoubleList(double ... par1ArrayOfDouble){
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
double[] adouble = par1ArrayOfDouble;
|
||||
int i = par1ArrayOfDouble.length;
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
double d1 = adouble[j];
|
||||
nbttaglist.appendTag(new NBTTagDouble(d1));
|
||||
}
|
||||
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTTagCompound NBTMerge(NBTTagCompound data, NBTTagCompound merge) {
|
||||
NBTTagCompound compound = (NBTTagCompound) data.copy();
|
||||
Set<String> names = merge.func_150296_c();
|
||||
for(String name : names){
|
||||
NBTBase base = merge.getTag(name);
|
||||
if(base.getId() == 10)
|
||||
base = NBTMerge(compound.getCompoundTag(name), (NBTTagCompound) base);
|
||||
compound.setTag(name, base);
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import noppes.npcs.controllers.SpawnController;
|
||||
import noppes.npcs.controllers.SpawnData;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class NPCSpawning {
|
||||
private static Set<ChunkCoordIntPair> eligibleChunksForSpawning = Sets.newHashSet();
|
||||
|
||||
public static void findChunksForSpawning(WorldServer world){
|
||||
if(SpawnController.instance.data.isEmpty() || world.getWorldInfo().getWorldTotalTime() % 400L != 0L)
|
||||
return;
|
||||
eligibleChunksForSpawning.clear();
|
||||
for (int i = 0; i < world.playerEntities.size(); ++i){
|
||||
EntityPlayer entityplayer = (EntityPlayer)world.playerEntities.get(i);
|
||||
int j = MathHelper.floor_double(entityplayer.posX / 16.0D);
|
||||
int k = MathHelper.floor_double(entityplayer.posZ / 16.0D);
|
||||
byte size = 7;
|
||||
|
||||
for (int x = -size; x <= size; ++x){
|
||||
for (int z = -size; z <= size; ++z){
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x + j, z + k);
|
||||
if (!eligibleChunksForSpawning.contains(chunkcoordintpair)){
|
||||
eligibleChunksForSpawning.add(chunkcoordintpair);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (countNPCs(world) > eligibleChunksForSpawning.size()){
|
||||
return;
|
||||
}
|
||||
ArrayList<ChunkCoordIntPair> tmp = new ArrayList(eligibleChunksForSpawning);
|
||||
Collections.shuffle(tmp);
|
||||
Iterator<ChunkCoordIntPair> iterator = tmp.iterator();
|
||||
|
||||
while (iterator.hasNext()){
|
||||
ChunkCoordIntPair chunkcoordintpair1 = iterator.next();
|
||||
|
||||
ChunkPosition chunkposition = getChunk(world, chunkcoordintpair1.chunkXPos, chunkcoordintpair1.chunkZPos);
|
||||
int j1 = chunkposition.chunkPosX;
|
||||
int k1 = chunkposition.chunkPosY;
|
||||
int l1 = chunkposition.chunkPosZ;
|
||||
|
||||
for(int i = 0; i < 3; i++){
|
||||
int x = j1;
|
||||
int y = k1;
|
||||
int z = l1;
|
||||
byte b1 = 6;
|
||||
|
||||
x += world.rand.nextInt(b1) - world.rand.nextInt(b1);
|
||||
y += world.rand.nextInt(1) - world.rand.nextInt(1);
|
||||
z += world.rand.nextInt(b1) - world.rand.nextInt(b1);
|
||||
|
||||
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
String name = world.getBiomeGenForCoords(x, z).biomeName;
|
||||
SpawnData data = SpawnController.instance.getRandomSpawnData(name, block.getMaterial() == Material.air);
|
||||
if (data == null || !canCreatureTypeSpawnAtLocation(data, world, x, y, z) || world.getClosestPlayer(x, y, z, 24.0D) != null)
|
||||
continue;
|
||||
|
||||
spawnData(data, world, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int countNPCs(World world){
|
||||
int count = 0;
|
||||
List<Entity> list = world.loadedEntityList;
|
||||
for (Entity entity : list){
|
||||
if (entity instanceof EntityNPCInterface){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
protected static ChunkPosition getChunk(World world, int x, int z){
|
||||
Chunk chunk = world.getChunkFromChunkCoords(x, z);
|
||||
int k = x * 16 + world.rand.nextInt(16);
|
||||
int l = z * 16 + world.rand.nextInt(16);
|
||||
int i1 = world.rand.nextInt(chunk == null ? world.getActualHeight() : chunk.getTopFilledSegment() + 16 - 1);
|
||||
return new ChunkPosition(k, i1, l);
|
||||
}
|
||||
|
||||
public static void performWorldGenSpawning(World world, int x, int z, Random rand){
|
||||
BiomeGenBase biome = world.getBiomeGenForCoords(x + 8, z + 8);
|
||||
while (rand.nextFloat() < biome.getSpawningChance()){
|
||||
SpawnData data = SpawnController.instance.getRandomSpawnData(biome.biomeName, true);
|
||||
if(data == null)
|
||||
continue;
|
||||
|
||||
int size = 16;
|
||||
|
||||
int j1 = x + rand.nextInt(size);
|
||||
int k1 = z + rand.nextInt(size);
|
||||
int l1 = j1;
|
||||
int i2 = k1;
|
||||
|
||||
for (int k2 = 0; k2 < 4; ++k2){
|
||||
int l2 = world.getTopSolidOrLiquidBlock(j1, k1);
|
||||
|
||||
if (!canCreatureTypeSpawnAtLocation(data, world, j1, l2, k1)){
|
||||
j1 += rand.nextInt(5) - rand.nextInt(5);
|
||||
|
||||
for (k1 += rand.nextInt(5) - rand.nextInt(5); j1 < x || j1 >= x + size || k1 < z || k1 >= z + size; k1 = i2 + rand.nextInt(5) - rand.nextInt(5))
|
||||
{
|
||||
j1 = l1 + rand.nextInt(5) - rand.nextInt(5);
|
||||
}
|
||||
}
|
||||
else if(spawnData(data, world, j1, l2, k1))
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean spawnData(SpawnData data, World world, int x, int y, int z){
|
||||
EntityLiving entityliving;
|
||||
|
||||
try{
|
||||
Entity entity = EntityList.createEntityFromNBT(data.compound1, world);
|
||||
if(entity == null || !(entity instanceof EntityLiving))
|
||||
return false;
|
||||
entityliving = (EntityLiving) entity;
|
||||
|
||||
if(entity instanceof EntityCustomNpc){
|
||||
EntityCustomNpc npc = (EntityCustomNpc) entity;
|
||||
npc.stats.spawnCycle = 3;
|
||||
npc.ai.returnToStart = false;
|
||||
npc.ai.startPos = new int[]{x,y, z};
|
||||
}
|
||||
entity.setLocationAndAngles(x + 0.5, y, z + 0.5, world.rand.nextFloat() * 360.0F, 0.0F);
|
||||
}
|
||||
catch (Exception exception){
|
||||
exception.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
Result canSpawn = ForgeEventFactory.canEntitySpawn(entityliving, world, x + 0.5f, y, z + 0.5f);
|
||||
if (canSpawn == Result.DENY || (canSpawn == Result.DEFAULT && !entityliving.getCanSpawnHere()))
|
||||
return false;
|
||||
|
||||
world.spawnEntityInWorld(entityliving);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean canCreatureTypeSpawnAtLocation(SpawnData data, World world, int x, int y, int z){
|
||||
if (data.liquid){
|
||||
return world.getBlock(x, y, z).getMaterial().isLiquid() && world.getBlock(x, y - 1, z).getMaterial().isLiquid() && !world.getBlock(x, y + 1, z).isNormalCube();
|
||||
}
|
||||
else if (!World.doesBlockHaveSolidTopSurface(world, x, y - 1, z)){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
Block block = world.getBlock(x, y - 1, z);
|
||||
boolean spawnBlock = block.canCreatureSpawn(EnumCreatureType.creature, world, x, y - 1, z);
|
||||
return spawnBlock && !world.getBlock(x, y, z).isNormalCube() && !world.getBlock(x, y, z).getMaterial().isLiquid() && !world.getBlock(x, y + 1, z).isNormalCube();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.ClipboardOwner;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class NoppesStringUtils {
|
||||
|
||||
final static int[] illegalChars = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47};
|
||||
static {
|
||||
Arrays.sort(illegalChars);
|
||||
}
|
||||
public static String cleanFileName(String badFileName) {
|
||||
StringBuilder cleanName = new StringBuilder();
|
||||
for (int i = 0; i < badFileName.length(); i++) {
|
||||
int c = (int)badFileName.charAt(i);
|
||||
if (Arrays.binarySearch(illegalChars, c) < 0) {
|
||||
cleanName.append((char)c);
|
||||
}
|
||||
}
|
||||
return cleanName.toString();
|
||||
}
|
||||
|
||||
public static String formatText(String text, Object... obs) {
|
||||
for(Object ob : obs){
|
||||
if(ob instanceof EntityPlayer){
|
||||
String username = ((EntityPlayer)ob).getDisplayName();
|
||||
text = text.replace("{player}", username);
|
||||
text = text.replace("@p", username);
|
||||
}
|
||||
else if(ob instanceof EntityNPCInterface)
|
||||
text = text.replace("@npc", ((EntityNPCInterface)ob).getCommandSenderName());
|
||||
|
||||
}
|
||||
text = text.replace("&", Character.toChars(167)[0] + "");
|
||||
return text;
|
||||
}
|
||||
|
||||
public static void setClipboardContents(String aString) {
|
||||
StringSelection stringSelection = new StringSelection(aString);
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(stringSelection, new ClipboardOwner() {
|
||||
@Override
|
||||
public void lostOwnership(Clipboard arg0, Transferable arg1) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static String getClipboardContents() {
|
||||
String result = "";
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
Transferable contents = clipboard.getContents(null);
|
||||
boolean hasTransferableText = contents != null && contents.isDataFlavorSupported(DataFlavor.stringFlavor);
|
||||
if (hasTransferableText) {
|
||||
try {
|
||||
result = (String) contents.getTransferData(DataFlavor.stringFlavor);
|
||||
} catch (UnsupportedFlavorException ex) {
|
||||
System.err.println(ex);
|
||||
ex.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
System.err.println(ex);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String translate(Object... arr) {
|
||||
String s = "";
|
||||
for(Object str : arr){
|
||||
s += StatCollector.translateToLocal(str.toString());
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,379 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import noppes.npcs.constants.EnumOptionType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumPlayerPacket;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.containers.ContainerNPCBankInterface;
|
||||
import noppes.npcs.containers.ContainerNPCFollower;
|
||||
import noppes.npcs.containers.ContainerNPCFollowerHire;
|
||||
import noppes.npcs.controllers.Bank;
|
||||
import noppes.npcs.controllers.BankController;
|
||||
import noppes.npcs.controllers.BankData;
|
||||
import noppes.npcs.controllers.Dialog;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.DialogOption;
|
||||
import noppes.npcs.controllers.Line;
|
||||
import noppes.npcs.controllers.PlayerBankData;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.PlayerQuestController;
|
||||
import noppes.npcs.controllers.PlayerQuestData;
|
||||
import noppes.npcs.controllers.PlayerTransportData;
|
||||
import noppes.npcs.controllers.QuestData;
|
||||
import noppes.npcs.controllers.TransportController;
|
||||
import noppes.npcs.controllers.TransportLocation;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleFollower;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
|
||||
public class NoppesUtilPlayer {
|
||||
|
||||
public static void changeFollowerState(EntityPlayerMP player, EntityNPCInterface npc) {
|
||||
if(npc.advanced.role != EnumRoleType.Follower)
|
||||
return;
|
||||
|
||||
RoleFollower role = (RoleFollower) npc.roleInterface;
|
||||
EntityPlayer owner = role.owner;
|
||||
if(owner == null || !owner.getCommandSenderName().equals(player.getCommandSenderName()))
|
||||
return;
|
||||
|
||||
role.isFollowing = !role.isFollowing;
|
||||
}
|
||||
public static void hireFollower(EntityPlayerMP player, EntityNPCInterface npc) {
|
||||
if(npc.advanced.role != EnumRoleType.Follower)
|
||||
return;
|
||||
Container con = player.openContainer;
|
||||
if(con == null || !(con instanceof ContainerNPCFollowerHire))
|
||||
return;
|
||||
|
||||
ContainerNPCFollowerHire container = (ContainerNPCFollowerHire) con;
|
||||
RoleFollower role = (RoleFollower) npc.roleInterface;
|
||||
followerBuy(role, container.currencyMatrix, player, npc);
|
||||
}
|
||||
public static void extendFollower(EntityPlayerMP player, EntityNPCInterface npc) {
|
||||
if(npc.advanced.role != EnumRoleType.Follower)
|
||||
return;
|
||||
Container con = player.openContainer;
|
||||
if(con == null || !(con instanceof ContainerNPCFollower))
|
||||
return;
|
||||
|
||||
ContainerNPCFollower container = (ContainerNPCFollower) con;
|
||||
RoleFollower role = (RoleFollower) npc.roleInterface;
|
||||
followerBuy(role, container.currencyMatrix, player, npc);
|
||||
}
|
||||
public static void transport(EntityPlayerMP player, EntityNPCInterface npc, String location){
|
||||
TransportLocation loc = TransportController.getInstance().getTransport(location);
|
||||
PlayerTransportData playerdata = PlayerDataController.instance.getPlayerData(player).transportData;
|
||||
|
||||
if(loc == null || !loc.isDefault() && !playerdata.transports.contains(loc.id))
|
||||
return;
|
||||
|
||||
teleportPlayer(player, loc.posX, loc.posY, loc.posZ, loc.dimension);
|
||||
}
|
||||
|
||||
public static void teleportPlayer(EntityPlayerMP player, double posX, double posY, double posZ, int dimension){
|
||||
if(player.dimension != dimension){
|
||||
int dim = player.dimension;
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
WorldServer wor = server.worldServerForDimension(dimension);
|
||||
if(wor == null){
|
||||
player.addChatMessage(new ChatComponentText("Broken transporter. Dimenion does not exist"));
|
||||
return;
|
||||
}
|
||||
player.setLocationAndAngles(posX, posY, posZ, player.rotationYaw, player.rotationPitch);
|
||||
server.getConfigurationManager().transferPlayerToDimension(player, dimension, new CustomTeleporter(wor));
|
||||
player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, player.rotationYaw, player.rotationPitch);
|
||||
|
||||
if(!wor.playerEntities.contains(player))
|
||||
wor.spawnEntityInWorld(player);
|
||||
}
|
||||
else{
|
||||
player.playerNetServerHandler.setPlayerLocation(posX, posY, posZ, player.rotationYaw, player.rotationPitch);
|
||||
}
|
||||
player.worldObj.updateEntityWithOptionalForce(player, false);
|
||||
}
|
||||
|
||||
private static void followerBuy(RoleFollower role,IInventory currencyInv,EntityPlayerMP player, EntityNPCInterface npc){
|
||||
ItemStack currency = currencyInv.getStackInSlot(0);
|
||||
if(currency == null)
|
||||
return;
|
||||
HashMap<ItemStack,Integer> cd = new HashMap<ItemStack,Integer>();
|
||||
for(int i : role.inventory.items.keySet()){
|
||||
ItemStack is = role.inventory.items.get(i);
|
||||
if(is == null || is.getItem() != currency.getItem() || is.getHasSubtypes() && is.getItemDamage() != currency.getItemDamage())
|
||||
continue;
|
||||
int days = 1;
|
||||
if(role.rates.containsKey(i))
|
||||
days = role.rates.get(i);
|
||||
|
||||
cd.put(is,days);
|
||||
}
|
||||
if(cd.size() == 0)
|
||||
return;
|
||||
int stackSize = currency.stackSize;
|
||||
int days = 0;
|
||||
|
||||
int possibleDays = 0;
|
||||
int possibleSize = stackSize;
|
||||
while(true){
|
||||
for(ItemStack item : cd.keySet()){
|
||||
int rDays = cd.get(item);
|
||||
int rValue = item.stackSize;
|
||||
if(rValue > stackSize)
|
||||
continue;
|
||||
int newStackSize = stackSize % rValue;
|
||||
int size = stackSize - newStackSize;
|
||||
int posDays = (size / rValue) * rDays;
|
||||
if(possibleDays <= posDays){
|
||||
possibleDays = posDays;
|
||||
possibleSize = newStackSize;
|
||||
}
|
||||
}
|
||||
if(stackSize == possibleSize)
|
||||
break;
|
||||
stackSize = possibleSize;
|
||||
days += possibleDays;
|
||||
possibleDays = 0;
|
||||
}
|
||||
if(days == 0)
|
||||
return;
|
||||
if(stackSize <= 0)
|
||||
currencyInv.setInventorySlotContents(0, null);
|
||||
else
|
||||
currency = currency.splitStack(stackSize);
|
||||
|
||||
npc.say(player, new Line(NoppesStringUtils.formatText(role.dialogHire.replace("{days}", days+""), player, npc)));
|
||||
role.setOwner(player);
|
||||
role.addDays(days);
|
||||
}
|
||||
|
||||
public static void bankUpgrade(EntityPlayerMP player, EntityNPCInterface npc) {
|
||||
if(npc.advanced.role != EnumRoleType.Bank)
|
||||
return;
|
||||
Container con = player.openContainer;
|
||||
if(con == null || !(con instanceof ContainerNPCBankInterface))
|
||||
return;
|
||||
|
||||
ContainerNPCBankInterface container = (ContainerNPCBankInterface) con;
|
||||
Bank bank = BankController.getInstance().getBank(container.bankid);
|
||||
ItemStack item = bank.upgradeInventory.getStackInSlot(container.slot);
|
||||
if(item == null)
|
||||
return;
|
||||
|
||||
int price = item.stackSize;
|
||||
ItemStack currency = container.currencyMatrix.getStackInSlot(0);
|
||||
if(currency == null || price > currency.stackSize)
|
||||
return;
|
||||
if(currency.stackSize - price == 0)
|
||||
container.currencyMatrix.setInventorySlotContents(0, null);
|
||||
else
|
||||
currency = currency.splitStack(price);
|
||||
player.closeContainer();
|
||||
PlayerBankData data = PlayerDataController.instance.getBankData(player,bank.id);
|
||||
BankData bankData = data.getBank(bank.id);
|
||||
bankData.upgradedSlots.put(container.slot, true);
|
||||
|
||||
bankData.openBankGui(player, npc, bank.id, container.slot);
|
||||
}
|
||||
public static void bankUnlock(EntityPlayerMP player, EntityNPCInterface npc) {
|
||||
if(npc.advanced.role != EnumRoleType.Bank)
|
||||
return;
|
||||
Container con = player.openContainer;
|
||||
if(con == null || !(con instanceof ContainerNPCBankInterface))
|
||||
return;
|
||||
ContainerNPCBankInterface container = (ContainerNPCBankInterface) con;
|
||||
Bank bank = BankController.getInstance().getBank(container.bankid);
|
||||
|
||||
ItemStack item = bank.currencyInventory.getStackInSlot(container.slot);
|
||||
if(item == null)
|
||||
return;
|
||||
|
||||
int price = item.stackSize;
|
||||
ItemStack currency = container.currencyMatrix.getStackInSlot(0);
|
||||
if(currency == null || price > currency.stackSize)
|
||||
return;
|
||||
if(currency.stackSize - price == 0)
|
||||
container.currencyMatrix.setInventorySlotContents(0, null);
|
||||
else
|
||||
currency = currency.splitStack(price);
|
||||
player.closeContainer();
|
||||
PlayerBankData data = PlayerDataController.instance.getBankData(player,bank.id);
|
||||
BankData bankData = data.getBank(bank.id);
|
||||
if(bankData.unlockedSlots + 1 <= bank.maxSlots)
|
||||
bankData.unlockedSlots++;
|
||||
|
||||
bankData.openBankGui(player, npc, bank.id, container.slot);
|
||||
}
|
||||
public static void sendData(EnumPlayerPacket enu, Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!Server.fillBuffer(buffer, enu, obs))
|
||||
return;
|
||||
CustomNpcs.ChannelPlayer.sendToServer(new FMLProxyPacket(buffer,"CustomNPCsPlayer"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void dialogSelected(int dialogId, int optionId, EntityPlayerMP player, EntityNPCInterface npc) {
|
||||
Dialog dialog = DialogController.instance.dialogs.get(dialogId);
|
||||
if(dialog == null)
|
||||
return;
|
||||
npc.script.callScript(EnumScriptType.DIALOG_OPTION, "player", player, "dialog", dialogId, "option", optionId + 1);
|
||||
|
||||
if(!dialog.hasDialogs(player) && !dialog.hasOtherOptions())
|
||||
return;
|
||||
DialogOption option = dialog.options.get(optionId);
|
||||
if(option == null || option.optionType == EnumOptionType.DialogOption && (!option.isAvailable(player) || !option.hasDialog()) || option.optionType == EnumOptionType.Disabled || option.optionType == EnumOptionType.QuitOption)
|
||||
return;
|
||||
if(option.optionType == EnumOptionType.RoleOption){
|
||||
if(npc.roleInterface != null)
|
||||
npc.roleInterface.interact(player);
|
||||
else
|
||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
||||
}
|
||||
else if(option.optionType == EnumOptionType.DialogOption){
|
||||
NoppesUtilServer.openDialog(player, npc, option.getDialog());
|
||||
}
|
||||
else if(option.optionType == EnumOptionType.CommandBlock){
|
||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
||||
NoppesUtilServer.runCommand(player, npc.getCommandSenderName(), option.command);
|
||||
}
|
||||
else
|
||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE);
|
||||
}
|
||||
public static void sendQuestLogData(EntityPlayerMP player) {
|
||||
if(!PlayerQuestController.hasActiveQuests(player)){
|
||||
return;
|
||||
}
|
||||
QuestLogData data = new QuestLogData();
|
||||
data.setData(player);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.writeNBT());
|
||||
}
|
||||
public static void questCompletion(EntityPlayerMP player, int questId) {
|
||||
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
QuestData data = playerdata.activeQuests.get(questId);
|
||||
if(data == null)
|
||||
return;
|
||||
|
||||
if(!data.quest.questInterface.isCompleted(player))
|
||||
return;
|
||||
|
||||
|
||||
data.quest.questInterface.handleComplete(player);
|
||||
if(data.quest.rewardExp > 0){
|
||||
player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 0.5F * ((player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.7F + 1.8F));
|
||||
|
||||
player.addExperience(data.quest.rewardExp);
|
||||
}
|
||||
data.quest.factionOptions.addPoints(player);
|
||||
if(data.quest.mail.isValid()){
|
||||
PlayerDataController.instance.addPlayerMessage(player.getCommandSenderName(), data.quest.mail);
|
||||
}
|
||||
if(!data.quest.randomReward){
|
||||
for(ItemStack item : data.quest.rewardItems.items.values()){
|
||||
NoppesUtilServer.GivePlayerItem(player, player, item);
|
||||
}
|
||||
}
|
||||
else{
|
||||
List<ItemStack> list = new ArrayList<ItemStack>();
|
||||
for(ItemStack item : data.quest.rewardItems.items.values()){
|
||||
if(item != null && item.getItem() != null)
|
||||
list.add(item);
|
||||
}
|
||||
if(!list.isEmpty()){
|
||||
NoppesUtilServer.GivePlayerItem(player, player, list.get(player.getRNG().nextInt(list.size())));
|
||||
}
|
||||
}
|
||||
if(!data.quest.command.isEmpty()){
|
||||
NoppesUtilServer.runCommand(player, "QuestCompletion", data.quest.command);
|
||||
}
|
||||
PlayerQuestController.setQuestFinished(data.quest, player);
|
||||
if(data.quest.hasNewQuest()) PlayerQuestController.addActiveQuest(data.quest.getNextQuest(), player);
|
||||
}
|
||||
|
||||
public static boolean compareItems(ItemStack item, ItemStack item2, boolean ignoreDamage, boolean ignoreNBT){
|
||||
if (item2 == null || item == null){
|
||||
return false;
|
||||
}
|
||||
boolean oreMatched = false;
|
||||
OreDictionary.itemMatches(item, item2, false);
|
||||
int[] ids = OreDictionary.getOreIDs(item);
|
||||
if(ids.length > 0){
|
||||
for(int id : ids){
|
||||
boolean match1 = false, match2 = false;
|
||||
for(ItemStack is : OreDictionary.getOres(id)){
|
||||
if(compareItemDetails(item, is, ignoreDamage, ignoreNBT)){
|
||||
match1 = true;
|
||||
}
|
||||
if(compareItemDetails(item2, is, ignoreDamage, ignoreNBT)){
|
||||
match2 = true;
|
||||
}
|
||||
}
|
||||
if(match1 && match2)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return compareItemDetails(item, item2, ignoreDamage, ignoreNBT);
|
||||
}
|
||||
private static boolean compareItemDetails(ItemStack item, ItemStack item2, boolean ignoreDamage, boolean ignoreNBT){
|
||||
if (item.getItem() != item2.getItem() ){
|
||||
return false;
|
||||
}
|
||||
if (!ignoreDamage && item.getItemDamage() != -1 && item.getItemDamage() != item2.getItemDamage()){
|
||||
return false;
|
||||
}
|
||||
if(!ignoreNBT && item.stackTagCompound != null && (item2.stackTagCompound == null || !item.stackTagCompound.equals(item2.stackTagCompound))){
|
||||
return false;
|
||||
}
|
||||
if(!ignoreNBT && item2.stackTagCompound != null && item.stackTagCompound == null){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static boolean compareItems(EntityPlayer player, ItemStack item, boolean ignoreDamage, boolean ignoreNBT){
|
||||
int size = 0;
|
||||
for(ItemStack is : player.inventory.mainInventory){
|
||||
if(is != null && compareItems(item, is, ignoreDamage, ignoreNBT))
|
||||
size += is.stackSize;
|
||||
}
|
||||
return size >= item.stackSize;
|
||||
}
|
||||
public static void consumeItem(EntityPlayer player, ItemStack item, boolean ignoreDamage, boolean ignoreNBT) {
|
||||
if(item == null)
|
||||
return;
|
||||
int size = item.stackSize;
|
||||
for(int i = 0; i < player.inventory.mainInventory.length; i++){
|
||||
ItemStack is = player.inventory.mainInventory[i];
|
||||
if(is == null || !compareItems(item, is, ignoreDamage, ignoreNBT))
|
||||
continue;
|
||||
if(size >= is.stackSize){
|
||||
size -= is.stackSize;
|
||||
player.inventory.mainInventory[i] = null;
|
||||
}
|
||||
else{
|
||||
player.inventory.mainInventory[i].splitStack(size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,661 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import net.minecraft.command.server.CommandBlockLogic;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.MobSpawnerBaseLogic;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityCommandBlock;
|
||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumPlayerData;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.containers.ContainerManageBanks;
|
||||
import noppes.npcs.containers.ContainerManageRecipes;
|
||||
import noppes.npcs.controllers.Bank;
|
||||
import noppes.npcs.controllers.BankController;
|
||||
import noppes.npcs.controllers.Dialog;
|
||||
import noppes.npcs.controllers.DialogCategory;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.DialogOption;
|
||||
import noppes.npcs.controllers.Faction;
|
||||
import noppes.npcs.controllers.FactionController;
|
||||
import noppes.npcs.controllers.PlayerBankData;
|
||||
import noppes.npcs.controllers.PlayerData;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.PlayerDialogData;
|
||||
import noppes.npcs.controllers.PlayerFactionData;
|
||||
import noppes.npcs.controllers.PlayerQuestController;
|
||||
import noppes.npcs.controllers.PlayerQuestData;
|
||||
import noppes.npcs.controllers.PlayerTransportData;
|
||||
import noppes.npcs.controllers.Quest;
|
||||
import noppes.npcs.controllers.QuestCategory;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.RecipeCarpentry;
|
||||
import noppes.npcs.controllers.RecipeController;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.controllers.TransportCategory;
|
||||
import noppes.npcs.controllers.TransportController;
|
||||
import noppes.npcs.controllers.TransportLocation;
|
||||
import noppes.npcs.entity.EntityDialogNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleTransporter;
|
||||
import noppes.npcs.scripted.ScriptEventDialog;
|
||||
|
||||
public class NoppesUtilServer {
|
||||
private static HashMap<String,Quest> editingQuests = new HashMap<String,Quest>();
|
||||
|
||||
public static void setEditingNpc(EntityPlayer player, EntityNPCInterface npc){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
data.editingNpc = npc;
|
||||
if(npc != null)
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.EDIT_NPC, npc.getEntityId());
|
||||
}
|
||||
public static EntityNPCInterface getEditingNpc(EntityPlayer player){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
return data.editingNpc;
|
||||
}
|
||||
|
||||
public static void setEditingQuest(EntityPlayer player, Quest quest) {
|
||||
editingQuests.put(player.getCommandSenderName(), quest);
|
||||
}
|
||||
public static Quest getEditingQuest(EntityPlayer player){
|
||||
return editingQuests.get(player.getCommandSenderName());
|
||||
}
|
||||
|
||||
public static void sendRoleData(EntityPlayer player, EntityNPCInterface npc){
|
||||
if(npc.advanced.role == EnumRoleType.None)
|
||||
return;
|
||||
NBTTagCompound comp = new NBTTagCompound();
|
||||
npc.roleInterface.writeToNBT(comp);
|
||||
comp.setInteger("EntityId", npc.getEntityId());
|
||||
comp.setInteger("Role", npc.advanced.role.ordinal());
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.ROLE, comp);
|
||||
}
|
||||
|
||||
public static void sendFactionDataAll(EntityPlayerMP player) {
|
||||
Map<String,Integer> map = new HashMap<String,Integer>();
|
||||
for(Faction faction : FactionController.getInstance().factions.values()){
|
||||
map.put(faction.name, faction.id);
|
||||
}
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
|
||||
public static void sendBankDataAll(EntityPlayerMP player) {
|
||||
Map<String,Integer> map = new HashMap<String,Integer>();
|
||||
for(Bank bank : BankController.getInstance().banks.values()){
|
||||
map.put(bank.name, bank.id);
|
||||
}
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
|
||||
public static NBTTagCompound writeItem(ItemStack item, NBTTagCompound nbt){
|
||||
String resourcelocation = Item.itemRegistry.getNameForObject(item.getItem());
|
||||
nbt.setString("id", resourcelocation == null ? "minecraft:air" : resourcelocation.toString());
|
||||
nbt.setByte("Count", (byte)item.stackSize);
|
||||
nbt.setShort("Damage", (short)item.getItemDamage());
|
||||
|
||||
if (item.stackTagCompound != null){
|
||||
nbt.setTag("tag", item.stackTagCompound);
|
||||
}
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public static ItemStack readItem(NBTTagCompound nbt){
|
||||
Item item;
|
||||
if (nbt.hasKey("id", 8)){
|
||||
item = getByNameOrId(nbt.getString("id"));
|
||||
}
|
||||
else{
|
||||
item = Item.getItemById(nbt.getShort("id"));
|
||||
}
|
||||
if(item == null)
|
||||
return null;
|
||||
ItemStack itemstack = new ItemStack(item);
|
||||
|
||||
itemstack.stackSize = nbt.getByte("Count");
|
||||
itemstack.setItemDamage(nbt.getShort("Damage"));
|
||||
|
||||
if (itemstack.getItemDamage() < 0){
|
||||
itemstack.setItemDamage(0);
|
||||
}
|
||||
|
||||
if (nbt.hasKey("tag", 10)){
|
||||
itemstack.stackTagCompound = nbt.getCompoundTag("tag");
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
public static Item getByNameOrId(String id)
|
||||
{
|
||||
Item item = (Item)Item.itemRegistry.getObject(id);
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Item.getItemById(Integer.parseInt(id));
|
||||
}
|
||||
catch (NumberFormatException numberformatexception)
|
||||
{
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia){
|
||||
Dialog dialog = dia.copy(player);
|
||||
if(npc instanceof EntityDialogNpc){
|
||||
dialog.hideNPC = true;
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG_DUMMY, npc.getCommandSenderName(), dialog.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.DIALOG, npc.getEntityId(), dialog.writeToNBT(new NBTTagCompound()));
|
||||
dia.factionOptions.addPoints(player);
|
||||
if(dialog.hasQuest())
|
||||
PlayerQuestController.addActiveQuest(dialog.getQuest(),player);
|
||||
if(!dialog.command.isEmpty()){
|
||||
runCommand(player, npc.getCommandSenderName(), dialog.command);
|
||||
}
|
||||
if(dialog.mail.isValid())
|
||||
PlayerDataController.instance.addPlayerMessage(player.getCommandSenderName(), dialog.mail);
|
||||
PlayerDialogData data = PlayerDataController.instance.getPlayerData(player).dialogData;
|
||||
if(!data.dialogsRead.contains(dialog.id))
|
||||
data.dialogsRead.add(dialog.id);
|
||||
setEditingNpc(player, npc);
|
||||
npc.script.callScript(EnumScriptType.DIALOG, "event", new ScriptEventDialog(), "player", player, "dialog", dialog.id);
|
||||
}
|
||||
public static void runCommand(EntityPlayer player, String name, String command){
|
||||
runCommand(player, name, command, player);
|
||||
}
|
||||
|
||||
public static void runCommand(EntityLivingBase executer, String name, String command, EntityPlayer player){
|
||||
if(player != null)
|
||||
command = command.replace("@dp", player.getCommandSenderName());
|
||||
command = command.replace("@npc", name);
|
||||
TileEntityCommandBlock tile = new TileEntityCommandBlock();
|
||||
tile.setWorldObj(executer.worldObj);
|
||||
tile.xCoord = MathHelper.floor_double(executer.posX);
|
||||
tile.yCoord = MathHelper.floor_double(executer.posY);
|
||||
tile.zCoord = MathHelper.floor_double(executer.posZ);
|
||||
|
||||
CommandBlockLogic logic = tile.func_145993_a();
|
||||
logic.func_145752_a(command);
|
||||
logic.func_145754_b("@"+name);
|
||||
logic.func_145755_a(executer.worldObj);
|
||||
}
|
||||
|
||||
public static void consumeItemStack(int i, EntityPlayer player){
|
||||
ItemStack item = player.inventory.getCurrentItem();
|
||||
if(player.capabilities.isCreativeMode || item == null)
|
||||
return;
|
||||
|
||||
--item.stackSize;
|
||||
if (item.stackSize <= 0)
|
||||
player.destroyCurrentEquippedItem();
|
||||
}
|
||||
|
||||
public static DataOutputStream getDataOutputStream(ByteArrayOutputStream stream) throws IOException{
|
||||
return new DataOutputStream(new GZIPOutputStream(stream));
|
||||
}
|
||||
public static void sendOpenGui(EntityPlayer player,
|
||||
EnumGuiType gui, EntityNPCInterface npc) {
|
||||
sendOpenGui(player, gui, npc, 0, 0, 0);
|
||||
}
|
||||
public static void sendOpenGui(EntityPlayer player,
|
||||
EnumGuiType gui, EntityNPCInterface npc, int i, int j, int k) {
|
||||
if(!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
setEditingNpc(player, npc);
|
||||
sendExtraData(player, npc,gui, i, j, k);
|
||||
if(CustomNpcs.proxy.getServerGuiElement(gui.ordinal(), player, player.worldObj, i, j, k) != null){
|
||||
player.openGui(CustomNpcs.instance, gui.ordinal(), player.worldObj, i, j, k);
|
||||
return;
|
||||
}
|
||||
else{
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI, gui.ordinal(), i, j, k);
|
||||
}
|
||||
ArrayList<String> list = getScrollData(player, gui, npc);
|
||||
if(list == null || list.isEmpty())
|
||||
return;
|
||||
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SCROLL_LIST, list);
|
||||
}
|
||||
|
||||
|
||||
private static void sendExtraData(EntityPlayer player, EntityNPCInterface npc, EnumGuiType gui, int i, int j, int k) {
|
||||
if(gui == EnumGuiType.PlayerFollower || gui == EnumGuiType.PlayerFollowerHire || gui == EnumGuiType.PlayerTrader || gui == EnumGuiType.PlayerTransporter){
|
||||
sendRoleData(player, npc);
|
||||
}
|
||||
}
|
||||
|
||||
private static ArrayList<String> getScrollData(EntityPlayer player, EnumGuiType gui, EntityNPCInterface npc) {
|
||||
if(gui == EnumGuiType.PlayerTransporter){
|
||||
RoleTransporter role = (RoleTransporter) npc.roleInterface;
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
TransportLocation location = role.getLocation();
|
||||
String name = role.getLocation().name;
|
||||
for(TransportLocation loc: location.category.getDefaultLocations()){
|
||||
if(!list.contains(loc.name)){
|
||||
list.add(loc.name);
|
||||
}
|
||||
}
|
||||
PlayerTransportData playerdata = PlayerDataController.instance.getPlayerData(player).transportData;
|
||||
for(int i : playerdata.transports){
|
||||
TransportLocation loc = TransportController.getInstance().getTransport(i);
|
||||
if(loc != null && location.category.locations.containsKey(loc.id)){
|
||||
if(!list.contains(loc.name)){
|
||||
list.add(loc.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.remove(name);
|
||||
return list;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static void spawnParticle(Entity entity,String particle,int dimension){
|
||||
Server.sendAssociatedData(entity, EnumPacketClient.PARTICLE, entity.posX, entity.posY, entity.posZ, entity.height, entity.width, entity.yOffset, particle);
|
||||
}
|
||||
|
||||
|
||||
public static void deleteNpc(EntityNPCInterface npc,EntityPlayer player) {
|
||||
Server.sendAssociatedData(npc, EnumPacketClient.DELETE_NPC, npc.getEntityId());
|
||||
}
|
||||
|
||||
public static void createMobSpawner(int x, int y, int z, NBTTagCompound comp, EntityPlayer player) {
|
||||
comp.removeTag("Pos");
|
||||
ServerCloneController.Instance.cleanTags(comp);
|
||||
|
||||
if(comp.getString("id").equalsIgnoreCase("entityhorse")){
|
||||
player.addChatMessage(new ChatComponentTranslation("Currently you cant create horse spawner, its a minecraft bug"));
|
||||
return;
|
||||
}
|
||||
|
||||
player.worldObj.setBlock(x, y, z, Blocks.mob_spawner); //setBlock
|
||||
TileEntityMobSpawner tile = (TileEntityMobSpawner) player.worldObj.getTileEntity(x, y, z);
|
||||
MobSpawnerBaseLogic logic = tile.func_145881_a();
|
||||
|
||||
logic.setRandomEntity(logic.new WeightedRandomMinecart(comp, comp.getString("id")));
|
||||
}
|
||||
|
||||
public static void sendQuestCategoryData(EntityPlayerMP player) {
|
||||
Map<String,Integer> map = new HashMap<String,Integer>();
|
||||
for(QuestCategory category : QuestController.instance.categories.values()){
|
||||
map.put(category.title, category.id);
|
||||
}
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
|
||||
public static void sendPlayerData(EnumPlayerData type, EntityPlayerMP player, String name) throws IOException {
|
||||
Map<String,Integer> map = new HashMap<String,Integer>();
|
||||
|
||||
if(type == EnumPlayerData.Players){
|
||||
File loc = PlayerDataController.instance.getSaveDir();
|
||||
for(String username : PlayerDataController.instance.getUsernameData().keySet()){
|
||||
map.put(username, 0);
|
||||
}
|
||||
}
|
||||
else{
|
||||
PlayerData playerdata = PlayerDataController.instance.getDataFromUsername(name);
|
||||
if(type == EnumPlayerData.Dialog){
|
||||
PlayerDialogData data = playerdata.dialogData;
|
||||
|
||||
for(int questId : data.dialogsRead){
|
||||
Dialog dialog = DialogController.instance.dialogs.get(questId);
|
||||
if(dialog == null)
|
||||
continue;
|
||||
map.put(dialog.category.title + ": " + dialog.title,questId);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPlayerData.Quest){
|
||||
PlayerQuestData data = playerdata.questData;
|
||||
|
||||
for(int questId : data.activeQuests.keySet()){
|
||||
Quest quest = QuestController.instance.quests.get(questId);
|
||||
if(quest == null)
|
||||
continue;
|
||||
map.put(quest.category.title + ": " + quest.title + "(Active quest)",questId);
|
||||
}
|
||||
for(int questId : data.finishedQuests.keySet()){
|
||||
Quest quest = QuestController.instance.quests.get(questId);
|
||||
if(quest == null)
|
||||
continue;
|
||||
map.put(quest.category.title + ": " + quest.title + "(Finished quest)",questId);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPlayerData.Transport){
|
||||
PlayerTransportData data = playerdata.transportData;
|
||||
|
||||
for(int questId : data.transports){
|
||||
TransportLocation location = TransportController.getInstance().getTransport(questId);
|
||||
if(location == null)
|
||||
continue;
|
||||
map.put(location.category.title + ": " + location.name,questId);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPlayerData.Bank){
|
||||
PlayerBankData data = playerdata.bankData;
|
||||
|
||||
for(int bankId : data.banks.keySet()){
|
||||
Bank bank = BankController.getInstance().banks.get(bankId);
|
||||
if(bank == null)
|
||||
continue;
|
||||
map.put(bank.name,bankId);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPlayerData.Factions){
|
||||
PlayerFactionData data = playerdata.factionData;
|
||||
for(int factionId : data.factionData.keySet()){
|
||||
Faction faction = FactionController.getInstance().factions.get(factionId);
|
||||
if(faction == null)
|
||||
continue;
|
||||
map.put(faction.name + "(" + data.getFactionPoints(factionId) + ")" ,factionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NoppesUtilServer.sendScrollData(player, map);
|
||||
}
|
||||
|
||||
public static void removePlayerData(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
int id = buffer.readInt();
|
||||
if(EnumPlayerData.values().length <= id)
|
||||
return;
|
||||
String name = Server.readString(buffer);
|
||||
EnumPlayerData type = EnumPlayerData.values()[id];
|
||||
EntityPlayer pl = MinecraftServer.getServer().getConfigurationManager().func_152612_a(name);
|
||||
PlayerData playerdata = null;
|
||||
if(pl == null)
|
||||
playerdata = PlayerDataController.instance.getDataFromUsername(name);
|
||||
else
|
||||
playerdata = PlayerDataController.instance.getPlayerData(pl);
|
||||
|
||||
if(type == EnumPlayerData.Players){
|
||||
File file = new File(PlayerDataController.instance.getSaveDir(), playerdata.uuid + ".json");
|
||||
if(file.exists())
|
||||
file.delete();
|
||||
if(pl != null){
|
||||
playerdata.setNBT(new NBTTagCompound());
|
||||
sendPlayerData(type, player, name);
|
||||
playerdata.saveNBTData(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(type == EnumPlayerData.Quest){
|
||||
PlayerQuestData data = playerdata.questData;
|
||||
int questId = buffer.readInt();
|
||||
data.activeQuests.remove(questId);
|
||||
data.finishedQuests.remove(questId);
|
||||
playerdata.saveNBTData(null);
|
||||
}
|
||||
if(type == EnumPlayerData.Dialog){
|
||||
PlayerDialogData data = playerdata.dialogData;
|
||||
data.dialogsRead.remove(buffer.readInt());
|
||||
playerdata.saveNBTData(null);
|
||||
}
|
||||
if(type == EnumPlayerData.Transport){
|
||||
PlayerTransportData data = playerdata.transportData;
|
||||
data.transports.remove(buffer.readInt());
|
||||
playerdata.saveNBTData(null);
|
||||
}
|
||||
if(type == EnumPlayerData.Bank){
|
||||
PlayerBankData data = playerdata.bankData;
|
||||
data.banks.remove(buffer.readInt());
|
||||
playerdata.saveNBTData(null);
|
||||
}
|
||||
if(type == EnumPlayerData.Factions){
|
||||
PlayerFactionData data = playerdata.factionData;
|
||||
data.factionData.remove(buffer.readInt());
|
||||
playerdata.saveNBTData(null);
|
||||
}
|
||||
sendPlayerData(type, player, name);
|
||||
}
|
||||
|
||||
public static void sendRecipeData(EntityPlayerMP player, int size) {
|
||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||
if(size == 3){
|
||||
for(RecipeCarpentry recipe : RecipeController.instance.globalRecipes.values()){
|
||||
map.put(recipe.name, recipe.id);
|
||||
}
|
||||
}
|
||||
else{
|
||||
for(RecipeCarpentry recipe : RecipeController.instance.anvilRecipes.values()){
|
||||
map.put(recipe.name, recipe.id);
|
||||
}
|
||||
}
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
public static void sendScrollData(EntityPlayerMP player, Map<String,Integer> map){
|
||||
Map<String, Integer> send = new HashMap<String, Integer>();
|
||||
for(String key : map.keySet()){
|
||||
send.put(key, map.get(key));
|
||||
if(send.size() == 100){
|
||||
Server.sendData(player, EnumPacketClient.SCROLL_DATA_PART, send);
|
||||
send = new HashMap<String, Integer>();
|
||||
}
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.SCROLL_DATA, send);
|
||||
}
|
||||
|
||||
public static void sendDialogData(EntityPlayerMP player, DialogCategory category) {
|
||||
if(category == null)
|
||||
return;
|
||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||
for(Dialog dialog : category.dialogs.values()){
|
||||
map.put(dialog.title, dialog.id);
|
||||
}
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
|
||||
public static void sendQuestData(EntityPlayerMP player, QuestCategory category) {
|
||||
if(category == null)
|
||||
return;
|
||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||
for(Quest quest : category.quests.values()){
|
||||
map.put(quest.title, quest.id);
|
||||
}
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
|
||||
public static void sendTransportCategoryData(EntityPlayerMP player) {
|
||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||
for(TransportCategory category : TransportController.getInstance().categories.values()){
|
||||
map.put(category.title, category.id);
|
||||
}
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
|
||||
public static void sendTransportData(EntityPlayerMP player, int categoryid) {
|
||||
TransportCategory category = TransportController.getInstance().categories.get(categoryid);
|
||||
if(category == null)
|
||||
return;
|
||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||
for(TransportLocation transport : category.locations.values()){
|
||||
map.put(transport.name, transport.id);
|
||||
}
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
|
||||
|
||||
public static void sendNpcDialogs(EntityPlayer player) {
|
||||
EntityNPCInterface npc = getEditingNpc(player);
|
||||
if(npc == null)
|
||||
return;
|
||||
for(int pos : npc.dialogs.keySet()){
|
||||
DialogOption option = npc.dialogs.get(pos);
|
||||
if(option == null || !option.hasDialog())
|
||||
continue;
|
||||
|
||||
NBTTagCompound compound = option.writeNBT();
|
||||
compound.setInteger("Position", pos);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_DATA, compound);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static DialogOption setNpcDialog(int slot, int dialogId, EntityPlayer player) throws IOException {
|
||||
EntityNPCInterface npc = getEditingNpc(player);
|
||||
if(npc == null)
|
||||
return null;
|
||||
if(!npc.dialogs.containsKey(slot))
|
||||
npc.dialogs.put(slot, new DialogOption());
|
||||
|
||||
DialogOption option = npc.dialogs.get(slot);
|
||||
option.dialogId = dialogId;
|
||||
if(option.hasDialog())
|
||||
option.title = option.getDialog().title;
|
||||
|
||||
return option;
|
||||
}
|
||||
|
||||
public static void saveTileEntity(EntityPlayerMP player, NBTTagCompound compound){
|
||||
int x = compound.getInteger("x");
|
||||
int y = compound.getInteger("y");
|
||||
int z = compound.getInteger("z");
|
||||
|
||||
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
|
||||
if(tile != null)
|
||||
tile.readFromNBT(compound);
|
||||
|
||||
}
|
||||
|
||||
public static void setRecipeGui(EntityPlayerMP player, RecipeCarpentry recipe){
|
||||
if(recipe == null)
|
||||
return;
|
||||
if(!(player.openContainer instanceof ContainerManageRecipes))
|
||||
return;
|
||||
|
||||
ContainerManageRecipes container = (ContainerManageRecipes) player.openContainer;
|
||||
container.setRecipe(recipe);
|
||||
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, recipe.writeNBT());
|
||||
}
|
||||
|
||||
public static void sendBank(EntityPlayerMP player,Bank bank) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
bank.writeEntityToNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
|
||||
if(player.openContainer instanceof ContainerManageBanks){
|
||||
((ContainerManageBanks)player.openContainer).setBank(bank);
|
||||
}
|
||||
player.sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory());
|
||||
}
|
||||
|
||||
public static void sendNearbyNpcs(EntityPlayerMP player) {
|
||||
List<EntityNPCInterface> npcs = player.worldObj.getEntitiesWithinAABB(EntityNPCInterface.class, player.boundingBox.expand(120, 120, 120));
|
||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||
for(EntityNPCInterface npc : npcs){
|
||||
if(npc.isDead)
|
||||
continue;
|
||||
float distance = player.getDistanceToEntity(npc);
|
||||
DecimalFormat df = new DecimalFormat("#.#");
|
||||
String s = df.format(distance);
|
||||
if(distance < 10)
|
||||
s = "0" + s;
|
||||
map.put(s + " : " + npc.display.name, npc.getEntityId());
|
||||
}
|
||||
|
||||
sendScrollData(player, map);
|
||||
}
|
||||
|
||||
public static void sendGuiError(EntityPlayer player, int i) {
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.GUI_ERROR, i, new NBTTagCompound());
|
||||
}
|
||||
|
||||
public static void sendGuiClose(EntityPlayerMP player, int i, NBTTagCompound comp) {
|
||||
if(player.openContainer != player.inventoryContainer){
|
||||
player.openContainer = player.inventoryContainer;
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.GUI_CLOSE, i, comp);
|
||||
}
|
||||
|
||||
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){
|
||||
return null;
|
||||
}
|
||||
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)};
|
||||
}
|
||||
worldObj.spawnEntityInWorld(entity);
|
||||
return entity;
|
||||
}
|
||||
public static boolean isOp(EntityPlayer player) {
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile());
|
||||
}
|
||||
|
||||
|
||||
public static void GivePlayerItem(Entity entity, EntityPlayer player, ItemStack item) {
|
||||
if (entity.worldObj.isRemote || item == null) {
|
||||
return;
|
||||
}
|
||||
item = item.copy();
|
||||
float f = 0.7F;
|
||||
double d = (double) (entity.worldObj.rand.nextFloat() * f) + (double) (1.0F - f);
|
||||
double d1 = (double) (entity.worldObj.rand.nextFloat() * f) + (double) (1.0F - f);
|
||||
double d2 = (double) (entity.worldObj.rand.nextFloat() * f) + (double) (1.0F - f);
|
||||
EntityItem entityitem = new EntityItem(entity.worldObj, entity.posX + d, entity.posY + d1, entity.posZ + d2,
|
||||
item);
|
||||
entityitem.delayBeforeCanPickup = 2;
|
||||
entity.worldObj.spawnEntityInWorld(entityitem);
|
||||
|
||||
int i = item.stackSize;
|
||||
|
||||
if (player.inventory.addItemStackToInventory(item)) {
|
||||
entity.worldObj.playSoundAtEntity(entityitem, "random.pop", 0.2F,
|
||||
((entity.worldObj.rand.nextFloat() - entity.worldObj.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
|
||||
player.onItemPickup(entityitem, i);
|
||||
|
||||
if (item.stackSize <= 0) {
|
||||
entityitem.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
public static EntityPlayer getPlayer(UUID id) {
|
||||
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
for(EntityPlayer player : list){
|
||||
if(id.equals(player.getUniqueID()))
|
||||
return player;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.EntityDamageSource;
|
||||
|
||||
public class NpcDamageSource extends EntityDamageSource{
|
||||
|
||||
public NpcDamageSource(String par1Str, Entity par2Entity) {
|
||||
super(par1Str, par2Entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDifficultyScaled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.EntityDamageSourceIndirect;
|
||||
|
||||
public class NpcDamageSourceInderect extends EntityDamageSourceIndirect{
|
||||
|
||||
public NpcDamageSourceInderect(String par1Str, Entity par2Entity, Entity par3Entity) {
|
||||
super(par1Str, par2Entity, par3Entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDifficultyScaled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class NpcMiscInventory implements IInventory {
|
||||
public HashMap<Integer,ItemStack> items = new HashMap<Integer,ItemStack>();
|
||||
public int stackLimit = 64;
|
||||
|
||||
private int size;
|
||||
|
||||
public NpcMiscInventory(int size){
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public NBTTagCompound getToNBT(){
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setTag("NpcMiscInv", NBTTags.nbtItemStackList(items));
|
||||
return nbttagcompound;
|
||||
}
|
||||
public void setFromNBT(NBTTagCompound nbttagcompound){
|
||||
items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcMiscInv", 10));
|
||||
}
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int var1) {
|
||||
return items.get(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1, int par2) {
|
||||
if (items.get(par1) == null)
|
||||
return null;
|
||||
|
||||
ItemStack var4 = null;
|
||||
if (items.get(par1).stackSize <= par2){
|
||||
var4 = items.get(par1);
|
||||
items.put(par1,null);
|
||||
}
|
||||
else{
|
||||
var4 = items.get(par1).splitStack(par2);
|
||||
|
||||
if (items.get(par1).stackSize == 0){
|
||||
items.put(par1,null);
|
||||
}
|
||||
}
|
||||
|
||||
return var4;
|
||||
}
|
||||
|
||||
|
||||
public boolean decrStackSize(ItemStack eating, int decrease) {
|
||||
for(int slot : items.keySet()){
|
||||
ItemStack item = items.get(slot);
|
||||
if(items != null && eating == item && item.stackSize >= decrease){
|
||||
item.splitStack(decrease);
|
||||
if(item.stackSize <= 0)
|
||||
items.put(slot, null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int var1) {
|
||||
if (items.get(var1) != null)
|
||||
{
|
||||
ItemStack var3 = items.get(var1);
|
||||
items.put(var1,null);
|
||||
return var3;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int var1, ItemStack var2) {
|
||||
if(var1 >= getSizeInventory())
|
||||
return;
|
||||
items.put(var1,var2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return stackLimit;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "Npc Misc Inventory";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void openInventory() {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
|
||||
}
|
||||
public boolean addItemStack(ItemStack item) {
|
||||
ItemStack mergable;
|
||||
boolean merged = false;
|
||||
while((mergable = getMergableItem(item)) != null && mergable.stackSize > 0){
|
||||
int size = mergable.getMaxStackSize() - mergable.stackSize;
|
||||
if(size > item.stackSize){
|
||||
mergable.stackSize = mergable.getMaxStackSize();
|
||||
item.stackSize -= size;
|
||||
merged = true;
|
||||
}
|
||||
else{
|
||||
mergable.stackSize += item.stackSize;
|
||||
item.stackSize = 0;
|
||||
}
|
||||
}
|
||||
if(item.stackSize <= 0)
|
||||
return true;
|
||||
int slot = firstFreeSlot();
|
||||
if(slot >= 0){
|
||||
items.put(slot, item.copy());
|
||||
item.stackSize = 0;
|
||||
return true;
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
|
||||
public ItemStack getMergableItem(ItemStack item){
|
||||
for(ItemStack is : items.values()){
|
||||
if(NoppesUtilPlayer.compareItems(item, is, false, false) && is.stackSize < is.getMaxStackSize()){
|
||||
return is;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int firstFreeSlot(){
|
||||
for(int i = 0; i < getSizeInventory(); i++){
|
||||
if(items.get(i) == null)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public void setSize(int i) {
|
||||
size = i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemEditableBook;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemWritableBook;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import noppes.npcs.blocks.tiles.TileBigSign;
|
||||
import noppes.npcs.blocks.tiles.TileBook;
|
||||
import noppes.npcs.constants.EnumCompanionTalent;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumPlayerPacket;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.containers.ContainerMail;
|
||||
import noppes.npcs.controllers.BankData;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.PlayerFactionData;
|
||||
import noppes.npcs.controllers.PlayerMail;
|
||||
import noppes.npcs.controllers.PlayerMailData;
|
||||
import noppes.npcs.controllers.PlayerQuestController;
|
||||
import noppes.npcs.controllers.PlayerQuestData;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleCompanion;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
|
||||
public class PacketHandlerPlayer{
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerPacket(ServerCustomPacketEvent event) {
|
||||
EntityPlayerMP player = ((NetHandlerPlayServer)event.handler).playerEntity;
|
||||
ByteBuf buffer = event.packet.payload();
|
||||
try {
|
||||
player(buffer, player, EnumPlayerPacket.values()[buffer.readInt()]);
|
||||
} catch (IOException e) {
|
||||
LogWriter.except(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void player(ByteBuf buffer, EntityPlayerMP player, EnumPlayerPacket type) throws IOException {
|
||||
if(type == EnumPlayerPacket.CompanionTalentExp){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Companion || player != npc.getOwner())
|
||||
return;
|
||||
int id = buffer.readInt();
|
||||
int exp = buffer.readInt();
|
||||
RoleCompanion role = (RoleCompanion) npc.roleInterface;
|
||||
if(exp <= 0 || !role.canAddExp(-exp) || id < 0 || id >= EnumCompanionTalent.values().length) //should never happen unless hacking
|
||||
return;
|
||||
EnumCompanionTalent talent = EnumCompanionTalent.values()[id];
|
||||
role.addExp(-exp);
|
||||
role.addTalentExp(talent, exp);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.CompanionOpenInv){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Companion || player != npc.getOwner())
|
||||
return;
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.CompanionInv, npc);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.FollowerHire){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
||||
return;
|
||||
NoppesUtilPlayer.hireFollower(player,npc);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.FollowerExtend){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
||||
return;
|
||||
NoppesUtilPlayer.extendFollower(player,npc);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.FollowerState){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Follower)
|
||||
return;
|
||||
NoppesUtilPlayer.changeFollowerState(player,npc);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.RoleGet){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role == EnumRoleType.None)
|
||||
return;
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.Transport){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Transporter)
|
||||
return;
|
||||
NoppesUtilPlayer.transport(player, npc, Server.readString(buffer));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.BankUpgrade){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Bank)
|
||||
return;
|
||||
NoppesUtilPlayer.bankUpgrade(player, npc);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.BankUnlock){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Bank)
|
||||
return;
|
||||
NoppesUtilPlayer.bankUnlock(player, npc);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.BankSlotOpen){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null || npc.advanced.role != EnumRoleType.Bank)
|
||||
return;
|
||||
int slot = buffer.readInt();
|
||||
int bankId = buffer.readInt();
|
||||
BankData data = PlayerDataController.instance.getBankData(player,bankId).getBankOrDefault(bankId);
|
||||
data.openBankGui(player, npc, bankId, slot);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.Dialog){
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(npc == null)
|
||||
return;
|
||||
NoppesUtilPlayer.dialogSelected(buffer.readInt(),buffer.readInt(),player,npc);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.CheckQuestCompletion){
|
||||
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
playerdata.checkQuestCompletion(player,null);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.QuestLog){
|
||||
NoppesUtilPlayer.sendQuestLogData(player);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.QuestCompletion){
|
||||
NoppesUtilPlayer.questCompletion(player,buffer.readInt());
|
||||
}
|
||||
else if(type == EnumPlayerPacket.FactionsGet){
|
||||
PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData;
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.getPlayerGuiData());
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailGet){
|
||||
PlayerMailData data = PlayerDataController.instance.getPlayerData(player).mailData;
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.saveNBTData(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailDelete){
|
||||
long time = buffer.readLong();
|
||||
String username = Server.readString(buffer);
|
||||
PlayerMailData data = PlayerDataController.instance.getPlayerData(player).mailData;
|
||||
|
||||
Iterator<PlayerMail> it = data.playermail.iterator();
|
||||
while(it.hasNext()){
|
||||
PlayerMail mail = it.next();
|
||||
if(mail.time == time && mail.sender.equals(username)){
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.saveNBTData(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailSend){
|
||||
if(!(player.openContainer instanceof ContainerMail))
|
||||
return;
|
||||
String username = PlayerDataController.instance.hasPlayer(Server.readString(buffer));
|
||||
if(username.isEmpty()){
|
||||
NoppesUtilServer.sendGuiError(player, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerMail mail = new PlayerMail();
|
||||
//String s = player.func_145748_c_().getFormattedText();
|
||||
String s = player.getDisplayName();
|
||||
if(!s.equals(player.getCommandSenderName()))
|
||||
s += "(" + player.getCommandSenderName() + ")";
|
||||
mail.readNBT(Server.readNBT(buffer));
|
||||
mail.sender = s;
|
||||
mail.items = ((ContainerMail)player.openContainer).mail.items;
|
||||
|
||||
if(mail.subject.isEmpty()){
|
||||
NoppesUtilServer.sendGuiError(player, 1);
|
||||
return;
|
||||
}
|
||||
PlayerDataController.instance.addPlayerMessage(username, mail);
|
||||
|
||||
NBTTagCompound comp = new NBTTagCompound();
|
||||
comp.setString("username", username);
|
||||
NoppesUtilServer.sendGuiClose(player, 1,comp);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailboxOpenMail){
|
||||
long time = buffer.readLong();
|
||||
String username = Server.readString(buffer);
|
||||
player.closeContainer();
|
||||
PlayerMailData data = PlayerDataController.instance.getPlayerData(player).mailData;
|
||||
|
||||
Iterator<PlayerMail> it = data.playermail.iterator();
|
||||
while(it.hasNext()){
|
||||
PlayerMail mail = it.next();
|
||||
if(mail.time == time && mail.sender.equals(username)){
|
||||
ContainerMail.staticmail = mail;
|
||||
player.openGui(CustomNpcs.instance, EnumGuiType.PlayerMailman.ordinal(), player.worldObj, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailRead){
|
||||
long time = buffer.readLong();
|
||||
String username = Server.readString(buffer);
|
||||
PlayerMailData data = PlayerDataController.instance.getPlayerData(player).mailData;
|
||||
|
||||
Iterator<PlayerMail> it = data.playermail.iterator();
|
||||
while(it.hasNext()){
|
||||
PlayerMail mail = it.next();
|
||||
if(mail.time == time && mail.sender.equals(username)){
|
||||
mail.beenRead = true;
|
||||
if(mail.hasQuest())
|
||||
PlayerQuestController.addActiveQuest(mail.getQuest(), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == EnumPlayerPacket.SignSave){
|
||||
int x = buffer.readInt(), y = buffer.readInt(), z = buffer.readInt();
|
||||
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
|
||||
if(tile == null || !(tile instanceof TileBigSign))
|
||||
return;
|
||||
TileBigSign sign = (TileBigSign) tile;
|
||||
if(sign.canEdit){
|
||||
sign.setText(Server.readString(buffer));
|
||||
sign.canEdit = false;
|
||||
player.worldObj.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPlayerPacket.SaveBook){
|
||||
int x = buffer.readInt(), y = buffer.readInt(), z = buffer.readInt();
|
||||
TileEntity tileentity = player.worldObj.getTileEntity(x, y, z);
|
||||
if(!(tileentity instanceof TileBook))
|
||||
return;
|
||||
TileBook tile = (TileBook) tileentity;
|
||||
if(tile.book.getItem() == Items.written_book)
|
||||
return;
|
||||
boolean sign = buffer.readBoolean();
|
||||
ItemStack book = ItemStack.loadItemStackFromNBT(Server.readNBT(buffer));
|
||||
if(book == null)
|
||||
return;
|
||||
if(book.getItem() == Items.writable_book && !sign && ItemWritableBook.func_150930_a(book.getTagCompound())){
|
||||
tile.book.setTagInfo("pages", book.getTagCompound().getTagList("pages", 8));
|
||||
}
|
||||
if(book.getItem() == Items.written_book && sign && ItemEditableBook.validBookTagContents(book.getTagCompound())){
|
||||
tile.book.setTagInfo("author", new NBTTagString(player.getCommandSenderName()));
|
||||
tile.book.setTagInfo("title", new NBTTagString(book.getTagCompound().getString("title")));
|
||||
tile.book.setTagInfo("pages", book.getTagCompound().getTagList("pages", 8));
|
||||
tile.book.func_150996_a(Items.written_book);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,788 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import foxz.utils.Market;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import noppes.npcs.constants.EnumCompanionStage;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumJobType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.constants.EnumPlayerData;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.containers.ContainerMail;
|
||||
import noppes.npcs.controllers.Bank;
|
||||
import noppes.npcs.controllers.BankController;
|
||||
import noppes.npcs.controllers.Dialog;
|
||||
import noppes.npcs.controllers.DialogCategory;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.DialogOption;
|
||||
import noppes.npcs.controllers.Faction;
|
||||
import noppes.npcs.controllers.FactionController;
|
||||
import noppes.npcs.controllers.LinkedNpcController;
|
||||
import noppes.npcs.controllers.LinkedNpcController.LinkedData;
|
||||
import noppes.npcs.controllers.PlayerData;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.PlayerMail;
|
||||
import noppes.npcs.controllers.Quest;
|
||||
import noppes.npcs.controllers.QuestCategory;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.RecipeCarpentry;
|
||||
import noppes.npcs.controllers.RecipeController;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.controllers.SpawnController;
|
||||
import noppes.npcs.controllers.SpawnData;
|
||||
import noppes.npcs.controllers.TransportController;
|
||||
import noppes.npcs.controllers.TransportLocation;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobSpawner;
|
||||
import noppes.npcs.roles.RoleCompanion;
|
||||
import noppes.npcs.roles.RoleTrader;
|
||||
import noppes.npcs.roles.RoleTransporter;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
|
||||
public class PacketHandlerServer{
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerPacket(ServerCustomPacketEvent event) {
|
||||
EntityPlayerMP player = ((NetHandlerPlayServer)event.handler).playerEntity;
|
||||
if(CustomNpcs.OpsOnly && !NoppesUtilServer.isOp(player)){
|
||||
warn(player, "tried to use custom npcs without being an op");
|
||||
return;
|
||||
}
|
||||
ByteBuf buffer = event.packet.payload();
|
||||
EnumPacketServer type = null;
|
||||
try {
|
||||
type = EnumPacketServer.values()[buffer.readInt()];
|
||||
|
||||
ItemStack item = player.inventory.getCurrentItem();
|
||||
|
||||
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
|
||||
if(type.needsNpc && npc == null){
|
||||
|
||||
}
|
||||
else if(type.hasPermission() && !CustomNpcsPermissions.Instance.hasPermission(player, type.permission)){
|
||||
//player doesnt have permission todo this
|
||||
}
|
||||
else if(item == null )
|
||||
warn(player, "tried to use custom npcs without a tool in hand, probably a hacker");
|
||||
else if(item.getItem() == CustomItems.wand)
|
||||
wandPackets(type, buffer, player, npc);
|
||||
else if(item.getItem() == CustomItems.moving)
|
||||
movingPackets(type, buffer, player, npc);
|
||||
else if(item.getItem() == CustomItems.mount)
|
||||
mountPackets(type, buffer, player);
|
||||
else if(item.getItem() == CustomItems.cloner)
|
||||
clonePackets(type, buffer, player);
|
||||
else if(item.getItem() == CustomItems.teleporter)
|
||||
featherPackets(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);
|
||||
} catch (Exception e) {
|
||||
LogWriter.error("Error with EnumPacketServer." + type, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void scriptPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws Exception {
|
||||
if(type == EnumPacketServer.ScriptDataSave){
|
||||
npc.script.readFromNBT(Server.readNBT(buffer));
|
||||
npc.updateAI = true;
|
||||
npc.script.hasInited = false;
|
||||
}
|
||||
else if(type == EnumPacketServer.ScriptDataGet){
|
||||
NBTTagCompound compound = npc.script.writeToNBT(new NBTTagCompound());
|
||||
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
}
|
||||
|
||||
private void featherPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
if(type == EnumPacketServer.DimensionsGet){
|
||||
HashMap<String,Integer> map = new HashMap<String,Integer>();
|
||||
for(int id : DimensionManager.getStaticDimensionIDs()){
|
||||
WorldProvider provider = DimensionManager.createProviderFor(id);
|
||||
map.put(provider.getDimensionName(), id);
|
||||
}
|
||||
NoppesUtilServer.sendScrollData(player, map);
|
||||
}
|
||||
else if(type == EnumPacketServer.DimensionTeleport){
|
||||
int dimension = buffer.readInt();
|
||||
WorldServer world = MinecraftServer.getServer().worldServerForDimension(dimension);
|
||||
ChunkCoordinates coords = world.getEntrancePortalLocation();
|
||||
if(coords == null){
|
||||
coords = world.getSpawnPoint();
|
||||
if(!world.isAirBlock(coords.posX, coords.posY, coords.posZ))
|
||||
coords.posY = world.getTopSolidOrLiquidBlock(coords.posX, coords.posZ);
|
||||
else{
|
||||
while(world.isAirBlock(coords.posX, coords.posY - 1, coords.posZ) && coords.posY > 0){
|
||||
coords.posY--;
|
||||
}
|
||||
if(coords.posY == 0)
|
||||
coords.posY = world.getTopSolidOrLiquidBlock(coords.posX, coords.posZ);
|
||||
}
|
||||
}
|
||||
NoppesUtilPlayer.teleportPlayer(player, coords.posX, coords.posY, coords.posZ, dimension);
|
||||
}
|
||||
}
|
||||
|
||||
private void movingPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws IOException {
|
||||
if(type == EnumPacketServer.MovingPathGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.ai.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.MovingPathSave){
|
||||
npc.ai.setMovingPath(NBTTags.getIntegerArraySet(Server.readNBT(buffer).getTagList("MovingPathNew",10)));
|
||||
}
|
||||
}
|
||||
|
||||
private void blockPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
if (type == EnumPacketServer.SaveTileEntity) {
|
||||
NoppesUtilServer.saveTileEntity(player, Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketServer.GetTileEntity){
|
||||
TileEntity tile = player.worldObj.getTileEntity(buffer.readInt(), buffer.readInt(), buffer.readInt());
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
tile.writeToNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogCategoriesGet){
|
||||
NoppesUtilServer.sendScrollData(player, DialogController.instance.getScroll());
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogsGetFromDialog){
|
||||
Dialog dialog = DialogController.instance.dialogs.get(buffer.readInt());
|
||||
if(dialog == null)
|
||||
return;
|
||||
NoppesUtilServer.sendDialogData(player,dialog.category);
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogsGet){
|
||||
NoppesUtilServer.sendDialogData(player,DialogController.instance.categories.get(buffer.readInt()));
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestsGetFromQuest){
|
||||
Quest quest = QuestController.instance.quests.get(buffer.readInt());
|
||||
if(quest == null)
|
||||
return;
|
||||
NoppesUtilServer.sendQuestData(player,quest.category);
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestCategoriesGet){
|
||||
NoppesUtilServer.sendQuestCategoryData(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestsGet){
|
||||
QuestCategory category = QuestController.instance.categories.get(buffer.readInt());
|
||||
NoppesUtilServer.sendQuestData(player,category);
|
||||
}
|
||||
else if(type == EnumPacketServer.FactionsGet){
|
||||
NoppesUtilServer.sendFactionDataAll(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogGet){
|
||||
Dialog dialog = DialogController.instance.dialogs.get(buffer.readInt());
|
||||
if(dialog != null){
|
||||
NBTTagCompound compound = dialog.writeToNBT(new NBTTagCompound());
|
||||
Quest quest = QuestController.instance.quests.get(dialog.quest);
|
||||
if(quest != null)
|
||||
compound.setString("DialogQuestName", quest.title);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestGet){
|
||||
Quest quest = QuestController.instance.quests.get(buffer.readInt());
|
||||
if(quest != null){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(quest.hasNewQuest())
|
||||
compound.setString("NextQuestTitle", quest.getNextQuest().title);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, quest.writeToNBT(compound));
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.FactionGet){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
Faction faction = FactionController.getInstance().getFaction(buffer.readInt());
|
||||
faction.writeNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
}
|
||||
|
||||
private void wandPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws IOException{
|
||||
if(type == EnumPacketServer.Delete){
|
||||
npc.delete();
|
||||
NoppesUtilServer.deleteNpc(npc,player);
|
||||
}
|
||||
else if(type == EnumPacketServer.LinkedAdd){
|
||||
LinkedNpcController.Instance.addData(Server.readString(buffer));
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(LinkedData data : LinkedNpcController.Instance.list)
|
||||
list.add(data.name);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SCROLL_LIST, list);
|
||||
}
|
||||
else if(type == EnumPacketServer.LinkedRemove){
|
||||
LinkedNpcController.Instance.removeData(Server.readString(buffer));
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(LinkedData data : LinkedNpcController.Instance.list)
|
||||
list.add(data.name);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SCROLL_LIST, list);
|
||||
}
|
||||
else if(type == EnumPacketServer.LinkedGetAll){
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(LinkedData data : LinkedNpcController.Instance.list)
|
||||
list.add(data.name);
|
||||
Server.sendData(player, EnumPacketClient.SCROLL_LIST, list);
|
||||
if(npc != null)
|
||||
Server.sendData(player, EnumPacketClient.SCROLL_SELECTED, npc.linkedName);
|
||||
}
|
||||
else if(type == EnumPacketServer.LinkedSet){
|
||||
npc.linkedName = Server.readString(buffer);
|
||||
LinkedNpcController.Instance.loadNpcData(npc);
|
||||
}
|
||||
else if(type == EnumPacketServer.NpcMenuClose){
|
||||
npc.reset();
|
||||
if(npc.linkedData != null)
|
||||
LinkedNpcController.Instance.saveNpcData(npc);
|
||||
NoppesUtilServer.setEditingNpc(player, null);
|
||||
}
|
||||
else if(type == EnumPacketServer.BanksGet){
|
||||
NoppesUtilServer.sendBankDataAll(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.BankGet){
|
||||
Bank bank = BankController.getInstance().getBank(buffer.readInt());
|
||||
NoppesUtilServer.sendBank(player,bank);
|
||||
}
|
||||
else if(type == EnumPacketServer.BankSave){
|
||||
Bank bank = new Bank();
|
||||
bank.readEntityFromNBT(Server.readNBT(buffer));
|
||||
BankController.getInstance().saveBank(bank);
|
||||
NoppesUtilServer.sendBankDataAll(player);
|
||||
NoppesUtilServer.sendBank(player,bank);
|
||||
}
|
||||
else if(type == EnumPacketServer.BankRemove){
|
||||
BankController.getInstance().removeBank(buffer.readInt());
|
||||
NoppesUtilServer.sendBankDataAll(player);
|
||||
NoppesUtilServer.sendBank(player,new Bank());
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteMainMenu){
|
||||
Entity entity = player.worldObj.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) entity);
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteDelete){
|
||||
Entity entity = player.worldObj.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
npc = (EntityNPCInterface) entity;
|
||||
npc.delete();
|
||||
NoppesUtilServer.deleteNpc(npc,player);
|
||||
NoppesUtilServer.sendNearbyNpcs(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteNpcsGet){
|
||||
NoppesUtilServer.sendNearbyNpcs(player);
|
||||
Server.sendData(player, EnumPacketClient.SCROLL_SELECTED, CustomNpcs.FreezeNPCs?"Unfreeze Npcs":"Freeze Npcs");
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteFreeze){
|
||||
CustomNpcs.FreezeNPCs = !CustomNpcs.FreezeNPCs;
|
||||
Server.sendData(player, EnumPacketClient.SCROLL_SELECTED, CustomNpcs.FreezeNPCs?"Unfreeze Npcs":"Freeze Npcs");
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteReset){
|
||||
Entity entity = player.worldObj.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
npc = (EntityNPCInterface) entity;
|
||||
npc.reset();
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteTpToNpc){
|
||||
Entity entity = player.worldObj.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
npc = (EntityNPCInterface) entity;
|
||||
player.playerNetServerHandler.setPlayerLocation(npc.posX, npc.posY, npc.posZ, 0, 0);
|
||||
}
|
||||
else if(type == EnumPacketServer.Gui){
|
||||
EnumGuiType gui = EnumGuiType.values()[buffer.readInt()];
|
||||
int i = buffer.readInt();
|
||||
int j = buffer.readInt();
|
||||
int k = buffer.readInt();
|
||||
NoppesUtilServer.sendOpenGui(player, gui, npc, i, j, k);
|
||||
}
|
||||
else if(type == EnumPacketServer.RecipesGet){
|
||||
NoppesUtilServer.sendRecipeData(player,buffer.readInt());
|
||||
}
|
||||
else if(type == EnumPacketServer.RecipeGet){
|
||||
RecipeCarpentry recipe = RecipeController.instance.getRecipe(buffer.readInt());
|
||||
NoppesUtilServer.setRecipeGui(player,recipe);
|
||||
}
|
||||
else if(type == EnumPacketServer.RecipeRemove){
|
||||
RecipeCarpentry recipe = RecipeController.instance.removeRecipe(buffer.readInt());
|
||||
NoppesUtilServer.sendRecipeData(player, recipe.isGlobal?3:4);
|
||||
NoppesUtilServer.setRecipeGui(player,new RecipeCarpentry(""));
|
||||
}
|
||||
else if(type == EnumPacketServer.RecipeSave){
|
||||
RecipeCarpentry recipe = RecipeController.instance.saveRecipe(Server.readNBT(buffer));
|
||||
NoppesUtilServer.sendRecipeData(player, recipe.isGlobal?3:4);
|
||||
NoppesUtilServer.setRecipeGui(player,recipe);
|
||||
}
|
||||
else if(type == EnumPacketServer.NaturalSpawnGetAll){
|
||||
NoppesUtilServer.sendScrollData(player, SpawnController.instance.getScroll());
|
||||
}
|
||||
else if(type == EnumPacketServer.NaturalSpawnGet){
|
||||
SpawnData spawn = SpawnController.instance.getSpawnData(buffer.readInt());
|
||||
if(spawn != null){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, spawn.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.NaturalSpawnSave){
|
||||
SpawnData data = new SpawnData();
|
||||
data.readNBT(Server.readNBT(buffer));
|
||||
SpawnController.instance.saveSpawnData(data);
|
||||
|
||||
NoppesUtilServer.sendScrollData(player, SpawnController.instance.getScroll());
|
||||
}
|
||||
else if(type == EnumPacketServer.NaturalSpawnRemove){
|
||||
SpawnController.instance.removeSpawnData(buffer.readInt());
|
||||
NoppesUtilServer.sendScrollData(player, SpawnController.instance.getScroll());
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogCategorySave){
|
||||
DialogCategory category = new DialogCategory();
|
||||
category.readNBT(Server.readNBT(buffer));
|
||||
DialogController.instance.saveCategory(category);
|
||||
NoppesUtilServer.sendScrollData(player, DialogController.instance.getScroll());
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogCategoryRemove){
|
||||
DialogController.instance.removeCategory(buffer.readInt());
|
||||
NoppesUtilServer.sendScrollData(player, DialogController.instance.getScroll());
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogCategoryGet){
|
||||
DialogCategory category = DialogController.instance.categories.get(buffer.readInt());
|
||||
if(category != null){
|
||||
NBTTagCompound comp = category.writeNBT(new NBTTagCompound());
|
||||
comp.removeTag("Dialogs");
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, comp);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogSave){
|
||||
int category = buffer.readInt();
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.readNBT(Server.readNBT(buffer));
|
||||
DialogController.instance.saveDialog(category,dialog);
|
||||
if(dialog.category != null)
|
||||
NoppesUtilServer.sendDialogData(player,dialog.category);
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestOpenGui){
|
||||
Quest quest = new Quest();
|
||||
int gui = buffer.readInt();
|
||||
quest.readNBT(Server.readNBT(buffer));
|
||||
NoppesUtilServer.setEditingQuest(player,quest);
|
||||
player.openGui(CustomNpcs.instance, gui , player.worldObj, 0, 0, 0);
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogRemove){
|
||||
Dialog dialog = DialogController.instance.dialogs.get(buffer.readInt());
|
||||
if(dialog != null && dialog.category != null){
|
||||
DialogController.instance.removeDialog(dialog);
|
||||
NoppesUtilServer.sendDialogData(player,dialog.category);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogNpcGet){
|
||||
NoppesUtilServer.sendNpcDialogs(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogNpcSet){
|
||||
int slot = buffer.readInt();
|
||||
int dialog = buffer.readInt();
|
||||
DialogOption option = NoppesUtilServer.setNpcDialog(slot,dialog,player);
|
||||
if(option != null && option.hasDialog()){
|
||||
NBTTagCompound compound = option.writeNBT();
|
||||
compound.setInteger("Position", slot);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogNpcRemove){
|
||||
npc.dialogs.remove(buffer.readInt());
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestCategoryGet){
|
||||
QuestCategory category = QuestController.instance.categories.get(buffer.readInt());
|
||||
if(category != null){
|
||||
NBTTagCompound comp = category.writeNBT(new NBTTagCompound());
|
||||
comp.removeTag("Dialogs");
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, comp);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestCategorySave){
|
||||
QuestCategory category = new QuestCategory();
|
||||
category.readNBT(Server.readNBT(buffer));
|
||||
QuestController.instance.saveCategory(category);
|
||||
NoppesUtilServer.sendQuestCategoryData(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestCategoryRemove){
|
||||
QuestController.instance.removeCategory(buffer.readInt());
|
||||
NoppesUtilServer.sendQuestCategoryData(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestSave){
|
||||
int category = buffer.readInt();
|
||||
Quest quest = new Quest();
|
||||
quest.readNBT(Server.readNBT(buffer));
|
||||
QuestController.instance.saveQuest(category, quest);
|
||||
if(quest.category != null)
|
||||
NoppesUtilServer.sendQuestData(player,quest.category);
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestDialogGetTitle){
|
||||
Dialog quest = DialogController.instance.dialogs.get(buffer.readInt());
|
||||
Dialog quest2 = DialogController.instance.dialogs.get(buffer.readInt());
|
||||
Dialog quest3 = DialogController.instance.dialogs.get(buffer.readInt());
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(quest != null)
|
||||
compound.setString("1", quest.title);
|
||||
if(quest2 != null)
|
||||
compound.setString("2", quest2.title);
|
||||
if(quest3 != null)
|
||||
compound.setString("3", quest3.title);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestRemove){
|
||||
Quest quest = QuestController.instance.quests.get(buffer.readInt());
|
||||
if(quest != null){
|
||||
QuestController.instance.removeQuest(quest);
|
||||
NoppesUtilServer.sendQuestData(player,quest.category);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.TransportCategoriesGet){
|
||||
NoppesUtilServer.sendTransportCategoryData(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.TransportCategorySave){
|
||||
TransportController.getInstance().saveCategory(Server.readString(buffer), buffer.readInt());
|
||||
}
|
||||
else if(type == EnumPacketServer.TransportCategoryRemove){
|
||||
TransportController.getInstance().removeCategory(buffer.readInt());
|
||||
NoppesUtilServer.sendTransportCategoryData(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.TransportRemove){
|
||||
int id = buffer.readInt();
|
||||
TransportLocation loc = TransportController.getInstance().removeLocation(id);
|
||||
if(loc != null)
|
||||
NoppesUtilServer.sendTransportData(player,loc.category.id);
|
||||
}
|
||||
else if(type == EnumPacketServer.TransportsGet){
|
||||
NoppesUtilServer.sendTransportData(player,buffer.readInt());
|
||||
}
|
||||
else if(type == EnumPacketServer.TransportSave){
|
||||
int cat = buffer.readInt();
|
||||
TransportLocation location = TransportController.getInstance().saveLocation(cat,Server.readNBT(buffer),player, npc);
|
||||
if(location != null){
|
||||
if(npc.advanced.role != EnumRoleType.Transporter)
|
||||
return;
|
||||
RoleTransporter role = (RoleTransporter) npc.roleInterface;
|
||||
role.setTransport(location);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.TransportGetLocation){
|
||||
if(npc.advanced.role != EnumRoleType.Transporter)
|
||||
return;
|
||||
RoleTransporter role = (RoleTransporter) npc.roleInterface;
|
||||
if(role.hasTransport()){
|
||||
Server.sendData(player,EnumPacketClient.GUI_DATA,role.getLocation().writeNBT());
|
||||
Server.sendData(player, EnumPacketClient.SCROLL_SELECTED,role.getLocation().category.title);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.FactionSet){
|
||||
npc.setFaction(buffer.readInt());
|
||||
}
|
||||
else if(type == EnumPacketServer.FactionSave){
|
||||
Faction faction = new Faction();
|
||||
faction.readNBT(Server.readNBT(buffer));
|
||||
FactionController.getInstance().saveFaction(faction);
|
||||
NoppesUtilServer.sendFactionDataAll(player);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
faction.writeNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.FactionRemove){
|
||||
FactionController.getInstance().removeFaction(buffer.readInt());
|
||||
NoppesUtilServer.sendFactionDataAll(player);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
(new Faction()).writeNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.PlayerDataGet){
|
||||
int id = buffer.readInt();
|
||||
if(EnumPlayerData.values().length <= id)
|
||||
return;
|
||||
String name = null;
|
||||
EnumPlayerData datatype = EnumPlayerData.values()[id];
|
||||
if(datatype != EnumPlayerData.Players)
|
||||
name = Server.readString(buffer);
|
||||
NoppesUtilServer.sendPlayerData(datatype,player,name);
|
||||
}
|
||||
else if(type == EnumPacketServer.PlayerDataRemove){
|
||||
NoppesUtilServer.removePlayerData(buffer,player);
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuDisplayGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.display.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuDisplaySave){
|
||||
npc.display.readToNBT(Server.readNBT(buffer));
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuStatsGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.stats.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuStatsSave){
|
||||
npc.stats.readToNBT(Server.readNBT(buffer));
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuInvGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.inventory.writeEntityToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuInvSave){
|
||||
npc.inventory.readEntityFromNBT(Server.readNBT(buffer));
|
||||
npc.updateAI = true;
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuAIGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.ai.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuAISave){
|
||||
npc.ai.readToNBT(Server.readNBT(buffer));
|
||||
npc.setHealth(npc.getMaxHealth());
|
||||
npc.updateAI = true;
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuAdvancedGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.MainmenuAdvancedSave){
|
||||
npc.advanced.readToNBT(Server.readNBT(buffer));
|
||||
npc.updateAI = true;
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.JobSave){
|
||||
NBTTagCompound original = npc.jobInterface.writeToNBT(new NBTTagCompound());
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
Set<String> names = compound.func_150296_c();
|
||||
for(String name : names)
|
||||
original.setTag(name, compound.getTag(name));
|
||||
npc.jobInterface.readFromNBT(original);
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.JobGet){
|
||||
if(npc.jobInterface == null)
|
||||
return;
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("JobData", true);
|
||||
npc.jobInterface.writeToNBT(compound);
|
||||
|
||||
if(npc.advanced.job == EnumJobType.Spawner)
|
||||
((JobSpawner)npc.jobInterface).cleanCompound(compound);
|
||||
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
|
||||
if(npc.advanced.job == EnumJobType.Spawner)
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, ((JobSpawner)npc.jobInterface).getTitles());
|
||||
}
|
||||
else if(type == EnumPacketServer.JobSpawnerAdd){
|
||||
if(npc.advanced.job != EnumJobType.Spawner)
|
||||
return;
|
||||
JobSpawner job = (JobSpawner) npc.jobInterface;
|
||||
if(buffer.readBoolean()){
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(null, Server.readString(buffer), buffer.readInt());
|
||||
|
||||
job.setJobCompound(buffer.readInt(), compound);
|
||||
}
|
||||
else{
|
||||
job.setJobCompound(buffer.readInt(), Server.readNBT(buffer));
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, job.getTitles());
|
||||
}
|
||||
else if(type == EnumPacketServer.RoleCompanionUpdate){
|
||||
if(npc.advanced.role != EnumRoleType.Companion)
|
||||
return;
|
||||
((RoleCompanion)npc.roleInterface).matureTo(EnumCompanionStage.values()[buffer.readInt()]);
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.JobSpawnerRemove){
|
||||
if(npc.advanced.job != EnumJobType.Spawner)
|
||||
return;
|
||||
}
|
||||
else if(type == EnumPacketServer.RoleSave){
|
||||
npc.roleInterface.readFromNBT(Server.readNBT(buffer));
|
||||
npc.updateClient = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.RoleGet){
|
||||
if(npc.roleInterface == null)
|
||||
return;
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("RoleData", true);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.roleInterface.writeToNBT(compound));
|
||||
}
|
||||
else if(type == EnumPacketServer.MerchantUpdate){
|
||||
Entity entity = player.worldObj.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityVillager))
|
||||
return;
|
||||
MerchantRecipeList list = MerchantRecipeList.func_151390_b(new PacketBuffer(buffer));
|
||||
((EntityVillager)entity).setRecipes(list);
|
||||
}
|
||||
else if(type == EnumPacketServer.ModelDataSave){
|
||||
if(npc instanceof EntityCustomNpc)
|
||||
((EntityCustomNpc)npc).modelData.readFromNBT(Server.readNBT(buffer));
|
||||
}
|
||||
else if(type == EnumPacketServer.MailOpenSetup){
|
||||
PlayerMail mail = new PlayerMail();
|
||||
mail.readNBT(Server.readNBT(buffer));
|
||||
ContainerMail.staticmail = mail;
|
||||
player.openGui(CustomNpcs.instance, EnumGuiType.PlayerMailman.ordinal(), player.worldObj, 1, 0, 0);
|
||||
}
|
||||
else if(type == EnumPacketServer.TransformSave){
|
||||
boolean isValid = npc.transform.isValid();
|
||||
npc.transform.readOptions(Server.readNBT(buffer));
|
||||
if(isValid != npc.transform.isValid())
|
||||
npc.updateAI = true;
|
||||
}
|
||||
else if(type == EnumPacketServer.TransformGet){
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, npc.transform.writeOptions(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPacketServer.TransformLoad){
|
||||
if(npc.transform.isValid())
|
||||
npc.transform.transform(buffer.readBoolean());
|
||||
}
|
||||
else if(type == EnumPacketServer.TraderMarketSave){
|
||||
String market = Server.readString(buffer);
|
||||
boolean bo = buffer.readBoolean();
|
||||
if(npc.roleInterface instanceof RoleTrader){
|
||||
if(bo)
|
||||
Market.setMarket(npc, market);
|
||||
else
|
||||
Market.save((RoleTrader)npc.roleInterface, market);
|
||||
//NoppesUtilServer.sendRoleData(player, npc);
|
||||
}
|
||||
}
|
||||
else
|
||||
blockPackets(type, buffer, player);
|
||||
|
||||
}
|
||||
private void mountPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException{
|
||||
if(type == EnumPacketServer.SpawnRider){
|
||||
Entity entity = EntityList.createEntityFromNBT(Server.readNBT(buffer), player.worldObj);
|
||||
player.worldObj.spawnEntityInWorld(entity);
|
||||
entity.mountEntity(ServerEventsHandler.mounted);
|
||||
}
|
||||
else if(type == EnumPacketServer.PlayerRider){
|
||||
player.mountEntity(ServerEventsHandler.mounted);
|
||||
}
|
||||
else if(type == EnumPacketServer.CloneList){
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for(String name : ServerCloneController.Instance.getClones(buffer.readInt()))
|
||||
list.appendTag(new NBTTagString(name));
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("List", list);
|
||||
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else
|
||||
warn(player,"tried todo something with the wrong tool, probably a hacker");
|
||||
}
|
||||
|
||||
private void clonePackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
if(type == EnumPacketServer.SpawnMob){
|
||||
boolean server = buffer.readBoolean();
|
||||
int x = buffer.readInt();
|
||||
int y = buffer.readInt();
|
||||
int z = buffer.readInt();
|
||||
NBTTagCompound compound;
|
||||
if(server)
|
||||
compound = ServerCloneController.Instance.getCloneData(player, Server.readString(buffer), buffer.readInt());
|
||||
else
|
||||
compound = Server.readNBT(buffer);
|
||||
if(compound == null)
|
||||
return;
|
||||
Entity entity = NoppesUtilServer.spawnClone(compound, x, y, z, player.worldObj);
|
||||
if(entity == null){
|
||||
player.addChatMessage(new ChatComponentText("Failed to create an entity out of your clone"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.MobSpawner){
|
||||
boolean server = buffer.readBoolean();
|
||||
int x = buffer.readInt();
|
||||
int y = buffer.readInt();
|
||||
int z = buffer.readInt();
|
||||
NBTTagCompound compound;
|
||||
if(server)
|
||||
compound = ServerCloneController.Instance.getCloneData(player, Server.readString(buffer), buffer.readInt());
|
||||
else
|
||||
compound = Server.readNBT(buffer);
|
||||
if(compound != null)
|
||||
NoppesUtilServer.createMobSpawner(x, y, z, compound, player);
|
||||
}
|
||||
else if(type == EnumPacketServer.ClonePreSave){
|
||||
boolean bo = ServerCloneController.Instance.getCloneData(null, Server.readString(buffer), buffer.readInt()) != null;
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("NameExists", bo);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.CloneSave){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
if(data.cloned == null)
|
||||
return;
|
||||
ServerCloneController.Instance.addClone(data.cloned, Server.readString(buffer), buffer.readInt());
|
||||
}
|
||||
else if(type == EnumPacketServer.CloneRemove){
|
||||
int tab = buffer.readInt();
|
||||
ServerCloneController.Instance.removeClone(Server.readString(buffer), tab);
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for(String name : ServerCloneController.Instance.getClones(tab))
|
||||
list.appendTag(new NBTTagString(name));
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("List", list);
|
||||
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.CloneList){
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for(String name : ServerCloneController.Instance.getClones(buffer.readInt()))
|
||||
list.appendTag(new NBTTagString(name));
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("List", list);
|
||||
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else
|
||||
warn(player,"tried todo something with the wrong tool, probably a hacker");
|
||||
}
|
||||
|
||||
private void warn(EntityPlayer player, String warning){
|
||||
MinecraftServer.getServer().logWarning(player.getCommandSenderName() + ": " + warning);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.constants.EnumQuestCompletion;
|
||||
import noppes.npcs.controllers.PlayerQuestController;
|
||||
import noppes.npcs.controllers.Quest;
|
||||
|
||||
public class QuestLogData {
|
||||
public HashMap<String,Vector<String>> categories = new HashMap<String,Vector<String>>();
|
||||
public String selectedQuest = "";
|
||||
public String selectedCategory = "";
|
||||
public HashMap<String,String> questText = new HashMap<String,String>();
|
||||
public HashMap<String,Vector<String>> questStatus = new HashMap<String,Vector<String>>();
|
||||
public HashMap<String,String> finish = new HashMap<String,String>();
|
||||
|
||||
public NBTTagCompound writeNBT(){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("Categories", NBTTags.nbtVectorMap(categories));
|
||||
compound.setTag("Logs", NBTTags.nbtStringStringMap(questText));
|
||||
compound.setTag("Status", NBTTags.nbtVectorMap(questStatus));
|
||||
compound.setTag("QuestFinisher", NBTTags.nbtStringStringMap(finish));
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void readNBT(NBTTagCompound compound){
|
||||
categories = NBTTags.getVectorMap(compound.getTagList("Categories", 10));
|
||||
questText = NBTTags.getStringStringMap(compound.getTagList("Logs", 10));
|
||||
questStatus = NBTTags.getVectorMap(compound.getTagList("Status", 10));
|
||||
finish = NBTTags.getStringStringMap(compound.getTagList("QuestFinisher", 10));
|
||||
|
||||
}
|
||||
public void setData(EntityPlayer player){
|
||||
|
||||
for(Quest quest : PlayerQuestController.getActiveQuests(player))
|
||||
{
|
||||
String category = quest.category.title;
|
||||
if(!categories.containsKey(category))
|
||||
categories.put(category, new Vector<String>());
|
||||
Vector<String> list = categories.get(category);
|
||||
list.add(quest.title);
|
||||
|
||||
questText.put(category + ":" + quest.title, quest.logText);
|
||||
|
||||
questStatus.put(category + ":" + quest.title, quest.questInterface.getQuestLogStatus(player));
|
||||
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(player))
|
||||
finish.put(category + ":" + quest.title, quest.completerNpc);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasSelectedQuest() {
|
||||
return !selectedQuest.isEmpty();
|
||||
}
|
||||
|
||||
public String getQuestText() {
|
||||
return questText.get(selectedCategory + ":" + selectedQuest);
|
||||
}
|
||||
|
||||
public Vector<String> getQuestStatus() {
|
||||
return questStatus.get(selectedCategory + ":" + selectedQuest);
|
||||
}
|
||||
|
||||
public String getComplete() {
|
||||
return finish.get(selectedCategory + ":" + selectedQuest);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
public class Resistances {
|
||||
|
||||
public float knockback = 1f;
|
||||
public float arrow = 1f;
|
||||
public float playermelee = 1f;
|
||||
public float explosion = 1f;
|
||||
|
||||
public NBTTagCompound writeToNBT() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setFloat("Knockback", knockback);
|
||||
compound.setFloat("Arrow", arrow);
|
||||
compound.setFloat("Melee", playermelee);
|
||||
compound.setFloat("Explosion", explosion);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void readToNBT(NBTTagCompound compound) {
|
||||
knockback = compound.getFloat("Knockback");
|
||||
arrow = compound.getFloat("Arrow");
|
||||
playermelee = compound.getFloat("Melee");
|
||||
explosion = compound.getFloat("Explosion");
|
||||
}
|
||||
|
||||
public float applyResistance(DamageSource source, float damage) {
|
||||
if(source.damageType.equals("arrow") || source.damageType.equals("thrown")){
|
||||
damage *= (2 - arrow);
|
||||
}
|
||||
else if(source.damageType.equals("player") || source.damageType.equals("mob")){
|
||||
damage *= (2 - playermelee);
|
||||
}
|
||||
else if(source.damageType.equals("explosion") || source.damageType.equals("explosion.player")){
|
||||
damage *= (2 - explosion);
|
||||
}
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTSizeTracker;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
|
||||
public class Server {
|
||||
|
||||
public static boolean sendData(EntityPlayerMP player, EnumPacketClient enu, Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!fillBuffer(buffer, enu, obs))
|
||||
return false;
|
||||
CustomNpcs.Channel.sendTo(new FMLProxyPacket(buffer, "CustomNPCs"), player);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void sendAssociatedData(Entity entity, EnumPacketClient enu, Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!fillBuffer(buffer, enu, obs))
|
||||
return;
|
||||
TargetPoint point = new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 60);
|
||||
CustomNpcs.Channel.sendToAllAround(new FMLProxyPacket(buffer,"CustomNPCs"), point);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void sendToAll(EnumPacketClient enu, Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
try {
|
||||
if(!fillBuffer(buffer, enu, obs))
|
||||
return;
|
||||
CustomNpcs.Channel.sendToAll(new FMLProxyPacket(buffer,"CustomNPCs"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean fillBuffer(ByteBuf buffer, Enum enu, Object... obs) throws IOException{
|
||||
buffer.writeInt(enu.ordinal());
|
||||
for(Object ob : obs){
|
||||
if(ob == null)
|
||||
continue;
|
||||
if(ob instanceof Map){
|
||||
Map<String,Integer> map = (Map<String, Integer>) ob;
|
||||
|
||||
buffer.writeInt(map.size());
|
||||
for(String key : map.keySet()){
|
||||
int value = map.get(key);
|
||||
buffer.writeInt(value);
|
||||
writeString(buffer, key);
|
||||
}
|
||||
}
|
||||
else if(ob instanceof MerchantRecipeList)
|
||||
((MerchantRecipeList)ob).func_151391_a(new PacketBuffer(buffer));
|
||||
else if(ob instanceof List){
|
||||
List<String> list = (List<String>) ob;
|
||||
buffer.writeInt(list.size());
|
||||
for(String s : list)
|
||||
writeString(buffer, s);
|
||||
}
|
||||
else if(ob instanceof Enum)
|
||||
buffer.writeInt(((Enum<?>) ob).ordinal());
|
||||
else if(ob instanceof Integer)
|
||||
buffer.writeInt((Integer) ob);
|
||||
else if(ob instanceof Boolean)
|
||||
buffer.writeBoolean((Boolean) ob);
|
||||
else if(ob instanceof String)
|
||||
writeString(buffer, (String) ob);
|
||||
else if(ob instanceof Float)
|
||||
buffer.writeFloat((Float) ob);
|
||||
else if(ob instanceof Long)
|
||||
buffer.writeLong((Long) ob);
|
||||
else if(ob instanceof Double)
|
||||
buffer.writeDouble((Double) ob);
|
||||
else if(ob instanceof NBTTagCompound)
|
||||
writeNBT(buffer, (NBTTagCompound) ob);
|
||||
}
|
||||
if(buffer.array().length >= 32767){
|
||||
LogWriter.error("Packet " + enu + " was too big to be send");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void writeNBT(ByteBuf buffer, NBTTagCompound compound) throws IOException {
|
||||
byte[] bytes = CompressedStreamTools.compress(compound);
|
||||
buffer.writeShort((short)bytes.length);
|
||||
buffer.writeBytes(bytes);
|
||||
}
|
||||
|
||||
public static NBTTagCompound readNBT(ByteBuf buffer) throws IOException {
|
||||
byte[] bytes = new byte[buffer.readShort()];
|
||||
buffer.readBytes(bytes);
|
||||
return CompressedStreamTools.func_152457_a(bytes, new NBTSizeTracker(2097152L));
|
||||
}
|
||||
|
||||
public static void writeString(ByteBuf buffer, String s){
|
||||
byte[] bytes = s.getBytes(Charsets.UTF_8);
|
||||
buffer.writeShort((short)bytes.length);
|
||||
buffer.writeBytes(bytes);
|
||||
}
|
||||
|
||||
public static String readString(ByteBuf buffer){
|
||||
try{
|
||||
byte[] bytes = new byte[buffer.readShort()];
|
||||
buffer.readBytes(bytes);
|
||||
return new String(bytes, Charsets.UTF_8);
|
||||
}
|
||||
catch(IndexOutOfBoundsException ex){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
||||
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
|
||||
import noppes.npcs.blocks.tiles.TileBanner;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
import noppes.npcs.controllers.Line;
|
||||
import noppes.npcs.controllers.PlayerData;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.PlayerQuestData;
|
||||
import noppes.npcs.controllers.QuestData;
|
||||
import noppes.npcs.controllers.RecipeCarpentry;
|
||||
import noppes.npcs.controllers.RecipeController;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.items.ItemExcalibur;
|
||||
import noppes.npcs.items.ItemShield;
|
||||
import noppes.npcs.items.ItemSoulstoneEmpty;
|
||||
import noppes.npcs.quests.QuestKill;
|
||||
import noppes.npcs.roles.RoleFollower;
|
||||
|
||||
public class ServerEventsHandler {
|
||||
|
||||
public static EntityVillager Merchant;
|
||||
public static Entity mounted;
|
||||
|
||||
// private HashMap<String, Integer> exps = new HashMap<String, Integer>();
|
||||
//
|
||||
// @SubscribeEvent
|
||||
// public void onUpdate(LivingUpdateEvent event){
|
||||
// if(!(event.entityLiving instanceof EntityPlayer))
|
||||
// return;
|
||||
// EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
// if(exps.containsKey(player.getCommandSenderName())){
|
||||
// int prevExp = exps.get(player.getCommandSenderName());
|
||||
// if(prevExp > player.experienceTotal){
|
||||
// player.addChatMessage(new ChatComponentText("Omg exp was gotten:" + (player.experienceTotal - prevExp)));
|
||||
// }
|
||||
// else if(prevExp < player.experienceTotal){
|
||||
// player.addChatMessage(new ChatComponentText("Omg exp was lost:" + (prevExp - player.experienceTotal)));
|
||||
// }
|
||||
// }
|
||||
// exps.put(player.getCommandSenderName(), player.experienceTotal);
|
||||
// }
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(EntityInteractEvent event) {
|
||||
ItemStack item = event.entityPlayer.getCurrentEquippedItem();
|
||||
if(item == null)
|
||||
return;
|
||||
boolean isRemote = event.entityPlayer.worldObj.isRemote;
|
||||
boolean npcInteracted = event.target instanceof EntityNPCInterface;
|
||||
|
||||
if(!isRemote && CustomNpcs.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(event.entityPlayer.getGameProfile())){
|
||||
return;
|
||||
}
|
||||
|
||||
if(!isRemote && item.getItem() == CustomItems.soulstoneEmpty && event.target instanceof EntityLivingBase) {
|
||||
((ItemSoulstoneEmpty)item.getItem()).store((EntityLivingBase)event.target, item, event.entityPlayer);
|
||||
}
|
||||
|
||||
if(item.getItem() == CustomItems.wand && npcInteracted && !isRemote){
|
||||
if (!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI)){
|
||||
return;
|
||||
}
|
||||
event.setCanceled(true);
|
||||
NoppesUtilServer.sendOpenGui(event.entityPlayer, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) event.target);
|
||||
}
|
||||
else if(item.getItem() == CustomItems.cloner && !isRemote && !(event.target instanceof EntityPlayer)){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(!event.target.writeToNBTOptional(compound))
|
||||
return;
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(event.entityPlayer);
|
||||
ServerCloneController.Instance.cleanTags(compound);
|
||||
if(!Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.CLONE, compound))
|
||||
event.entityPlayer.addChatMessage(new ChatComponentText("Entity too big to clone"));
|
||||
data.cloned = compound;
|
||||
event.setCanceled(true);
|
||||
}
|
||||
else if(item.getItem() == CustomItems.scripter && !isRemote && npcInteracted){
|
||||
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI))
|
||||
return;
|
||||
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface)event.target);
|
||||
event.setCanceled(true);
|
||||
Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.GUI, EnumGuiType.Script.ordinal());
|
||||
}
|
||||
else if(item.getItem() == CustomItems.mount){
|
||||
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_MOUNTER))
|
||||
return;
|
||||
event.setCanceled(true);
|
||||
mounted = event.target;
|
||||
if(isRemote)
|
||||
CustomNpcs.proxy.openGui(MathHelper.floor_double(mounted.posX), MathHelper.floor_double(mounted.posY), MathHelper.floor_double(mounted.posZ), EnumGuiType.MobSpawnerMounter, event.entityPlayer);
|
||||
}
|
||||
else if(item.getItem() == CustomItems.wand && event.target instanceof EntityVillager){
|
||||
if(!CustomNpcsPermissions.Instance.hasPermission(event.entityPlayer, CustomNpcsPermissions.EDIT_VILLAGER))
|
||||
return;
|
||||
event.setCanceled(true);
|
||||
Merchant = (EntityVillager)event.target;
|
||||
|
||||
if(!isRemote){
|
||||
EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer;
|
||||
player.openGui(CustomNpcs.instance, EnumGuiType.MerchantAdd.ordinal(), player.worldObj, 0, 0, 0);
|
||||
MerchantRecipeList merchantrecipelist = Merchant.getRecipes(player);
|
||||
|
||||
if (merchantrecipelist != null)
|
||||
{
|
||||
Server.sendData(player, EnumPacketClient.VILLAGER_LIST, merchantrecipelist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(LivingHurtEvent event) {
|
||||
if(!(event.entityLiving instanceof EntityPlayer))
|
||||
return;
|
||||
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
if(event.source.isUnblockable() || event.source.isFireDamage())
|
||||
return;
|
||||
if(!player.isBlocking())
|
||||
return;
|
||||
ItemStack item = player.getCurrentEquippedItem();
|
||||
if(item == null || !(item.getItem() instanceof ItemShield))
|
||||
return;
|
||||
if(((ItemShield)item.getItem()).material.getDamageVsEntity() < player.getRNG().nextInt(9))
|
||||
return;
|
||||
float damage = item.getItemDamage() + event.ammount;
|
||||
|
||||
item.damageItem((int) event.ammount, player);
|
||||
|
||||
if(damage > item.getMaxDamage())
|
||||
event.ammount = damage - item.getMaxDamage();
|
||||
else{
|
||||
event.ammount = 0;
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(PlayerInteractEvent event) {
|
||||
EntityPlayer player = event.entityPlayer;
|
||||
Block block = player.worldObj.getBlock(event.x, event.y, event.z);
|
||||
if(event.action == Action.LEFT_CLICK_BLOCK && player.getHeldItem() != null && player.getHeldItem().getItem() == CustomItems.teleporter){
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
if(block == Blocks.crafting_table && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
|
||||
RecipeController controller = RecipeController.instance;
|
||||
NBTTagList list = new NBTTagList();
|
||||
int i = 0;
|
||||
for(RecipeCarpentry recipe : controller.globalRecipes.values()){
|
||||
list.appendTag(recipe.writeNBT());
|
||||
i++;
|
||||
if(i % 10 == 0){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("recipes", list);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||
list = new NBTTagList();
|
||||
}
|
||||
}
|
||||
|
||||
if(i % 10 != 0){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("recipes", list);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||
}
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_WORKBENCH);
|
||||
}
|
||||
if(block == CustomItems.carpentyBench && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
|
||||
RecipeController controller = RecipeController.instance;
|
||||
NBTTagList list = new NBTTagList();
|
||||
int i = 0;
|
||||
for(RecipeCarpentry recipe : controller.anvilRecipes.values()){
|
||||
list.appendTag(recipe.writeNBT());
|
||||
i++;
|
||||
if(i % 10 == 0){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("recipes", list);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||
list = new NBTTagList();
|
||||
}
|
||||
}
|
||||
|
||||
if(i % 10 != 0){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("recipes", list);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_ADD, compound);
|
||||
}
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNCRECIPES_CARPENTRYBENCH);
|
||||
}
|
||||
if((block == CustomItems.banner || block == CustomItems.wallBanner || block == CustomItems.sign) && event.action == Action.RIGHT_CLICK_BLOCK){
|
||||
ItemStack item = player.inventory.getCurrentItem();
|
||||
if(item == null || item.getItem() == null)
|
||||
return;
|
||||
int y = event.y;
|
||||
int meta = player.worldObj.getBlockMetadata(event.x, event.y, event.z);
|
||||
if(meta >= 7)
|
||||
y--;
|
||||
TileBanner tile = (TileBanner)player.worldObj.getTileEntity(event.x, y, event.z);
|
||||
if(!tile.canEdit()){
|
||||
if(item.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)){
|
||||
tile.time = System.currentTimeMillis();
|
||||
if(player.worldObj.isRemote)
|
||||
player.addChatComponentMessage(new ChatComponentTranslation("availability.editIcon"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(!player.worldObj.isRemote){
|
||||
tile.icon = item.copy();
|
||||
player.worldObj.markBlockForUpdate(event.x, y, event.z);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(LivingDeathEvent event) {
|
||||
if(event.entityLiving.worldObj.isRemote)
|
||||
return;
|
||||
if(event.source.getEntity() != null){
|
||||
if(event.source.getEntity() instanceof EntityPlayer){
|
||||
doExcalibur((EntityPlayer) event.source.getEntity(),event.entityLiving);
|
||||
}
|
||||
|
||||
if(event.source.getEntity() instanceof EntityNPCInterface && event.entityLiving != null){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity();
|
||||
Line line = npc.advanced.getKillLine();
|
||||
if(line != null)
|
||||
npc.saySurrounding(line.formatTarget(event.entityLiving));
|
||||
|
||||
npc.script.callScript(EnumScriptType.KILLS, "target", event.entityLiving);
|
||||
}
|
||||
|
||||
EntityPlayer player = null;
|
||||
if(event.source.getEntity() instanceof EntityPlayer)
|
||||
player = (EntityPlayer) event.source.getEntity();
|
||||
else if(event.source.getEntity() instanceof EntityNPCInterface && ((EntityNPCInterface)event.source.getEntity()).advanced.role == EnumRoleType.Follower)
|
||||
player = ((RoleFollower)((EntityNPCInterface)event.source.getEntity()).roleInterface).owner;
|
||||
if(player != null){
|
||||
doQuest(player, event.entityLiving, true);
|
||||
|
||||
if(event.entityLiving instanceof EntityNPCInterface)
|
||||
doFactionPoints(player, (EntityNPCInterface)event.entityLiving);
|
||||
}
|
||||
}
|
||||
if(event.entityLiving instanceof EntityPlayer){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer)event.entityLiving);
|
||||
data.saveNBTData(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void doExcalibur(EntityPlayer player, EntityLivingBase entity) {
|
||||
ItemStack item = player.getCurrentEquippedItem();
|
||||
if(item == null || item.getItem() != CustomItems.excalibur)
|
||||
return;
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.PLAY_MUSIC, "customnpcs:songs.excalibur");
|
||||
player.addChatMessage(new ChatComponentTranslation("<" + StatCollector.translateToLocal(item.getItem().getUnlocalizedName() + ".name") + "> " + ItemExcalibur.quotes[player.getRNG().nextInt(ItemExcalibur.quotes.length)]));
|
||||
}
|
||||
|
||||
private void doFactionPoints(EntityPlayer player, EntityNPCInterface npc) {
|
||||
npc.advanced.factions.addPoints(player);
|
||||
}
|
||||
|
||||
private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) {
|
||||
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
boolean change = false;
|
||||
String entityName = EntityList.getEntityString(entity);
|
||||
|
||||
for(QuestData data : playerdata.activeQuests.values()){
|
||||
if(data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill)
|
||||
continue;
|
||||
if(data.quest.type == EnumQuestType.AreaKill && all){
|
||||
List<EntityPlayer> list = player.worldObj.getEntitiesWithinAABB(EntityPlayer.class, entity.boundingBox.expand(10, 10, 10));
|
||||
for(EntityPlayer pl : list)
|
||||
if(pl != player)
|
||||
doQuest(pl, entity, false);
|
||||
|
||||
}
|
||||
String name = entityName;
|
||||
QuestKill quest = (QuestKill) data.quest.questInterface;
|
||||
if(quest.targets.containsKey(entity.getCommandSenderName()))
|
||||
name = entity.getCommandSenderName();
|
||||
else if(!quest.targets.containsKey(name))
|
||||
continue;
|
||||
HashMap<String, Integer> killed = quest.getKilled(data);
|
||||
if(killed.containsKey(name) && killed.get(name) >= quest.targets.get(name))
|
||||
continue;
|
||||
int amount = 0;
|
||||
if(killed.containsKey(name))
|
||||
amount = killed.get(name);
|
||||
killed.put(name, amount + 1);
|
||||
quest.setKilled(data, killed);
|
||||
change = true;
|
||||
}
|
||||
if(!change)
|
||||
return;
|
||||
|
||||
playerdata.checkQuestCompletion(player,EnumQuestType.Kill);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void pickUp(EntityItemPickupEvent event){
|
||||
if(event.entityPlayer.worldObj.isRemote)
|
||||
return;
|
||||
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(event.entityPlayer).questData;
|
||||
playerdata.checkQuestCompletion(event.entityPlayer, EnumQuestType.Item);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void world(EntityJoinWorldEvent event){
|
||||
if(event.world.isRemote || !(event.entity instanceof EntityPlayer))
|
||||
return;
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
|
||||
data.updateCompanion(event.world);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void populateChunk(PopulateChunkEvent.Post event){
|
||||
NPCSpawning.performWorldGenSpawning(event.world, event.chunkX, event.chunkZ, event.rand);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.client.AnalyticsTracking;
|
||||
import noppes.npcs.controllers.SpawnController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
|
||||
public class ServerTickHandler {
|
||||
@SubscribeEvent
|
||||
public void onServerTick(TickEvent.WorldTickEvent event){
|
||||
if(event.phase == Phase.START){
|
||||
NPCSpawning.findChunksForSpawning((WorldServer) event.world);
|
||||
}
|
||||
}
|
||||
|
||||
private String serverName = null;
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerLogin(PlayerEvent.PlayerLoggedInEvent event){
|
||||
if(serverName == null){
|
||||
String e = "local";
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
if(server.isDedicatedServer()){
|
||||
try {
|
||||
e = InetAddress.getByName(server.getServerHostname()).getCanonicalHostName();
|
||||
} catch (UnknownHostException e1) {
|
||||
e = MinecraftServer.getServer().getServerHostname();
|
||||
}
|
||||
if(server.getPort() != 25565)
|
||||
e += ":" + server.getPort();
|
||||
}
|
||||
if(e == null || e.startsWith("192.168") || e.contains("127.0.0.1") || e.startsWith("localhost"))
|
||||
e = "local";
|
||||
serverName = e;
|
||||
}
|
||||
AnalyticsTracking.sendData(event.player, "join", serverName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
public class TextBlock {
|
||||
public List<IChatComponent> lines = new ArrayList<IChatComponent>();
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.controllers.Line;
|
||||
import noppes.npcs.controllers.Lines;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class VersionCompatibility {
|
||||
public static int ModRev = 16;
|
||||
|
||||
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
|
||||
if(npc.npcVersion == ModRev)
|
||||
return;
|
||||
if(npc.npcVersion < 12){
|
||||
CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound()));
|
||||
CompatabilityFix(compound, npc.ai.writeToNBT(new NBTTagCompound()));
|
||||
CompatabilityFix(compound, npc.stats.writeToNBT(new NBTTagCompound()));
|
||||
CompatabilityFix(compound, npc.display.writeToNBT(new NBTTagCompound()));
|
||||
CompatabilityFix(compound, npc.inventory.writeEntityToNBT(new NBTTagCompound()));
|
||||
}
|
||||
if(npc.npcVersion < 5){
|
||||
String texture = compound.getString("Texture");
|
||||
texture = texture.replace("/mob/customnpcs/", "customnpcs:textures/entity/");
|
||||
texture = texture.replace("/mob/", "customnpcs:textures/entity/");
|
||||
compound.setString("Texture", texture);
|
||||
}
|
||||
if(npc.npcVersion < 6 && compound.getTag("NpcInteractLines") instanceof NBTTagList){
|
||||
List<String> interactLines = NBTTags.getStringList(compound.getTagList("NpcInteractLines", 10));
|
||||
Lines lines = new Lines();
|
||||
for(int i = 0; i < interactLines.size(); i++){
|
||||
Line line = new Line();
|
||||
line.text = (String) interactLines.toArray()[i];
|
||||
lines.lines.put(i, line);
|
||||
}
|
||||
compound.setTag("NpcInteractLines", lines.writeToNBT());
|
||||
|
||||
List<String> worldLines = NBTTags.getStringList(compound.getTagList("NpcLines", 10));
|
||||
lines = new Lines();
|
||||
for(int i = 0; i < worldLines.size(); i++){
|
||||
Line line = new Line();
|
||||
line.text = (String) worldLines.toArray()[i];
|
||||
lines.lines.put(i, line);
|
||||
}
|
||||
compound.setTag("NpcLines", lines.writeToNBT());
|
||||
|
||||
List<String> attackLines = NBTTags.getStringList(compound.getTagList("NpcAttackLines", 10));
|
||||
lines = new Lines();
|
||||
for(int i = 0; i < attackLines.size(); i++){
|
||||
Line line = new Line();
|
||||
line.text = (String) attackLines.toArray()[i];
|
||||
lines.lines.put(i, line);
|
||||
}
|
||||
compound.setTag("NpcAttackLines", lines.writeToNBT());
|
||||
|
||||
List<String> killedLines = NBTTags.getStringList(compound.getTagList("NpcKilledLines", 10));
|
||||
lines = new Lines();
|
||||
for(int i = 0; i < killedLines.size(); i++){
|
||||
Line line = new Line();
|
||||
line.text = (String) killedLines.toArray()[i];
|
||||
lines.lines.put(i, line);
|
||||
}
|
||||
compound.setTag("NpcKilledLines", lines.writeToNBT());
|
||||
|
||||
}
|
||||
if(npc.npcVersion == 12){
|
||||
NBTTagList list = compound.getTagList("StartPos", 3);
|
||||
if(list.tagCount() == 3){
|
||||
int z = ((NBTTagInt) list.removeTag(2)).func_150287_d();
|
||||
int y = ((NBTTagInt) list.removeTag(1)).func_150287_d();
|
||||
int x = ((NBTTagInt) list.removeTag(0)).func_150287_d();
|
||||
|
||||
compound.setIntArray("StartPosNew", new int[]{x,y,z});
|
||||
}
|
||||
}
|
||||
if(npc.npcVersion == 13){
|
||||
boolean bo = compound.getBoolean("HealthRegen");
|
||||
compound.setInteger("HealthRegen", bo?1:0);
|
||||
NBTTagCompound comp = compound.getCompoundTag("TransformStats");
|
||||
bo = comp.getBoolean("HealthRegen");
|
||||
comp.setInteger("HealthRegen", bo?1:0);
|
||||
compound.setTag("TransformStats", comp);
|
||||
|
||||
}
|
||||
npc.npcVersion = ModRev;
|
||||
}
|
||||
public static void CheckAvailabilityCompatibility(ICompatibilty compatibilty, NBTTagCompound compound){
|
||||
if(compatibilty.getVersion() == ModRev)
|
||||
return;
|
||||
CompatabilityFix(compound, compatibilty.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
compatibilty.setVersion(ModRev);
|
||||
}
|
||||
private static void CompatabilityFix(NBTTagCompound compound,
|
||||
NBTTagCompound check) {
|
||||
Collection<String> tags = check.func_150296_c();
|
||||
for(String name : tags){
|
||||
NBTBase nbt = check.getTag(name);
|
||||
if(!compound.hasKey(name)){
|
||||
compound.setTag(name, nbt);
|
||||
}
|
||||
else if(nbt instanceof NBTTagCompound && compound.getTag(name) instanceof NBTTagCompound){
|
||||
CompatabilityFix(compound.getCompoundTag(name), (NBTTagCompound)nbt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.pathfinding.PathEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIAmbushTarget extends EntityAIBase
|
||||
{
|
||||
private EntityNPCInterface theEntity;
|
||||
private EntityLivingBase targetEntity;
|
||||
private double shelterX;
|
||||
private double shelterY;
|
||||
private double shelterZ;
|
||||
private double movementSpeed;
|
||||
private double distance;
|
||||
private int delay = 0;
|
||||
private World theWorld;
|
||||
private int tick;
|
||||
private boolean attackFromBehind;
|
||||
|
||||
public EntityAIAmbushTarget(EntityNPCInterface par1EntityCreature, double par2, double par3, boolean par4)
|
||||
{
|
||||
this.theEntity = par1EntityCreature;
|
||||
this.movementSpeed = par2;
|
||||
this.theWorld = par1EntityCreature.worldObj;
|
||||
this.distance = par3 * par3;
|
||||
this.attackFromBehind = par4;
|
||||
this.setMutexBits(AiMutex.PASSIVE + AiMutex.LOOK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
this.targetEntity = this.theEntity.getAttackTarget();
|
||||
|
||||
if (this.targetEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < this.distance || !this.theEntity.canSee(targetEntity))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (delay > 0)
|
||||
{
|
||||
delay--;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec3 vec3 = this.findHidingSpot();
|
||||
|
||||
if (vec3 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.shelterX = vec3.xCoord;
|
||||
this.shelterY = vec3.yCoord;
|
||||
this.shelterZ = vec3.zCoord;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
boolean shouldHide = this.targetEntity.getDistanceSqToEntity(this.theEntity) > this.distance;
|
||||
boolean isSeen = this.theEntity.canSee(targetEntity);
|
||||
return (!this.theEntity.getNavigator().noPath() && shouldHide) || (!isSeen && (shouldHide || this.theEntity.ai.directLOS));
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.theEntity.getNavigator().tryMoveToXYZ(this.shelterX, this.shelterY, this.shelterZ, this.movementSpeed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
this.theEntity.getNavigator().clearPathEntity();
|
||||
if (this.theEntity.getAttackTarget() == null && this.targetEntity != null)
|
||||
{
|
||||
this.theEntity.setAttackTarget(targetEntity);
|
||||
}
|
||||
if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < this.distance)
|
||||
{
|
||||
this.delay = 60;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
|
||||
}
|
||||
|
||||
private Vec3 findHidingSpot()
|
||||
{
|
||||
Random random = this.theEntity.getRNG();
|
||||
Vec3 idealPos = null;
|
||||
|
||||
for (int i = 1; i <= 8; i++)
|
||||
{
|
||||
for (int y = -2; y <= 2; y++)
|
||||
{
|
||||
for (int x = -i; x <= i; x++)
|
||||
{
|
||||
for (int z = -i; z <= i; z++)
|
||||
{
|
||||
double j = MathHelper.floor_double(this.theEntity.posX + x) + 0.5D;
|
||||
double k = MathHelper.floor_double(this.theEntity.boundingBox.minY + y);
|
||||
double l = MathHelper.floor_double(this.theEntity.posZ + z) + 0.5D;
|
||||
|
||||
if (this.theWorld.getBlock((int)j, (int)k, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 1, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 2, (int)l).isOpaqueCube())
|
||||
{
|
||||
Vec3 vec1 = Vec3.createVectorHelper(this.targetEntity.posX, this.targetEntity.posY + (double)this.targetEntity.getEyeHeight(), this.targetEntity.posZ);
|
||||
Vec3 vec2 = Vec3.createVectorHelper(j, k + (double)this.theEntity.getEyeHeight(), l);
|
||||
MovingObjectPosition movingobjectposition = this.theWorld.rayTraceBlocks(vec1, vec2);
|
||||
if (movingobjectposition != null)
|
||||
{
|
||||
if (this.shelterX != j && this.shelterY != k && this.shelterZ != l)
|
||||
{
|
||||
idealPos = Vec3.createVectorHelper(j, k, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (idealPos != null)
|
||||
{
|
||||
return idealPos;
|
||||
}
|
||||
}
|
||||
delay = 60;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.constants.EnumAnimation;
|
||||
import noppes.npcs.constants.EnumMovingType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIAnimation extends EntityAIBase
|
||||
{
|
||||
private EntityNPCInterface npc;
|
||||
|
||||
private boolean isAttacking = false;
|
||||
private boolean isDead = false;
|
||||
private boolean isAtStartpoint = false;
|
||||
private boolean hasPath = false;
|
||||
private int tick = 4;
|
||||
|
||||
public EntityAIAnimation(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute(){
|
||||
isDead = !npc.isEntityAlive();
|
||||
if(isDead)
|
||||
return npc.currentAnimation != EnumAnimation.LYING;
|
||||
|
||||
if(npc.stats.aimWhileShooting && npc.isAttacking())
|
||||
return npc.currentAnimation != EnumAnimation.AIMING;
|
||||
if(npc.ai.animationType == EnumAnimation.NONE)
|
||||
return npc.currentAnimation != EnumAnimation.NONE;
|
||||
isAttacking = npc.isAttacking();
|
||||
if(npc.ai.returnToStart)
|
||||
isAtStartpoint = npc.isVeryNearAssignedPlace();
|
||||
hasPath = !npc.getNavigator().noPath();
|
||||
|
||||
if(npc.ai.movingType == EnumMovingType.Standing && hasNavigation() && npc.currentAnimation.getWalkingAnimation() == 0){
|
||||
return npc.currentAnimation != EnumAnimation.NONE;
|
||||
}
|
||||
|
||||
return npc.currentAnimation != npc.ai.animationType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTask(){
|
||||
if(npc.stats.aimWhileShooting && npc.isAttacking()){
|
||||
setAnimation(EnumAnimation.AIMING);
|
||||
return;
|
||||
}
|
||||
EnumAnimation type = npc.ai.animationType;
|
||||
if(isDead)
|
||||
type = EnumAnimation.LYING;
|
||||
else if(npc.ai.movingType == EnumMovingType.Standing && npc.ai.animationType.getWalkingAnimation() == 0 && hasNavigation())
|
||||
type = EnumAnimation.NONE;
|
||||
setAnimation(type);
|
||||
}
|
||||
|
||||
private void setAnimation(EnumAnimation animation){
|
||||
npc.setCurrentAnimation(animation);
|
||||
npc.updateHitbox();
|
||||
npc.setPosition(npc.posX, npc.posY, npc.posZ);
|
||||
}
|
||||
|
||||
private boolean hasNavigation() {
|
||||
return (isAttacking || npc.ai.returnToStart && !isAtStartpoint && !npc.isFollower() || hasPath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.pathfinding.PathEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIAttackTarget extends EntityAIBase
|
||||
{
|
||||
World worldObj;
|
||||
EntityNPCInterface attacker;
|
||||
EntityLivingBase entityTarget;
|
||||
|
||||
/**
|
||||
* An amount of decrementing ticks that allows the entity to attack once the tick reaches 0.
|
||||
*/
|
||||
int attackTick;
|
||||
|
||||
/** The PathEntity of our entity. */
|
||||
PathEntity entityPathEntity;
|
||||
private int field_75445_i;
|
||||
private boolean navOverride = false;
|
||||
|
||||
public EntityAIAttackTarget(EntityNPCInterface par1EntityLiving){
|
||||
this.attackTick = 0;
|
||||
this.attacker = par1EntityLiving;
|
||||
this.worldObj = par1EntityLiving.worldObj;
|
||||
this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute(){
|
||||
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
|
||||
|
||||
if (entitylivingbase == null){
|
||||
return false;
|
||||
}
|
||||
else if (!entitylivingbase.isEntityAlive()){
|
||||
return false;
|
||||
}
|
||||
else if (this.attacker.inventory.getProjectile() != null && this.attacker.ai.useRangeMelee == 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
double var2 = this.attacker.getDistanceSq(entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ);
|
||||
double var3 = this.attacker.ai.distanceToMelee * this.attacker.ai.distanceToMelee;
|
||||
|
||||
if (this.attacker.ai.useRangeMelee == 1 && var2 > var3){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
this.entityTarget = entitylivingbase;
|
||||
this.entityPathEntity = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
|
||||
return this.entityPathEntity != null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
this.entityTarget = this.attacker.getAttackTarget();
|
||||
|
||||
if(entityTarget == null || !entityTarget.isEntityAlive())
|
||||
return false;
|
||||
if(attacker.getDistanceToEntity(entityTarget) > attacker.stats.aggroRange)
|
||||
return false;
|
||||
if (this.attacker.ai.useRangeMelee == 1 && attacker.getDistanceSqToEntity(entityTarget) > (this.attacker.ai.distanceToMelee * this.attacker.ai.distanceToMelee))
|
||||
return false;
|
||||
|
||||
return this.attacker.isWithinHomeDistance(MathHelper.floor_double(entityTarget.posX), MathHelper.floor_double(entityTarget.posY), MathHelper.floor_double(entityTarget.posZ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting(){
|
||||
if(!navOverride)
|
||||
this.attacker.getNavigator().setPath(this.entityPathEntity, 1.3D);
|
||||
this.field_75445_i = 0;
|
||||
if (this.attacker.getRangedTask() != null && this.attacker.ai.useRangeMelee == 2)
|
||||
{
|
||||
this.attacker.getRangedTask().navOverride(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
this.entityPathEntity = null;
|
||||
this.entityTarget = null;
|
||||
this.attacker.setAttackTarget(null);
|
||||
this.attacker.getNavigator().clearPathEntity();
|
||||
if (this.attacker.getRangedTask() != null && this.attacker.ai.useRangeMelee == 2)
|
||||
{
|
||||
this.attacker.getRangedTask().navOverride(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
this.attacker.getLookHelper().setLookPositionWithEntity(this.entityTarget, 30.0F, 30.0F);
|
||||
if (!navOverride && --this.field_75445_i <= 0)
|
||||
{
|
||||
this.field_75445_i = 4 + this.attacker.getRNG().nextInt(7);
|
||||
this.attacker.getNavigator().tryMoveToEntityLiving(this.entityTarget, 1.3f);
|
||||
}
|
||||
|
||||
this.attackTick = Math.max(this.attackTick - 1, 0);
|
||||
double distance = this.attacker.getDistanceSq(this.entityTarget.posX, this.entityTarget.boundingBox.minY, this.entityTarget.posZ);
|
||||
double range = attacker.stats.attackRange * attacker.stats.attackRange + entityTarget.width;
|
||||
double minRange = this.attacker.width * 2.0F * this.attacker.width * 2.0F + entityTarget.width;
|
||||
if(minRange > range)
|
||||
range = minRange;
|
||||
if (distance <= range && (attacker.canSee(this.entityTarget) || distance < minRange))
|
||||
{
|
||||
if (this.attackTick <= 0)
|
||||
{
|
||||
this.attackTick = this.attacker.stats.attackSpeed;
|
||||
this.attacker.swingItem();
|
||||
this.attacker.attackEntityAsMob(this.entityTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void navOverride(boolean nav){
|
||||
this.navOverride = nav;
|
||||
this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.ai.RandomPositionGenerator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.pathfinding.PathEntity;
|
||||
import net.minecraft.pathfinding.PathNavigate;
|
||||
import net.minecraft.util.Vec3;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.constants.EnumNavType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIAvoidTarget extends EntityAIBase
|
||||
{
|
||||
/** The entity we are attached to */
|
||||
private EntityNPCInterface theEntity;
|
||||
private Entity closestLivingEntity;
|
||||
private float distanceFromEntity;
|
||||
|
||||
private float health;
|
||||
|
||||
/** The PathEntity of our entity */
|
||||
private PathEntity entityPathEntity;
|
||||
|
||||
/** The PathNavigate of our entity */
|
||||
private PathNavigate entityPathNavigate;
|
||||
|
||||
/** The class of the entity we should avoid */
|
||||
private Class targetEntityClass;
|
||||
|
||||
public EntityAIAvoidTarget(EntityNPCInterface par1EntityNPC)
|
||||
{
|
||||
this.theEntity = par1EntityNPC;
|
||||
this.distanceFromEntity = this.theEntity.stats.aggroRange;
|
||||
this.health = this.theEntity.getHealth();
|
||||
this.entityPathNavigate = par1EntityNPC.getNavigator();
|
||||
this.setMutexBits(AiMutex.PASSIVE + AiMutex.LOOK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
EntityLivingBase target = this.theEntity.getAttackTarget();
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
targetEntityClass = target.getClass();
|
||||
|
||||
if (this.targetEntityClass == EntityPlayer.class)
|
||||
{
|
||||
this.closestLivingEntity = this.theEntity.worldObj.getClosestPlayerToEntity(this.theEntity, (double)this.distanceFromEntity);
|
||||
|
||||
if (this.closestLivingEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
List var1 = this.theEntity.worldObj.getEntitiesWithinAABB(this.targetEntityClass, this.theEntity.boundingBox.expand((double)this.distanceFromEntity, 3.0D, (double)this.distanceFromEntity));
|
||||
|
||||
if (var1.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.closestLivingEntity = (Entity)var1.get(0);
|
||||
}
|
||||
|
||||
if (!this.theEntity.getEntitySenses().canSee(this.closestLivingEntity) && this.theEntity.ai.directLOS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec3 var2 = RandomPositionGeneratorAlt.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, Vec3.createVectorHelper(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ));
|
||||
|
||||
boolean var3 = this.theEntity.inventory.getProjectile() == null || this.theEntity.ai.useRangeMelee == 2;
|
||||
|
||||
boolean var4 = var3 ? this.health == this.theEntity.getHealth() : this.theEntity.getRangedTask() != null && !this.theEntity.getRangedTask().hasFired();
|
||||
|
||||
if (var2 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.closestLivingEntity.getDistanceSq(var2.xCoord, var2.yCoord, var2.zCoord) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.theEntity.ai.tacticalVariant == EnumNavType.HitNRun && var4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(var2.xCoord, var2.yCoord, var2.zCoord);
|
||||
return this.entityPathEntity == null ? false : this.entityPathEntity.isDestinationSame(var2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
return !this.entityPathNavigate.noPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.entityPathNavigate.setPath(this.entityPathEntity, 1.0D);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
this.closestLivingEntity = null;
|
||||
this.theEntity.setAttackTarget(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
if (this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) < 49.0D)
|
||||
{
|
||||
this.theEntity.getNavigator().setSpeed(1.2D);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.theEntity.getNavigator().setSpeed(1.0D);
|
||||
}
|
||||
if (this.theEntity.ai.tacticalVariant == EnumNavType.HitNRun)
|
||||
{
|
||||
float dist = this.theEntity.getDistanceToEntity(this.closestLivingEntity);
|
||||
if (dist > this.distanceFromEntity || dist < this.theEntity.ai.tacticalRadius)
|
||||
{
|
||||
this.health = this.theEntity.getHealth();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.ai.EntityAIDoorInteract;
|
||||
import net.minecraft.init.Blocks;
|
||||
|
||||
public class EntityAIBustDoor extends EntityAIDoorInteract
|
||||
{
|
||||
private int breakingTime;
|
||||
private int field_75358_j = -1;
|
||||
|
||||
public EntityAIBustDoor(EntityLiving par1EntityLiving){
|
||||
super(par1EntityLiving);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
return !super.shouldExecute() ? false : (!this.theEntity.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing") ? false : !this.field_151504_e.func_150015_f(this.theEntity.worldObj, this.entityPosX, this.entityPosY, this.entityPosZ));
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
super.startExecuting();
|
||||
this.breakingTime = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
double var1 = this.theEntity.getDistanceSq((double)this.entityPosX, (double)this.entityPosY, (double)this.entityPosZ);
|
||||
return this.breakingTime <= 240 && !this.field_151504_e.func_150015_f(this.theEntity.worldObj, this.entityPosX, this.entityPosY, this.entityPosZ) && var1 < 4.0D;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
super.resetTask();
|
||||
this.theEntity.worldObj.destroyBlockInWorldPartially(this.theEntity.getEntityId(), this.entityPosX, this.entityPosY, this.entityPosZ, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
super.updateTask();
|
||||
|
||||
if (this.theEntity.getRNG().nextInt(20) == 0)
|
||||
{
|
||||
this.theEntity.worldObj.playAuxSFX(1010, this.entityPosX, this.entityPosY, this.entityPosZ, 0);
|
||||
this.theEntity.swingItem();
|
||||
}
|
||||
|
||||
++this.breakingTime;
|
||||
int var1 = (int)((float)this.breakingTime / 240.0F * 10.0F);
|
||||
|
||||
if (var1 != this.field_75358_j)
|
||||
{
|
||||
this.theEntity.worldObj.destroyBlockInWorldPartially(this.theEntity.getEntityId(), this.entityPosX, this.entityPosY, this.entityPosZ, var1);
|
||||
this.field_75358_j = var1;
|
||||
}
|
||||
|
||||
if (this.breakingTime == 240)
|
||||
{
|
||||
this.theEntity.worldObj.setBlock(this.entityPosX, this.entityPosY, this.entityPosZ, Blocks.air);
|
||||
this.theEntity.worldObj.playAuxSFX(1012, this.entityPosX, this.entityPosY, this.entityPosZ, 0);
|
||||
this.theEntity.worldObj.playAuxSFX(2001, this.entityPosX, this.entityPosY, this.entityPosZ, Block.getIdFromBlock(this.field_151504_e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.ai.RandomPositionGenerator;
|
||||
import net.minecraft.util.Vec3;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIDodgeShoot extends EntityAIBase
|
||||
{
|
||||
private EntityNPCInterface entity;
|
||||
private double xPosition;
|
||||
private double yPosition;
|
||||
private double zPosition;
|
||||
|
||||
public EntityAIDodgeShoot(EntityNPCInterface par1EntityNPCInterface)
|
||||
{
|
||||
this.entity = par1EntityNPCInterface;
|
||||
this.setMutexBits(AiMutex.PASSIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
EntityLivingBase var1 = this.entity.getAttackTarget();
|
||||
|
||||
if (var1 == null || !var1.isEntityAlive())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (this.entity.inventory.getProjectile() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.entity.getRangedTask() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Vec3 vec = this.entity.getRangedTask().hasFired() ? RandomPositionGeneratorAlt.findRandomTarget(this.entity, 4, 1) : null;
|
||||
|
||||
if (vec == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.xPosition = vec.xCoord;
|
||||
this.yPosition = vec.yCoord;
|
||||
this.zPosition = vec.zCoord;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
return !this.entity.getNavigator().noPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, 1.2D);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
if (this.entity.getAttackTarget() != null)
|
||||
this.entity.getLookHelper().setLookPositionWithEntity(this.entity.getAttackTarget(), 30.0F, 30.0F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
|
||||
public class EntityAIFindShade extends EntityAIBase
|
||||
{
|
||||
private EntityCreature theCreature;
|
||||
private double shelterX;
|
||||
private double shelterY;
|
||||
private double shelterZ;
|
||||
private World theWorld;
|
||||
|
||||
public EntityAIFindShade(EntityCreature par1EntityCreature)
|
||||
{
|
||||
this.theCreature = par1EntityCreature;
|
||||
this.theWorld = par1EntityCreature.worldObj;
|
||||
this.setMutexBits(AiMutex.PASSIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (!this.theWorld.isDaytime())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!this.theWorld.canBlockSeeTheSky(MathHelper.floor_double(this.theCreature.posX), (int)this.theCreature.boundingBox.minY, MathHelper.floor_double(this.theCreature.posZ)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec3 var1 = this.findPossibleShelter();
|
||||
|
||||
if (var1 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.shelterX = var1.xCoord;
|
||||
this.shelterY = var1.yCoord;
|
||||
this.shelterZ = var1.zCoord;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
return !this.theCreature.getNavigator().noPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.theCreature.getNavigator().tryMoveToXYZ(this.shelterX, this.shelterY, this.shelterZ, 1.0D);
|
||||
}
|
||||
|
||||
private Vec3 findPossibleShelter()
|
||||
{
|
||||
Random var1 = this.theCreature.getRNG();
|
||||
|
||||
for (int var2 = 0; var2 < 10; ++var2)
|
||||
{
|
||||
int var3 = MathHelper.floor_double(this.theCreature.posX + (double)var1.nextInt(20) - 10.0D);
|
||||
int var4 = MathHelper.floor_double(this.theCreature.boundingBox.minY + (double)var1.nextInt(6) - 3.0D);
|
||||
int var5 = MathHelper.floor_double(this.theCreature.posZ + (double)var1.nextInt(20) - 10.0D);
|
||||
|
||||
float light = this.theWorld.getLightBrightness(var3, var4, var5) - 0.5F;
|
||||
if (!this.theWorld.canBlockSeeTheSky(var3, var4, var5) && light < 0.0F)
|
||||
{
|
||||
return Vec3.createVectorHelper((double)var3, (double)var4, (double)var5);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.ai.RandomPositionGenerator;
|
||||
import net.minecraft.pathfinding.PathEntity;
|
||||
import net.minecraft.pathfinding.PathPoint;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.constants.EnumAnimation;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIFollow extends EntityAIBase
|
||||
{
|
||||
private EntityNPCInterface npc;
|
||||
private EntityLivingBase owner;
|
||||
private double distance;
|
||||
public int updateTick = 0;
|
||||
|
||||
public EntityAIFollow(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
this.setMutexBits(AiMutex.PASSIVE + AiMutex.LOOK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute(){
|
||||
if(!excute())
|
||||
return false;
|
||||
return distance > npc.followRange();
|
||||
}
|
||||
|
||||
public boolean excute(){
|
||||
if(!npc.isEntityAlive() || !npc.isFollower() || npc.isAttacking() || (owner = npc.getOwner()) == null || npc.ai.animationType == EnumAnimation.SITTING)
|
||||
return false;
|
||||
distance = npc.getDistanceSqToEntity(owner);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startExecuting(){
|
||||
updateTick = 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean continueExecuting(){
|
||||
return !this.npc.getNavigator().noPath() && distance > 4 && excute();
|
||||
}
|
||||
@Override
|
||||
public void resetTask(){
|
||||
this.owner = null;
|
||||
this.npc.getNavigator().clearPathEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTask(){
|
||||
updateTick++;
|
||||
if(updateTick < 10)
|
||||
return;
|
||||
updateTick = 0;
|
||||
this.npc.getLookHelper().setLookPositionWithEntity(owner, 10.0F, (float)this.npc.getVerticalFaceSpeed());
|
||||
|
||||
double speed = 1 + distance / 150;
|
||||
if(speed > 3)
|
||||
speed = 3;
|
||||
if (this.npc.getNavigator().tryMoveToEntityLiving(owner, speed) || distance < 225.0D)
|
||||
return;
|
||||
|
||||
int i = MathHelper.floor_double(this.owner.posX) - 2;
|
||||
int j = MathHelper.floor_double(this.owner.posZ) - 2;
|
||||
int k = MathHelper.floor_double(this.owner.boundingBox.minY);
|
||||
|
||||
for (int l = 0; l <= 4; ++l)
|
||||
{
|
||||
for (int i1 = 0; i1 <= 4; ++i1)
|
||||
{
|
||||
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && World.doesBlockHaveSolidTopSurface(npc.worldObj, i + l, k - 1, j + i1) && !npc.worldObj.getBlock(i + l, k, j + i1).isNormalCube() && !npc.worldObj.getBlock(i + l, k + 1, j + i1).isNormalCube())
|
||||
{
|
||||
this.npc.setLocationAndAngles((double)((float)(i + l) + 0.5F), (double)k, (double)((float)(j + i1) + 0.5F), this.npc.rotationYaw, this.npc.rotationPitch);
|
||||
this.npc.getNavigator().clearPathEntity();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIJob extends EntityAIBase {
|
||||
|
||||
private EntityNPCInterface npc;
|
||||
public EntityAIJob(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute() {
|
||||
if(npc.isKilled() || npc.jobInterface == null)
|
||||
return false;
|
||||
return npc.jobInterface.aiShouldExecute();
|
||||
}
|
||||
|
||||
public void startExecuting()
|
||||
{
|
||||
npc.jobInterface.aiStartExecuting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
if(npc.isKilled() || npc.jobInterface == null)
|
||||
return false;
|
||||
return npc.jobInterface.aiContinueExecute();
|
||||
}
|
||||
|
||||
public void updateTask()
|
||||
{
|
||||
npc.jobInterface.aiUpdateTask();
|
||||
}
|
||||
|
||||
public void resetTask() {
|
||||
if(npc.jobInterface != null)
|
||||
npc.jobInterface.resetTask();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.constants.EnumStandingType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAILook extends EntityAIBase{
|
||||
private final EntityNPCInterface npc;
|
||||
private int idle = 0;
|
||||
private double lookX;
|
||||
private double lookZ;
|
||||
boolean rotatebody;
|
||||
|
||||
public EntityAILook(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
this.setMutexBits(AiMutex.LOOK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldExecute(){
|
||||
return !npc.isAttacking() && npc.getNavigator().noPath() && !npc.isPlayerSleeping() && npc.isEntityAlive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
@Override
|
||||
public void startExecuting(){
|
||||
rotatebody = npc.ai.standingType == EnumStandingType.RotateBody || npc.ai.standingType == EnumStandingType.HeadRotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
@Override
|
||||
public void resetTask(){
|
||||
rotatebody = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
@Override
|
||||
public void updateTask(){
|
||||
if(npc.ai.standingType == EnumStandingType.Stalking){
|
||||
EntityPlayer player = npc.worldObj.getClosestPlayerToEntity(npc, 16);
|
||||
if(player == null)
|
||||
rotatebody = true;
|
||||
else
|
||||
npc.getLookHelper().setLookPositionWithEntity(player, 10F, npc.getVerticalFaceSpeed());
|
||||
}
|
||||
if(npc.isInteracting()){
|
||||
Iterator<EntityLivingBase> ita = npc.interactingEntities.iterator();
|
||||
EntityLivingBase closest = null;
|
||||
double closestDistance = 12;
|
||||
while(ita.hasNext()){
|
||||
EntityLivingBase entity = ita.next();
|
||||
double distance = entity.getDistanceSqToEntity(npc);
|
||||
if(distance < closestDistance){
|
||||
closestDistance = entity.getDistanceSqToEntity(npc);
|
||||
closest = entity;
|
||||
}
|
||||
else if(distance > 12)
|
||||
ita.remove();
|
||||
}
|
||||
if(closest != null){
|
||||
npc.getLookHelper().setLookPositionWithEntity(closest, 10F, npc.getVerticalFaceSpeed());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(rotatebody){
|
||||
if(idle == 0 && npc.getRNG().nextFloat() < 0.02F){
|
||||
double var1 = (Math.PI * 2D) * this.npc.getRNG().nextDouble();
|
||||
if(npc.ai.standingType == EnumStandingType.HeadRotation)
|
||||
var1 = Math.PI / 180 * npc.ai.orientation + Math.PI * 0.2 + Math.PI * 0.6 * this.npc.getRNG().nextDouble();
|
||||
this.lookX = Math.cos(var1);
|
||||
this.lookZ = Math.sin(var1);
|
||||
this.idle = 20 + this.npc.getRNG().nextInt(20);
|
||||
}
|
||||
if(idle > 0){
|
||||
idle--;
|
||||
npc.getLookHelper().setLookPosition(npc.posX + lookX, npc.posY + npc.getEyeHeight(), npc.posZ + lookZ, 10F, npc.getVerticalFaceSpeed());
|
||||
}
|
||||
}
|
||||
|
||||
if(npc.ai.standingType == EnumStandingType.NoRotation){
|
||||
npc.rotationYawHead = npc.rotationYaw = npc.renderYawOffset = npc.ai.orientation;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
|
||||
public class EntityAIMoveIndoors extends EntityAIBase
|
||||
{
|
||||
private EntityCreature theCreature;
|
||||
private double shelterX;
|
||||
private double shelterY;
|
||||
private double shelterZ;
|
||||
private World theWorld;
|
||||
|
||||
public EntityAIMoveIndoors(EntityCreature par1EntityCreature)
|
||||
{
|
||||
this.theCreature = par1EntityCreature;
|
||||
this.theWorld = par1EntityCreature.worldObj;
|
||||
this.setMutexBits(AiMutex.PASSIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
|
||||
int x = MathHelper.floor_double(this.theCreature.posX);
|
||||
int y = (int)this.theCreature.boundingBox.minY;
|
||||
int z = MathHelper.floor_double(this.theCreature.posZ);
|
||||
if ((!this.theCreature.worldObj.isDaytime() || this.theCreature.worldObj.isRaining()) && !this.theCreature.worldObj.provider.hasNoSky)
|
||||
{
|
||||
if (!this.theWorld.canBlockSeeTheSky(x, y, z) && this.theWorld.getFullBlockLightValue(x, y, z) > 8)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec3 var1 = this.findPossibleShelter();
|
||||
|
||||
if (var1 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.shelterX = var1.xCoord;
|
||||
this.shelterY = var1.yCoord;
|
||||
this.shelterZ = var1.zCoord;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
return !this.theCreature.getNavigator().noPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.theCreature.getNavigator().tryMoveToXYZ(this.shelterX, this.shelterY, this.shelterZ, 1.0D);
|
||||
}
|
||||
|
||||
private Vec3 findPossibleShelter()
|
||||
{
|
||||
Random var1 = this.theCreature.getRNG();
|
||||
|
||||
for (int var2 = 0; var2 < 10; ++var2)
|
||||
{
|
||||
int var3 = MathHelper.floor_double(this.theCreature.posX + (double)var1.nextInt(20) - 10.0D);
|
||||
int var4 = MathHelper.floor_double(this.theCreature.boundingBox.minY + (double)var1.nextInt(6) - 3.0D);
|
||||
int var5 = MathHelper.floor_double(this.theCreature.posZ + (double)var1.nextInt(20) - 10.0D);
|
||||
|
||||
if (!this.theWorld.canBlockSeeTheSky(var3, var4, var5) && this.theWorld.getFullBlockLightValue(var3, var4, var5) > 8)
|
||||
{
|
||||
return Vec3.createVectorHelper((double)var3, (double)var4, (double)var5);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.constants.EnumMovingType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIMovingPath extends EntityAIBase
|
||||
{
|
||||
private EntityNPCInterface npc;
|
||||
private int[] pos;
|
||||
|
||||
public EntityAIMovingPath(EntityNPCInterface par1EntityNPCInterface){
|
||||
this.npc = par1EntityNPCInterface;
|
||||
this.setMutexBits(AiMutex.PASSIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldExecute(){
|
||||
if (npc.isAttacking() || npc.isInteracting() || npc.getRNG().nextInt(40) != 0 && npc.ai.movingPause || !npc.getNavigator().noPath() || npc.isInteracting())
|
||||
return false;
|
||||
|
||||
List<int[]> list = npc.ai.getMovingPath();
|
||||
if(list.size() < 2)
|
||||
return false;
|
||||
|
||||
npc.ai.incrementMovingPath();
|
||||
pos = npc.ai.getCurrentMovingPath();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
@Override
|
||||
public boolean continueExecuting(){
|
||||
if(npc.isAttacking() || npc.isInteracting()){
|
||||
npc.ai.decreaseMovingPath();
|
||||
return false;
|
||||
}
|
||||
return !this.npc.getNavigator().noPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
@Override
|
||||
public void startExecuting(){
|
||||
this.npc.getNavigator().tryMoveToXYZ(pos[0] + 0.5, pos[1], pos[2] + 0.5, 1.0D);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.monster.EntityPigZombie;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.pathfinding.PathEntity;
|
||||
import net.minecraft.pathfinding.PathPoint;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIOrbitTarget extends EntityAIBase
|
||||
{
|
||||
private EntityNPCInterface theEntity;
|
||||
private EntityLivingBase targetEntity;
|
||||
private double movePosX;
|
||||
private double movePosY;
|
||||
private double movePosZ;
|
||||
private double speed;
|
||||
private float distance;
|
||||
private int delay = 0;
|
||||
private float angle = 0;
|
||||
private int direction = 1;
|
||||
private float targetDistance;
|
||||
private boolean decay;
|
||||
private boolean canNavigate = true;
|
||||
private float decayRate = 1.0F;
|
||||
private int tick = 0;
|
||||
|
||||
public EntityAIOrbitTarget(EntityNPCInterface par1EntityCreature, double par2, float par4, boolean par5)
|
||||
{
|
||||
this.theEntity = par1EntityCreature;
|
||||
this.speed = par2;
|
||||
this.distance = par4;
|
||||
this.decay = par5;
|
||||
this.setMutexBits(AiMutex.PASSIVE + AiMutex.LOOK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (--delay > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this.targetEntity = this.theEntity.getAttackTarget();
|
||||
|
||||
if (this.targetEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
double d0 = this.theEntity.getDistanceToEntity(this.targetEntity);
|
||||
return d0 >= this.distance / 2.0F && (this.theEntity.inventory.getProjectile() == null ? d0 <= this.distance : true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
double d0 = this.targetEntity.getDistanceToEntity(this.theEntity);
|
||||
return this.targetEntity.isEntityAlive() && d0 >= this.distance / 2.0F && d0 <= this.distance * 1.5F && !this.theEntity.isInWater() && this.canNavigate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
this.theEntity.getNavigator().clearPathEntity();
|
||||
this.delay = 60;
|
||||
if (this.theEntity.getRangedTask() != null){
|
||||
this.theEntity.getRangedTask().navOverride(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.canNavigate = true;
|
||||
Random random = this.theEntity.getRNG();
|
||||
this.direction = random.nextInt(10) > 5 ? 1 : -1;
|
||||
this.decayRate = random.nextFloat() + (this.distance / 16.0F);
|
||||
this.targetDistance = this.theEntity.getDistanceToEntity(this.targetEntity);
|
||||
double d0 = this.theEntity.posX - this.targetEntity.posX;
|
||||
double d1 = this.theEntity.posZ - this.targetEntity.posZ;
|
||||
this.angle = (float) (Math.atan2(d1, d0) * 180.0F / Math.PI);
|
||||
if (this.theEntity.getRangedTask() != null){
|
||||
this.theEntity.getRangedTask().navOverride(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
|
||||
if (this.theEntity.getNavigator().noPath() && this.tick >= 0)
|
||||
{
|
||||
if (this.theEntity.onGround && !this.theEntity.isInWater())
|
||||
{
|
||||
double d0 = this.targetDistance * (double)(MathHelper.cos(angle / 180.0F * (float)Math.PI));
|
||||
double d1 = this.targetDistance * (double)(MathHelper.sin(angle / 180.0F * (float)Math.PI));
|
||||
this.movePosX = this.targetEntity.posX + d0;
|
||||
this.movePosY = this.targetEntity.boundingBox.maxY;
|
||||
this.movePosZ = this.targetEntity.posZ + d1;
|
||||
this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.speed);
|
||||
this.angle += 15.0F * this.direction;
|
||||
this.tick = MathHelper.ceiling_double_int(this.theEntity.getDistance(this.movePosX, this.movePosY, this.movePosZ) / (this.theEntity.getSpeed() / 20.0F));
|
||||
if (this.decay)
|
||||
{
|
||||
this.targetDistance -=decayRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.tick >= 0) this.tick--;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.ai.RandomPositionGenerator;
|
||||
import net.minecraft.util.Vec3;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
|
||||
public class EntityAIPanic extends EntityAIBase
|
||||
{
|
||||
private EntityCreature theEntityCreature;
|
||||
private float speed;
|
||||
private double randPosX;
|
||||
private double randPosY;
|
||||
private double randPosZ;
|
||||
|
||||
public EntityAIPanic(EntityCreature par1EntityCreature, float par2)
|
||||
{
|
||||
this.theEntityCreature = par1EntityCreature;
|
||||
this.speed = par2;
|
||||
this.setMutexBits(AiMutex.PASSIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute(){
|
||||
if (this.theEntityCreature.getAttackTarget() == null && !this.theEntityCreature.isBurning()){
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec3 var1 = RandomPositionGeneratorAlt.findRandomTarget(this.theEntityCreature, 5, 4);
|
||||
|
||||
if (var1 == null){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
this.randPosX = var1.xCoord;
|
||||
this.randPosY = var1.yCoord;
|
||||
this.randPosZ = var1.zCoord;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting(){
|
||||
this.theEntityCreature.getNavigator().tryMoveToXYZ(this.randPosX, this.randPosY, this.randPosZ, this.speed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting(){
|
||||
if(this.theEntityCreature.getAttackTarget() == null)
|
||||
return false;
|
||||
return !this.theEntityCreature.getNavigator().noPath();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.IRangedAttackMob;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.constants.EnumAnimation;
|
||||
import noppes.npcs.constants.EnumNavType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIRangedAttack extends EntityAIBase
|
||||
{
|
||||
/** The entity the AI instance has been applied to */
|
||||
private final EntityNPCInterface entityHost;
|
||||
|
||||
/**
|
||||
* The entity (as a RangedAttackMob) the AI instance has been applied to.
|
||||
*/
|
||||
private final IRangedAttackMob rangedAttackEntityHost;
|
||||
private EntityLivingBase attackTarget;
|
||||
|
||||
/**
|
||||
* A decrementing tick that spawns a ranged attack once this value reaches 0. It is then set back to the
|
||||
* maxRangedAttackTime.
|
||||
*/
|
||||
private int rangedAttackTime = 0;
|
||||
private int field_75318_f = 0;
|
||||
private int field_70846_g = 0;
|
||||
private int attackTick = 0;
|
||||
private boolean hasFired = false;
|
||||
private boolean navOverride = false;
|
||||
|
||||
public EntityAIRangedAttack(IRangedAttackMob par1IRangedAttackMob)
|
||||
{
|
||||
if (!(par1IRangedAttackMob instanceof EntityLivingBase))
|
||||
{
|
||||
throw new IllegalArgumentException("ArrowAttackGoal requires Mob implements RangedAttackMob");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.rangedAttackEntityHost = par1IRangedAttackMob;
|
||||
this.entityHost = (EntityNPCInterface)par1IRangedAttackMob;
|
||||
this.rangedAttackTime = this.entityHost.stats.minDelay / 2;
|
||||
this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
EntityLivingBase var1 = this.entityHost.getAttackTarget();
|
||||
|
||||
if (var1 == null || !var1.isEntityAlive()) return false;
|
||||
|
||||
if(entityHost.getDistanceToEntity(var1) > entityHost.stats.aggroRange) return false;
|
||||
|
||||
if (this.entityHost.inventory.getProjectile() == null) return false;
|
||||
|
||||
double var2 = this.entityHost.getDistanceSq(var1.posX, var1.boundingBox.minY, var1.posZ);
|
||||
double var3 = this.entityHost.ai.distanceToMelee * this.entityHost.ai.distanceToMelee;
|
||||
|
||||
if (this.entityHost.ai.useRangeMelee >= 1 && var2 <= var3) return false;
|
||||
|
||||
else
|
||||
{
|
||||
this.attackTarget = var1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
return this.shouldExecute() || !this.entityHost.getNavigator().noPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
this.attackTarget = null;
|
||||
this.entityHost.setAttackTarget(null);
|
||||
this.entityHost.getNavigator().clearPathEntity();
|
||||
this.field_75318_f = 0;
|
||||
this.hasFired = false;
|
||||
this.rangedAttackTime = this.entityHost.stats.minDelay / 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
this.entityHost.getLookHelper().setLookPositionWithEntity(this.attackTarget, 30.0F, 30.0F);
|
||||
double var1 = this.entityHost.getDistanceSq(this.attackTarget.posX, this.attackTarget.boundingBox.minY, this.attackTarget.posZ);
|
||||
float field_82642_h = this.entityHost.stats.rangedRange * this.entityHost.stats.rangedRange;
|
||||
|
||||
if (!navOverride && this.entityHost.ai.directLOS)
|
||||
{
|
||||
if (this.entityHost.getEntitySenses().canSee(this.attackTarget))
|
||||
{
|
||||
++this.field_75318_f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.field_75318_f = 0;
|
||||
}
|
||||
int v = this.entityHost.ai.tacticalVariant == EnumNavType.Default ? 20 : 5;
|
||||
if (var1 <= (double)field_82642_h && this.field_75318_f >= v)
|
||||
{
|
||||
this.entityHost.getNavigator().clearPathEntity();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.entityHost.getNavigator().tryMoveToEntityLiving(this.attackTarget, 1.0D);
|
||||
}
|
||||
}
|
||||
|
||||
this.rangedAttackTime = Math.max(this.rangedAttackTime - 1, 0);
|
||||
|
||||
if (this.rangedAttackTime <= 0)
|
||||
{
|
||||
if (var1 <= (double)field_82642_h && (this.entityHost.getEntitySenses().canSee(this.attackTarget) || this.entityHost.ai.canFireIndirect == 2))
|
||||
{
|
||||
if (this.field_70846_g++ <= this.entityHost.stats.burstCount)
|
||||
{
|
||||
this.rangedAttackTime = this.entityHost.stats.fireRate;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.field_70846_g = 0;
|
||||
this.hasFired = true;
|
||||
this.rangedAttackTime = (this.entityHost.stats.maxDelay - MathHelper.floor_float(this.entityHost.getRNG().nextFloat() * (this.entityHost.stats.maxDelay - this.entityHost.stats.minDelay)));
|
||||
}
|
||||
|
||||
if (this.field_70846_g > 1)
|
||||
{
|
||||
boolean indirect = false;
|
||||
|
||||
switch(this.entityHost.ai.canFireIndirect)
|
||||
{
|
||||
case 1 : indirect = var1 > (double)field_82642_h / 2; break;
|
||||
case 2 : indirect = !this.entityHost.getEntitySenses().canSee(this.attackTarget);
|
||||
}
|
||||
|
||||
this.rangedAttackEntityHost.attackEntityWithRangedAttack(this.attackTarget, indirect ? 1 : 0);
|
||||
if (this.entityHost.currentAnimation != EnumAnimation.AIMING)
|
||||
{
|
||||
this.entityHost.swingItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasFired()
|
||||
{
|
||||
return this.hasFired;
|
||||
}
|
||||
|
||||
public void navOverride(boolean nav){
|
||||
this.navOverride = nav;
|
||||
this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
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;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIReturn extends EntityAIBase
|
||||
{
|
||||
public static final int MaxTotalTicks = 600;
|
||||
private final EntityNPCInterface npc;
|
||||
private int stuckTicks = 0;
|
||||
private int totalTicks = 0;
|
||||
private double endPosX;
|
||||
private double endPosY;
|
||||
private double endPosZ;
|
||||
private boolean wasAttacked = false;
|
||||
private double[] preAttackPos;
|
||||
private int stuckCount = 0;
|
||||
|
||||
public EntityAIReturn(EntityNPCInterface npc)
|
||||
{
|
||||
this.npc = npc;
|
||||
this.setMutexBits(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute(){
|
||||
if(npc.hasOwner() || !npc.ai.returnToStart || npc.isKilled() || !npc.getNavigator().noPath() || 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){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (npc.ai.findShelter == 1 && npc.worldObj.isDaytime()){
|
||||
if (npc.worldObj.canBlockSeeTheSky((int)npc.getStartXPos(), (int)npc.getStartYPos(), (int)npc.getStartZPos())){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(npc.isAttacking()){
|
||||
if(!wasAttacked){
|
||||
wasAttacked = true;
|
||||
preAttackPos = new double[]{npc.posX, npc.posY, npc.posZ};
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if(!npc.isAttacking() && wasAttacked){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(npc.ai.movingType == EnumMovingType.MovingPath && npc.ai.getDistanceSqToPathPoint() < CustomNpcs.NpcNavRange * CustomNpcs.NpcNavRange)
|
||||
return false;
|
||||
|
||||
if(npc.ai.movingType == EnumMovingType.Wandering)
|
||||
return this.npc.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos()) > npc.ai.walkingRange * npc.ai.walkingRange;
|
||||
|
||||
if(npc.ai.movingType == EnumMovingType.Standing)
|
||||
return !this.npc.isVeryNearAssignedPlace();
|
||||
|
||||
return false;
|
||||
}
|
||||
public boolean continueExecuting(){
|
||||
return !npc.isFollower() && !npc.isKilled() && !npc.isAttacking() && !npc.isVeryNearAssignedPlace() && totalTicks <= MaxTotalTicks && !npc.isInteracting();
|
||||
}
|
||||
|
||||
public void updateTask(){
|
||||
totalTicks++;
|
||||
if(totalTicks > MaxTotalTicks){
|
||||
npc.setPosition(endPosX, endPosY, endPosZ);
|
||||
npc.getNavigator().clearPathEntity();
|
||||
return;
|
||||
}
|
||||
|
||||
if(stuckTicks > 0){
|
||||
stuckTicks--;
|
||||
}
|
||||
else if(npc.getNavigator().noPath()){
|
||||
stuckCount++;
|
||||
stuckTicks = 10;
|
||||
if(totalTicks > 30 && wasAttacked && isTooFar() || stuckCount > 5 ){
|
||||
npc.setPosition(endPosX, endPosY, endPosZ);
|
||||
npc.getNavigator().clearPathEntity();
|
||||
}
|
||||
else
|
||||
navigate(stuckCount % 2 == 1);
|
||||
}
|
||||
else{
|
||||
stuckCount = 0;
|
||||
}
|
||||
}
|
||||
private boolean isTooFar(){
|
||||
int allowedDistance = npc.stats.aggroRange * 2;
|
||||
if(npc.ai.movingType == EnumMovingType.Wandering)
|
||||
allowedDistance += npc.ai.walkingRange;
|
||||
return npc.getDistanceSq(endPosX, endPosY, endPosZ) > allowedDistance * allowedDistance;
|
||||
}
|
||||
|
||||
public void startExecuting()
|
||||
{
|
||||
stuckTicks = 0;
|
||||
totalTicks = 0;
|
||||
stuckCount = 0;
|
||||
navigate(false);
|
||||
}
|
||||
private void navigate(boolean towards) {
|
||||
if(!wasAttacked){
|
||||
endPosX = npc.getStartXPos();
|
||||
endPosY = npc.getStartYPos();
|
||||
endPosZ = npc.getStartZPos();
|
||||
}
|
||||
else{
|
||||
endPosX = preAttackPos[0];
|
||||
endPosY = preAttackPos[1];
|
||||
endPosZ = preAttackPos[2];
|
||||
}
|
||||
double posX = endPosX;
|
||||
double posY = endPosY;
|
||||
double posZ = endPosZ;
|
||||
double range = npc.getDistance(posX, posY, posZ);
|
||||
if(range > CustomNpcs.NpcNavRange || towards){
|
||||
int distance = (int) range;
|
||||
if(distance > CustomNpcs.NpcNavRange)
|
||||
distance = CustomNpcs.NpcNavRange / 2;
|
||||
else
|
||||
distance /= 2;
|
||||
if(distance > 2){
|
||||
Vec3 start = Vec3.createVectorHelper(posX, posY, posZ);
|
||||
Vec3 pos = RandomPositionGeneratorAlt.findRandomTargetBlockTowards(npc, distance,distance /2 > 7? 7:distance/2, start);
|
||||
if(pos != null){
|
||||
posX = pos.xCoord;
|
||||
posY = pos.yCoord;
|
||||
posZ = pos.zCoord;
|
||||
}
|
||||
}
|
||||
}
|
||||
npc.getNavigator().clearPathEntity();
|
||||
npc.getNavigator().tryMoveToXYZ(posX, posY, posZ, 1);
|
||||
}
|
||||
|
||||
public void resetTask(){
|
||||
wasAttacked = false;
|
||||
this.npc.getNavigator().clearPathEntity();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIRole extends EntityAIBase {
|
||||
|
||||
private EntityNPCInterface npc;
|
||||
public EntityAIRole(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute() {
|
||||
if(npc.isKilled() || npc.roleInterface == null)
|
||||
return false;
|
||||
return npc.roleInterface.aiShouldExecute();
|
||||
}
|
||||
|
||||
public void startExecuting()
|
||||
{
|
||||
npc.roleInterface.aiStartExecuting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
if(npc.isKilled() || npc.roleInterface == null)
|
||||
return false;
|
||||
return npc.roleInterface.aiContinueExecute();
|
||||
}
|
||||
|
||||
public void updateTask(){
|
||||
if(npc.roleInterface != null)
|
||||
npc.roleInterface.aiUpdateTask();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAISprintToTarget extends EntityAIBase
|
||||
{
|
||||
/** The entity that is leaping. */
|
||||
EntityNPCInterface runner;
|
||||
|
||||
/** The entity that the leaper is leaping towards. */
|
||||
EntityLivingBase runTarget;
|
||||
|
||||
public EntityAISprintToTarget(EntityNPCInterface par1EntityLiving)
|
||||
{
|
||||
this.runner = par1EntityLiving;
|
||||
this.setMutexBits(AiMutex.PASSIVE + AiMutex.PATHING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
this.runTarget = this.runner.getAttackTarget();
|
||||
|
||||
if (this.runTarget == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.runner.getNavigator().noPath())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(this.runner.ai.onAttack)
|
||||
{
|
||||
case 0 : return this.runner.getDistanceSqToEntity(this.runTarget) >= 64.0D ? (!this.runner.onGround ? false : true) : false;
|
||||
case 2 : return this.runner.getDistanceSqToEntity(this.runTarget) <= 49.0D ? (!this.runner.onGround ? false : true) : false;
|
||||
default : return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
return this.runner.isEntityAlive() && this.runner.onGround && this.runner.hurtTime <= 0 && (this.runner.motionX != 0.0D && this.runner.motionZ != 0.0D);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.runner.setSprinting(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
this.runner.setSprinting(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.constants.EnumNavType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIStalkTarget extends EntityAIBase
|
||||
{
|
||||
private EntityNPCInterface theEntity;
|
||||
private EntityLivingBase targetEntity;
|
||||
private Vec3 movePosition;
|
||||
private double distance;
|
||||
private boolean overRide;
|
||||
private World theWorld;
|
||||
private int delay;
|
||||
private int tick = 0;
|
||||
|
||||
public EntityAIStalkTarget(EntityNPCInterface par1EntityCreature, double par2)
|
||||
{
|
||||
this.theEntity = par1EntityCreature;
|
||||
this.theWorld = par1EntityCreature.worldObj;
|
||||
this.distance = par2 * par2;
|
||||
this.overRide = false;
|
||||
this.delay = 0;
|
||||
this.setMutexBits(AiMutex.PASSIVE + AiMutex.LOOK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
this.targetEntity = this.theEntity.getAttackTarget();
|
||||
|
||||
if (this.targetEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.tick > 0)
|
||||
{
|
||||
this.tick--;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.targetEntity.getDistanceSqToEntity(this.theEntity) > this.distance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
public void resetTask()
|
||||
{
|
||||
this.theEntity.getNavigator().clearPathEntity();
|
||||
if (this.theEntity.getAttackTarget() == null && this.targetEntity != null)
|
||||
{
|
||||
this.theEntity.setAttackTarget(targetEntity);
|
||||
}
|
||||
|
||||
if (this.theEntity.getRangedTask() != null)
|
||||
{
|
||||
this.theEntity.getRangedTask().navOverride(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void startExecuting()
|
||||
{
|
||||
if (this.theEntity.getRangedTask() != null)
|
||||
{
|
||||
this.theEntity.getRangedTask().navOverride(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
|
||||
|
||||
if (this.theEntity.getNavigator().noPath() || this.overRide)
|
||||
{
|
||||
if (this.isLookingAway())
|
||||
{
|
||||
this.movePosition = this.stalkTarget();
|
||||
if (this.movePosition != null)
|
||||
{
|
||||
this.theEntity.getNavigator().tryMoveToXYZ(this.movePosition.xCoord, this.movePosition.yCoord, this.movePosition.zCoord, 1.0D);
|
||||
this.overRide = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tick = 100;
|
||||
}
|
||||
|
||||
}
|
||||
else if (this.theEntity.canSee(targetEntity))
|
||||
{
|
||||
this.movePosition = this.hideFromTarget();
|
||||
if (this.movePosition != null)
|
||||
{
|
||||
this.theEntity.getNavigator().tryMoveToXYZ(this.movePosition.xCoord, this.movePosition.yCoord, this.movePosition.zCoord, 1.33D);
|
||||
this.overRide = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tick = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.delay > 0) this.delay--;
|
||||
|
||||
if (!this.isLookingAway() && this.theEntity.canSee(targetEntity) && this.delay == 0)
|
||||
{
|
||||
this.overRide = true;
|
||||
this.delay = 60;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Vec3 hideFromTarget()
|
||||
{
|
||||
Vec3 vec;
|
||||
for (int i = 1; i <= 8; i++)
|
||||
{
|
||||
vec = findSecludedXYZ(i, false);
|
||||
if (vec != null) {
|
||||
return vec;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Vec3 stalkTarget()
|
||||
{
|
||||
Vec3 vec;
|
||||
for (int i = 8; i >= 1; i--)
|
||||
{
|
||||
vec = findSecludedXYZ(i, true);
|
||||
if (vec != null) {
|
||||
return vec;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Vec3 findSecludedXYZ(int radius, boolean nearest)
|
||||
{
|
||||
Vec3 idealPos = null;
|
||||
boolean weight;
|
||||
double dist = this.targetEntity.getDistanceSqToEntity(this.theEntity);
|
||||
double u = 0, v = 0, w = 0;
|
||||
|
||||
if (this.movePosition != null)
|
||||
{
|
||||
u = this.movePosition.xCoord;
|
||||
v = this.movePosition.yCoord;
|
||||
w = this.movePosition.zCoord;
|
||||
}
|
||||
|
||||
for (int y = -2; y <= 2; y++)
|
||||
{
|
||||
for (int x = -radius; x <= radius; x++)
|
||||
{
|
||||
for (int z = -radius; z <= radius; z++)
|
||||
{
|
||||
double j = MathHelper.floor_double(this.theEntity.posX + x) + 0.5D;
|
||||
double k = MathHelper.floor_double(this.theEntity.boundingBox.minY + y);
|
||||
double l = MathHelper.floor_double(this.theEntity.posZ + z) + 0.5D;
|
||||
|
||||
if (this.theWorld.getBlock((int)j, (int)k, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 1, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 2, (int)l).isOpaqueCube())
|
||||
{
|
||||
Vec3 vec1 = Vec3.createVectorHelper(this.targetEntity.posX, this.targetEntity.posY + (double)this.targetEntity.getEyeHeight(), this.targetEntity.posZ);
|
||||
Vec3 vec2 = Vec3.createVectorHelper(j, k + (double)this.theEntity.getEyeHeight(), l);
|
||||
MovingObjectPosition movingobjectposition = this.theWorld.rayTraceBlocks(vec1, vec2);
|
||||
if (movingobjectposition != null)
|
||||
{
|
||||
weight = nearest ? this.targetEntity.getDistanceSq(j, k, l) <= dist : true;
|
||||
if (weight && (j != u || k != v || l != w))
|
||||
{
|
||||
idealPos = Vec3.createVectorHelper(j, k, l);
|
||||
if (nearest) dist = this.targetEntity.getDistanceSq(j, k, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return idealPos;
|
||||
}
|
||||
|
||||
private boolean isLookingAway()
|
||||
{
|
||||
Vec3 vec3 = this.targetEntity.getLook(1.0F).normalize();
|
||||
Vec3 vec31 = Vec3.createVectorHelper(this.theEntity.posX - this.targetEntity.posX, this.theEntity.boundingBox.minY + (double)(this.theEntity.height / 2.0F) - (this.targetEntity.posY + (double)this.targetEntity.getEyeHeight()), this.theEntity.posZ - this.targetEntity.posZ);
|
||||
double d0 = vec31.lengthVector();
|
||||
vec31 = vec31.normalize();
|
||||
double d1 = vec3.dotProduct(vec31);
|
||||
return d1 < 0.6;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NoppesStringUtils;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAITransform extends EntityAIBase {
|
||||
|
||||
private EntityNPCInterface npc;
|
||||
public EntityAITransform(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
setMutexBits(AiMutex.PASSIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute() {
|
||||
if(npc.isKilled() || npc.isAttacking() || npc.transform.editingModus)
|
||||
return false;
|
||||
|
||||
return npc.worldObj.getWorldTime() % 24000 < 12000?npc.transform.isActive:!npc.transform.isActive;
|
||||
}
|
||||
|
||||
public void startExecuting(){
|
||||
npc.transform.transform(!npc.transform.isActive);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.IEntitySelector;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.ai.selector.NPCInteractSelector;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.controllers.Line;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIWander extends EntityAIBase
|
||||
{
|
||||
private EntityNPCInterface entity;
|
||||
public final IEntitySelector selector;
|
||||
private double xPosition;
|
||||
private double yPosition;
|
||||
private double zPosition;
|
||||
private EntityNPCInterface nearbyNPC;
|
||||
|
||||
public EntityAIWander(EntityNPCInterface npc){
|
||||
this.entity = npc;
|
||||
this.setMutexBits(AiMutex.PASSIVE);
|
||||
selector = new NPCInteractSelector(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute(){
|
||||
if (this.entity.getAge() >= 100 || !entity.getNavigator().noPath() || entity.isInteracting() || this.entity.getRNG().nextInt(80) != 0){
|
||||
return false;
|
||||
}
|
||||
if(entity.ai.npcInteracting && entity.getRNG().nextInt(4) == 1)
|
||||
nearbyNPC = getNearbyNPC();
|
||||
|
||||
if(nearbyNPC != null){
|
||||
this.xPosition = MathHelper.floor_double(nearbyNPC.posX);
|
||||
this.yPosition = MathHelper.floor_double(nearbyNPC.posY);
|
||||
this.zPosition = MathHelper.floor_double(nearbyNPC.posZ);
|
||||
nearbyNPC.addInteract(entity);
|
||||
}
|
||||
else{
|
||||
Vec3 vec = getVec();
|
||||
if (vec == null){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
this.xPosition = vec.xCoord;
|
||||
this.yPosition = vec.yCoord;
|
||||
this.zPosition = vec.zCoord;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTask() {
|
||||
if(nearbyNPC != null){
|
||||
nearbyNPC.getNavigator().clearPathEntity();
|
||||
}
|
||||
}
|
||||
private EntityNPCInterface getNearbyNPC() {
|
||||
List<EntityNPCInterface> list = entity.worldObj.getEntitiesWithinAABBExcludingEntity(entity, entity.boundingBox.expand(entity.ai.walkingRange, entity.ai.walkingRange > 7?7:entity.ai.walkingRange, entity.ai.walkingRange), selector);
|
||||
Iterator<EntityNPCInterface> ita = list.iterator();
|
||||
while(ita.hasNext()){
|
||||
EntityNPCInterface npc = ita.next();
|
||||
if(!npc.ai.stopAndInteract || npc.isAttacking() || !npc.isEntityAlive() || entity.faction.isAggressiveToNpc(npc))
|
||||
ita.remove();
|
||||
}
|
||||
|
||||
if(list.isEmpty())
|
||||
return null;
|
||||
|
||||
return list.get(entity.getRNG().nextInt(list.size()));
|
||||
}
|
||||
|
||||
private Vec3 getVec(){
|
||||
if(entity.ai.walkingRange > 0){
|
||||
double distance = this.entity.getDistanceSq(this.entity.getStartXPos(), this.entity.getStartYPos(), this.entity.getStartZPos());
|
||||
int range = (int) MathHelper.sqrt_double(this.entity.ai.walkingRange * this.entity.ai.walkingRange - distance);
|
||||
if(range > CustomNpcs.NpcNavRange)
|
||||
range = CustomNpcs.NpcNavRange;
|
||||
if(range < 3){
|
||||
range = this.entity.ai.walkingRange;
|
||||
if(range > CustomNpcs.NpcNavRange)
|
||||
range = CustomNpcs.NpcNavRange;
|
||||
Vec3 start = Vec3.createVectorHelper(this.entity.getStartXPos(), this.entity.getStartYPos(), this.entity.getStartZPos());
|
||||
return RandomPositionGeneratorAlt.findRandomTargetBlockTowards(this.entity, range / 2, range / 2 > 7?7:range / 2, start);
|
||||
}
|
||||
else{
|
||||
return RandomPositionGeneratorAlt.findRandomTarget(this.entity, range, range / 2 > 7?7:range / 2);
|
||||
}
|
||||
}
|
||||
return RandomPositionGeneratorAlt.findRandomTarget(this.entity, CustomNpcs.NpcNavRange, 7);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean continueExecuting(){
|
||||
if(nearbyNPC != null && (!selector.isEntityApplicable(nearbyNPC) || entity.getDistanceSqToEntity(nearbyNPC) < entity.width * 1.5))
|
||||
return false;
|
||||
return !this.entity.getNavigator().noPath() && this.entity.isEntityAlive() && !entity.isInteracting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startExecuting(){
|
||||
this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTask() {
|
||||
if(nearbyNPC != null && entity.getDistanceSqToEntity(nearbyNPC) < 12){
|
||||
Line line = new Line(".........");
|
||||
line.hideText = true;
|
||||
if(entity.getRNG().nextBoolean())
|
||||
entity.saySurrounding(line);
|
||||
else
|
||||
nearbyNPC.saySurrounding(line);
|
||||
|
||||
entity.addInteract(nearbyNPC);
|
||||
nearbyNPC.addInteract(entity);
|
||||
}
|
||||
nearbyNPC = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIWatchClosest extends EntityAIBase
|
||||
{
|
||||
private EntityNPCInterface theWatcher;
|
||||
|
||||
/** The closest entity which is being watched by this one. */
|
||||
protected Entity closestEntity;
|
||||
private float field_75333_c;
|
||||
private int lookTime;
|
||||
private float field_75331_e;
|
||||
private Class watchedClass;
|
||||
|
||||
public EntityAIWatchClosest(EntityNPCInterface par1EntityLiving, Class par2Class, float par3){
|
||||
this.theWatcher = par1EntityLiving;
|
||||
this.watchedClass = par2Class;
|
||||
this.field_75333_c = par3;
|
||||
this.field_75331_e = 0.002F;
|
||||
this.setMutexBits(AiMutex.LOOK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldExecute(){
|
||||
if (this.theWatcher.getRNG().nextFloat() >= this.field_75331_e || theWatcher.isInteracting()){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
if (this.theWatcher.getAttackTarget() != null)
|
||||
{
|
||||
this.closestEntity = this.theWatcher.getAttackTarget();
|
||||
}
|
||||
|
||||
if (this.watchedClass == EntityPlayer.class)
|
||||
{
|
||||
this.closestEntity = this.theWatcher.worldObj.getClosestPlayerToEntity(this.theWatcher, (double)this.field_75333_c);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.closestEntity = this.theWatcher.worldObj.findNearestEntityWithinAABB(this.watchedClass, this.theWatcher.boundingBox.expand((double)this.field_75333_c, 3.0D, (double)this.field_75333_c), this.theWatcher);
|
||||
if (this.closestEntity != null)
|
||||
{
|
||||
return this.theWatcher.canSee(this.closestEntity);
|
||||
}
|
||||
}
|
||||
|
||||
return this.closestEntity != null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
@Override
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
if(theWatcher.isInteracting() || theWatcher.isAttacking() || !this.closestEntity.isEntityAlive() || !theWatcher.isEntityAlive())
|
||||
return false;
|
||||
return this.theWatcher.getDistanceSqToEntity(this.closestEntity) > (double)(this.field_75333_c * this.field_75333_c) ? false : this.lookTime > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
@Override
|
||||
public void startExecuting(){
|
||||
this.lookTime = 60 + this.theWatcher.getRNG().nextInt(60);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the task
|
||||
*/
|
||||
@Override
|
||||
public void resetTask(){
|
||||
this.closestEntity = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
@Override
|
||||
public void updateTask()
|
||||
{
|
||||
this.theWatcher.getLookHelper().setLookPosition(this.closestEntity.posX, this.closestEntity.posY + (double)this.closestEntity.getEyeHeight(), this.closestEntity.posZ, 10.0F, (float)this.theWatcher.getVerticalFaceSpeed());
|
||||
--this.lookTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIWaterNav extends EntityAIBase
|
||||
{
|
||||
private EntityNPCInterface theEntity;
|
||||
|
||||
public EntityAIWaterNav(EntityNPCInterface par1EntityNPCInterface)
|
||||
{
|
||||
this.theEntity = par1EntityNPCInterface;
|
||||
par1EntityNPCInterface.getNavigator().setCanSwim(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (this.theEntity.isInWater() || this.theEntity.handleLavaMovement())
|
||||
{
|
||||
if (this.theEntity.ai.canSwim)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (this.theEntity.isCollidedHorizontally)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
if (this.theEntity.getRNG().nextFloat() < 0.8F)
|
||||
{
|
||||
this.theEntity.getJumpHelper().setJumping();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIWorldLines extends EntityAIBase {
|
||||
|
||||
private EntityNPCInterface npc;
|
||||
public EntityAIWorldLines(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
this.setMutexBits(AiMutex.PASSIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute() {
|
||||
return !npc.isAttacking() && !npc.isKilled() && npc.advanced.hasWorldLines() && npc.getRNG().nextInt(1900) == 1;
|
||||
}
|
||||
|
||||
public void startExecuting()
|
||||
{
|
||||
npc.saySurrounding(npc.advanced.getWorldLine());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.ai.RandomPositionGenerator;
|
||||
import net.minecraft.pathfinding.PathEntity;
|
||||
import net.minecraft.pathfinding.PathPoint;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
|
||||
public class EntityAIZigZagTarget extends EntityAIBase
|
||||
{
|
||||
private EntityCreature theEntity;
|
||||
private EntityLivingBase targetEntity;
|
||||
private double movePosX;
|
||||
private double movePosY;
|
||||
private double movePosZ;
|
||||
private int entityPosX;
|
||||
private int entityPosY;
|
||||
private int entityPosZ;
|
||||
private double field_75425_f;
|
||||
private float field_75426_g;
|
||||
|
||||
public EntityAIZigZagTarget(EntityCreature par1EntityCreature, double par2, float par4)
|
||||
{
|
||||
this.theEntity = par1EntityCreature;
|
||||
this.field_75425_f = par2;
|
||||
this.field_75426_g = par4;
|
||||
this.setMutexBits(AiMutex.PASSIVE + AiMutex.LOOK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
this.targetEntity = this.theEntity.getAttackTarget();
|
||||
|
||||
if (this.targetEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < (double)(this.field_75426_g * this.field_75426_g))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
PathEntity pathentity = this.theEntity.getNavigator().getPathToEntityLiving(targetEntity);
|
||||
|
||||
if (pathentity != null)
|
||||
{
|
||||
if (pathentity.getCurrentPathLength() >= this.field_75426_g)
|
||||
{
|
||||
PathPoint pathpoint = pathentity.getPathPointFromIndex(MathHelper.floor_double(this.field_75426_g / 2.0D));
|
||||
this.entityPosX = pathpoint.xCoord;
|
||||
this.entityPosY = pathpoint.yCoord;
|
||||
this.entityPosZ = pathpoint.zCoord;
|
||||
|
||||
Vec3 vec3 = RandomPositionGeneratorAlt.findRandomTargetBlockTowards(this.theEntity, (int)field_75426_g, 3, Vec3.createVectorHelper(this.entityPosX, this.entityPosY, this.entityPosZ));
|
||||
|
||||
if (vec3 != null)
|
||||
{
|
||||
if (this.targetEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < this.targetEntity.getDistanceSq(entityPosX, entityPosY, entityPosZ))
|
||||
// if (this.theEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) > field_75426_g * field_75426_g && this.targetEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < this.targetEntity.getDistanceSq(entityPosX, entityPosY, entityPosZ))
|
||||
{
|
||||
this.movePosX = vec3.xCoord;
|
||||
this.movePosY = vec3.yCoord;
|
||||
this.movePosZ = vec3.zCoord;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether an in-progress EntityAIBase should continue executing
|
||||
*/
|
||||
public boolean continueExecuting()
|
||||
{
|
||||
return !this.theEntity.getNavigator().noPath() && this.targetEntity.isEntityAlive() && this.targetEntity.getDistanceSqToEntity(this.theEntity) > (double)(this.field_75426_g * this.field_75426_g);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.field_75425_f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the task
|
||||
*/
|
||||
public void updateTask()
|
||||
{
|
||||
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package noppes.npcs.ai;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
public class RandomPositionGeneratorAlt
|
||||
{
|
||||
/**
|
||||
* used to store a driection when the user passes a point to move towards or away from. WARNING: NEVER THREAD SAFE.
|
||||
* MULTIPLE findTowards and findAway calls, will share this var
|
||||
*/
|
||||
private static Vec3 staticVector = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
|
||||
|
||||
/**
|
||||
* finds a random target within par1(x,z) and par2 (y) blocks
|
||||
*/
|
||||
public static Vec3 findRandomTarget(EntityCreature par0EntityCreature, int par1, int par2)
|
||||
{
|
||||
/**
|
||||
* searches 10 blocks at random in a within par1(x,z) and par2 (y) distance, ignores those not in the direction
|
||||
* of par3Vec3, then points to the tile for which creature.getBlockPathWeight returns the highest number
|
||||
*/
|
||||
return findRandomTargetBlock(par0EntityCreature, par1, par2, (Vec3)null);
|
||||
}
|
||||
|
||||
/**
|
||||
* finds a random target within par1(x,z) and par2 (y) blocks in the direction of the point par3
|
||||
*/
|
||||
public static Vec3 findRandomTargetBlockTowards(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3)
|
||||
{
|
||||
staticVector.xCoord = par3Vec3.xCoord - par0EntityCreature.posX;
|
||||
staticVector.yCoord = par3Vec3.yCoord - par0EntityCreature.posY;
|
||||
staticVector.zCoord = par3Vec3.zCoord - par0EntityCreature.posZ;
|
||||
/**
|
||||
* searches 10 blocks at random in a within par1(x,z) and par2 (y) distance, ignores those not in the direction
|
||||
* of par3Vec3, then points to the tile for which creature.getBlockPathWeight returns the highest number
|
||||
*/
|
||||
return findRandomTargetBlock(par0EntityCreature, par1, par2, staticVector);
|
||||
}
|
||||
|
||||
/**
|
||||
* finds a random target within par1(x,z) and par2 (y) blocks in the reverse direction of the point par3
|
||||
*/
|
||||
public static Vec3 findRandomTargetBlockAwayFrom(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3)
|
||||
{
|
||||
staticVector.xCoord = par0EntityCreature.posX - par3Vec3.xCoord;
|
||||
staticVector.yCoord = par0EntityCreature.posY - par3Vec3.yCoord;
|
||||
staticVector.zCoord = par0EntityCreature.posZ - par3Vec3.zCoord;
|
||||
/**
|
||||
* searches 10 blocks at random in a within par1(x,z) and par2 (y) distance, ignores those not in the direction
|
||||
* of par3Vec3, then points to the tile for which creature.getBlockPathWeight returns the highest number
|
||||
*/
|
||||
return findRandomTargetBlock(par0EntityCreature, par1, par2, staticVector);
|
||||
}
|
||||
|
||||
/**
|
||||
* searches 10 blocks at random in a within par1(x,z) and par2 (y) distance, ignores those not in the direction of
|
||||
* par3Vec3, then points to the tile for which creature.getBlockPathWeight returns the highest number
|
||||
*/
|
||||
private static Vec3 findRandomTargetBlock(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3)
|
||||
{
|
||||
if(par1 <= 0)
|
||||
par1 = 1;
|
||||
if(par2 <= 0)
|
||||
par2 = 1;
|
||||
Random random = par0EntityCreature.getRNG();
|
||||
boolean flag = false;
|
||||
int k = 0;
|
||||
int l = 0;
|
||||
int i1 = 0;
|
||||
float f = -99999.0F;
|
||||
boolean flag1;
|
||||
|
||||
if (par0EntityCreature.hasHome())
|
||||
{
|
||||
double d0 = (double)(par0EntityCreature.getHomePosition().getDistanceSquared(MathHelper.floor_double(par0EntityCreature.posX), MathHelper.floor_double(par0EntityCreature.posY), MathHelper.floor_double(par0EntityCreature.posZ)) + 4.0F);
|
||||
double d1 = (double)(par0EntityCreature.func_110174_bM() + (float)par1);
|
||||
flag1 = d0 < d1 * d1;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag1 = false;
|
||||
}
|
||||
|
||||
for (int l1 = 0; l1 < 10; ++l1)
|
||||
{
|
||||
int j1 = random.nextInt(2 * par1) - par1;
|
||||
int i2 = random.nextInt(2 * par2) - par2;
|
||||
int k1 = random.nextInt(2 * par1) - par1;
|
||||
|
||||
if (par3Vec3 == null || (double)j1 * par3Vec3.xCoord + (double)k1 * par3Vec3.zCoord >= 0.0D)
|
||||
{
|
||||
if(random.nextBoolean()){
|
||||
j1 += MathHelper.floor_double(par0EntityCreature.posX);
|
||||
i2 += MathHelper.floor_double(par0EntityCreature.posY);
|
||||
k1 += MathHelper.floor_double(par0EntityCreature.posZ);
|
||||
}
|
||||
else{
|
||||
j1 += MathHelper.ceiling_double_int(par0EntityCreature.posX);
|
||||
i2 += MathHelper.ceiling_double_int(par0EntityCreature.posY);
|
||||
k1 += MathHelper.ceiling_double_int(par0EntityCreature.posZ);
|
||||
}
|
||||
if (!flag1 || par0EntityCreature.isWithinHomeDistance(j1, i2, k1))
|
||||
{
|
||||
float f1 = par0EntityCreature.getBlockPathWeight(j1, i2, k1);
|
||||
|
||||
if (f1 > f)
|
||||
{
|
||||
f = f1;
|
||||
k = j1;
|
||||
l = i2;
|
||||
i1 = k1;
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
return Vec3.createVectorHelper((double)k, (double)l, (double)i1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package noppes.npcs.ai.selector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.IEntitySelector;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.potion.Potion;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.constants.EnumCompanionJobs;
|
||||
import noppes.npcs.constants.EnumJobType;
|
||||
import noppes.npcs.constants.EnumMovingType;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.controllers.PixelmonHelper;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobGuard;
|
||||
import noppes.npcs.roles.RoleCompanion;
|
||||
import noppes.npcs.roles.companion.CompanionGuard;
|
||||
|
||||
public class NPCAttackSelector implements IEntitySelector
|
||||
{
|
||||
private EntityNPCInterface npc;
|
||||
|
||||
public NPCAttackSelector(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
}
|
||||
/**
|
||||
* Return whether the specified entity is applicable to this filter.
|
||||
*/
|
||||
@Override
|
||||
public boolean isEntityApplicable(Entity entity){
|
||||
if(!entity.isEntityAlive() || entity == npc || npc.getDistanceToEntity(entity) > npc.stats.aggroRange || !(entity instanceof EntityLivingBase) || ((EntityLivingBase)entity).getHealth() < 1)
|
||||
return false;
|
||||
if (this.npc.ai.directLOS && !this.npc.getEntitySenses().canSee(entity))
|
||||
return false;
|
||||
|
||||
if(!npc.stats.attackInvisible &&((EntityLivingBase)entity).isPotionActive(Potion.invisibility) && npc.getDistanceSqToEntity(entity) < 9)
|
||||
return false;
|
||||
|
||||
//prevent the npc from going on an endless killing spree
|
||||
if(!npc.isFollower() && npc.ai.returnToStart){
|
||||
int allowedDistance = npc.stats.aggroRange * 2;
|
||||
if(npc.ai.movingType == EnumMovingType.Wandering)
|
||||
allowedDistance += npc.ai.walkingRange;
|
||||
double distance = entity.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos());
|
||||
if(npc.ai.movingType == EnumMovingType.MovingPath){
|
||||
int[] arr = npc.ai.getCurrentMovingPath();
|
||||
distance = entity.getDistanceSq(arr[0], arr[1], arr[2]);
|
||||
}
|
||||
|
||||
if(distance > allowedDistance * allowedDistance)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(npc.advanced.job == EnumJobType.Guard && ((JobGuard)npc.jobInterface).isEntityApplicable(entity))
|
||||
return true;
|
||||
|
||||
if(npc.advanced.role == EnumRoleType.Companion){
|
||||
RoleCompanion role = (RoleCompanion)npc.roleInterface;
|
||||
if(role.job == EnumCompanionJobs.GUARD && ((CompanionGuard)role.jobInterface).isEntityApplicable(entity))
|
||||
return true;
|
||||
}
|
||||
if(entity instanceof EntityPlayerMP){
|
||||
if(npc.faction.isAggressiveToPlayer((EntityPlayer) entity)){
|
||||
if(PixelmonHelper.Enabled && npc.advanced.job == EnumJobType.Spawner)
|
||||
return PixelmonHelper.canBattle((EntityPlayerMP)entity, npc);
|
||||
return !((EntityPlayerMP)entity).capabilities.disableDamage;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(entity instanceof EntityNPCInterface){
|
||||
if(((EntityNPCInterface)entity).isKilled())
|
||||
return false;
|
||||
if(npc.advanced.attackOtherFactions)
|
||||
return npc.faction.isAggressiveToNpc((EntityNPCInterface)entity);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package noppes.npcs.ai.selector;
|
||||
|
||||
import net.minecraft.command.IEntitySelector;
|
||||
import net.minecraft.entity.Entity;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class NPCInteractSelector implements IEntitySelector {
|
||||
private EntityNPCInterface npc;
|
||||
public NPCInteractSelector(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
}
|
||||
@Override
|
||||
public boolean isEntityApplicable(Entity entity) {
|
||||
if(entity == npc || !(entity instanceof EntityNPCInterface) || !npc.isEntityAlive())
|
||||
return false;
|
||||
EntityNPCInterface selected = (EntityNPCInterface) entity;
|
||||
if(selected.isAttacking() || npc.getFaction().isAggressiveToNpc(selected) || !npc.ai.stopAndInteract)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package noppes.npcs.ai.target;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.IEntitySelector;
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
|
||||
import net.minecraft.entity.ai.EntityAITarget;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIClearTarget extends EntityAITarget
|
||||
{
|
||||
private EntityNPCInterface npc;
|
||||
private EntityLivingBase target;
|
||||
public EntityAIClearTarget(EntityNPCInterface npc){
|
||||
super(npc, false);
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute(){
|
||||
target = taskOwner.getAttackTarget();
|
||||
if (target == null)
|
||||
return false;
|
||||
|
||||
if(target instanceof EntityPlayer && ((EntityPlayer)target).capabilities.disableDamage)
|
||||
return true;
|
||||
|
||||
int distance = npc.stats.aggroRange * 2 * npc.stats.aggroRange;
|
||||
if(npc.getOwner() != null && npc.getDistanceSqToEntity(npc.getOwner()) > distance){
|
||||
return true;
|
||||
}
|
||||
|
||||
return npc.getDistanceSqToEntity(target) > distance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startExecuting(){
|
||||
this.taskOwner.setAttackTarget(null);
|
||||
if(target == taskOwner.getAITarget())
|
||||
this.taskOwner.setRevengeTarget(null);
|
||||
super.startExecuting();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package noppes.npcs.ai.target;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.IEntitySelector;
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
|
||||
import net.minecraft.entity.ai.EntityAITarget;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class EntityAIClosestTarget extends EntityAITarget
|
||||
{
|
||||
private final Class targetClass;
|
||||
private final int targetChance;
|
||||
|
||||
/** Instance of EntityAINearestAttackableTargetSorter. */
|
||||
private final EntityAINearestAttackableTarget.Sorter theNearestAttackableTargetSorter;
|
||||
private final IEntitySelector field_82643_g;
|
||||
private EntityLivingBase targetEntity;
|
||||
|
||||
public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4)
|
||||
{
|
||||
this(par1EntityCreature, par2Class, par3, par4, false);
|
||||
}
|
||||
|
||||
public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5)
|
||||
{
|
||||
this(par1EntityCreature, par2Class, par3, par4, par5, (IEntitySelector)null);
|
||||
}
|
||||
|
||||
public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5, IEntitySelector par6IEntitySelector)
|
||||
{
|
||||
super(par1EntityCreature, par4, par5);
|
||||
this.targetClass = par2Class;
|
||||
this.targetChance = par3;
|
||||
this.theNearestAttackableTargetSorter = new EntityAINearestAttackableTarget.Sorter(par1EntityCreature);
|
||||
this.setMutexBits(1);
|
||||
this.field_82643_g = par6IEntitySelector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (this.targetChance > 0 && this.taskOwner.getRNG().nextInt(this.targetChance) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
double d0 = this.getTargetDistance();
|
||||
List list = this.taskOwner.worldObj.selectEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand(d0, MathHelper.ceiling_double_int(d0 / 2.0D), d0), this.field_82643_g);
|
||||
Collections.sort(list, this.theNearestAttackableTargetSorter);
|
||||
|
||||
if (list.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.targetEntity = (EntityLivingBase)list.get(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.taskOwner.setAttackTarget(this.targetEntity);
|
||||
if (this.targetEntity instanceof EntityMob)
|
||||
{
|
||||
if (((EntityMob) this.targetEntity).getAttackTarget() == null)
|
||||
{
|
||||
((EntityMob)this.targetEntity).setAttackTarget(this.taskOwner);
|
||||
((EntityMob)this.targetEntity).setTarget(this.taskOwner);
|
||||
}
|
||||
}
|
||||
super.startExecuting();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package noppes.npcs.ai.target;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAITarget;
|
||||
import net.minecraft.entity.passive.EntityTameable;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIOwnerHurtByTarget extends EntityAITarget
|
||||
{
|
||||
EntityNPCInterface npc;
|
||||
EntityLivingBase theOwnerAttacker;
|
||||
private int field_142051_e;
|
||||
|
||||
public EntityAIOwnerHurtByTarget(EntityNPCInterface npc){
|
||||
super(npc, false);
|
||||
this.npc = npc;
|
||||
this.setMutexBits(AiMutex.PASSIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute(){
|
||||
if (!this.npc.isFollower() || !(npc.roleInterface != null && npc.roleInterface.defendOwner())){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
EntityLivingBase entitylivingbase = this.npc.getOwner();
|
||||
|
||||
if (entitylivingbase == null){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
this.theOwnerAttacker = entitylivingbase.getAITarget();
|
||||
int i = entitylivingbase.func_142015_aE();
|
||||
return i != this.field_142051_e && this.isSuitableTarget(this.theOwnerAttacker, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting(){
|
||||
this.taskOwner.setAttackTarget(this.theOwnerAttacker);
|
||||
EntityLivingBase entitylivingbase = this.npc.getOwner();
|
||||
|
||||
if (entitylivingbase != null){
|
||||
this.field_142051_e = entitylivingbase.func_142015_aE();
|
||||
}
|
||||
|
||||
super.startExecuting();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package noppes.npcs.ai.target;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAITarget;
|
||||
import net.minecraft.entity.passive.EntityTameable;
|
||||
import noppes.npcs.constants.AiMutex;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
public class EntityAIOwnerHurtTarget extends EntityAITarget
|
||||
{
|
||||
EntityNPCInterface npc;
|
||||
EntityLivingBase theTarget;
|
||||
private int field_142050_e;
|
||||
|
||||
public EntityAIOwnerHurtTarget(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc, false);
|
||||
this.npc = npc;
|
||||
this.setMutexBits(AiMutex.PASSIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the EntityAIBase should begin execution.
|
||||
*/
|
||||
public boolean shouldExecute()
|
||||
{
|
||||
if (!this.npc.isFollower() || !(npc.roleInterface != null && npc.roleInterface.defendOwner()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityLivingBase entitylivingbase = this.npc.getOwner();
|
||||
|
||||
if (entitylivingbase == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.theTarget = entitylivingbase.getLastAttacker();
|
||||
int i = entitylivingbase.getLastAttackerTime();
|
||||
return i != this.field_142050_e && this.isSuitableTarget(this.theTarget, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a one shot task or start executing a continuous task
|
||||
*/
|
||||
public void startExecuting()
|
||||
{
|
||||
this.taskOwner.setAttackTarget(this.theTarget);
|
||||
EntityLivingBase entitylivingbase = this.npc.getOwner();
|
||||
|
||||
if (entitylivingbase != null)
|
||||
{
|
||||
this.field_142050_e = entitylivingbase.getLastAttackerTime();
|
||||
}
|
||||
|
||||
super.startExecuting();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockColored;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.blocks.tiles.TileBanner;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockBanner extends BlockContainer{
|
||||
|
||||
public int renderId = -1;
|
||||
|
||||
public BlockBanner() {
|
||||
super(Material.rock);
|
||||
setBlockBounds(0, 0, 0, 1, 2, 1);
|
||||
}
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
ItemStack item = player.inventory.getCurrentItem();
|
||||
if(item == null)
|
||||
return false;
|
||||
int meta = par1World.getBlockMetadata(i, j, k);
|
||||
if(meta >= 7)
|
||||
j--;
|
||||
TileBanner tile = (TileBanner) par1World.getTileEntity(i, j, k);
|
||||
if(tile.canEdit())
|
||||
return true;
|
||||
else if(item.getItem() != Items.dye)
|
||||
return false;
|
||||
|
||||
int color = BlockColored.func_150031_c(item.getItemDamage());
|
||||
if(tile.color != color){
|
||||
NoppesUtilServer.consumeItemStack(1, player);
|
||||
tile.color = color;
|
||||
par1World.markBlockForUpdate(i, j, k);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
par3List.add(new ItemStack(par1, 1, 1));
|
||||
par3List.add(new ItemStack(par1, 1, 2));
|
||||
par3List.add(new ItemStack(par1, 1, 3));
|
||||
par3List.add(new ItemStack(par1, 1, 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int par1)
|
||||
{
|
||||
return par1 % 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(meta >= 7)
|
||||
setBlockBounds(0, -1, 0, 1, 1, 1);
|
||||
else
|
||||
setBlockBounds(0, 0, 0, 1, 2, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
|
||||
{
|
||||
if(!par1World.isAirBlock(par2, par3 + 1, par4)){
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
}
|
||||
else{
|
||||
|
||||
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
l %= 4;
|
||||
|
||||
TileBanner tile = (TileBanner) par1World.getTileEntity(par2, par3, par4);
|
||||
tile.rotation = l;
|
||||
tile.color = 15 - par6ItemStack.getItemDamage();
|
||||
tile.time = System.currentTimeMillis();
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
|
||||
par1World.setBlock(par2, par3 + 1, par4, this, par6ItemStack.getItemDamage() + 7, 2);
|
||||
|
||||
if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote)
|
||||
((EntityPlayer)par5EntityLivingBase).addChatComponentMessage(new ChatComponentTranslation("availability.editIcon"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock(){
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int getRenderType(){
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister)
|
||||
{
|
||||
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int p_149691_1_, int meta)
|
||||
{
|
||||
meta %= 7;
|
||||
if(meta == 1)
|
||||
return Blocks.stone.getIcon(p_149691_1_, 0);
|
||||
else if(meta == 2)
|
||||
return Blocks.iron_block.getIcon(p_149691_1_, 0);
|
||||
else if(meta == 3)
|
||||
return Blocks.gold_block.getIcon(p_149691_1_, 0);
|
||||
else if(meta == 4)
|
||||
return Blocks.diamond_block.getIcon(p_149691_1_, 0);
|
||||
return Blocks.planks.getIcon(p_149691_1_, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
if(var2 < 7)
|
||||
return new TileBanner();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_)
|
||||
{
|
||||
if (p_149681_5_ >= 7 && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this)
|
||||
p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_);
|
||||
|
||||
else if (p_149681_5_ < 7 && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_) == this)
|
||||
p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ + 1, p_149681_4_);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.blocks.tiles.TileBarrel;
|
||||
import noppes.npcs.blocks.tiles.TileNpcContainer;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
|
||||
public class BlockBarrel extends BlockRotated{
|
||||
|
||||
public BlockBarrel() {
|
||||
super(Blocks.planks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
par3List.add(new ItemStack(par1, 1, 1));
|
||||
par3List.add(new ItemStack(par1, 1, 2));
|
||||
par3List.add(new ItemStack(par1, 1, 3));
|
||||
par3List.add(new ItemStack(par1, 1, 4));
|
||||
par3List.add(new ItemStack(par1, 1, 5));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int par1){
|
||||
return par1;
|
||||
}
|
||||
|
||||
public int maxRotation(){
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
if(par1World.isRemote)
|
||||
return true;
|
||||
|
||||
par1World.playSoundEffect(i, j + 0.5D, k, "random.chestopen", 0.5F, par1World.rand.nextFloat() * 0.1F + 0.9F);
|
||||
player.openGui(CustomNpcs.instance, EnumGuiType.Crate.ordinal(), par1World, i, j, k);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
|
||||
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileBarrel();
|
||||
}
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_){
|
||||
TileNpcContainer tile = (TileNpcContainer)world.getTileEntity(x, y, z);
|
||||
if (tile == null)
|
||||
return;
|
||||
tile.dropItems(world, x, y, z);
|
||||
|
||||
world.func_147453_f(x, y, z, block);
|
||||
super.breakBlock(world, x, y, z, block, p_149749_6_);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.blocks.tiles.TileBeam;
|
||||
import noppes.npcs.blocks.tiles.TileColorable;
|
||||
|
||||
public class BlockBeam extends BlockRotated{
|
||||
|
||||
public BlockBeam() {
|
||||
super(Blocks.planks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
|
||||
par3List.add(new ItemStack(par1, 1, 0));
|
||||
par3List.add(new ItemStack(par1, 1, 1));
|
||||
par3List.add(new ItemStack(par1, 1, 2));
|
||||
par3List.add(new ItemStack(par1, 1, 3));
|
||||
par3List.add(new ItemStack(par1, 1, 4));
|
||||
par3List.add(new ItemStack(par1, 1, 5));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int par1){
|
||||
return par1;
|
||||
}
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
if(!(tileentity instanceof TileColorable)){
|
||||
super.setBlockBoundsBasedOnState(world, x, y, z);
|
||||
return;
|
||||
}
|
||||
TileColorable tile = (TileColorable) tileentity;
|
||||
if(tile.rotation == 0){
|
||||
setBlockBounds(0.33f, 0.33f, 0.25f, 0.67f, 0.67f, 1f );
|
||||
}
|
||||
else if(tile.rotation == 2){
|
||||
setBlockBounds(0.33f, 0.33f, 0, 0.67f, 0.67f, 0.75f );
|
||||
}
|
||||
else if(tile.rotation == 3){
|
||||
setBlockBounds(0.25f, 0.33f, 0.33f, 1f, 0.67f, 0.67f );
|
||||
}
|
||||
else if(tile.rotation == 1){
|
||||
setBlockBounds(0, 0.33f, 0.33f, 0.75f, 0.67f, 0.67f );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
|
||||
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileBeam();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.blocks.tiles.TileBigSign;
|
||||
import noppes.npcs.blocks.tiles.TileColorable;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockBigSign extends BlockContainer{
|
||||
|
||||
public int renderId = -1;
|
||||
|
||||
public BlockBigSign() {
|
||||
super(Material.wood);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int par1){
|
||||
return par1;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_){
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
if(par1World.isRemote)
|
||||
return false;
|
||||
ItemStack currentItem = player.inventory.getCurrentItem();
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)) {
|
||||
TileBigSign tile = (TileBigSign) par1World.getTileEntity(i, j, k);
|
||||
tile.canEdit = true;
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.BigSign, null, i, j, k);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
|
||||
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
l %= 4;
|
||||
|
||||
TileBigSign tile = (TileBigSign) par1World.getTileEntity(par2, par3, par4);
|
||||
tile.rotation = l;
|
||||
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
|
||||
|
||||
if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote){
|
||||
CustomNpcs.proxy.openGui(par2, par3, par4, EnumGuiType.BigSign, (EntityPlayer) par5EntityLivingBase);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
|
||||
TileEntity tileentity = world.getTileEntity(x, y, z);
|
||||
if(!(tileentity instanceof TileColorable)){
|
||||
super.setBlockBoundsBasedOnState(world, x, y, z);
|
||||
return;
|
||||
}
|
||||
TileColorable tile = (TileColorable) tileentity;
|
||||
int meta = tile.getBlockMetadata();
|
||||
float xStart = 0;
|
||||
float zStart = 0;
|
||||
float xEnd = 1;
|
||||
float zEnd = 1;
|
||||
if(tile.rotation == 0)
|
||||
zStart = 0.87f;
|
||||
else if(tile.rotation == 2)
|
||||
zEnd = 0.13f;
|
||||
else if(tile.rotation == 3)
|
||||
xStart = 0.87f;
|
||||
else if(tile.rotation == 1)
|
||||
xEnd = 0.13f;
|
||||
setBlockBounds(xStart, 0, zStart, xEnd, 1, zEnd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock(){
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int getRenderType(){
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister)
|
||||
{
|
||||
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int p_149691_1_, int meta)
|
||||
{
|
||||
return Blocks.planks.getIcon(p_149691_1_, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileBigSign();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEnchantmentTable;
|
||||
import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockFurnace;
|
||||
import net.minecraft.block.BlockGlowstone;
|
||||
import net.minecraft.block.BlockSapling;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockBlood extends Block{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon blockIcon2;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon blockIcon3;
|
||||
|
||||
private final int renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
public BlockBlood(){
|
||||
super(Material.rock);
|
||||
this.setBlockUnbreakable();
|
||||
setCreativeTab(CustomItems.tabMisc);
|
||||
setBlockBounds(0.01f, 0.01f, 0.01f, 0.99f, 0.99f, 0.99f);
|
||||
this.setLightLevel(0.08f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata){
|
||||
metadata += side;
|
||||
if(metadata % 3 == 1)
|
||||
return blockIcon2;
|
||||
if(metadata % 3 == 2)
|
||||
return blockIcon3;
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4){
|
||||
return AxisAlignedBB.getBoundingBox(par2, par3, par4 , par2, par3, par4 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister){
|
||||
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName());
|
||||
this.blockIcon2 = par1IconRegister.registerIcon(getTextureName() + "2");
|
||||
this.blockIcon3 = par1IconRegister.registerIcon(getTextureName() + "3");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered(IBlockAccess world, int par2, int par3, int par4, int par5){
|
||||
Block block = world.getBlock(par2, par3, par4);
|
||||
return block != Blocks.air && block.renderAsNormalBlock(); //only render the side if a block is adjacent
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderBlockPass(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack item){
|
||||
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw / 90.0F) + 0.5D) & 3;
|
||||
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6, 2); //add metadata based on player rotation
|
||||
}
|
||||
|
||||
public int getRenderType(){
|
||||
return renderId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.blocks.tiles.TileBook;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
|
||||
public class BlockBook extends BlockRotated{
|
||||
|
||||
public BlockBook() {
|
||||
super(Blocks.planks);
|
||||
setBlockBounds(0, 0, 0, 1, 0.2f, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
if(par1World.isRemote)
|
||||
return true;
|
||||
TileEntity tile = par1World.getTileEntity(i, j, k);
|
||||
if(!(tile instanceof TileBook))
|
||||
return false;
|
||||
ItemStack currentItem = player.inventory.getCurrentItem();
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)) {
|
||||
((TileBook)tile).book.func_150996_a(Items.writable_book);
|
||||
}
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.OPEN_BOOK, i, j, k, ((TileBook)tile).book.writeToNBT(new NBTTagCompound()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(){
|
||||
return "item.book";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileBook();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.blocks.tiles.TileBorder;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
|
||||
public class BlockBorder extends BlockContainer{
|
||||
public int renderId = -1;
|
||||
|
||||
public BlockBorder() {
|
||||
super(Material.rock);
|
||||
setBlockUnbreakable();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
if(side == 1){
|
||||
return this.blockIcon;
|
||||
}
|
||||
return Blocks.iron_block.getIcon(side, meta);
|
||||
}
|
||||
@Override
|
||||
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
ItemStack currentItem = player.inventory.getCurrentItem();
|
||||
if (currentItem != null && currentItem.getItem() == CustomItems.wand) {
|
||||
CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.Border, player);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
|
||||
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
l %= 4;
|
||||
|
||||
TileBorder tile = (TileBorder) par1World.getTileEntity(x, y, z);
|
||||
|
||||
TileBorder adjacent = getTile(par1World, x - 1, y, z);
|
||||
if(adjacent == null)
|
||||
adjacent = getTile(par1World, x, y, z - 1);
|
||||
if(adjacent == null)
|
||||
adjacent = getTile(par1World, x, y, z + 1);
|
||||
if(adjacent == null)
|
||||
adjacent = getTile(par1World, x + 1, y, z);
|
||||
|
||||
if(adjacent != null){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
adjacent.writeExtraNBT(compound);
|
||||
tile.readExtraNBT(compound);
|
||||
}
|
||||
|
||||
tile.rotation = l;
|
||||
|
||||
if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote){
|
||||
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Border, (EntityPlayer) par5EntityLivingBase);
|
||||
}
|
||||
}
|
||||
|
||||
private TileBorder getTile(World world, int x, int y, int z){
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile != null && tile instanceof TileBorder)
|
||||
return (TileBorder) tile;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType(){
|
||||
return renderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileBorder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package noppes.npcs.blocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomItems;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.blocks.tiles.TileCampfire;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockCampfire extends BlockLightable{
|
||||
|
||||
public BlockCampfire(boolean lit) {
|
||||
super(Blocks.cobblestone, lit);
|
||||
setBlockBounds(0, 0, 0, 1, 0.5f, 1);
|
||||
if(lit)
|
||||
setLightLevel(0.9375F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileCampfire();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
|
||||
ItemStack item = player.inventory.getCurrentItem();
|
||||
if(item == null)
|
||||
return true;
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if((item.getItem() == Items.flint || item.getItem() == Items.flint_and_steel) && unlitBlock() == this){
|
||||
if(world.rand.nextInt(3) == 0 && !world.isRemote)
|
||||
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
|
||||
CustomNpcs.proxy.spawnParticle("largesmoke", x + 0.5f, y + 0.5f, z + 0.5f, 0.0D, 0.0D, 0.0D, 2);
|
||||
if(item.getItem() == Items.flint)
|
||||
NoppesUtilServer.consumeItemStack(1, player);
|
||||
else
|
||||
item.damageItem(1, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(item.getItem() == Item.getItemFromBlock(Blocks.sand) && litBlock() == this){
|
||||
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxRotation(){
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random random){
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(meta == 1)
|
||||
return;
|
||||
|
||||
if(random.nextInt(36) == 0){
|
||||
world.playSound(x + 0.5F, y + 0.5F, z + 0.5F, "fire.fire", 1.0F + random.nextFloat(), 0.3F + random.nextFloat() * 0.7f , false);
|
||||
}
|
||||
|
||||
TileCampfire tile = (TileCampfire) world.getTileEntity(x, y, z);
|
||||
|
||||
float xOffset = 0.5f, yOffset = 0.7f, zOffset = 0.5f;
|
||||
|
||||
double d0 = (double)((float)x + xOffset);
|
||||
double d1 = (double)((float)y + yOffset);
|
||||
double d2 = (double)((float)z + zOffset);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
CustomNpcs.proxy.spawnParticle("largesmoke", d0, d1, d2, 0.0D, 0.0D, 0.0D, 2);
|
||||
CustomNpcs.proxy.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D, 4);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block unlitBlock() {
|
||||
return CustomItems.campfire_unlit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block litBlock() {
|
||||
return CustomItems.campfire;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 1768 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user