mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 00:09:41 +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,21 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
|
||||
public class ScriptAnimal extends ScriptLiving{
|
||||
|
||||
public ScriptAnimal(EntityAnimal entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return EntityType.ANIMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean typeOf(int type){
|
||||
return type == EntityType.ANIMAL?true:super.typeOf(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTBase.NBTPrimitive;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
|
||||
public class ScriptEntity {
|
||||
protected Entity entity;
|
||||
private Map<String,Object> tempData = new HashMap<String,Object>();
|
||||
|
||||
public ScriptEntity(Entity entity){
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return The entities x position
|
||||
*/
|
||||
public double getX(){
|
||||
return entity.posX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x The entities x position
|
||||
*/
|
||||
public void setX(double x){
|
||||
entity.posX = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The entities y position
|
||||
*/
|
||||
public double getY(){
|
||||
return entity.posY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param y The entities y position
|
||||
*/
|
||||
public void setY(double y){
|
||||
entity.posY = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The entities x position
|
||||
*/
|
||||
public double getZ(){
|
||||
return entity.posZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param z The entities x position
|
||||
*/
|
||||
public void setZ(double z){
|
||||
entity.posZ = z;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The block x position
|
||||
*/
|
||||
public int getBlockX(){
|
||||
return MathHelper.floor_double(entity.posX);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The block y position
|
||||
*/
|
||||
public int getBlockY(){
|
||||
return MathHelper.floor_double(entity.posY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The block z position
|
||||
*/
|
||||
public int getBlockZ(){
|
||||
return MathHelper.floor_double(entity.posZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x The x position
|
||||
* @param y The y position
|
||||
* @param z The z position
|
||||
*/
|
||||
public void setPosition(double x, double y, double z){
|
||||
entity.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param range The search range for entities around this entity
|
||||
* @return Array of entities within range
|
||||
*/
|
||||
public ScriptEntity[] getSurroundingEntities(int range){
|
||||
List<Entity> entities = entity.worldObj.getEntitiesWithinAABB(Entity.class, entity.boundingBox.expand(range, range, range));
|
||||
List<ScriptEntity> list = new ArrayList<ScriptEntity>();
|
||||
for(Entity living : entities){
|
||||
if(living != entity)
|
||||
list.add(ScriptController.Instance.getScriptForEntity(living));
|
||||
}
|
||||
return list.toArray(new ScriptEntity[list.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param range The search range for entities around this entity
|
||||
* @param type The EntityType you want to find
|
||||
* @return Array of entities within range
|
||||
*/
|
||||
public ScriptEntity[] getSurroundingEntities(int range, int type){
|
||||
Class cls = Entity.class;
|
||||
if(type == EntityType.LIVING)
|
||||
cls = EntityLivingBase.class;
|
||||
else if(type == EntityType.PLAYER)
|
||||
cls = EntityPlayer.class;
|
||||
else if(type == EntityType.ANIMAL)
|
||||
cls = EntityAnimal.class;
|
||||
else if(type == EntityType.MONSTER)
|
||||
cls = EntityMob.class;
|
||||
else if(type == EntityType.NPC)
|
||||
cls = EntityNPCInterface.class;
|
||||
|
||||
List<Entity> entities = entity.worldObj.getEntitiesWithinAABB(cls, entity.boundingBox.expand(range, range, range));
|
||||
List<ScriptEntity> list = new ArrayList<ScriptEntity>();
|
||||
for(Entity living : entities){
|
||||
if(living != entity)
|
||||
list.add(ScriptController.Instance.getScriptForEntity(living));
|
||||
}
|
||||
return list.toArray(new ScriptEntity[list.size()]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Whether the entity is alive or not
|
||||
*/
|
||||
public boolean isAlive(){
|
||||
return entity.isEntityAlive();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key Get temp data for this key
|
||||
* @return Returns the stored temp data
|
||||
*/
|
||||
public Object getTempData(String key){
|
||||
return tempData.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tempdata gets cleared when the entity gets unloaded or the world restarts
|
||||
* @param key The key for the data stored
|
||||
* @param value The data stored
|
||||
*/
|
||||
public void setTempData(String key, Object value){
|
||||
tempData.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key thats going to be tested against the temp data
|
||||
* @return Whether or not temp data containes the key
|
||||
*/
|
||||
public boolean hasTempData(String key){
|
||||
return tempData.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key for the temp data to be removed
|
||||
*/
|
||||
public void removeTempData(String key){
|
||||
tempData.remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all tempdata
|
||||
*/
|
||||
public void clearTempData(){
|
||||
tempData.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key of the data to be returned
|
||||
* @return Returns the stored data
|
||||
*/
|
||||
public Object getStoredData(String key){
|
||||
NBTTagCompound compound = getStoredCompound();
|
||||
if(!compound.hasKey(key))
|
||||
return null;
|
||||
NBTBase base = compound.getTag(key);
|
||||
if(base instanceof NBTPrimitive)
|
||||
return ((NBTPrimitive)base).func_150286_g();
|
||||
return ((NBTTagString)base).func_150285_a_();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stored data persists through world restart. Unlike tempdata only Strings and Numbers can be saved
|
||||
* @param key The key for the data stored
|
||||
* @param value The data stored. This data can be either a Number or a String. Other data is not stored
|
||||
*/
|
||||
public void setStoredData(String key, Object value){
|
||||
NBTTagCompound compound = getStoredCompound();
|
||||
if(value instanceof Number){
|
||||
compound.setDouble(key, ((Number) value).doubleValue());
|
||||
}
|
||||
else if(value instanceof String)
|
||||
compound.setString(key, (String)value);
|
||||
saveStoredCompound(compound);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key of the data to be checked
|
||||
* @return Returns whether or not the stored data contains the key
|
||||
*/
|
||||
public boolean hasStoredData(String key){
|
||||
return getStoredCompound().hasKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key of the data to be removed
|
||||
*/
|
||||
public void removeStoredData(String key){
|
||||
NBTTagCompound compound = getStoredCompound();
|
||||
compound.removeTag(key);
|
||||
saveStoredCompound(compound);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all stored data
|
||||
*/
|
||||
public void clearStoredData(){
|
||||
entity.getEntityData().removeTag("CNPCStoredData");
|
||||
}
|
||||
|
||||
private NBTTagCompound getStoredCompound(){
|
||||
NBTTagCompound compound = entity.getEntityData().getCompoundTag("CNPCStoredData");
|
||||
if(compound == null)
|
||||
entity.getEntityData().setTag("CNPCStoredData", compound = new NBTTagCompound());
|
||||
return compound;
|
||||
}
|
||||
|
||||
private void saveStoredCompound(NBTTagCompound compound){
|
||||
entity.getEntityData().setTag("CNPCStoredData", compound);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The age of this entity in ticks
|
||||
*/
|
||||
public long getAge(){
|
||||
return entity.ticksExisted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Despawns this entity. Removes it permanently
|
||||
*/
|
||||
public void despawn(){
|
||||
entity.isDead = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return whether or not this entity is standing in water
|
||||
*/
|
||||
public boolean inWater(){
|
||||
return entity.isInsideOfMaterial(Material.water);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return whether or not this entity is standing in lava
|
||||
*/
|
||||
public boolean inLava(){
|
||||
return entity.isInsideOfMaterial(Material.lava);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return whether or not this entity is standing in fire
|
||||
*/
|
||||
public boolean inFire(){
|
||||
return entity.isInsideOfMaterial(Material.fire);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return whether or not this entity is on fire
|
||||
*/
|
||||
public boolean isBurning(){
|
||||
return entity.isBurning();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ticks Amount of world ticks this entity will burn. 20 ticks equals 1 second
|
||||
*/
|
||||
public void setBurning(int ticks){
|
||||
entity.setFire(ticks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes fire from this entity
|
||||
*/
|
||||
public void extinguish(){
|
||||
entity.extinguish();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Name as which it's registered in minecraft
|
||||
*/
|
||||
public String getTypeName(){
|
||||
return EntityList.getEntityString(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item Item to be dropped
|
||||
*/
|
||||
public void dropItem(ScriptItemStack item){
|
||||
entity.entityDropItem(item.item, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return the rider
|
||||
*/
|
||||
public ScriptEntity getRider(){
|
||||
return ScriptController.Instance.getScriptForEntity(entity.riddenByEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entity The entity to ride this entity
|
||||
*/
|
||||
public void setRider(ScriptEntity entity){
|
||||
if(entity != null){
|
||||
entity.entity.mountEntity(this.entity);;
|
||||
}
|
||||
else if(this.entity.riddenByEntity != null)
|
||||
this.entity.riddenByEntity.mountEntity(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return the entity, this entity is riding
|
||||
*/
|
||||
public ScriptEntity getMount(){
|
||||
return ScriptController.Instance.getScriptForEntity(entity.ridingEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entity The entity this entity will mount
|
||||
*/
|
||||
public void setMount(ScriptEntity entity){
|
||||
if(entity == null)
|
||||
this.entity.mountEntity(null);
|
||||
else
|
||||
this.entity.mountEntity(entity.entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see noppes.npcs.scripted.constants.EntityType
|
||||
* @return Returns the EntityType of this entity
|
||||
*/
|
||||
public int getType(){
|
||||
return EntityType.UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param type @EntityType to check
|
||||
* @return Returns whether the entity is type of the given @EntityType
|
||||
*/
|
||||
public boolean typeOf(int type){
|
||||
return type == EntityType.UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rotation The rotation to be set (0-360)
|
||||
*/
|
||||
public void setRotation(float rotation){
|
||||
entity.rotationYaw = rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Current rotation of the npc
|
||||
*/
|
||||
public float getRotation(){
|
||||
return entity.rotationYaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param power How strong the knockback is
|
||||
* @param direction The direction in which he flies back (0-360). Usually based on getRotation()
|
||||
*/
|
||||
public void knockback(int power, float direction){
|
||||
float v = direction * (float)Math.PI / 180.0F;
|
||||
entity.addVelocity(-MathHelper.sin(v) * (float)power, 0.1D + power * 0.04f, MathHelper.cos(v) * (float)power);
|
||||
entity.motionX *= 0.6D;
|
||||
entity.motionZ *= 0.6D;
|
||||
entity.attackEntityFrom(DamageSource.outOfWorld, 0.0001F);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns whether or not this entity is sneaking
|
||||
*/
|
||||
public boolean isSneaking(){
|
||||
return entity.isSneaking();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns whether or not this entity is sprinting
|
||||
*/
|
||||
public boolean isSprinting(){
|
||||
return entity.isSprinting();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* Expert users only
|
||||
* @return Returns minecrafts entity
|
||||
*/
|
||||
public Entity getMCEntity(){
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
public
|
||||
class ScriptEvent{
|
||||
private boolean isCancelled = false;
|
||||
|
||||
public void setCancelled(boolean bo){
|
||||
isCancelled = bo;
|
||||
}
|
||||
|
||||
public boolean isCancelled(){
|
||||
return isCancelled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
|
||||
public class ScriptEventAttack extends ScriptEvent{
|
||||
|
||||
private float damage;
|
||||
private ScriptLivingBase target;
|
||||
private boolean isRanged;
|
||||
|
||||
public ScriptEventAttack(float damage, EntityLivingBase target, boolean isRanged){
|
||||
this.damage = damage;
|
||||
this.isRanged = isRanged;
|
||||
this.target = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
* @deprecated
|
||||
*/
|
||||
public ScriptLivingBase getTarget(){
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the damage value
|
||||
*/
|
||||
public float getDamage(){
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param damage The new damage value
|
||||
*/
|
||||
public void setDamage(float damage){
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the damage type
|
||||
*/
|
||||
public boolean isRange(){
|
||||
return isRanged;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
|
||||
public class ScriptEventDamaged extends ScriptEvent{
|
||||
|
||||
private float damage;
|
||||
private boolean clear = false;
|
||||
private ScriptLivingBase source;
|
||||
private DamageSource damagesource;
|
||||
|
||||
public ScriptEventDamaged(float damage, EntityLivingBase attackingEntity, DamageSource damagesource){
|
||||
this.damage = damage;
|
||||
this.damagesource = damagesource;
|
||||
this.source = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(attackingEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
*/
|
||||
public ScriptLivingBase getSource(){
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setClearTarget(boolean bo){
|
||||
this.clear = bo;
|
||||
}
|
||||
|
||||
public boolean getClearTarget(){
|
||||
return clear;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the damage value
|
||||
*/
|
||||
public float getDamage(){
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param damage The new damage value
|
||||
*/
|
||||
public void setDamage(float damage){
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the damage type
|
||||
*/
|
||||
public String getType(){
|
||||
return damagesource.damageType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
|
||||
public class ScriptEventDialog extends ScriptEvent{
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public boolean isClosing(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
|
||||
public class ScriptEventKilled extends ScriptEvent{
|
||||
|
||||
private ScriptLivingBase source;
|
||||
private DamageSource damagesource;
|
||||
|
||||
public ScriptEventKilled(EntityLivingBase target, DamageSource damagesource){
|
||||
this.damagesource = damagesource;
|
||||
this.source = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
*/
|
||||
public ScriptLivingBase getSource(){
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the damage type
|
||||
*/
|
||||
public String getType(){
|
||||
return damagesource.damageType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
|
||||
public class ScriptEventTarget extends ScriptEvent{
|
||||
|
||||
private ScriptLivingBase target;
|
||||
|
||||
public ScriptEventTarget(EntityLivingBase target){
|
||||
if(target != null)
|
||||
this.target = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(target);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return The source of the damage
|
||||
*/
|
||||
public ScriptLivingBase getTarget(){
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(ScriptLivingBase target){
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import noppes.npcs.controllers.Faction;
|
||||
|
||||
public class ScriptFaction {
|
||||
private Faction faction;
|
||||
|
||||
public ScriptFaction(Faction faction){
|
||||
this.faction = faction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the factions id
|
||||
*/
|
||||
public int getId(){
|
||||
return faction.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return the factions name
|
||||
*/
|
||||
public String getName(){
|
||||
return faction.name;
|
||||
}
|
||||
|
||||
public int getDefaultPoints(){
|
||||
return faction.defaultPoints;
|
||||
}
|
||||
|
||||
public int getColor(){
|
||||
return faction.color;
|
||||
}
|
||||
|
||||
public boolean isFriendlyToPlayer(ScriptPlayer player){
|
||||
return faction.isFriendlyToPlayer(player.player);
|
||||
}
|
||||
|
||||
public boolean isNeutralToPlayer(ScriptPlayer player){
|
||||
return faction.isNeutralToPlayer(player.player);
|
||||
}
|
||||
|
||||
public boolean isAggressiveToPlayer(ScriptPlayer player){
|
||||
return faction.isAggressiveToPlayer(player.player);
|
||||
}
|
||||
|
||||
public boolean isAggressiveToNpc(ScriptNpc npc){
|
||||
return faction.isAggressiveToNpc(npc.npc);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTBase.NBTPrimitive;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
|
||||
public class ScriptItemStack {
|
||||
protected ItemStack item;
|
||||
|
||||
public ScriptItemStack(ItemStack item){
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The minecraft name for this item
|
||||
*/
|
||||
public String getName(){
|
||||
return Item.itemRegistry.getNameForObject(item.getItem());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the stacksize
|
||||
*/
|
||||
public int getStackSize(){
|
||||
return item.stackSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return whether or not the item has a custom name
|
||||
*/
|
||||
public boolean hasCustomName(){
|
||||
return item.hasDisplayName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name The custom name this item will get
|
||||
*/
|
||||
public void setCustomName(String name){
|
||||
item.setStackDisplayName(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return the ingame displayed name. This is either the item name or the custom name if it has one.
|
||||
*/
|
||||
public String getDisplayName(){
|
||||
return item.getDisplayName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Get the items ingame name. Use this incase the item ingame has custom name and you want the original name.
|
||||
*/
|
||||
public String getItemName(){
|
||||
return item.getItem().getItemStackDisplayName(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param size The size of the itemstack. A number between 1 and 64
|
||||
*/
|
||||
public void setStackSize(int size){
|
||||
if(size < 0)
|
||||
size = 1;
|
||||
else if(size > 64)
|
||||
size = 64;
|
||||
item.stackSize = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the item damage of this item. For tools this is the durability for other items the color and more.
|
||||
*/
|
||||
public int getItemDamage(){
|
||||
return item.getItemDamage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value The value to be set as item damage. For tools this is the durability for other items the color and more.
|
||||
*/
|
||||
public void setItemDamage(int value){
|
||||
item.setItemDamage(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key of this NBTTag
|
||||
* @param value The value to be stored. Can be a Number or String
|
||||
*/
|
||||
public void setTag(String key, Object value){
|
||||
if(value instanceof Number)
|
||||
getTag().setDouble(key, ((Number) value).doubleValue());
|
||||
else if(value instanceof String)
|
||||
getTag().setString(key, (String) value);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key of the NBTTag
|
||||
* @return Returns whether or not the key exists
|
||||
*/
|
||||
public boolean hasTag(String key){
|
||||
return getTag().hasKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key of the NBTTag
|
||||
* @return Returns the value associated with the key. Returns null of it doesnt exist
|
||||
*/
|
||||
public Object getTag(String key){
|
||||
NBTBase tag = getTag().getTag(key);
|
||||
if(tag == null)
|
||||
return null;
|
||||
if(tag instanceof NBTPrimitive)
|
||||
return ((NBTPrimitive)tag).func_150286_g();
|
||||
if(tag instanceof NBTTagString)
|
||||
return ((NBTTagString)tag).func_150285_a_();
|
||||
return tag;
|
||||
}
|
||||
|
||||
public boolean isEnchanted(){
|
||||
return item.isItemEnchanted();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10d
|
||||
* @param id The enchantment id
|
||||
* @return
|
||||
*/
|
||||
public boolean hasEnchant(int id){
|
||||
if(!isEnchanted())
|
||||
return false;
|
||||
NBTTagList list = item.getEnchantmentTagList();
|
||||
for(int i = 0; i < list.tagCount(); i++){
|
||||
NBTTagCompound compound = list.getCompoundTagAt(i);
|
||||
if(compound.getShort("id") == id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10d
|
||||
* @return Returns whether this item is a book
|
||||
*/
|
||||
public boolean isWrittenBook(){
|
||||
return item.getItem() == Items.written_book || item.getItem() == Items.writable_book;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10d
|
||||
* @return Returns the books title
|
||||
*/
|
||||
public String getBookTitle(){
|
||||
return item.getTagCompound().getString("title");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10d
|
||||
* @return Returns the books author
|
||||
*/
|
||||
public String getBookAuthor(){
|
||||
return item.getTagCompound().getString("author");
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10d
|
||||
* @return If the item is a book, returns a string array with book pages
|
||||
*/
|
||||
public String[] getBookText(){
|
||||
if(!isWrittenBook())
|
||||
return null;
|
||||
List<String> list = new ArrayList<String>();
|
||||
NBTTagList pages = item.getTagCompound().getTagList("pages", 8);
|
||||
for (int i = 0; i < pages.tagCount(); ++i){
|
||||
list.add(pages.getStringTagAt(i));
|
||||
}
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
private NBTTagCompound getTag(){
|
||||
if(item.stackTagCompound == null)
|
||||
item.stackTagCompound = new NBTTagCompound();
|
||||
return item.stackTagCompound;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns whether or not this item is a block
|
||||
*/
|
||||
public boolean isBlock(){
|
||||
Block block = Block.getBlockFromItem(item.getItem());
|
||||
if(block == null || block == Blocks.air)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* No support is given for this method. Dont use if you dont know what you are doing.
|
||||
* @return Minecraft ItemStack
|
||||
*/
|
||||
public ItemStack getMCItemStack() {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.entity.NPCEntityHelper;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
|
||||
public class ScriptLiving extends ScriptLivingBase{
|
||||
|
||||
private EntityLiving entity;
|
||||
public ScriptLiving(EntityLiving entity) {
|
||||
super(entity);
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAttacking(){
|
||||
return super.isAttacking() || entity.getAttackTarget() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttackTarget(ScriptLivingBase living){
|
||||
if(living == null)
|
||||
entity.setAttackTarget(null);
|
||||
else
|
||||
entity.setAttackTarget(living.entity);
|
||||
super.setAttackTarget(living);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptLivingBase getAttackTarget(){
|
||||
ScriptLivingBase base = (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(entity.getAttackTarget());
|
||||
return (base != null)? base: super.getAttackTarget();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start path finding toward this target
|
||||
* @param x Destination x position
|
||||
* @param y Destination x position
|
||||
* @param z Destination x position
|
||||
* @param speed Walking speed of the entity 0.7 is default
|
||||
*/
|
||||
public void navigateTo(double x, double y, double z, double speed){
|
||||
entity.getNavigator().tryMoveToXYZ(x, y, z, speed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop navigating wherever this npc was walking to
|
||||
*/
|
||||
public void clearNavigation(){
|
||||
entity.getNavigator().clearPathEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether or not this entity is navigating somewhere
|
||||
*/
|
||||
public boolean isNavigating(){
|
||||
return !entity.getNavigator().noPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSeeEntity(ScriptEntity entity){
|
||||
return this.entity.getEntitySenses().canSee(entity.entity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTBase.NBTPrimitive;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
|
||||
public class ScriptLivingBase extends ScriptEntity{
|
||||
protected EntityLivingBase entity;
|
||||
|
||||
public ScriptLivingBase(EntityLivingBase entity){
|
||||
super(entity);
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The entity's current health
|
||||
*/
|
||||
public float getHealth(){
|
||||
return entity.getHealth();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param health The new health of this entity
|
||||
*/
|
||||
public void setHealth(float health){
|
||||
entity.setHealth(health);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Entity's max health
|
||||
*/
|
||||
public float getMaxHealth(){
|
||||
return entity.getMaxHealth();
|
||||
}
|
||||
/**
|
||||
* @return Whether or not this entity is attacking something
|
||||
*/
|
||||
public boolean isAttacking(){
|
||||
return entity.getAITarget() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param living Entity which this entity will attack
|
||||
*/
|
||||
public void setAttackTarget(ScriptLivingBase living){
|
||||
if(living == null)
|
||||
entity.setRevengeTarget(null);
|
||||
else
|
||||
entity.setRevengeTarget(living.entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The entity which this entity is attacking
|
||||
*/
|
||||
public ScriptLivingBase getAttackTarget(){
|
||||
return (ScriptLivingBase)ScriptController.Instance.getScriptForEntity(entity.getAITarget());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return EntityType.LIVING;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean typeOf(int type){
|
||||
return type == EntityType.LIVING?true:super.typeOf(type);
|
||||
}
|
||||
/**
|
||||
* @param entity Entity to check
|
||||
* @return Whether or not this entity can see the given entity
|
||||
*/
|
||||
public boolean canSeeEntity(ScriptEntity entity){
|
||||
return this.entity.canEntityBeSeen(entity.entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expert use only
|
||||
* @return Returns the minecraft entity object
|
||||
*/
|
||||
public EntityLivingBase getMinecraftEntity(){
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the entity swing its hand
|
||||
*/
|
||||
public void swingHand(){
|
||||
entity.swingItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Works the same as the <a href="http://minecraft.gamepedia.com/Commands#effect">/effect command</a>
|
||||
* @param effect
|
||||
* @param duration The duration in seconds
|
||||
* @param strength The amplifier of the potion effect
|
||||
* @param hideParticles Whether or not you want to hide potion particles
|
||||
*/
|
||||
public void addPotionEffect(int effect, int duration, int strength, boolean hideParticles){
|
||||
if (effect < 0 || effect >= Potion.potionTypes.length || Potion.potionTypes[effect] == null)
|
||||
return;
|
||||
|
||||
if(strength < 0)
|
||||
strength = 0;
|
||||
else if(strength > 255)
|
||||
strength = 255;
|
||||
|
||||
if(duration < 0)
|
||||
duration = 0;
|
||||
else if(duration > 1000000)
|
||||
duration = 1000000;
|
||||
|
||||
if(!Potion.potionTypes[effect].isInstant())
|
||||
duration *= 20;
|
||||
|
||||
if(duration == 0)
|
||||
entity.removePotionEffect(effect);
|
||||
else
|
||||
entity.addPotionEffect(new PotionEffect(effect, duration, strength));
|
||||
//TODO in 1.8 add hideParticles option
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all potion effects
|
||||
*/
|
||||
public void clearPotionEffects(){
|
||||
entity.clearActivePotions();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param effect Potion effect to check
|
||||
* @return Returns -1 if its not active. Otherwise returns the strenght of the potion
|
||||
*/
|
||||
public int getPotionEffect(int effect){
|
||||
PotionEffect pf = entity.getActivePotionEffect(Potion.potionTypes[effect]);
|
||||
if(pf == null)
|
||||
return -1;
|
||||
return pf.getAmplifier();
|
||||
}
|
||||
|
||||
/**
|
||||
* Note not all Living Entities support this
|
||||
* @since 1.7.10c
|
||||
* @return The item the entity is holding
|
||||
*/
|
||||
public ScriptItemStack getHeldItem(){
|
||||
ItemStack item = entity.getHeldItem();
|
||||
if(item == null)
|
||||
return null;
|
||||
return new ScriptItemStack(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note not all Living Entities support this
|
||||
* @since 1.7.10c
|
||||
* @param item The item to be set
|
||||
*/
|
||||
public void setHeldItem(ScriptItemStack item){
|
||||
entity.setCurrentItemOrArmor(0, item == null?null:item.item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note not all Living Entities support this
|
||||
* @param slot Slot of what armor piece to get, 0:boots, 1:pants, 2:body, 3:head
|
||||
* @return The item in the given slot
|
||||
*/
|
||||
public ScriptItemStack getArmor(int slot){
|
||||
ItemStack item = entity.getEquipmentInSlot(slot + 1);
|
||||
if(item == null)
|
||||
return null;
|
||||
return new ScriptItemStack(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note not all Living Entities support this
|
||||
* @since 1.7.10c
|
||||
* @param slot Slot of what armor piece to set, 0:boots, 1:pants, 2:body, 3:head
|
||||
* @param item Item to be set
|
||||
*/
|
||||
public void setArmor(int slot, ScriptItemStack item){
|
||||
entity.setCurrentItemOrArmor(slot + 1, item == null?null:item.item);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
|
||||
public class ScriptMonster extends ScriptLiving{
|
||||
|
||||
public ScriptMonster(EntityMob entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return EntityType.MONSTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean typeOf(int type){
|
||||
return type == EntityType.MONSTER?true:super.typeOf(type);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,663 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.constants.EnumAnimation;
|
||||
import noppes.npcs.constants.EnumJobType;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.controllers.Line;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobBard;
|
||||
import noppes.npcs.scripted.constants.AnimationType;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.roles.ScriptJobBard;
|
||||
import noppes.npcs.scripted.roles.ScriptJobConversation;
|
||||
import noppes.npcs.scripted.roles.ScriptJobFollower;
|
||||
import noppes.npcs.scripted.roles.ScriptJobGuard;
|
||||
import noppes.npcs.scripted.roles.ScriptJobHealer;
|
||||
import noppes.npcs.scripted.roles.ScriptJobInterface;
|
||||
import noppes.npcs.scripted.roles.ScriptJobItemGiver;
|
||||
import noppes.npcs.scripted.roles.ScriptJobPuppet;
|
||||
import noppes.npcs.scripted.roles.ScriptJobSpawner;
|
||||
import noppes.npcs.scripted.roles.ScriptRoleBank;
|
||||
import noppes.npcs.scripted.roles.ScriptRoleFollower;
|
||||
import noppes.npcs.scripted.roles.ScriptRoleInterface;
|
||||
import noppes.npcs.scripted.roles.ScriptRoleMailman;
|
||||
import noppes.npcs.scripted.roles.ScriptRoleTrader;
|
||||
import noppes.npcs.scripted.roles.ScriptRoleTransporter;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
public class ScriptNpc extends ScriptLiving{
|
||||
protected EntityCustomNpc npc;
|
||||
|
||||
public ScriptNpc(EntityCustomNpc npc){
|
||||
super(npc);
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the current npcs size 1-30
|
||||
*/
|
||||
public int getSize(){
|
||||
return npc.display.modelSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param size The size of the npc (1-30) default is 5
|
||||
*/
|
||||
public void setSize(int size){
|
||||
if(size > 30)
|
||||
size = 30;
|
||||
else if(size < 1)
|
||||
size = 1;
|
||||
npc.display.modelSize = size;
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The npcs name
|
||||
*/
|
||||
public String getName(){
|
||||
return npc.display.name;
|
||||
}
|
||||
|
||||
public void setRotation(float rotation){
|
||||
npc.ai.orientation = (int)rotation;
|
||||
super.setRotation(rotation);
|
||||
}
|
||||
/**
|
||||
* @param name The name of the npc
|
||||
*/
|
||||
public void setName(String name){
|
||||
npc.display.name = name;
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10
|
||||
* @return The npcs title
|
||||
*/
|
||||
public String getTitle(){
|
||||
return npc.display.title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10
|
||||
* @param title The title of the npc
|
||||
*/
|
||||
public void setTitle(String title){
|
||||
npc.display.title = title;
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The npcs texture
|
||||
*/
|
||||
public String getTexture(){
|
||||
return npc.display.texture;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param texture The texture of the npc
|
||||
*/
|
||||
public void setTexture(String texture){
|
||||
npc.display.texture = texture;
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Home position x
|
||||
*/
|
||||
public int getHomeX(){
|
||||
return npc.getStartPos()[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x The home x position
|
||||
*/
|
||||
public void setHomeX(int x){
|
||||
npc.ai.startPos[0] = x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Home position x
|
||||
*/
|
||||
public int getHomeY(){
|
||||
return npc.getStartPos()[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param y The home y position
|
||||
*/
|
||||
public void setHomeY(int y){
|
||||
npc.ai.startPos[1] = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Home position x
|
||||
*/
|
||||
public int getHomeZ(){
|
||||
return npc.getStartPos()[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param z The home x position
|
||||
*/
|
||||
public void setHomeZ(int z){
|
||||
npc.ai.startPos[2] = z;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x The home x position
|
||||
* @param y The home y position
|
||||
* @param z The home z position
|
||||
*/
|
||||
public void setHome(int x, int y, int z){
|
||||
npc.ai.startPos = new int[]{x, y, z};
|
||||
}
|
||||
/**
|
||||
* @param health New max health
|
||||
*/
|
||||
public void setMaxHealth(int health){
|
||||
npc.stats.setMaxHealth(health);
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bo Whether or not the npc will try to return to his home position
|
||||
*/
|
||||
public void setReturnToHome(boolean bo){
|
||||
npc.ai.returnToStart = bo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether or not the npc returns home
|
||||
*/
|
||||
public boolean getReturnToHome(){
|
||||
return npc.ai.returnToStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The faction of the npc
|
||||
*/
|
||||
public ScriptFaction getFaction(){
|
||||
return new ScriptFaction(npc.getFaction());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id The id of the new faction
|
||||
*/
|
||||
public void setFaction(int id){
|
||||
npc.setFaction(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return EntityType.NPC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean typeOf(int type){
|
||||
return type == EntityType.NPC?true:super.typeOf(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param target The targeted npc
|
||||
* @param item The item you want to shoot
|
||||
* @param accuracy Accuracy of the shot (0-100)
|
||||
*/
|
||||
public void shootItem(ScriptLivingBase target, ScriptItemStack item, int accuracy){
|
||||
if(item == null)
|
||||
return;
|
||||
if(accuracy < 0)
|
||||
accuracy = 0;
|
||||
else if(accuracy > 100)
|
||||
accuracy = 100;
|
||||
npc.shoot(target.entity, accuracy, item.item, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message The message the npc will say
|
||||
*/
|
||||
public void say(String message){
|
||||
npc.saySurrounding(new Line(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message The message the npc will say
|
||||
*/
|
||||
public void say(ScriptPlayer player, String message){
|
||||
if(player == null || message == null || message.isEmpty())
|
||||
return;
|
||||
npc.say(player.player, new Line(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Kill the npc, doesnt't despawn it
|
||||
*/
|
||||
public void kill(){
|
||||
npc.setDead();
|
||||
}
|
||||
|
||||
/**
|
||||
* Basically completely resets the npc. This will also call the Init script
|
||||
*/
|
||||
public void reset(){
|
||||
npc.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the npcs current role
|
||||
*/
|
||||
public ScriptRoleInterface getRole(){
|
||||
if(npc.advanced.role == EnumRoleType.Bank)
|
||||
return new ScriptRoleBank(npc);
|
||||
else if(npc.advanced.role == EnumRoleType.Follower)
|
||||
return new ScriptRoleFollower(npc);
|
||||
else if(npc.advanced.role == EnumRoleType.Postman)
|
||||
return new ScriptRoleMailman(npc);
|
||||
else if(npc.advanced.role == EnumRoleType.Trader)
|
||||
return new ScriptRoleTrader(npc);
|
||||
else if(npc.advanced.role == EnumRoleType.Transporter)
|
||||
return new ScriptRoleTransporter(npc);
|
||||
return new ScriptRoleInterface(npc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the npcs current job
|
||||
*/
|
||||
public ScriptJobInterface getJob(){
|
||||
if(npc.advanced.job == EnumJobType.Bard)
|
||||
return new ScriptJobBard(npc);
|
||||
else if(npc.advanced.job == EnumJobType.Conversation)
|
||||
return new ScriptJobConversation(npc);
|
||||
else if(npc.advanced.job == EnumJobType.Follower)
|
||||
return new ScriptJobFollower(npc);
|
||||
else if(npc.advanced.job == EnumJobType.Guard)
|
||||
return new ScriptJobGuard(npc);
|
||||
else if(npc.advanced.job == EnumJobType.Healer)
|
||||
return new ScriptJobHealer(npc);
|
||||
else if(npc.advanced.job == EnumJobType.Puppet)
|
||||
return new ScriptJobPuppet(npc);
|
||||
else if(npc.advanced.job == EnumJobType.ItemGiver)
|
||||
return new ScriptJobItemGiver(npc);
|
||||
else if(npc.advanced.job == EnumJobType.Spawner)
|
||||
return new ScriptJobSpawner(npc);
|
||||
return new ScriptJobInterface(npc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The item held in the right hand
|
||||
*/
|
||||
public ScriptItemStack getRightItem(){
|
||||
ItemStack item = npc.inventory.getWeapon();
|
||||
if(item == null || item.getItem() == null)
|
||||
return null;
|
||||
return new ScriptItemStack(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item Item to be held in the right hand
|
||||
*/
|
||||
public void setRightItem(ScriptItemStack item){
|
||||
if(item == null)
|
||||
npc.inventory.setWeapon(null);
|
||||
else
|
||||
npc.inventory.setWeapon(item.item);
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The item held in the left hand
|
||||
*/
|
||||
public ScriptItemStack getLefttItem(){
|
||||
ItemStack item = npc.getOffHand();
|
||||
if(item == null || item.getItem() == null)
|
||||
return null;
|
||||
return new ScriptItemStack(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item Item to be held in the left hand
|
||||
*/
|
||||
public void setLeftItem(ScriptItemStack item){
|
||||
if(item == null)
|
||||
npc.inventory.setOffHand(null);
|
||||
else
|
||||
npc.inventory.setOffHand(item.item);
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the projectile the npc uses
|
||||
*/
|
||||
public ScriptItemStack getProjectileItem(){
|
||||
ItemStack item = npc.inventory.getProjectile();
|
||||
if(item == null || item.getItem() == null)
|
||||
return null;
|
||||
return new ScriptItemStack(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item Item to be used as projectile
|
||||
*/
|
||||
public void setProjectileItem(ScriptItemStack item){
|
||||
if(item == null)
|
||||
npc.inventory.setProjectile(null);
|
||||
else
|
||||
npc.inventory.setProjectile(item.item);
|
||||
npc.script.aiNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot The armor slot to return. 0:head, 1:body, 2:legs, 3:boots
|
||||
* @return Returns the worn armor in slot
|
||||
*/
|
||||
@Override
|
||||
public ScriptItemStack getArmor(int slot){
|
||||
ItemStack item = npc.inventory.armor.get(slot);
|
||||
if(item == null)
|
||||
return null;
|
||||
return new ScriptItemStack(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot The armor slot to set. 0:head, 1:body, 2:legs, 3:boots
|
||||
* @param item Item to be set as armor
|
||||
*/
|
||||
@Override
|
||||
public void setArmor(int slot, ScriptItemStack item){
|
||||
if(item == null)
|
||||
npc.inventory.armor.put(slot, null);
|
||||
else
|
||||
npc.inventory.armor.put(slot, item.item);
|
||||
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type The AnimationType
|
||||
*/
|
||||
public void setAnimation(int type){
|
||||
if(type == AnimationType.NORMAL)
|
||||
npc.ai.animationType = EnumAnimation.NONE;
|
||||
else if(type == AnimationType.SITTING)
|
||||
npc.ai.animationType = EnumAnimation.SITTING;
|
||||
else if(type == AnimationType.DANCING)
|
||||
npc.ai.animationType = EnumAnimation.DANCING;
|
||||
else if(type == AnimationType.SNEAKING)
|
||||
npc.ai.animationType = EnumAnimation.SNEAKING;
|
||||
else if(type == AnimationType.LYING)
|
||||
npc.ai.animationType = EnumAnimation.LYING;
|
||||
else if(type == AnimationType.HUGGING)
|
||||
npc.ai.animationType = EnumAnimation.HUG;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type The visibility type of the npc, 0:visible, 1:invisible, 2:semi-visible
|
||||
*/
|
||||
public void setVisibleType(int type){
|
||||
npc.display.visible = type;
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The visibility type of the npc, 0:visible, 1:invisible, 2:semi-visible
|
||||
*/
|
||||
public int getVisibleType(){
|
||||
return npc.display.visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type The visibility type of the name, 0:visible, 1:invisible, 2:when-attacking
|
||||
*/
|
||||
public void setShowName(int type){
|
||||
npc.display.showName = type;
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the visibility type of the name, 0:visible, 1:invisible, 2:when-attacking
|
||||
*/
|
||||
public int getShowName(){
|
||||
return npc.display.showName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the visiblity of the boss bar, 0:invisible, 1:visible, 2:when-attacking
|
||||
*/
|
||||
public int getShowBossBar(){
|
||||
return npc.display.showBossBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type The visibility type of the boss bar, 0:invisible, 1:visible, 2:when-attacking
|
||||
*/
|
||||
public void setShowBossBar(int type){
|
||||
npc.display.showBossBar = (byte) type;
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The melee strength
|
||||
*/
|
||||
public int getMeleeStrength(){
|
||||
return npc.stats.getAttackStrength();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param strength The melee strength
|
||||
*/
|
||||
public void setMeleeStrength(int strength){
|
||||
npc.stats.setAttackStrength(strength);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The melee speed
|
||||
*/
|
||||
public int getMeleeSpeed(){
|
||||
return npc.stats.attackSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param speed The melee speed
|
||||
*/
|
||||
public void setMeleeSpeed(int speed){
|
||||
npc.stats.attackSpeed = speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The ranged strength
|
||||
*/
|
||||
public int getRangedStrength(){
|
||||
return npc.stats.pDamage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param strength The ranged strength
|
||||
*/
|
||||
public void setRangedStrength(int strength){
|
||||
npc.stats.pDamage = strength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The ranged speed
|
||||
*/
|
||||
public int getRangedSpeed(){
|
||||
return npc.stats.pSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param speed The ranged speed
|
||||
*/
|
||||
public void setRangedSpeed(int speed){
|
||||
npc.stats.pSpeed = speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The ranged burst count
|
||||
*/
|
||||
public int getRangedBurst(){
|
||||
return npc.stats.burstCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param count The ranged burst count
|
||||
*/
|
||||
public void setRangedBurst(int count){
|
||||
npc.stats.burstCount = count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player The player to give the item to
|
||||
* @param item The item given to the player
|
||||
*/
|
||||
public void giveItem(ScriptPlayer player, ScriptItemStack item){
|
||||
npc.givePlayerItem(player.player, item.item);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* On servers the enable-command-block option in the server.properties needs to be set to true
|
||||
* @param command The command to be executed
|
||||
*/
|
||||
public void executeCommand(String command){
|
||||
NoppesUtilServer.runCommand(npc, npc.getCommandSenderName(), command, null);
|
||||
}
|
||||
|
||||
public void setHeadScale(float x, float y, float z){
|
||||
npc.modelData.head.scaleX = ValueUtil.correctFloat(x, 0.5f, 1.5f);
|
||||
npc.modelData.head.scaleY = ValueUtil.correctFloat(y, 0.5f, 1.5f);
|
||||
npc.modelData.head.scaleZ = ValueUtil.correctFloat(z, 0.5f, 1.5f);
|
||||
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
public void setBodyScale(float x, float y, float z){
|
||||
npc.modelData.body.scaleX = ValueUtil.correctFloat(x, 0.5f, 1.5f);
|
||||
npc.modelData.body.scaleY = ValueUtil.correctFloat(y, 0.5f, 1.5f);
|
||||
npc.modelData.body.scaleZ = ValueUtil.correctFloat(z, 0.5f, 1.5f);
|
||||
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
public void setArmsScale(float x, float y, float z){
|
||||
npc.modelData.arms.scaleX = ValueUtil.correctFloat(x, 0.5f, 1.5f);
|
||||
npc.modelData.arms.scaleY = ValueUtil.correctFloat(y, 0.5f, 1.5f);
|
||||
npc.modelData.arms.scaleZ = ValueUtil.correctFloat(z, 0.5f, 1.5f);
|
||||
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
public void setLegsScale(float x, float y, float z){
|
||||
npc.modelData.legs.scaleX = ValueUtil.correctFloat(x, 0.5f, 1.5f);
|
||||
npc.modelData.legs.scaleY = ValueUtil.correctFloat(y, 0.5f, 1.5f);
|
||||
npc.modelData.legs.scaleZ = ValueUtil.correctFloat(z, 0.5f, 1.5f);
|
||||
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param resistance Explosion resistance (0-2) default is 1
|
||||
*/
|
||||
public void seExplosionResistance(float resistance){
|
||||
npc.stats.resistances.explosion = ValueUtil.correctFloat(resistance, 0, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns Explosion Resistance
|
||||
*/
|
||||
public float getExplosionResistance(){
|
||||
return npc.stats.resistances.explosion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resistance Melee resistance (0-2) default is 1
|
||||
*/
|
||||
public void setMeleeResistance(float resistance){
|
||||
npc.stats.resistances.playermelee = ValueUtil.correctFloat(resistance, 0, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns Melee Resistance
|
||||
*/
|
||||
public float getMeleeResistance(){
|
||||
return npc.stats.resistances.playermelee;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resistance Arrow resistance (0-2) default is 1
|
||||
*/
|
||||
public void setArrowResistance(float resistance){
|
||||
npc.stats.resistances.arrow = ValueUtil.correctFloat(resistance, 0, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns Arrow Resistance
|
||||
*/
|
||||
public float getArrowResistance(){
|
||||
return npc.stats.resistances.arrow;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resistance Knockback resistance (0-2) default is 1
|
||||
*/
|
||||
public void setKnockbackResistance(float resistance){
|
||||
npc.stats.resistances.knockback = ValueUtil.correctFloat(resistance, 0, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns Knockback Resistance
|
||||
*/
|
||||
public float getKnockbackResistance(){
|
||||
return npc.stats.resistances.knockback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type Retaliation type. 0:normal, 1:panic, 2:retreat, 3:nothing
|
||||
*/
|
||||
public void setRetaliateType(int type){
|
||||
npc.ai.onAttack = type;
|
||||
npc.setResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the combat health regen per second
|
||||
*/
|
||||
public int getCombatRegen(){
|
||||
return npc.stats.combatRegen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param regen The combat health regen per second
|
||||
*/
|
||||
public void setCombatRegen(int regen){
|
||||
npc.stats.combatRegen = regen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the health regen per second when not in combat
|
||||
*/
|
||||
public int getHealthRegen(){
|
||||
return npc.stats.healthRegen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param regen The health regen per second when not in combat
|
||||
*/
|
||||
public void setHealthRegen(int regen){
|
||||
npc.stats.healthRegen = regen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAge(){
|
||||
return npc.totalTicksAlive;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.entity.passive.EntityTameable;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.controllers.PixelmonHelper;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
public class ScriptPixelmon extends ScriptAnimal{
|
||||
private EntityTameable pixelmon;
|
||||
private NBTTagCompound compound = null;
|
||||
public ScriptPixelmon(EntityTameable pixelmon){
|
||||
super(pixelmon);
|
||||
this.pixelmon = pixelmon;
|
||||
compound = new NBTTagCompound();
|
||||
pixelmon.writeEntityToNBT(compound);
|
||||
}
|
||||
public ScriptPixelmon(EntityTameable pixelmon, NBTTagCompound compound){
|
||||
this(pixelmon);
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
public boolean getIsShiny(){
|
||||
return compound.getBoolean("IsShiny");
|
||||
}
|
||||
|
||||
public void setIsShiny(boolean bo){
|
||||
compound.setBoolean("IsShiny", bo);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
public int getLevel(){
|
||||
return compound.getInteger("Level");
|
||||
}
|
||||
|
||||
public void setLevel(int level){
|
||||
compound.setInteger("Level", level);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed
|
||||
*/
|
||||
public int getIV(int type){
|
||||
if(type == 0)
|
||||
return compound.getInteger("IVHP");
|
||||
if(type == 1)
|
||||
return compound.getInteger("IVAttack");
|
||||
if(type == 2)
|
||||
return compound.getInteger("IVDefence");
|
||||
if(type == 3)
|
||||
return compound.getInteger("IVSpAtt");
|
||||
if(type == 4)
|
||||
return compound.getInteger("IVSpDef");
|
||||
if(type == 5)
|
||||
return compound.getInteger("IVSpeed");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed
|
||||
*/
|
||||
public void setIV(int type, int value){
|
||||
if(type == 0)
|
||||
compound.setInteger("IVHP", value);
|
||||
else if(type == 1)
|
||||
compound.setInteger("IVAttack", value);
|
||||
else if(type == 2)
|
||||
compound.setInteger("IVDefence", value);
|
||||
else if(type == 3)
|
||||
compound.setInteger("IVSpAtt", value);
|
||||
else if(type == 4)
|
||||
compound.setInteger("IVSpDef", value);
|
||||
else if(type == 5)
|
||||
compound.setInteger("IVSpeed", value);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed
|
||||
*/
|
||||
public int getEV(int type){
|
||||
if(type == 0)
|
||||
return compound.getInteger("EVHP");
|
||||
if(type == 1)
|
||||
return compound.getInteger("EVAttack");
|
||||
if(type == 2)
|
||||
return compound.getInteger("EVDefence");
|
||||
if(type == 3)
|
||||
return compound.getInteger("EVSpecialAttack");
|
||||
if(type == 4)
|
||||
return compound.getInteger("EVSpecialDefence");
|
||||
if(type == 5)
|
||||
return compound.getInteger("EVSpeed");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed
|
||||
*/
|
||||
public void setEV(int type, int value){
|
||||
if(type == 0)
|
||||
compound.setInteger("EVHP", value);
|
||||
else if(type == 1)
|
||||
compound.setInteger("EVAttack", value);
|
||||
else if(type == 2)
|
||||
compound.setInteger("EVDefence", value);
|
||||
else if(type == 3)
|
||||
compound.setInteger("EVSpecialAttack", value);
|
||||
else if(type == 4)
|
||||
compound.setInteger("EVSpecialDefence", value);
|
||||
else if(type == 5)
|
||||
compound.setInteger("EVSpeed", value);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed
|
||||
*/
|
||||
public int getStat(int type){
|
||||
if(type == 0)
|
||||
return compound.getInteger("StatsHP");
|
||||
if(type == 1)
|
||||
return compound.getInteger("StatsAttack");
|
||||
if(type == 2)
|
||||
return compound.getInteger("StatsDefence");
|
||||
if(type == 3)
|
||||
return compound.getInteger("StatsSpecialAttack");
|
||||
if(type == 4)
|
||||
return compound.getInteger("StatsSpecialDefence");
|
||||
if(type == 5)
|
||||
return compound.getInteger("StatsSpeed");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param type 0:HP, 1:Attack, 2:Defense, 3:SpAttack, 4:SpDefense, 5:Speed
|
||||
*/
|
||||
public void setStat(int type, int value){
|
||||
if(type == 0)
|
||||
compound.setInteger("StatsHP", value);
|
||||
else if(type == 1)
|
||||
compound.setInteger("StatsAttack", value);
|
||||
else if(type == 2)
|
||||
compound.setInteger("StatsDefence", value);
|
||||
else if(type == 3)
|
||||
compound.setInteger("StatsSpecialAttack", value);
|
||||
else if(type == 4)
|
||||
compound.setInteger("StatsSpecialDefence", value);
|
||||
else if(type == 5)
|
||||
compound.setInteger("StatsSpeed", value);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return type 0:Pygmy, 1:Runt, 2:Small, 3:Normal, 4:Huge, 5:Giant, 6:Enormous, 7:Ginormous, 8:Microscopic
|
||||
*/
|
||||
public int getSize(){
|
||||
return compound.getShort("Growth");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type 0:Pygmy, 1:Runt, 2:Small, 3:Normal, 4:Huge, 5:Giant, 6:Enormous, 7:Ginormous, 8:Microscopic
|
||||
*/
|
||||
public void setSize(int type){
|
||||
compound.setShort("Growth", (short) type);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 0-255
|
||||
*/
|
||||
public int getHapiness(){
|
||||
return compound.getInteger("Friendship");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value 0-255
|
||||
*/
|
||||
public void setHapiness(int value){
|
||||
value = ValueUtil.CorrectInt(value, 0, 255);
|
||||
compound.setInteger("Friendship", value);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 0:Hardy, 1:Serious, 2:Docile, 3:Bashful, 4:Quirky, 5:Lonely, 6:Brave, 7:Adamant, 8:Naughty, 9:Bold, 10:Relaxed, 11:Impish, 12:Lax, 13:Timid, 14:Hasty, 15:Jolly, 16:Naive, 17:Modest, 18:Mild, 19:Quiet, 20:Rash, 21:Calm, 22:Gentle, 23:Sassy, 24:Careful
|
||||
*/
|
||||
public int getNature(){
|
||||
return compound.getShort("Nature");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type 0:Hardy, 1:Serious, 2:Docile, 3:Bashful, 4:Quirky, 5:Lonely, 6:Brave, 7:Adamant, 8:Naughty, 9:Bold, 10:Relaxed, 11:Impish, 12:Lax, 13:Timid, 14:Hasty, 15:Jolly, 16:Naive, 17:Modest, 18:Mild, 19:Quiet, 20:Rash, 21:Calm, 22:Gentle, 23:Sassy, 24:Careful
|
||||
*/
|
||||
public void setNature(int type){
|
||||
compound.setShort("Nature", (short) type);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return -1:Uncaught, 0:Pokeball, 1:GreatBall, 2:UltraBall, 3:MasterBall, 4:LevelBall, 5:MoonBall, 6:FriendBall, 7:LoveBall, 8:SafariBall, 9:HeavyBall, 10:FastBall, 11:RepeatBall, 12:TimerBall, 13:NestBall, 14:NetBall, 15:DiveBall, 16:LuxuryBall, 17:HealBall, 18:DuskBall, 19:PremierBall, 20:SportBall, 21:QuickBall, 22:ParkBall, 23:LureBall, 24:CherishBall, 25:GSBall
|
||||
*/
|
||||
public int getPokeball(){
|
||||
if(compound.hasKey("CaughtBall"))
|
||||
return -1;
|
||||
return compound.getInteger("CaughtBall");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type -1:Uncaught, 0:Pokeball, 1:GreatBall, 2:UltraBall, 3:MasterBall, 4:LevelBall, 5:MoonBall, 6:FriendBall, 7:LoveBall, 8:SafariBall, 9:HeavyBall, 10:FastBall, 11:RepeatBall, 12:TimerBall, 13:NestBall, 14:NetBall, 15:DiveBall, 16:LuxuryBall, 17:HealBall, 18:DuskBall, 19:PremierBall, 20:SportBall, 21:QuickBall, 22:ParkBall, 23:LureBall, 24:CherishBall, 25:GSBall
|
||||
*/
|
||||
public void setPokeball(int type){
|
||||
compound.setInteger("CaughtBall", type);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
public String getNickname(){
|
||||
return compound.getString("Nickname");
|
||||
}
|
||||
|
||||
public boolean hasNickname(){
|
||||
return !getNickname().isEmpty();
|
||||
}
|
||||
|
||||
public void setNickname(String name){
|
||||
compound.setString("Nickname", name);
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
|
||||
public String getMove(int slot){
|
||||
if(!compound.hasKey("PixelmonMoveID" + slot))
|
||||
return null;
|
||||
return PixelmonHelper.getAttackName(compound.getInteger("PixelmonMoveID" + slot));
|
||||
}
|
||||
|
||||
public void setMove(int slot, String move){
|
||||
slot = ValueUtil.CorrectInt(slot, 0, 3);
|
||||
int id = PixelmonHelper.getAttackID(move);
|
||||
compound.removeTag("PixelmonMovePP" + slot);
|
||||
compound.removeTag("PixelmonMovePPBase" + slot);
|
||||
if(id < 0){
|
||||
compound.removeTag("PixelmonMoveID" + slot);
|
||||
}
|
||||
else{
|
||||
compound.setInteger("PixelmonMoveID" + slot, id);
|
||||
}
|
||||
int size = 0;
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(compound.hasKey("PixelmonMoveID" + i))
|
||||
size++;
|
||||
}
|
||||
compound.setInteger("PixelmonNumberMoves", size);
|
||||
|
||||
pixelmon.readEntityFromNBT(compound);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.entity.passive.EntityTameable;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.controllers.PixelmonHelper;
|
||||
|
||||
public class ScriptPixelmonPlayerData {
|
||||
private EntityPlayerMP player;
|
||||
public ScriptPixelmonPlayerData(EntityPlayerMP player){
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public ScriptPixelmon getPartySlot(int slot){
|
||||
NBTTagCompound compound = PixelmonHelper.getPartySlot(slot, player);
|
||||
if(compound == null)
|
||||
return null;
|
||||
EntityTameable pixelmon = PixelmonHelper.pixelmonFromNBT(compound, player);
|
||||
return new ScriptPixelmon(pixelmon, compound);
|
||||
}
|
||||
|
||||
public int countPCPixelmon(){
|
||||
return PixelmonHelper.countPCPixelmon(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.stats.StatBase;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.NoppesStringUtils;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.controllers.PixelmonHelper;
|
||||
import noppes.npcs.controllers.PlayerData;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.PlayerDialogData;
|
||||
import noppes.npcs.controllers.PlayerQuestData;
|
||||
import noppes.npcs.controllers.Quest;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.QuestData;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
public class ScriptPlayer extends ScriptLivingBase{
|
||||
protected EntityPlayerMP player;
|
||||
public ScriptPlayer(EntityPlayerMP player){
|
||||
super(player);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the displayed name of the player
|
||||
*/
|
||||
public String getDisplayName(){
|
||||
return player.getDisplayName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the players name
|
||||
*/
|
||||
public String getName(){
|
||||
return player.getCommandSenderName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(double x, double y, double z){
|
||||
NoppesUtilPlayer.teleportPlayer(player, x, y, z, player.dimension);
|
||||
}
|
||||
|
||||
public boolean hasFinishedQuest(int id){
|
||||
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
return data.finishedQuests.containsKey(id);
|
||||
}
|
||||
|
||||
public boolean hasActiveQuest(int id){
|
||||
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
return data.activeQuests.containsKey(id);
|
||||
}
|
||||
|
||||
public boolean hasReadDialog(int id){
|
||||
PlayerDialogData data = PlayerDataController.instance.getPlayerData(player).dialogData;
|
||||
return data.dialogsRead.contains(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the quest from active quest list
|
||||
* @param id The Quest ID
|
||||
*/
|
||||
public void startQuest(int id){
|
||||
Quest quest = QuestController.instance.quests.get(id);
|
||||
if (quest == null)
|
||||
return;
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
if(data.questData.activeQuests.containsKey(id))
|
||||
return;
|
||||
QuestData questdata = new QuestData(quest);
|
||||
data.questData.activeQuests.put(id, questdata);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the quest from finished quest list
|
||||
* @param id The Quest ID
|
||||
*/
|
||||
public void finishQuest(int id){
|
||||
Quest quest = QuestController.instance.quests.get(id);
|
||||
if (quest == null)
|
||||
return;
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
data.questData.finishedQuests.put(id, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the quest from active quest list
|
||||
* @param id The Quest ID
|
||||
*/
|
||||
public void stopQuest(int id){
|
||||
Quest quest = QuestController.instance.quests.get(id);
|
||||
if (quest == null)
|
||||
return;
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
data.questData.activeQuests.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the quest from active and finished quest list
|
||||
* @param id The Quest ID
|
||||
*/
|
||||
public void removeQuest(int id){
|
||||
Quest quest = QuestController.instance.quests.get(id);
|
||||
if (quest == null)
|
||||
return;
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
data.questData.activeQuests.remove(id);
|
||||
data.questData.finishedQuests.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return EntityType.PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean typeOf(int type){
|
||||
return type == EntityType.PLAYER?true:super.typeOf(type);
|
||||
}
|
||||
/**
|
||||
* @param faction The faction id
|
||||
* @param points The points to increase. Use negative values to decrease
|
||||
*/
|
||||
public void addFactionPoints(int faction, int points){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
data.factionData.increasePoints(faction, points);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param faction The faction id
|
||||
* @return points
|
||||
*/
|
||||
public int getFactionPoints(int faction) {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
return data.factionData.getFactionPoints(faction);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message The message you want to send
|
||||
*/
|
||||
public void sendMessage(String message){
|
||||
player.addChatMessage(new ChatComponentTranslation(NoppesStringUtils.formatText(message,player)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return gamemode. 0: Survival, 1: Creative, 2: Adventure
|
||||
*/
|
||||
public int getMode(){
|
||||
return player.theItemInWorldManager.getGameType().getID();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type The gamemode type. 0:SURVIVAL, 1:CREATIVE, 2:ADVENTURE
|
||||
*/
|
||||
public void setMode(int type){
|
||||
player.setGameType(WorldSettings.getGameTypeById(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item The item to be checked
|
||||
* @return How many of this item the player has
|
||||
*/
|
||||
public int inventoryItemCount(ScriptItemStack item){
|
||||
int i = 0;
|
||||
for(ItemStack is : player.inventory.mainInventory){
|
||||
if (is != null && is.isItemEqual(item.item))
|
||||
i += is.stackSize;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10d
|
||||
* @return Returns a IItemStack array size 36
|
||||
*/
|
||||
public ScriptItemStack[] getInventory(){
|
||||
ScriptItemStack[] items = new ScriptItemStack[36];
|
||||
for(int i = 0; i < player.inventory.mainInventory.length; i++){
|
||||
ItemStack item = player.inventory.mainInventory[i];
|
||||
if(item != null)
|
||||
items[i] = new ScriptItemStack(item);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item The Item type to be removed
|
||||
* @param amount How many will be removed
|
||||
* @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given
|
||||
*/
|
||||
public boolean removeItem(ScriptItemStack item, int amount){
|
||||
int count = inventoryItemCount(item);
|
||||
if(amount > count)
|
||||
return false;
|
||||
else if(count == amount)
|
||||
removeAllItems(item);
|
||||
else{
|
||||
for(int i = 0; i < player.inventory.mainInventory.length; i++){
|
||||
ItemStack is = player.inventory.mainInventory[i];
|
||||
if (is != null && is.isItemEqual(item.item)){
|
||||
if(amount > is.stackSize){
|
||||
player.inventory.mainInventory[i] = null;
|
||||
amount -= is.stackSize;
|
||||
}
|
||||
else{
|
||||
is.splitStack(amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param id The items name
|
||||
* @param damage The damage value
|
||||
* @param amount How many will be removed
|
||||
* @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given or item doesnt exist
|
||||
*/
|
||||
public boolean removeItem(String id, int damage, int amount){
|
||||
Item item = (Item)Item.itemRegistry.getObject(id);
|
||||
if(item == null)
|
||||
return false;
|
||||
return removeItem(new ScriptItemStack(new ItemStack(item, 1, damage)), amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param item Item to be added
|
||||
* @param amount The amount of the item to be added
|
||||
* @return Returns whether or not it gave the item succesfully
|
||||
*/
|
||||
public boolean giveItem(ScriptItemStack item, int amount){
|
||||
String itemname = Item.itemRegistry.getNameForObject(item.getMCItemStack().getItem());
|
||||
return giveItem(itemname, item.getItemDamage(), amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param id The items name
|
||||
* @param damage The damage value
|
||||
* @param amount The amount of the item to be added
|
||||
* @return Returns whether or not it gave the item succesfully
|
||||
*/
|
||||
public boolean giveItem(String id, int damage, int amount){
|
||||
Item item = (Item)Item.itemRegistry.getObject(id);
|
||||
if(item == null)
|
||||
return false;
|
||||
return player.inventory.addItemStackToInventory(new ItemStack(item, amount, damage));
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as the /spawnpoint command
|
||||
* @param x The x position
|
||||
* @param y The y position
|
||||
* @param z The z position
|
||||
*/
|
||||
public void setSpawnpoint(int x, int y, int z){
|
||||
x = ValueUtil.CorrectInt(x, -30000000, 30000000);
|
||||
z = ValueUtil.CorrectInt(z, -30000000, 30000000);
|
||||
y = ValueUtil.CorrectInt(y, 0, 256);
|
||||
player.setSpawnChunk(new ChunkCoordinates(x, y, z), true);
|
||||
}
|
||||
|
||||
public void resetSpawnpoint(){
|
||||
player.setSpawnChunk(null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item The item to be removed from the players inventory
|
||||
*/
|
||||
public void removeAllItems(ScriptItemStack item){
|
||||
for(int i = 0; i < player.inventory.mainInventory.length; i++){
|
||||
ItemStack is = player.inventory.mainInventory[i];
|
||||
if (is != null && is.isItemEqual(item.item))
|
||||
player.inventory.mainInventory[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param achievement The achievement id. For a complete list see http://minecraft.gamepedia.com/Achievements
|
||||
* @return Returns whether or not the player has this achievement
|
||||
*/
|
||||
public boolean hasAchievement(String achievement){
|
||||
StatBase statbase = StatList.func_151177_a(achievement);
|
||||
if(statbase == null || !(statbase instanceof Achievement)){
|
||||
return false;
|
||||
}
|
||||
return player.func_147099_x().hasAchievementUnlocked((Achievement) statbase);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param permission Bukkit/Cauldron permission
|
||||
* @return Returns whether or not the player has the permission
|
||||
*/
|
||||
public boolean hasBukkitPermission(String permission){
|
||||
return CustomNpcsPermissions.hasPermissionString(player, permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns the exp level
|
||||
*/
|
||||
public int getExpLevel(){
|
||||
return player.experienceLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param level The new exp level you want to set
|
||||
*/
|
||||
public void setExpLevel(int level){
|
||||
player.experienceLevel = level;
|
||||
player.addExperienceLevel(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires pixelmon to be installed
|
||||
* @since 1.7.10d
|
||||
*/
|
||||
public ScriptPixelmonPlayerData getPixelmonData(){
|
||||
if(!PixelmonHelper.Enabled)
|
||||
return null;
|
||||
return new ScriptPixelmonPlayerData(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.scoreboard.IScoreObjectiveCriteria;
|
||||
import net.minecraft.scoreboard.Score;
|
||||
import net.minecraft.scoreboard.ScoreObjective;
|
||||
import net.minecraft.scoreboard.ScorePlayerTeam;
|
||||
import net.minecraft.scoreboard.Scoreboard;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
/**
|
||||
* @author Karel
|
||||
*/
|
||||
public class ScriptScoreboard {
|
||||
private Scoreboard board;
|
||||
|
||||
protected ScriptScoreboard(){
|
||||
board = MinecraftServer.getServer().worldServerForDimension(0).getScoreboard();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns an array with all ScoreboardObjectives
|
||||
*/
|
||||
public ScriptScoreboardObjective[] getObjectives(){
|
||||
List<ScoreObjective> collection = new ArrayList<ScoreObjective>(board.getScoreObjectives());
|
||||
ScriptScoreboardObjective[] objectives = new ScriptScoreboardObjective[collection.size()];
|
||||
for(int i = 0; i < collection.size(); i++){
|
||||
objectives[i] = new ScriptScoreboardObjective(collection.get(i));
|
||||
}
|
||||
return objectives;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Name of the objective
|
||||
* @return Returns the ScoreboardObjective
|
||||
*/
|
||||
public ScriptScoreboardObjective getObjective(String name){
|
||||
ScoreObjective obj = board.getObjective(name);
|
||||
if(obj == null)
|
||||
return null;
|
||||
return new ScriptScoreboardObjective(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param objective Objective to check
|
||||
* @return Returns whether or not the objective exists
|
||||
*/
|
||||
public boolean hasObjective(String objective){
|
||||
return board.getObjective(objective) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param objective Objective to remove
|
||||
*/
|
||||
public void removeObjective(String objective){
|
||||
ScoreObjective obj = board.getObjective(objective);
|
||||
if(obj != null)
|
||||
board.func_96519_k(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @version 1.8
|
||||
* @param objective Scoreboard objective name (1-16 chars)
|
||||
* @param criteria The criteria see http://minecraft.gamepedia.com/Scoreboard#Objectives
|
||||
* @return Returns the created ScoreboardObjective, returns null if it failed to create
|
||||
*/
|
||||
public ScriptScoreboardObjective addObjective(String objective, String criteria){
|
||||
if(hasObjective(objective))
|
||||
return null;
|
||||
|
||||
IScoreObjectiveCriteria icriteria = (IScoreObjectiveCriteria)IScoreObjectiveCriteria.field_96643_a.get(criteria);
|
||||
if(icriteria == null)
|
||||
return null;
|
||||
|
||||
if(objective.length() == 0 || objective.length() > 16)
|
||||
return null;
|
||||
|
||||
ScoreObjective obj = board.addScoreObjective(objective, icriteria);
|
||||
return new ScriptScoreboardObjective(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param player Name of a player or non existing thing
|
||||
* @param objective Scoreboard objective name
|
||||
* @param score Score as integer between -2,147,483,648 and 2,147,483,647
|
||||
* @param datatag Optional tag to specify type, can be left empty
|
||||
*/
|
||||
public void setPlayerScore(String player, String objective, int score, String datatag){
|
||||
ScoreObjective objec = board.getObjective(objective);
|
||||
if(objec == null || objec.getCriteria().isReadOnly() ||
|
||||
score < Integer.MIN_VALUE || score > Integer.MAX_VALUE)
|
||||
return;
|
||||
|
||||
Score sco = board.func_96529_a(player, objec);
|
||||
sco.setScorePoints(score);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param player Name of a player or non existing thing
|
||||
* @param objective Scoreboard objective name
|
||||
* @param datatag Optional tag to specify type, can be left empty
|
||||
* @return Returns score value
|
||||
*/
|
||||
public int getPlayerScore(String player, String objective, String datatag){
|
||||
ScoreObjective objec = board.getObjective(objective);
|
||||
if(objec == null || objec.getCriteria().isReadOnly())
|
||||
return 0;
|
||||
|
||||
return board.func_96529_a(player, objec).getScorePoints();
|
||||
}
|
||||
|
||||
/**
|
||||
* @version 1.8
|
||||
* @param player Name of a player or non existing thing
|
||||
* @param objective Scoreboard objective name
|
||||
* @param datatag Optional tag to specify type, can be left empty
|
||||
* @return Returns whether or not the player has the objective
|
||||
*/
|
||||
public boolean hasPlayerObjective(String player, String objective, String datatag){
|
||||
ScoreObjective objec = board.getObjective(objective);
|
||||
if(objec == null)
|
||||
return false;
|
||||
|
||||
return board.func_96510_d(player).get(objec) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @version 1.8
|
||||
* @param player Name of a player or non existing thing
|
||||
* @param objective Scoreboard objective name
|
||||
* @param datatag Optional tag to specify type, can be left empty
|
||||
*/
|
||||
public void deletePlayerScore(String player, String objective, String datatag){
|
||||
ScoreObjective objec = board.getObjective(objective);
|
||||
if(objec == null)
|
||||
return;
|
||||
|
||||
if(board.func_96510_d(player).remove(objec) != null)
|
||||
board.func_96516_a(player);
|
||||
}
|
||||
|
||||
public ScriptScoreboardTeam[] getTeams(){
|
||||
List<ScorePlayerTeam> list = new ArrayList<ScorePlayerTeam>(board.getTeams());
|
||||
ScriptScoreboardTeam[] teams = new ScriptScoreboardTeam[list.size()];
|
||||
for(int i = 0; i < list.size(); i++){
|
||||
teams[i] = new ScriptScoreboardTeam(list.get(i), board);
|
||||
}
|
||||
return teams;
|
||||
}
|
||||
|
||||
public boolean hasTeam(String name){
|
||||
return board.getPlayersTeam(name) != null;
|
||||
}
|
||||
|
||||
public ScriptScoreboardTeam addTeam(String name){
|
||||
if(hasTeam(name))
|
||||
return null;
|
||||
return new ScriptScoreboardTeam(board.createTeam(name), board);
|
||||
}
|
||||
|
||||
public ScriptScoreboardTeam getTeam(String name){
|
||||
ScorePlayerTeam team = board.getPlayersTeam(name);
|
||||
if(team == null)
|
||||
return null;
|
||||
return new ScriptScoreboardTeam(team, board);
|
||||
}
|
||||
|
||||
public void removeTeam(String name){
|
||||
ScorePlayerTeam team = board.getPlayersTeam(name);
|
||||
if(team != null)
|
||||
board.removeTeam(team);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import net.minecraft.scoreboard.ScoreObjective;
|
||||
|
||||
public class ScriptScoreboardObjective {
|
||||
private ScoreObjective objective;
|
||||
|
||||
protected ScriptScoreboardObjective(ScoreObjective objective){
|
||||
this.objective = objective;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns objective name
|
||||
*/
|
||||
public String getName(){
|
||||
return objective.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns display name
|
||||
*/
|
||||
public String getDisplayName(){
|
||||
return objective.getDisplayName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param name Name used for display (1-32 chars)
|
||||
*/
|
||||
public void setDisplayName(String name){
|
||||
if(name.length() > 0 && name.length() <= 32)
|
||||
objective.setDisplayName(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns the criteria string
|
||||
*/
|
||||
public String getCriteria(){
|
||||
return objective.getCriteria().func_96636_a();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return whether or not the objective value can be changed. E.g. player health can't be changed
|
||||
*/
|
||||
public boolean isReadyOnly(){
|
||||
return objective.getCriteria().isReadOnly();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.scoreboard.ScorePlayerTeam;
|
||||
import net.minecraft.scoreboard.Scoreboard;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
public class ScriptScoreboardTeam {
|
||||
private ScorePlayerTeam team;
|
||||
private Scoreboard board;
|
||||
protected ScriptScoreboardTeam(ScorePlayerTeam team, Scoreboard board){
|
||||
this.team = team;
|
||||
this.board = board;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return team.getRegisteredName();
|
||||
}
|
||||
|
||||
public String getDisplayName(){
|
||||
return team.func_96669_c();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Name used as display (1-32 chars)
|
||||
*/
|
||||
public void setDisplayName(String name){
|
||||
if(name.length() > 0 && name.length() <= 32)
|
||||
team.setTeamName(name);
|
||||
}
|
||||
|
||||
public void addPlayer(String player){
|
||||
board.func_151392_a(player, getName());
|
||||
}
|
||||
|
||||
public void removePlayer(String player){
|
||||
board.removePlayerFromTeam(player, team);
|
||||
}
|
||||
|
||||
public String[] getPlayers(){
|
||||
List<String> list = new ArrayList<String>(team.getMembershipCollection());
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
public void clearPlayers(){
|
||||
List<String> list = new ArrayList<String>(team.getMembershipCollection());
|
||||
for(String player : list){
|
||||
board.removePlayerFromTeam(player, team);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getFriendlyFire(){
|
||||
return team.getAllowFriendlyFire();
|
||||
}
|
||||
|
||||
public void setFriendlyFire(boolean bo){
|
||||
team.setAllowFriendlyFire(bo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color Valid color values are "black", "dark_blue", "dark_green", "dark_aqua", "dark_red", "dark_purple", "gold", "gray", "dark_gray", "blue", "green", "aqua", "red", "light_purple", "yellow", and "white". Or "reset" if you want default
|
||||
*/
|
||||
public void setColor(String color){
|
||||
EnumChatFormatting enumchatformatting = EnumChatFormatting.getValueByName(color);
|
||||
|
||||
if (enumchatformatting == null || enumchatformatting.isFancyStyling())
|
||||
return;
|
||||
|
||||
team.setNamePrefix(enumchatformatting.toString());
|
||||
team.setNameSuffix(EnumChatFormatting.RESET.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns color string. Returns null if no color was set
|
||||
*/
|
||||
public String getColor(){
|
||||
String prefix = team.getColorPrefix();
|
||||
if(prefix == null || prefix.isEmpty())
|
||||
return null;
|
||||
for(EnumChatFormatting format : EnumChatFormatting.values()){
|
||||
if(prefix.equals(format.toString()) && format != EnumChatFormatting.RESET)
|
||||
return format.getFriendlyName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setSeeInvisibleTeamPlayers(boolean bo){
|
||||
team.setSeeFriendlyInvisiblesEnabled(bo);
|
||||
}
|
||||
|
||||
public boolean getSeeInvisibleTeamPlayers(){
|
||||
return team.func_98297_h();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTBase.NBTPrimitive;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntitySign;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.blocks.tiles.TileBigSign;
|
||||
import noppes.npcs.blocks.tiles.TileSign;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
|
||||
public class ScriptWorld{
|
||||
private static Map<String,Object> tempData = new HashMap<String,Object>();
|
||||
protected WorldServer world;
|
||||
public ScriptWorld(WorldServer world){
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The worlds time
|
||||
*/
|
||||
public long getTime(){
|
||||
return world.getWorldTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The total world time
|
||||
*/
|
||||
public long getTotalTime(){
|
||||
return world.getTotalWorldTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x World position x
|
||||
* @param y World position y
|
||||
* @param z World position z
|
||||
* @return The block at the given position. Returns null if there isn't a block
|
||||
*/
|
||||
public ScriptItemStack getBlock(int x, int y, int z){
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if(block == null || block.isAir(world, x, y, z))
|
||||
return null;
|
||||
return new ScriptItemStack(new ItemStack(block, 1, world.getBlockMetadata(x, y, z)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x World position x
|
||||
* @param y World position y
|
||||
* @param z World position z
|
||||
* @return Text from signs
|
||||
* @since 1.7.10d
|
||||
*/
|
||||
public String getSignText(int x, int y, int z){
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile instanceof TileBigSign)
|
||||
return ((TileBigSign)tile).getText();
|
||||
|
||||
if(tile instanceof TileEntitySign){
|
||||
TileEntitySign tileSign = (TileEntitySign)tile;
|
||||
String s = tileSign.signText[0] + "\n";
|
||||
s += tileSign.signText[1] + "\n";
|
||||
s += tileSign.signText[2] + "\n";
|
||||
s += tileSign.signText[3];
|
||||
return s;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x World position x
|
||||
* @param y World position y
|
||||
* @param z World position z
|
||||
* @param item The block to be set
|
||||
*/
|
||||
public void setBlock(int x, int y, int z, ScriptItemStack item){
|
||||
if(item == null){
|
||||
removeBlock(x, y, z);
|
||||
return;
|
||||
}
|
||||
Block block = Block.getBlockFromItem(item.item.getItem());
|
||||
if(block == null || block == Blocks.air)
|
||||
return;
|
||||
world.setBlock(x, y, z, block);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x World position x
|
||||
* @param y World position y
|
||||
* @param z World position z
|
||||
*/
|
||||
public void removeBlock(int x, int y, int z){
|
||||
world.setBlock(x, y, z, Blocks.air);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name The name of the player to be returned
|
||||
* @return The Player with name. Null is returned when the player isnt found
|
||||
*/
|
||||
public ScriptPlayer getPlayer(String name){
|
||||
EntityPlayer player = world.getPlayerEntityByName(name);
|
||||
if(player == null)
|
||||
return null;
|
||||
return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param time The world time to be set
|
||||
*/
|
||||
public void setTime(long time){
|
||||
world.setWorldTime(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether or not its daytime
|
||||
*/
|
||||
public boolean isDay(){
|
||||
return world.getWorldTime() % 24000 < 12000;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether or not its currently raining
|
||||
*/
|
||||
public boolean isRaining(){
|
||||
return world.getWorldInfo().isRaining();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bo Set if it's raining
|
||||
*/
|
||||
public void setRaining(boolean bo){
|
||||
world.getWorldInfo().setRaining(bo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x The x position
|
||||
* @param y The y position
|
||||
* @param z The z position
|
||||
*/
|
||||
public void thunderStrike(double x, double y, double z){
|
||||
world.addWeatherEffect(new EntityLightningBolt(world, x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a packet from the server to the client everytime its called. Probably should not use this too much.
|
||||
* @param particle Particle name. Particle name list: http://minecraft.gamepedia.com/Particles
|
||||
* @param x The x position
|
||||
* @param y The y position
|
||||
* @param z The z position
|
||||
* @param dx Usually used for the x motion
|
||||
* @param dy Usually used for the y motion
|
||||
* @param dz Usually used for the z motion
|
||||
* @param speed Speed of the particles, usually between 0 and 1
|
||||
* @param count Particle count
|
||||
*/
|
||||
public void spawnParticle(String particle, double x, double y, double z, double dx, double dy, double dz, double speed, int count){
|
||||
world.func_147487_a(particle, x, y, z, count, dx, dy, dz, speed);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id The items name
|
||||
* @param damage The damage value
|
||||
* @param size The number of items in the item
|
||||
* @return Returns the item
|
||||
*/
|
||||
public ScriptItemStack createItem(String id, int damage, int size){
|
||||
Item item = (Item)Item.itemRegistry.getObject(id);
|
||||
if(item == null)
|
||||
return null;
|
||||
return new ScriptItemStack(new ItemStack(item, size, damage));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key Get temp data for this key
|
||||
* @return Returns the stored temp data
|
||||
*/
|
||||
public Object getTempData(String key){
|
||||
return tempData.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tempdata gets cleared when the server restarts. All worlds share the same temp data.
|
||||
* @param key The key for the data stored
|
||||
* @param value The data stored
|
||||
*/
|
||||
public void setTempData(String key, Object value){
|
||||
tempData.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key thats going to be tested against the temp data
|
||||
* @return Whether or not temp data containes the key
|
||||
*/
|
||||
public boolean hasTempData(String key){
|
||||
return tempData.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key for the temp data to be removed
|
||||
*/
|
||||
public void removeTempData(String key){
|
||||
tempData.remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all tempdata
|
||||
*/
|
||||
public void clearTempData(){
|
||||
tempData.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key of the data to be returned
|
||||
* @return Returns the stored data
|
||||
*/
|
||||
public Object getStoredData(String key){
|
||||
NBTTagCompound compound = ScriptController.Instance.compound;
|
||||
if(!compound.hasKey(key))
|
||||
return null;
|
||||
NBTBase base = compound.getTag(key);
|
||||
if(base instanceof NBTPrimitive)
|
||||
return ((NBTPrimitive)base).func_150286_g();
|
||||
return ((NBTTagString)base).func_150285_a_();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stored data persists through world restart. Unlike tempdata only Strings and Numbers can be saved
|
||||
* @param key The key for the data stored
|
||||
* @param value The data stored. This data can be either a Number or a String. Other data is not stored
|
||||
*/
|
||||
public void setStoredData(String key, Object value){
|
||||
NBTTagCompound compound = ScriptController.Instance.compound;
|
||||
if(value instanceof Number)
|
||||
compound.setDouble(key, ((Number) value).doubleValue());
|
||||
else if(value instanceof String)
|
||||
compound.setString(key, (String)value);
|
||||
ScriptController.Instance.shouldSave = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key of the data to be checked
|
||||
* @return Returns whether or not the stored data contains the key
|
||||
*/
|
||||
public boolean hasStoredData(String key){
|
||||
return ScriptController.Instance.compound.hasKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key of the data to be removed
|
||||
*/
|
||||
public void removeStoredData(String key){
|
||||
ScriptController.Instance.compound.removeTag(key);
|
||||
ScriptController.Instance.shouldSave = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all stored data
|
||||
*/
|
||||
public void clearStoredData(){
|
||||
ScriptController.Instance.compound = new NBTTagCompound();
|
||||
ScriptController.Instance.shouldSave = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x Position x
|
||||
* @param y Position y
|
||||
* @param z Position z
|
||||
* @param range Range of the explosion
|
||||
* @param fire Whether or not the explosion does fire damage
|
||||
* @param grief Whether or not the explosion does damage to blocks
|
||||
*/
|
||||
public void explode(double x, double y, double z, float range, boolean fire, boolean grief){
|
||||
world.newExplosion(null, x, y, z, range, fire, grief);
|
||||
}
|
||||
|
||||
public ScriptPlayer[] getAllServerPlayers(){
|
||||
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
ScriptPlayer[] arr = new ScriptPlayer[list.size()];
|
||||
for(int i = 0; i < list.size(); i++){
|
||||
arr[i] = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(list.get(i));
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param x Position x
|
||||
* @param z Position z
|
||||
* @return Returns the name of the biome
|
||||
*/
|
||||
public String getBiomeName(int x, int z){
|
||||
return world.getBiomeGenForCoords(x, z).biomeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets you spawn a server side cloned entity
|
||||
* @param x The x position the clone will be spawned at
|
||||
* @param y The y position the clone will be spawned at
|
||||
* @param z The z position the clone will be spawned at
|
||||
* @param tab The tab in which the clone is
|
||||
* @param name Name of the cloned entity
|
||||
* @return Returns the entity which was spawned
|
||||
*/
|
||||
public ScriptEntity spawnClone(int x, int y, int z, int tab, String name){
|
||||
NBTTagCompound compound = ServerCloneController.Instance.getCloneData(null, name, tab);
|
||||
if(compound == null)
|
||||
return null;
|
||||
Entity entity = NoppesUtilServer.spawnClone(compound, x, y, z, world);
|
||||
if(entity == null)
|
||||
return null;
|
||||
return ScriptController.Instance.getScriptForEntity(entity);
|
||||
}
|
||||
|
||||
public ScriptScoreboard getScoreboard(){
|
||||
return new ScriptScoreboard();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* Expert use only
|
||||
* @return Returns minecraft world object
|
||||
*/
|
||||
public World getMCWorld(){
|
||||
return world;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package noppes.npcs.scripted.constants;
|
||||
|
||||
public class AnimationType {
|
||||
public static final int NORMAL = 0;
|
||||
public static final int SITTING = 1;
|
||||
public static final int LYING = 2;
|
||||
public static final int HUGGING = 3;
|
||||
public static final int SNEAKING = 4;
|
||||
public static final int DANCING = 5;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package noppes.npcs.scripted.constants;
|
||||
|
||||
public class EntityType {
|
||||
public static final int UNKNOWN = 0;
|
||||
public static final int PLAYER = 1;
|
||||
public static final int NPC = 2;
|
||||
public static final int MONSTER = 3;
|
||||
public static final int ANIMAL = 4;
|
||||
public static final int LIVING = 5;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package noppes.npcs.scripted.constants;
|
||||
|
||||
public class JobType {
|
||||
public static final int UNKNOWN = 0;
|
||||
public static final int BARD = 1;
|
||||
public static final int HEALER = 2;
|
||||
public static final int GUARD = 3;
|
||||
public static final int FOLLOWER = 4;
|
||||
public static final int ITEMGIVER = 5;
|
||||
public static final int SPAWNER = 6;
|
||||
public static final int CONVERSATION = 7;
|
||||
public static final int PUPPET = 8;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package noppes.npcs.scripted.constants;
|
||||
|
||||
public class RoleType {
|
||||
public static final int UNKNOWN = 0;
|
||||
public static final int MAILMAN = 1;
|
||||
public static final int TRADER = 2;
|
||||
public static final int FOLLOWER = 3;
|
||||
public static final int BANK = 4;
|
||||
public static final int TRANSPORTER = 5;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobBard;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
|
||||
public class ScriptJobBard extends ScriptJobInterface{
|
||||
private JobBard job;
|
||||
public ScriptJobBard(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
this.job = (JobBard) npc.jobInterface;
|
||||
}
|
||||
@Override
|
||||
public int getType(){
|
||||
return JobType.BARD;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The song the bard is playing
|
||||
*/
|
||||
public String getSong(){
|
||||
return job.song;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param song The song you want the bard to play
|
||||
*/
|
||||
public void setSong(String song){
|
||||
job.song = song;
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobConversation;
|
||||
import noppes.npcs.roles.JobGuard;
|
||||
import noppes.npcs.roles.JobItemGiver;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.ScriptPlayer;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
|
||||
public class ScriptJobConversation extends ScriptJobInterface{
|
||||
private JobConversation job;
|
||||
public ScriptJobConversation(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
this.job = (JobConversation) npc.jobInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return JobType.SPAWNER;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobFollower;
|
||||
import noppes.npcs.roles.JobGuard;
|
||||
import noppes.npcs.scripted.ScriptNpc;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
|
||||
public class ScriptJobFollower extends ScriptJobInterface{
|
||||
private JobFollower job;
|
||||
public ScriptJobFollower(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
this.job = (JobFollower) npc.jobInterface;
|
||||
}
|
||||
|
||||
public String getFollowingName(){
|
||||
return job.name;
|
||||
}
|
||||
|
||||
public void setFollowingName(String name){
|
||||
job.name = name;
|
||||
}
|
||||
|
||||
public ScriptNpc getFollowingNpc(){
|
||||
if(!isFollowing())
|
||||
return null;
|
||||
return job.following.script.dummyNpc;
|
||||
}
|
||||
|
||||
public boolean isFollowing(){
|
||||
return job.isFollowing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return JobType.FOLLOWER;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobGuard;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
|
||||
public class ScriptJobGuard extends ScriptJobInterface{
|
||||
private JobGuard job;
|
||||
public ScriptJobGuard(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
this.job = (JobGuard) npc.jobInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return JobType.GUARD;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobGuard;
|
||||
import noppes.npcs.roles.JobHealer;
|
||||
import noppes.npcs.scripted.ScriptLivingBase;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
|
||||
public class ScriptJobHealer extends ScriptJobInterface{
|
||||
private JobHealer job;
|
||||
public ScriptJobHealer(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
this.job = (JobHealer) npc.jobInterface;
|
||||
}
|
||||
|
||||
public void heal(ScriptLivingBase entity, float amount){
|
||||
job.heal(entity.getMinecraftEntity(), amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return JobType.HEALER;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
|
||||
public class ScriptJobInterface {
|
||||
protected EntityNPCInterface npc;
|
||||
|
||||
public ScriptJobInterface(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
}
|
||||
/**
|
||||
* @see noppes.npcs.scripted.constants.JobType
|
||||
* @return Returns the JobType
|
||||
*/
|
||||
public int getType(){
|
||||
return JobType.UNKNOWN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobGuard;
|
||||
import noppes.npcs.roles.JobItemGiver;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.ScriptPlayer;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
|
||||
public class ScriptJobItemGiver extends ScriptJobInterface{
|
||||
private JobItemGiver job;
|
||||
public ScriptJobItemGiver(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
this.job = (JobItemGiver) npc.jobInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return JobType.ITEMGIVER;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobGuard;
|
||||
import noppes.npcs.roles.JobHealer;
|
||||
import noppes.npcs.roles.JobPuppet;
|
||||
import noppes.npcs.scripted.ScriptLivingBase;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
|
||||
public class ScriptJobPuppet extends ScriptJobInterface{
|
||||
private JobPuppet job;
|
||||
public ScriptJobPuppet(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
this.job = (JobPuppet) npc.jobInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
|
||||
* @return Returns X rotation in degrees (0-360)
|
||||
*/
|
||||
public int getRotationX(int part){
|
||||
if(part == 0)
|
||||
return floatToInt(job.head.rotationX);
|
||||
if(part == 1)
|
||||
return floatToInt(job.body.rotationX);
|
||||
if(part == 2)
|
||||
return floatToInt(job.larm.rotationX);
|
||||
if(part == 3)
|
||||
return floatToInt(job.rarm.rotationX);
|
||||
if(part == 4)
|
||||
return floatToInt(job.lleg.rotationX);
|
||||
if(part == 5)
|
||||
return floatToInt(job.rleg.rotationX);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
|
||||
* @return Returns Y rotation in degrees (0-360)
|
||||
*/
|
||||
public int getRotationY(int part){
|
||||
if(part == 0)
|
||||
return floatToInt(job.head.rotationY);
|
||||
if(part == 1)
|
||||
return floatToInt(job.body.rotationY);
|
||||
if(part == 2)
|
||||
return floatToInt(job.larm.rotationY);
|
||||
if(part == 3)
|
||||
return floatToInt(job.rarm.rotationY);
|
||||
if(part == 4)
|
||||
return floatToInt(job.lleg.rotationY);
|
||||
if(part == 5)
|
||||
return floatToInt(job.rleg.rotationY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
|
||||
* @return Returns Z rotation in degrees (0-360)
|
||||
*/
|
||||
public int getRotationZ(int part){
|
||||
if(part == 0)
|
||||
return floatToInt(job.head.rotationZ);
|
||||
if(part == 1)
|
||||
return floatToInt(job.body.rotationZ);
|
||||
if(part == 2)
|
||||
return floatToInt(job.larm.rotationZ);
|
||||
if(part == 3)
|
||||
return floatToInt(job.rarm.rotationZ);
|
||||
if(part == 4)
|
||||
return floatToInt(job.lleg.rotationZ);
|
||||
if(part == 5)
|
||||
return floatToInt(job.rleg.rotationZ);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
|
||||
* @param rotation Rotation the of the body part
|
||||
*/
|
||||
public void setRotationX(int part, int rotation){
|
||||
float f = rotation / 360f - 0.5f;
|
||||
if(getRotationX(part) != f)
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
|
||||
if(part == 0)
|
||||
job.head.rotationX = f;
|
||||
if(part == 1)
|
||||
job.body.rotationX = f;
|
||||
if(part == 2)
|
||||
job.larm.rotationX = f;
|
||||
if(part == 3)
|
||||
job.rarm.rotationX = f;
|
||||
if(part == 4)
|
||||
job.lleg.rotationX = f;
|
||||
if(part == 5)
|
||||
job.rleg.rotationX = f;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param type Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
|
||||
* @param rotation Rotation the of the body part
|
||||
*/
|
||||
public void setRotationY(int part, int rotation){
|
||||
float f = rotation / 360f - 0.5f;
|
||||
if(getRotationY(part) != f)
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
|
||||
if(part == 0)
|
||||
job.head.rotationY = f;
|
||||
if(part == 1)
|
||||
job.body.rotationY = f;
|
||||
if(part == 2)
|
||||
job.larm.rotationY = f;
|
||||
if(part == 3)
|
||||
job.rarm.rotationY = f;
|
||||
if(part == 4)
|
||||
job.lleg.rotationY = f;
|
||||
if(part == 5)
|
||||
job.rleg.rotationY = f;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
|
||||
* @param rotation Rotation the of the body part
|
||||
*/
|
||||
public void setRotationZ(int part, int rotation){
|
||||
float f = rotation / 360f - 0.5f;
|
||||
if(getRotationZ(part) != f)
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
|
||||
if(part == 0)
|
||||
job.head.rotationZ = f;
|
||||
if(part == 1)
|
||||
job.body.rotationZ = f;
|
||||
if(part == 2)
|
||||
job.larm.rotationZ = f;
|
||||
if(part == 3)
|
||||
job.rarm.rotationZ = f;
|
||||
if(part == 4)
|
||||
job.lleg.rotationZ = f;
|
||||
if(part == 5)
|
||||
job.rleg.rotationZ = f;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
|
||||
* @return Returns whether or not the body part is enabled
|
||||
*/
|
||||
public boolean isEnabled(int part){
|
||||
if(part == 0)
|
||||
return !job.head.disabled;
|
||||
if(part == 1)
|
||||
return !job.body.disabled;
|
||||
if(part == 2)
|
||||
return !job.larm.disabled;
|
||||
if(part == 3)
|
||||
return !job.rarm.disabled;
|
||||
if(part == 4)
|
||||
return !job.lleg.disabled;
|
||||
if(part == 5)
|
||||
return !job.rleg.disabled;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param part Body part (0:head, 1:body, 2:leftarm, 3:rightarm, 4:leftleg, 5:rightleg)
|
||||
* @param bo Whether or not the body part is enabled
|
||||
*/
|
||||
public void setEnabled(int part, boolean bo){
|
||||
if(isEnabled(part) != bo)
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
|
||||
if(part == 0)
|
||||
job.head.disabled = !bo;
|
||||
if(part == 1)
|
||||
job.body.disabled = !bo;
|
||||
if(part == 2)
|
||||
job.larm.disabled = !bo;
|
||||
if(part == 3)
|
||||
job.rarm.disabled = !bo;
|
||||
if(part == 4)
|
||||
job.lleg.disabled = !bo;
|
||||
if(part == 5)
|
||||
job.rleg.disabled = !bo;
|
||||
}
|
||||
|
||||
private int floatToInt(float f){
|
||||
return (int)((f + 0.5) * 360);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return JobType.PUPPET;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.JobGuard;
|
||||
import noppes.npcs.roles.JobItemGiver;
|
||||
import noppes.npcs.roles.JobSpawner;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.ScriptLivingBase;
|
||||
import noppes.npcs.scripted.ScriptPlayer;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
|
||||
public class ScriptJobSpawner extends ScriptJobInterface{
|
||||
private JobSpawner job;
|
||||
public ScriptJobSpawner(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
this.job = (JobSpawner) npc.jobInterface;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return JobType.SPAWNER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Npc needs to be attacking something or be set to Despawn Spawns On Target Lost: No, otherwise it will despawn right away
|
||||
* @param number The entity going to be spawned (1-6)
|
||||
* @return Returns spawned entity
|
||||
*/
|
||||
public ScriptLivingBase spawnEntity(int number){
|
||||
EntityLivingBase base = job.spawnEntity(number);
|
||||
if(base == null)
|
||||
return null;
|
||||
|
||||
return (ScriptLivingBase) ScriptController.Instance.getScriptForEntity(base);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all spawned entities
|
||||
*/
|
||||
public void removeAllSpawned(){
|
||||
for(EntityLivingBase entity : job.spawned){
|
||||
entity.isDead = true;
|
||||
}
|
||||
job.spawned = new ArrayList<EntityLivingBase>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
|
||||
public class ScriptRoleBank extends ScriptRoleInterface{
|
||||
|
||||
public ScriptRoleBank(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return RoleType.BANK;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleFollower;
|
||||
import noppes.npcs.scripted.ScriptPlayer;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
|
||||
public class ScriptRoleFollower extends ScriptRoleInterface{
|
||||
private RoleFollower role;
|
||||
public ScriptRoleFollower(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
role = (RoleFollower) npc.roleInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param player Player who is set as the owner. If null given everything resets
|
||||
*/
|
||||
public void setOwner(ScriptPlayer player){
|
||||
if(player == null || player.getMinecraftEntity() == null){
|
||||
role.setOwner(null);
|
||||
return;
|
||||
}
|
||||
EntityPlayer mcplayer = (EntityPlayer) player.getMinecraftEntity();
|
||||
role.setOwner(mcplayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns the followers owner. Returns null if he has no owner or the owner is offline
|
||||
*/
|
||||
public ScriptPlayer getOwner(){
|
||||
if(role.owner == null)
|
||||
return null;
|
||||
|
||||
return (ScriptPlayer) ScriptController.Instance.getScriptForEntity(role.owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns whether or not the follower has an owner
|
||||
*/
|
||||
public boolean hasOwner(){
|
||||
return role.owner != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns days left
|
||||
*/
|
||||
public int getDaysLeft(){
|
||||
return role.getDaysLeft();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param days The days you want to add to the days remaining
|
||||
*/
|
||||
public void addDaysLeft(int days){
|
||||
role.addDays(days);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns whether or not the follower is set to infinite days
|
||||
*/
|
||||
public boolean getInfiniteDays(){
|
||||
return role.infiniteDays;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param infinite Sets whether the days hired are infinite
|
||||
*/
|
||||
public void setInfiniteDays(boolean infinite){
|
||||
role.infiniteDays = infinite;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Return whether the gui is disabled
|
||||
*/
|
||||
public boolean getGuiDisabled(){
|
||||
return role.disableGui;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param disabled Set the gui to be disabled or not
|
||||
*/
|
||||
public void setGuiDisabled(boolean disabled){
|
||||
role.disableGui = disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return RoleType.FOLLOWER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
|
||||
public class ScriptRoleInterface {
|
||||
protected EntityNPCInterface npc;
|
||||
|
||||
public ScriptRoleInterface(EntityNPCInterface npc){
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see noppes.npcs.scripted.constants.RoleType
|
||||
* @return The RoleType of this role
|
||||
*/
|
||||
public int getType(){
|
||||
return RoleType.UNKNOWN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
|
||||
public class ScriptRoleMailman extends ScriptRoleInterface{
|
||||
|
||||
public ScriptRoleMailman(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return RoleType.MAILMAN;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleTrader;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
import foxz.utils.Market;
|
||||
|
||||
public class ScriptRoleTrader extends ScriptRoleInterface{
|
||||
private RoleTrader role;
|
||||
public ScriptRoleTrader(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
role = (RoleTrader) npc.roleInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot Slot number 0-17
|
||||
* @param currency Currency item
|
||||
* @param currency2 Currency item number two
|
||||
* @param sold Item to be sold by this npc
|
||||
*/
|
||||
public void setSellOption(int slot, ScriptItemStack currency, ScriptItemStack currency2, ScriptItemStack sold){
|
||||
if(sold == null || slot >= 18 || slot < 0)
|
||||
return;
|
||||
if(currency == null)
|
||||
currency = currency2;
|
||||
|
||||
if(currency != null)
|
||||
role.inventoryCurrency.items.put(slot, currency.getMCItemStack());
|
||||
else
|
||||
role.inventoryCurrency.items.remove(slot);
|
||||
if(currency2 != null)
|
||||
role.inventoryCurrency.items.put(slot + 18, currency2.getMCItemStack());
|
||||
else
|
||||
role.inventoryCurrency.items.remove(slot + 18);
|
||||
|
||||
role.inventorySold.items.put(slot, sold.getMCItemStack());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot Slot number 0-17
|
||||
* @param currency Currency item
|
||||
* @param sold Item to be sold by this npc
|
||||
*/
|
||||
public void setSellOption(int slot, ScriptItemStack currency, ScriptItemStack sold){
|
||||
setSellOption(slot, currency, null, sold);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot Slot number 0-17
|
||||
*/
|
||||
public void removeSellOption(int slot){
|
||||
if(slot >= 18 || slot < 0)
|
||||
return;
|
||||
role.inventoryCurrency.items.remove(slot);
|
||||
role.inventoryCurrency.items.remove(slot + 18);
|
||||
role.inventorySold.items.remove(slot);
|
||||
}
|
||||
/**
|
||||
* @param name The trader Linked Market name
|
||||
*/
|
||||
public void setMarket(String name){
|
||||
role.marketName = name;
|
||||
Market.load(role, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Get the currently set Linked Market name
|
||||
*/
|
||||
public String getMarket(){
|
||||
return role.marketName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return RoleType.TRADER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
|
||||
public class ScriptRoleTransporter extends ScriptRoleInterface{
|
||||
|
||||
public ScriptRoleTransporter(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return RoleType.TRANSPORTER;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user