Proper Reformating

This commit is contained in:
Kam committed 2025-03-13 17:14:45 -04:00
1 parent ce75880aba
commit 180d257024
1179 files changed
+59847 -61583

No files matched your search

@@ -19,34 +19,34 @@ import noppes.npcs.blocks.tiles.TileScripted;
import java.util.Set;
public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{
public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted {
private TileScripted tile;
public BlockScriptedWrapper(World world, Block block, int x, int y, int z) {
super(world, block, new BlockPos(x,y,z));
super(world, block, new BlockPos(x, y, z));
tile = (TileScripted) super.tile.getMCTileEntity();
}
@Override
public void setModel(IItemStack item){
if(item == null)
public void setModel(IItemStack item) {
if (item == null)
tile.setItemModel(null, null);
else
tile.setItemModel(item.getMCItemStack(), Block.getBlockFromItem(item.getMCItemStack().getItem()));
}
@Override
public void setModel(String name){
if(name == null)
public void setModel(String name) {
if (name == null)
tile.setItemModel(null, null);
else{
else {
Block block = Block.getBlockFromName(name);
if(block!=null) {
if (block != null) {
tile.setItemModel(new ItemStack(Item.getItemFromBlock(block)), block);
}else{
if(Item.itemRegistry.containsKey(name)) {
} else {
if (Item.itemRegistry.containsKey(name)) {
tile.setItemModel(new ItemStack((Item) Item.itemRegistry.getObject(name)), null);
}else{
} else {
tile.setItemModel(null, null);
}
}
@@ -54,103 +54,103 @@ public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{
}
@Override
public IItemStack getModel(){
public IItemStack getModel() {
return NpcAPI.Instance().getIItemStack(tile.itemModel);
}
@Override
public void setRedstonePower(int strength){
public void setRedstonePower(int strength) {
tile.setRedstonePower(strength);
}
@Override
public int getRedstonePower(){
public int getRedstonePower() {
return tile.powering;
}
@Override
public void setIsLadder(boolean bo){
public void setIsLadder(boolean bo) {
tile.isLadder = bo;
tile.needsClientUpdate = true;
}
@Override
public boolean getIsLadder(){
public boolean getIsLadder() {
return tile.isLadder;
}
@Override
public void setIsPassible(boolean bo){
public void setIsPassible(boolean bo) {
setIsPassable(bo);
}
@Override
public boolean getIsPassible(){
public boolean getIsPassible() {
return getIsPassable();
}
@Override
public void setIsPassable(boolean bo){
public void setIsPassable(boolean bo) {
tile.isPassible = bo;
tile.needsClientUpdate = true;
}
@Override
public boolean getIsPassable(){
if(tile == null)
public boolean getIsPassable() {
if (tile == null)
return false;
return tile.isPassible;
}
@Override
public void setLight(int value){
public void setLight(int value) {
tile.setLightValue(value);
}
@Override
public int getLight(){
if(tile == null)
public int getLight() {
if (tile == null)
return 0;
return tile.lightValue;
}
@Override
public void setScale(float x, float y, float z){
public void setScale(float x, float y, float z) {
tile.setScale(x, y, z);
}
@Override
public float getScaleX(){
public float getScaleX() {
return tile.scaleX;
}
@Override
public float getScaleY(){
public float getScaleY() {
return tile.scaleY;
}
@Override
public float getScaleZ(){
public float getScaleZ() {
return tile.scaleZ;
}
@Override
public void setRotation(int x, int y, int z){
tile.setRotation(x % 360, y % 360, z % 360);
public void setRotation(int x, int y, int z) {
tile.setRotation(x % 360, y % 360, z % 360);
}
@Override
public int getRotationX(){
public int getRotationX() {
return tile.rotationX;
}
@Override
public int getRotationY(){
public int getRotationY() {
return tile.rotationY;
}
@Override
public int getRotationZ(){
public int getRotationZ() {
return tile.rotationZ;
}
@@ -175,8 +175,8 @@ public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{
}
@Override
public void executeCommand(String command){
if(!MinecraftServer.getServer().isCommandBlockEnabled())
public void executeCommand(String command) {
if (!MinecraftServer.getServer().isCommandBlockEnabled())
throw new CustomNPCsException("Command blocks need to be enabled to executeCommands");
NoppesUtilServer.runCommand(world.getMCWorld(), "ScriptedBlock", command);
}
@@ -217,16 +217,16 @@ public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{
}
@Override
public void setTileEntity(ITileEntity tile){
public void setTileEntity(ITileEntity tile) {
this.tile = (TileScripted) tile;
super.setTileEntity(tile);
}
private NBTTagCompound getNBT(){
if(tile == null)
private NBTTagCompound getNBT() {
if (tile == null)
return null;
NBTTagCompound compound = tile.getTileData().getCompoundTag("CustomNPCsData");
if(compound.hasNoTags() && !tile.getTileData().hasKey("CustomNPCsData")){
if (compound.hasNoTags() && !tile.getTileData().hasKey("CustomNPCsData")) {
tile.getTileData().setTag("CustomNPCsData", compound);
}
return compound;
@@ -235,31 +235,31 @@ public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{
@Override
public void setStoredData(String key, Object value) {
NBTTagCompound compound = getNBT();
if(compound == null)
if (compound == null)
return;
if(value instanceof Number)
if (value instanceof Number)
compound.setDouble(key, ((Number) value).doubleValue());
else if(value instanceof String)
compound.setString(key, (String)value);
else if (value instanceof String)
compound.setString(key, (String) value);
}
@Override
public Object getStoredData(String key) {
NBTTagCompound compound = getNBT();
if(compound == null)
if (compound == null)
return null;
if(!compound.hasKey(key))
if (!compound.hasKey(key))
return null;
NBTBase base = compound.getTag(key);
if(base instanceof NBTBase.NBTPrimitive)
return ((NBTBase.NBTPrimitive)base).func_150286_g();
return ((NBTTagString)base).func_150285_a_();
if (base instanceof NBTBase.NBTPrimitive)
return ((NBTBase.NBTPrimitive) base).func_150286_g();
return ((NBTTagString) base).func_150285_a_();
}
@Override
public void removeStoredData(String key) {
NBTTagCompound compound = getNBT();
if(compound == null)
if (compound == null)
return;
compound.removeTag(key);
}
@@ -267,14 +267,14 @@ public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{
@Override
public boolean hasStoredData(String key) {
NBTTagCompound compound = getNBT();
if(compound == null)
if (compound == null)
return false;
return compound.hasKey(key);
}
@Override
public void clearStoredData() {
if(tile == null)
if (tile == null)
return;
tile.getTileData().setTag("CustomNPCsData", new NBTTagCompound());
}
@@ -282,41 +282,42 @@ public class BlockScriptedWrapper extends ScriptBlock implements IBlockScripted{
@Override
public String[] getStoredDataKeys() {
NBTTagCompound compound = getNBT();
if(compound == null)
if (compound == null)
return new String[0];
return ((Set<String>)compound.func_150296_c()).toArray(new String[0]);
return ((Set<String>) compound.func_150296_c()).toArray(new String[0]);
}
@Override
public void removeTempData(String key) {
if(tile == null)
if (tile == null)
return;
tile.tempData.remove(key);
}
@Override
public void setTempData(String key, Object value) {
if(tile == null)
if (tile == null)
return;
tile.tempData.put(key, value);
}
@Override
public boolean hasTempData(String key) {
if(tile == null)
if (tile == null)
return false;
return tile.tempData.containsKey(key);
}
@Override
public Object getTempData(String key) {
if(tile == null)
if (tile == null)
return null;
return tile.tempData.get(key);
}
@Override
public void clearTempData() {
if(tile == null)
if (tile == null)
return;
tile.tempData.clear();
}
+75 -69
View File
@@ -73,10 +73,10 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class NpcAPI extends AbstractNpcAPI {
private static final Map<String,Object> tempData = new HashMap<>();
private static final Map<String, Object> tempData = new HashMap<>();
private static final Map<Integer, ScriptWorld> worldCache = new LRUHashMap<>(10);
private static final CacheHashMap<ItemStack, CacheHashMap.CachedObject<ScriptItemStack>> scriptItemCache = new CacheHashMap<>(60*1000);
public static final HashMap<String,Object> engineObjects = new HashMap<>();
private static final CacheHashMap<ItemStack, CacheHashMap.CachedObject<ScriptItemStack>> scriptItemCache = new CacheHashMap<>(60 * 1000);
public static final HashMap<String, Object> engineObjects = new HashMap<>();
public static final EventBus EVENT_BUS = new EventBus();
private static AbstractNpcAPI instance = null;
@@ -91,23 +91,23 @@ public class NpcAPI extends AbstractNpcAPI {
scriptItemCache.clear();
}
public Object getTempData(String key){
public Object getTempData(String key) {
return tempData.get(key);
}
public void setTempData(String key, Object value){
public void setTempData(String key, Object value) {
tempData.put(key, value);
}
public boolean hasTempData(String key){
public boolean hasTempData(String key) {
return tempData.containsKey(key);
}
public void removeTempData(String key){
public void removeTempData(String key) {
tempData.remove(key);
}
public void clearTempData(){
public void clearTempData() {
tempData.clear();
}
@@ -115,35 +115,35 @@ public class NpcAPI extends AbstractNpcAPI {
return tempData.keySet().toArray(new String[0]);
}
public Object getStoredData(String key){
public Object getStoredData(String key) {
NBTTagCompound compound = ScriptController.Instance.compound;
if(!compound.hasKey(key))
if (!compound.hasKey(key))
return null;
NBTBase base = compound.getTag(key);
if(base instanceof NBTBase.NBTPrimitive)
return ((NBTBase.NBTPrimitive)base).func_150286_g();
return ((NBTTagString)base).func_150285_a_();
if (base instanceof NBTBase.NBTPrimitive)
return ((NBTBase.NBTPrimitive) base).func_150286_g();
return ((NBTTagString) base).func_150285_a_();
}
public void setStoredData(String key, Object value){
public void setStoredData(String key, Object value) {
NBTTagCompound compound = ScriptController.Instance.compound;
if(value instanceof Number)
if (value instanceof Number)
compound.setDouble(key, ((Number) value).doubleValue());
else if(value instanceof String)
compound.setString(key, (String)value);
else if (value instanceof String)
compound.setString(key, (String) value);
ScriptController.Instance.shouldSave = true;
}
public boolean hasStoredData(String key){
public boolean hasStoredData(String key) {
return ScriptController.Instance.compound.hasKey(key);
}
public void removeStoredData(String key){
public void removeStoredData(String key) {
ScriptController.Instance.compound.removeTag(key);
ScriptController.Instance.shouldSave = true;
}
public void clearStoredData(){
public void clearStoredData() {
ScriptController.Instance.compound = new NBTTagCompound();
ScriptController.Instance.shouldSave = true;
}
@@ -153,7 +153,7 @@ public class NpcAPI extends AbstractNpcAPI {
if (compound != null) {
Set keySet = compound.func_150296_c();
List<String> list = new ArrayList<>();
for(Object o : keySet){
for (Object o : keySet) {
list.add((String) o);
}
String[] array = list.toArray(new String[list.size()]);
@@ -163,15 +163,15 @@ public class NpcAPI extends AbstractNpcAPI {
}
public void registerICommand(ICommand command) {
((CommandHandler)CustomNpcs.getServer().getCommandManager()).registerCommand((ScriptedCommand) command);
((CommandHandler) CustomNpcs.getServer().getCommandManager()).registerCommand((ScriptedCommand) command);
}
public ICommand getICommand(String commandName, int priorityLevel) {
return new ScriptedCommand(commandName,priorityLevel);
return new ScriptedCommand(commandName, priorityLevel);
}
public void addGlobalObject(String key, Object obj) {
NpcAPI.engineObjects.put(key,obj);
NpcAPI.engineObjects.put(key, obj);
}
public void removeGlobalObject(String key) {
@@ -182,7 +182,7 @@ public class NpcAPI extends AbstractNpcAPI {
return NpcAPI.engineObjects.containsKey(key);
}
public HashMap<String,Object> getEngineObjects() {
public HashMap<String, Object> getEngineObjects() {
return NpcAPI.engineObjects;
}
@@ -241,13 +241,21 @@ public class NpcAPI extends AbstractNpcAPI {
return ServerCloneController.Instance;
}
public INaturalSpawnsHandler getNaturalSpawns() { return SpawnController.Instance; }
public INaturalSpawnsHandler getNaturalSpawns() {
return SpawnController.Instance;
}
public IProfileHandler getProfileHandler() { return ProfileController.Instance; }
public IProfileHandler getProfileHandler() {
return ProfileController.Instance;
}
public ICustomEffectHandler getCustomEffectHandler() { return CustomEffectController.Instance; }
public ICustomEffectHandler getCustomEffectHandler() {
return CustomEffectController.Instance;
}
public IPartyHandler getPartyHandler() { return PartyController.Instance(); }
public IPartyHandler getPartyHandler() {
return PartyController.Instance();
}
public ITransportHandler getLocations() {
return TransportController.getInstance();
@@ -272,21 +280,21 @@ public class NpcAPI extends AbstractNpcAPI {
public static Boolean dbcLoaded = null;
public IEntity<?> getIEntity(Entity entity) {
if(entity == null)
if (entity == null)
return null;
if(entity instanceof EntityNPCInterface)
return ((EntityNPCInterface)entity).wrappedNPC;
else{
if (entity instanceof EntityNPCInterface)
return ((EntityNPCInterface) entity).wrappedNPC;
else {
ScriptEntityData data = (ScriptEntityData) entity.getExtendedProperties("ScriptedObject");
if (data == null) {
if (entity instanceof EntityPlayerMP) {
if(dbcLoaded == null){
if (dbcLoaded == null) {
dbcLoaded = Loader.isModLoaded("jinryuujrmcore");
}
data = dbcLoaded ? new ScriptEntityData(new ScriptDBCPlayer<>((EntityPlayerMP) entity)) : new ScriptEntityData(new ScriptPlayer<>((EntityPlayerMP) entity));
}
else if (PixelmonHelper.isPixelmon(entity))
} else if (PixelmonHelper.isPixelmon(entity))
return new ScriptPixelmon<EntityTameable>((EntityTameable) entity);
else if (entity instanceof EntityAnimal)
data = new ScriptEntityData(new ScriptAnimal<>((EntityAnimal) entity));
@@ -336,14 +344,14 @@ public class NpcAPI extends AbstractNpcAPI {
public IBlock getIBlock(IWorld world, int x, int y, int z) {
Block block = world.getMCWorld().getBlock(x, y, z);
if(block == null || block.isAir(world.getMCWorld(), x, y, z))
if (block == null || block.isAir(world.getMCWorld(), x, y, z))
return null;
return new ScriptBlock(world.getMCWorld(), world.getMCWorld().getBlock(x, y, z), new BlockPos(x,y,z));
return new ScriptBlock(world.getMCWorld(), world.getMCWorld().getBlock(x, y, z), new BlockPos(x, y, z));
}
public IBlock getIBlock(IWorld world, IPos pos) {
return pos == null ? null : this.getIBlock(world, pos.getX(),pos.getY(),pos.getZ());
return pos == null ? null : this.getIBlock(world, pos.getX(), pos.getY(), pos.getZ());
}
public ITileEntity getITileEntity(IWorld world, IPos pos) {
@@ -351,12 +359,12 @@ public class NpcAPI extends AbstractNpcAPI {
return null;
}
TileEntity tileEntity = world.getMCWorld().getTileEntity(pos.getX(), pos.getY(),pos.getZ());
TileEntity tileEntity = world.getMCWorld().getTileEntity(pos.getX(), pos.getY(), pos.getZ());
return this.getITileEntity(tileEntity);
}
public ITileEntity getITileEntity(IWorld world, int x, int y, int z) {
TileEntity tileEntity = world.getMCWorld().getTileEntity(x,y,z);
TileEntity tileEntity = world.getMCWorld().getTileEntity(x, y, z);
return this.getITileEntity(tileEntity);
}
@@ -369,7 +377,7 @@ public class NpcAPI extends AbstractNpcAPI {
}
public IPos getIPos(double x, double y, double z) {
return this.getIPos(new BlockPos(x,y,z));
return this.getIPos(new BlockPos(x, y, z));
}
public IPos getIPos(int x, int y, int z) {
@@ -387,7 +395,7 @@ public class NpcAPI extends AbstractNpcAPI {
public IPos[] getAllInBox(IPos from, IPos to, boolean sortByDistance) {
ArrayList<IPos> list = new ArrayList<>();
if (from != null && to != null) {
Iterator<BlockPos> posIterable = BlockPos.getAllInBox(from.getMCPos(),to.getMCPos()).iterator();
Iterator<BlockPos> posIterable = BlockPos.getAllInBox(from.getMCPos(), to.getMCPos()).iterator();
posIterable.forEachRemaining(BlockPos -> list.add(this.getIPos(BlockPos)));
if (sortByDistance) {
list.sort(Comparator.comparingDouble(pos -> pos.distanceTo(from)));
@@ -397,11 +405,11 @@ public class NpcAPI extends AbstractNpcAPI {
}
public IPos[] getAllInBox(IPos from, IPos to) {
return this.getAllInBox(from,to,true);
return this.getAllInBox(from, to, true);
}
public INbt getINbt(NBTTagCompound nbtTagCompound) {
return nbtTagCompound == null?new ScriptNbt(new NBTTagCompound()):new ScriptNbt(nbtTagCompound);
return nbtTagCompound == null ? new ScriptNbt(new NBTTagCompound()) : new ScriptNbt(nbtTagCompound);
}
public INbt stringToNbt(String str) {
@@ -430,7 +438,7 @@ public class NpcAPI extends AbstractNpcAPI {
return null;
} else {
EntityCustomNpc npc = new EntityCustomNpc(world.getMCWorld());
npc.setPositionAndRotation((double)x + 0.5D, y, (double)z + 0.5D, 0.0F, 0.0F);
npc.setPositionAndRotation((double) x + 0.5D, y, (double) z + 0.5D, 0.0F, 0.0F);
npc.setHealth(npc.getMaxHealth());
world.getMCWorld().spawnEntityInWorld(npc);
return npc.wrappedNPC;
@@ -457,7 +465,7 @@ public class NpcAPI extends AbstractNpcAPI {
}
public IItemStack getIItemStack(ItemStack itemstack) {
if(itemstack == null)
if (itemstack == null)
return null;
synchronized (scriptItemCache) {
@@ -521,10 +529,10 @@ public class NpcAPI extends AbstractNpcAPI {
public IWorld getIWorldLoad(int dimensionId) {
try {
IWorld iWorld = this.getIWorld(dimensionId);
if(iWorld != null)
if (iWorld != null)
return iWorld;
} catch (CustomNPCsException ignored) {
}
catch (CustomNPCsException ignored){}
WorldServer worldServer = CustomNpcs.getServer().worldServerForDimension(dimensionId);
if (worldServer != null) {
@@ -539,7 +547,7 @@ public class NpcAPI extends AbstractNpcAPI {
}
public IContainer getIContainer(Container container) {
return container instanceof ContainerNpcInterface ? ContainerNpcInterface.getOrCreateIContainer((ContainerNpcInterface)container) : new ScriptContainer(container);
return container instanceof ContainerNpcInterface ? ContainerNpcInterface.getOrCreateIContainer((ContainerNpcInterface) container) : new ScriptContainer(container);
}
private void checkWorld() {
@@ -552,7 +560,7 @@ public class NpcAPI extends AbstractNpcAPI {
this.checkWorld();
IWorld[] worlds = new IWorld[CustomNpcs.getServer().worldServers.length];
for(int i = 0; i < CustomNpcs.getServer().worldServers.length; ++i) {
for (int i = 0; i < CustomNpcs.getServer().worldServers.length; ++i) {
worlds[i] = this.getIWorld(CustomNpcs.getServer().worldServers[i]);
}
@@ -572,15 +580,15 @@ public class NpcAPI extends AbstractNpcAPI {
}
public IDamageSource getIDamageSource(IEntity<?> entity) {
if(entity.getType() == 1)//if player
return new ScriptDamageSource(new EntityDamageSource("player",entity.getMCEntity()));
if (entity.getType() == 1)//if player
return new ScriptDamageSource(new EntityDamageSource("player", entity.getMCEntity()));
else
return new ScriptDamageSource(new EntityDamageSource(entity.getTypeName(),entity.getMCEntity()));
return new ScriptDamageSource(new EntityDamageSource(entity.getTypeName(), entity.getMCEntity()));
}
public void executeCommand(IWorld world, String command) {
//if(!world.getMCWorld().isRemote)
NoppesUtilServer.runCommand(world.getMCWorld(), "API", command);
NoppesUtilServer.runCommand(world.getMCWorld(), "API", command);
}
public String getRandomName(int dictionary, int gender) {
@@ -596,11 +604,11 @@ public class NpcAPI extends AbstractNpcAPI {
return player == null ? null : (IPlayer<?>) NpcAPI.Instance().getIEntity(player);
}
public IPlayer<?>[] getAllServerPlayers(){
public IPlayer<?>[] getAllServerPlayers() {
List<?> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
IPlayer<?>[] arr = new IPlayer[list.size()];
for(int i = 0; i < list.size(); i++){
arr[i] = (IPlayer<?>) NpcAPI.Instance().getIEntity((EntityPlayerMP)list.get(i));
for (int i = 0; i < list.size(); i++) {
arr[i] = (IPlayer<?>) NpcAPI.Instance().getIEntity((EntityPlayerMP) list.get(i));
}
return arr;
@@ -610,30 +618,28 @@ public class NpcAPI extends AbstractNpcAPI {
return MinecraftServer.getServer().getConfigurationManager().getAllUsernames();
}
public void playSoundAtEntity(IEntity<?> entity, String sound, float volume, float pitch){
public void playSoundAtEntity(IEntity<?> entity, String sound, float volume, float pitch) {
entity.getWorld().getMCWorld().playSoundAtEntity(entity.getMCEntity(), sound, volume, pitch);
}
public void playSoundToNearExcept(IPlayer<?> player, String sound, float volume, float pitch){
public void playSoundToNearExcept(IPlayer<?> player, String sound, float volume, float pitch) {
player.getWorld().getMCWorld().playSoundToNearExcept(player.getMCEntity(), sound, volume, pitch);
}
public String getMOTD()
{
public String getMOTD() {
return MinecraftServer.getServer().getMOTD();
}
public void setMOTD(String motd)
{
public void setMOTD(String motd) {
MinecraftServer.getServer().setMOTD(motd);
}
public IParticle createParticle(String directory){
public IParticle createParticle(String directory) {
return new ScriptParticle(directory);
}
@Deprecated
public IParticle createEntityParticle(String directory){
public IParticle createEntityParticle(String directory) {
return new ScriptParticle(directory);
}
@@ -726,7 +732,7 @@ public class NpcAPI extends AbstractNpcAPI {
}
public IFrame createFrame(int duration, float speed, byte smooth) {
return new Frame(duration,speed,smooth);
return new Frame(duration, speed, smooth);
}
public IFramePart createPart(String name) {
@@ -749,7 +755,7 @@ public class NpcAPI extends AbstractNpcAPI {
}
public IFramePart createPart(String name, float[] rotation, float[] pivot, float speed, byte smooth) {
FramePart part = (FramePart) this.createPart(name,rotation,pivot);
FramePart part = (FramePart) this.createPart(name, rotation, pivot);
part.setSpeed(speed);
part.setSmooth(smooth);
return part;
@@ -776,7 +782,7 @@ public class NpcAPI extends AbstractNpcAPI {
}
public IFramePart createPart(int partId, float[] rotation, float[] pivot, float speed, byte smooth) {
FramePart part = (FramePart) this.createPart(partId,rotation,pivot);
FramePart part = (FramePart) this.createPart(partId, rotation, pivot);
part.setSpeed(speed);
part.setSmooth(smooth);
return part;
@@ -28,11 +28,11 @@ public class ScreenSize implements IScreenSize {
@Override
public int getWidthPercent(double percent) {
return (int) (((double)width)*percent/100);
return (int) (((double) width) * percent / 100);
}
@Override
public int getHeightPercent(double percent) {
return (int) (((double)height)*percent/100);
return (int) (((double) height) * percent / 100);
}
}
@@ -22,7 +22,7 @@ public class ScriptBlock implements IBlock {
this.block = block;
this.pos = pos;
this.bPos = NpcAPI.Instance().getIPos(pos);
this.tile = NpcAPI.Instance().getITileEntity(world.getTileEntity(pos.getX(),pos.getY(), pos.getZ()));
this.tile = NpcAPI.Instance().getITileEntity(world.getTileEntity(pos.getX(), pos.getY(), pos.getZ()));
}
public IPos getPosition() {
@@ -43,16 +43,16 @@ public class ScriptBlock implements IBlock {
this.block = world.getBlock(pos).getMCBlock();
this.pos = pos.getMCPos();
this.bPos = pos;
this.tile = NpcAPI.Instance().getITileEntity(world.getMCWorld().getTileEntity(pos.getX(),pos.getY(),pos.getZ()));
this.tile = NpcAPI.Instance().getITileEntity(world.getMCWorld().getTileEntity(pos.getX(), pos.getY(), pos.getZ()));
return true;
}
public boolean setPosition(IPos pos) {
return this.setPosition(pos,world);
return this.setPosition(pos, world);
}
public boolean setPos(IPos pos, IWorld world) {
return this.setPosition(pos,world);
return this.setPosition(pos, world);
}
public boolean setPos(IPos pos) {
@@ -60,19 +60,19 @@ public class ScriptBlock implements IBlock {
}
public boolean setPosition(int x, int y, int z, IWorld world) {
return this.setPos(NpcAPI.Instance().getIPos(x,y,z),world);
return this.setPos(NpcAPI.Instance().getIPos(x, y, z), world);
}
public boolean setPosition(int x, int y, int z) {
return this.setPos(NpcAPI.Instance().getIPos(x,y,z));
return this.setPos(NpcAPI.Instance().getIPos(x, y, z));
}
public boolean setPos(int x, int y, int z, IWorld world) {
return this.setPosition(x,y,z, world);
return this.setPosition(x, y, z, world);
}
public boolean setPos(int x, int y, int z) {
return this.setPosition(x,y,z);
return this.setPosition(x, y, z);
}
public int getX() {
@@ -96,18 +96,18 @@ public class ScriptBlock implements IBlock {
}
public IBlock setBlock(String blockName) {
Block block = (Block)Block.blockRegistry.getObject(new ResourceLocation(blockName));
if(block == null) {
Block block = (Block) Block.blockRegistry.getObject(new ResourceLocation(blockName));
if (block == null) {
return this;
} else {
this.world.getMCWorld().setBlock(getX(),getY(),getZ(),block);
return NpcAPI.Instance().getIBlock(world, getX(),getY(),getZ());
this.world.getMCWorld().setBlock(getX(), getY(), getZ(), block);
return NpcAPI.Instance().getIBlock(world, getX(), getY(), getZ());
}
}
public IBlock setBlock(IBlock block) {
this.world.getMCWorld().setBlock(getX(),getY(),getZ(),block.getMCBlock());
return NpcAPI.Instance().getIBlock(world, getX(),getY(),getZ());
this.world.getMCWorld().setBlock(getX(), getY(), getZ(), block.getMCBlock());
return NpcAPI.Instance().getIBlock(world, getX(), getY(), getZ());
}
public boolean isContainer() {
@@ -115,10 +115,10 @@ public class ScriptBlock implements IBlock {
}
public IContainer getContainer() {
if(!this.isContainer()) {
if (!this.isContainer()) {
throw new CustomNPCsException("This block is not a container", new Object[0]);
} else {
return NpcAPI.Instance().getIContainer((IInventory)this.tile.getMCTileEntity());
return NpcAPI.Instance().getIContainer((IInventory) this.tile.getMCTileEntity());
}
}
@@ -127,7 +127,7 @@ public class ScriptBlock implements IBlock {
}
public String getDisplayName() {
return this.tile == null || this.tile.getMCTileEntity() == null ? this.getName():this.tile.getMCTileEntity().blockType.getItemIconName();
return this.tile == null || this.tile.getMCTileEntity() == null ? this.getName() : this.tile.getMCTileEntity().blockType.getItemIconName();
}
public IWorld getWorld() {
@@ -146,8 +146,8 @@ public class ScriptBlock implements IBlock {
return this.tile;
}
public void setTileEntity(ITileEntity tileEntity){
world.setTileEntity(pos.getX(),pos.getY(), pos.getZ(),tileEntity);
public void setTileEntity(ITileEntity tileEntity) {
world.setTileEntity(pos.getX(), pos.getY(), pos.getZ(), tileEntity);
this.tile = tileEntity;
}
@@ -168,7 +168,7 @@ public class ScriptBlock implements IBlock {
}
public boolean canCollide(double maxVolume) {
AxisAlignedBB alignedBB = block.getCollisionBoundingBoxFromPool(world.getMCWorld(),getX(),getY(),getZ());
AxisAlignedBB alignedBB = block.getCollisionBoundingBoxFromPool(world.getMCWorld(), getX(), getY(), getZ());
if (alignedBB == null) {
return false;
}
@@ -183,7 +183,7 @@ public class ScriptBlock implements IBlock {
}
public void setBounds(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
this.block.setBlockBounds(minX,minY,minZ,maxX,maxY,maxZ);
this.block.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
}
public double getBlockBoundsMinX() {
@@ -215,8 +215,8 @@ public class ScriptBlock implements IBlock {
}
public boolean equals(Object obj) {
return obj instanceof IBlock && ((ScriptBlock)obj).getName().equals(this.getName()) &&
((ScriptBlock)obj).getWorld() == this.getWorld() &&
((ScriptBlock)obj).getPos().equals(this.getPos());
return obj instanceof IBlock && ((ScriptBlock) obj).getName().equals(this.getName()) &&
((ScriptBlock) obj).getWorld() == this.getWorld() &&
((ScriptBlock) obj).getPos().equals(this.getPos());
}
}
@@ -109,7 +109,7 @@ public class ScriptBlockPos implements IPos {
}
public IPos crossProduct(double x, double y, double z) {
return this.crossProduct(NpcAPI.Instance().getIPos(x,y,z));
return this.crossProduct(NpcAPI.Instance().getIPos(x, y, z));
}
public IPos crossProduct(IPos pos) {
@@ -118,7 +118,7 @@ public class ScriptBlockPos implements IPos {
public IPos divide(double scalar) {
return NpcAPI.Instance().getIPos(
getXD()/scalar , getYD()/scalar, getZD()/scalar
getXD() / scalar, getYD() / scalar, getZD() / scalar
);
}
@@ -160,9 +160,9 @@ public class ScriptBlockPos implements IPos {
}
public String toString() {
double xd = Math.floor(this.getXD() * 1000)/1000.0D;
double yd = Math.floor(this.getYD() * 1000)/1000.0D;
double zd = Math.floor(this.getZD() * 1000)/1000.0D;
double xd = Math.floor(this.getXD() * 1000) / 1000.0D;
double yd = Math.floor(this.getYD() * 1000) / 1000.0D;
double zd = Math.floor(this.getZD() * 1000) / 1000.0D;
return "(" + xd + ", " + yd + ", " + zd + ")";
}
@@ -53,7 +53,7 @@ public class ScriptContainer implements IContainer {
public int count(IItemStack item, boolean ignoreDamage, boolean ignoreNBT) {
int count = 0;
for(int i = 0; i < this.getSize(); ++i) {
for (int i = 0; i < this.getSize(); ++i) {
IItemStack toCompare = this.getSlot(i);
if (NoppesUtilPlayer.compareItems(item.getMCItemStack(), toCompare.getMCItemStack(), ignoreDamage, ignoreNBT)) {
count += toCompare.getStackSize();
@@ -74,7 +74,7 @@ public class ScriptContainer implements IContainer {
public IItemStack[] getItems() {
IItemStack[] items = new IItemStack[this.getSize()];
for(int i = 0; i < this.getSize(); ++i) {
for (int i = 0; i < this.getSize(); ++i) {
items[i] = this.getSlot(i);
}
@@ -89,7 +89,7 @@ public class ScriptContainer implements IContainer {
container.detectAndSendChanges();
}
public boolean isPlayerNotUsingContainer(IPlayer player){
public boolean isPlayerNotUsingContainer(IPlayer player) {
return container.isPlayerNotUsingContainer((EntityPlayerMP) player.getMCEntity());
}
}
@@ -105,18 +105,18 @@ public class ScriptNbt implements INbt {
NBTTagList list = this.compound.getTagList(key, type);
Object[] nbts = new Object[list.tagCount()];
for(int i = 0; i < list.tagCount(); ++i) {
if(list.func_150303_d() == 10) {
for (int i = 0; i < list.tagCount(); ++i) {
if (list.func_150303_d() == 10) {
nbts[i] = new ScriptNbt(list.getCompoundTagAt(i));
} else if(list.func_150303_d() == 8) {
} else if (list.func_150303_d() == 8) {
nbts[i] = list.getStringTagAt(i);
} else if(list.func_150303_d() == 6) {
} else if (list.func_150303_d() == 6) {
nbts[i] = Double.valueOf(list.func_150309_d(i));
} else if(list.func_150303_d() == 5) {
} else if (list.func_150303_d() == 5) {
nbts[i] = Float.valueOf(list.func_150308_e(i));
} else if(list.func_150303_d() == 3) {
} else if (list.func_150303_d() == 3) {
nbts[i] = Integer.valueOf(list.getStringTagAt(i));
} else if(list.func_150303_d() == 11) {
} else if (list.func_150303_d() == 11) {
nbts[i] = list.func_150306_c(i);
}
}
@@ -126,12 +126,12 @@ public class ScriptNbt implements INbt {
public int getListType(String key) {
NBTBase b = this.compound.getTag(key);
if(b == null) {
if (b == null) {
return 0;
} else if(b.getId() != 9) {
} else if (b.getId() != 9) {
throw new CustomNPCsException("NBT tag " + key + " isn\'t a list", new Object[0]);
} else {
return ((NBTTagList)b).func_150303_d();
return ((NBTTagList) b).func_150303_d();
}
}
@@ -140,19 +140,19 @@ public class ScriptNbt implements INbt {
Object[] var4 = value;
int var5 = value.length;
for(int var6 = 0; var6 < var5; ++var6) {
for (int var6 = 0; var6 < var5; ++var6) {
Object nbt = var4[var6];
if(nbt instanceof INbt) {
if (nbt instanceof INbt) {
list.appendTag(((INbt) nbt).getMCNBT());
} else if(nbt instanceof String) {
} else if (nbt instanceof String) {
list.appendTag(new NBTTagString((String) nbt));
} else if(nbt instanceof Double) {
} else if (nbt instanceof Double) {
list.appendTag(new NBTTagDouble(((Double) nbt).doubleValue()));
} else if(nbt instanceof Float) {
} else if (nbt instanceof Float) {
list.appendTag(new NBTTagFloat(((Float) nbt).floatValue()));
} else if(nbt instanceof Integer) {
} else if (nbt instanceof Integer) {
list.appendTag(new NBTTagInt(((Integer) nbt).intValue()));
} else if(nbt instanceof int[]) {
} else if (nbt instanceof int[]) {
list.appendTag(new NBTTagIntArray((int[]) ((int[]) nbt)));
}
}
@@ -165,7 +165,7 @@ public class ScriptNbt implements INbt {
}
public void setCompound(String key, INbt value) {
if(value == null) {
if (value == null) {
throw new CustomNPCsException("Value cant be null", new Object[0]);
} else {
this.compound.setTag(key, value.getMCNBT());
@@ -173,7 +173,7 @@ public class ScriptNbt implements INbt {
}
public String[] getKeys() {
return (String[])this.compound.func_150296_c().toArray(new String[this.compound.func_150296_c().size()]);
return (String[]) this.compound.func_150296_c().toArray(new String[this.compound.func_150296_c().size()]);
}
public int getType(String key) {
@@ -195,8 +195,8 @@ public class ScriptNbt implements INbt {
public void clear() {
Iterator var1 = this.compound.func_150296_c().iterator();
while(var1.hasNext()) {
String name = (String)var1.next();
while (var1.hasNext()) {
String name = (String) var1.next();
this.compound.removeTag(name);
}
@@ -19,12 +19,12 @@ public class ScriptParticle implements IParticle {
public int amount = 1;
public int maxAge = 20;
public double x = 0,y = 0,z = 0;
public double motionX = 0,motionY = 0,motionZ = 0;
public double x = 0, y = 0, z = 0;
public double motionX = 0, motionY = 0, motionZ = 0;
public float gravity = 0;
public float scaleX1 = 20.0f,scaleX2 = 20.0f,scaleXRate = 0.0f;
public float scaleY1 = 20.0f,scaleY2 = 20.0f,scaleYRate = 0.0f;
public float alpha1 = 1.0f,alpha2 = 1.0f,alphaRate = 0.0f;
public float scaleX1 = 20.0f, scaleX2 = 20.0f, scaleXRate = 0.0f;
public float scaleY1 = 20.0f, scaleY2 = 20.0f, scaleYRate = 0.0f;
public float alpha1 = 1.0f, alpha2 = 1.0f, alphaRate = 0.0f;
public int scaleXRateStart = 0, scaleYRateStart, alphaRateStart = 0;
public float rotationX1 = 0;
@@ -53,7 +53,7 @@ public class ScriptParticle implements IParticle {
public boolean glows = true;
public boolean noClip = true;
public ScriptParticle(String directory){
public ScriptParticle(String directory) {
this.directory = directory;
}
@@ -67,7 +67,8 @@ public class ScriptParticle implements IParticle {
if (!field.get(this).equals(field.get(newParticle))) {
compound = writeNBTTag(compound, field.getType(), field.getName(), field.get(this));
}
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
}
return compound;
@@ -120,18 +121,19 @@ public class ScriptParticle implements IParticle {
for (Field field : ScriptParticle.class.getDeclaredFields()) {
try {
if (compound.hasKey(field.getName())) {
Object val = ScriptParticle.readNBTTag(compound,field.getName());
Object val = ScriptParticle.readNBTTag(compound, field.getName());
if (val != null) {
field.set(particle, val);
}
}
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
}
return particle;
}
public void spawn(IEntity entity){
public void spawn(IEntity entity) {
int entityID = entity.getMCEntity().getEntityId();
NBTTagCompound compound = this.writeToNBT();
@@ -140,12 +142,12 @@ public class ScriptParticle implements IParticle {
NoppesUtilServer.spawnScriptedParticle(compound, entity.getWorld().getDimensionID());
}
public void spawn(IWorld world){
public void spawn(IWorld world) {
NBTTagCompound compound = this.writeToNBT();
NoppesUtilServer.spawnScriptedParticle(compound, world.getDimensionID());
}
public void spawn(IWorld world, double x, double y, double z){
public void spawn(IWorld world, double x, double y, double z) {
double prevX = this.x;
double prevY = this.y;
double prevZ = this.z;
@@ -170,22 +172,38 @@ public class ScriptParticle implements IParticle {
spawn(world);
}
public void spawnInWorld(IWorld world, double x, double y, double z){
public void spawnInWorld(IWorld world, double x, double y, double z) {
spawn(world, x, y, z);
}
public void setGlows(boolean glows) { this.glows = glows; }
public boolean getGlows() { return this.glows; }
public void setGlows(boolean glows) {
this.glows = glows;
}
public void setNoClip(boolean noClip) { this.noClip = noClip; }
public boolean getNoClip() { return this.noClip; }
public boolean getGlows() {
return this.glows;
}
public void setFacePlayer(boolean facePlayer) { this.facePlayer = facePlayer; }
public boolean getFacePlayer() { return facePlayer; }
public void setNoClip(boolean noClip) {
this.noClip = noClip;
}
public boolean getNoClip() {
return this.noClip;
}
public void setFacePlayer(boolean facePlayer) {
this.facePlayer = facePlayer;
}
public boolean getFacePlayer() {
return facePlayer;
}
public String getDirectory() {
return directory;
}
public void setDirectory(String directory) {
this.directory = directory;
}
@@ -193,6 +211,7 @@ public class ScriptParticle implements IParticle {
public void setAmount(int amount) {
this.amount = amount;
}
public int getAmount() {
return amount;
}
@@ -200,72 +219,105 @@ public class ScriptParticle implements IParticle {
public void setMaxAge(int maxAge) {
this.maxAge = maxAge;
}
public int getMaxAge() {
return maxAge;
}
public void setSize(int width, int height){
public void setSize(int width, int height) {
this.width = width;
this.height = height;
}
public int getWidth() { return width; }
public int getHeight() { return height; }
public void setOffset(int offsetX, int offsetY){
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public void setOffset(int offsetX, int offsetY) {
this.offsetX = offsetX;
this.offsetY = offsetY;
}
public int getOffsetX() { return offsetX; }
public int getOffsetY() { return offsetY; }
public void setAnim(int animRate, boolean animLoop, int animStart, int animEnd){
public int getOffsetX() {
return offsetX;
}
public int getOffsetY() {
return offsetY;
}
public void setAnim(int animRate, boolean animLoop, int animStart, int animEnd) {
this.animRate = animRate;
this.animLoop = animLoop;
this.animStart = animStart;
this.animEnd = animEnd;
}
public int getAnimRate() { return animRate; }
public boolean getAnimLoop() { return animLoop; }
public int getAnimStart() { return animStart; }
public int getAnimEnd() { return animEnd; }
public void setPosition(double x, double y, double z){
public int getAnimRate() {
return animRate;
}
public boolean getAnimLoop() {
return animLoop;
}
public int getAnimStart() {
return animStart;
}
public int getAnimEnd() {
return animEnd;
}
public void setPosition(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public double getZ() {
return z;
}
public void setPosition(IPos pos) {
this.setPosition(pos.getXD(),pos.getYD(),pos.getZD());
}
public void getPos() {
NpcAPI.Instance().getIPos(x,y,z);
this.setPosition(pos.getXD(), pos.getYD(), pos.getZD());
}
public void setMotion(double motionX, double motionY, double motionZ, float gravity){
public void getPos() {
NpcAPI.Instance().getIPos(x, y, z);
}
public void setMotion(double motionX, double motionY, double motionZ, float gravity) {
this.motionX = motionX;
this.motionY = motionY;
this.motionZ = motionZ;
this.gravity = gravity;
}
public double getMotionX() {
return motionX;
}
public double getMotionY() {
return motionY;
}
public double getMotionZ() {
return motionZ;
}
public float getGravity() {
return gravity;
}
@@ -276,34 +328,42 @@ public class ScriptParticle implements IParticle {
this.HEXColorRate = HEXColorRate;
this.HEXColorStart = HEXColorStart;
}
public int getHEXColor1() {
return HEXColor;
}
public int getHEXColor2() {
return HEXColor2;
}
public float getHEXColorRate() {
return HEXColorRate;
}
public int getHEXColorStart() {
return HEXColorStart;
}
public void setAlpha(float alpha1, float alpha2, float alphaRate, int alphaRateStart){
public void setAlpha(float alpha1, float alpha2, float alphaRate, int alphaRateStart) {
this.alpha1 = alpha1;
this.alpha2 = alpha2;
this.alphaRate = alphaRate;
this.alphaRateStart = alphaRateStart;
}
public float getAlpha1() {
return alpha1;
}
public float getAlpha2() {
return alpha2;
}
public float getAlphaRate() {
return alphaRate;
}
public int getAlphaRateStart() {
return alphaRateStart;
}
@@ -315,81 +375,126 @@ public class ScriptParticle implements IParticle {
this.scaleXRateStart = this.scaleYRateStart = scaleRateStart;
}
public void setScaleX(float scale1, float scale2, float scaleRate, int scaleRateStart){
public void setScaleX(float scale1, float scale2, float scaleRate, int scaleRateStart) {
this.scaleX1 = scale1;
this.scaleX2 = scale2;
this.scaleXRate = scaleRate;
this.scaleXRateStart = scaleRateStart;
}
public float getScaleX1() {
return scaleX1;
}
public float getScaleX2() {
return scaleX2;
}
public float getScaleXRate() {
return scaleXRate;
}
public int getScaleXRateStart() {
return scaleXRateStart;
}
public void setScaleY(float scale1, float scale2, float scaleRate, int scaleRateStart){
public void setScaleY(float scale1, float scale2, float scaleRate, int scaleRateStart) {
this.scaleY1 = scale1;
this.scaleY2 = scale2;
this.scaleYRate = scaleRate;
this.scaleYRateStart = scaleRateStart;
}
public float getScaleY1() {
return scaleY1;
}
public float getScaleY2() {
return scaleY2;
}
public float getScaleYRate() {
return scaleYRate;
}
public int getScaleYRateStart() {
return scaleYRateStart;
}
public void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart){
public void setRotationX(float rotationX1, float rotationX2, float rotationXRate, int rotationXRateStart) {
this.rotationX1 = rotationX1;
this.rotationX2 = rotationX2;
this.rotationXRate = rotationXRate;
this.rotationXRateStart = rotationXRateStart;
}
public float getRotationX1() {return rotationX1;}
public float getRotationX2() {return rotationX2;}
public float getRotationXRate() {return rotationXRate;}
public int getRotationXRateStart() {return rotationXRateStart;}
public void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart){
public float getRotationX1() {
return rotationX1;
}
public float getRotationX2() {
return rotationX2;
}
public float getRotationXRate() {
return rotationXRate;
}
public int getRotationXRateStart() {
return rotationXRateStart;
}
public void setRotationY(float rotationY1, float rotationY2, float rotationYRate, int rotationYRateStart) {
this.rotationY1 = rotationY1;
this.rotationY2 = rotationY2;
this.rotationYRate = rotationYRate;
this.rotationYRateStart = rotationYRateStart;
}
public float getRotationY1() {return rotationY1;}
public float getRotationY2() {return rotationY2;}
public float getRotationYRate() {return rotationYRate;}
public int getRotationYRateStart() {return rotationYRateStart;}
public void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart){
public float getRotationY1() {
return rotationY1;
}
public float getRotationY2() {
return rotationY2;
}
public float getRotationYRate() {
return rotationYRate;
}
public int getRotationYRateStart() {
return rotationYRateStart;
}
public void setRotationZ(float rotationZ1, float rotationZ2, float rotationZRate, int rotationZRateStart) {
this.rotationZ1 = rotationZ1;
this.rotationZ2 = rotationZ2;
this.rotationZRate = rotationZRate;
this.rotationZRateStart = rotationZRateStart;
}
public float getRotationZ1() {return rotationZ1;}
public float getRotationZ2() {return rotationZ2;}
public float getRotationZRate() {return rotationZRate;}
public int getRotationZRateStart() {return rotationZRateStart;}
public float getRotationZ1() {
return rotationZ1;
}
public float getRotationZ2() {
return rotationZ2;
}
public float getRotationZRate() {
return rotationZRate;
}
public int getRotationZRateStart() {
return rotationZRateStart;
}
@Deprecated
public void setHEXColor(int HEXColor) {
this.HEXColor = HEXColor;
}
@Deprecated
public int getHEXColor() {
return HEXColor;
@@ -8,20 +8,21 @@ import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.scripted.entity.ScriptPixelmon;
public class ScriptPixelmonPlayerData implements IPixelmonPlayerData {
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);
}
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);
}
}
@@ -30,11 +30,12 @@ public class ScriptSound implements ISound {
for (Field field : ScriptSound.class.getDeclaredFields()) {
try {
if (field.getName().equals("sourceEntity") && this.sourceEntity != null) {
compound.setInteger("EntityID",this.sourceEntity.getEntityId());
compound.setInteger("EntityID", this.sourceEntity.getEntityId());
} else if (!field.get(this).equals(field.get(newSound))) {
compound = writeNBTTag(compound, field.getType(), field.getName(), field.get(this));
}
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
}
return compound;
@@ -94,7 +95,8 @@ public class ScriptSound implements ISound {
}
}
}
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
}
return particle;
@@ -128,8 +130,7 @@ public class ScriptSound implements ISound {
this.volume = volume;
}
public float getVolume()
{
public float getVolume() {
return this.volume;
}
@@ -137,8 +138,7 @@ public class ScriptSound implements ISound {
this.pitch = pitch;
}
public float getPitch()
{
public float getPitch() {
return this.pitch;
}
@@ -13,11 +13,11 @@ public class ScriptTileEntity<T extends TileEntity> implements ITileEntity {
this.world = NpcAPI.Instance().getIWorld(tileEntity.getWorldObj());
}
public int getBlockMetadata(){
public int getBlockMetadata() {
return tileEntity.getBlockMetadata();
}
public IWorld getWorld(){
public IWorld getWorld() {
return world;
}
@@ -30,32 +30,31 @@ public class ScriptTileEntity<T extends TileEntity> implements ITileEntity {
return this.tileEntity;
}
public void markDirty()
{
public void markDirty() {
this.tileEntity.markDirty();
}
public void readFromNBT(INbt nbt){
public void readFromNBT(INbt nbt) {
this.tileEntity.readFromNBT(nbt.getMCNBT());
}
public double getDistanceFrom(double x, double y, double z){
return this.tileEntity.getDistanceFrom(x,y,z);
public double getDistanceFrom(double x, double y, double z) {
return this.tileEntity.getDistanceFrom(x, y, z);
}
public double getDistanceFrom(IPos pos){
return this.getDistanceFrom(pos.getXD(),pos.getYD(),pos.getZD());
public double getDistanceFrom(IPos pos) {
return this.getDistanceFrom(pos.getXD(), pos.getYD(), pos.getZD());
}
public IBlock getBlockType(){
public IBlock getBlockType() {
return NpcAPI.Instance().getIBlock(world, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
}
public boolean isInvalid(){
public boolean isInvalid() {
return tileEntity.isInvalid();
}
public void invalidate(){
public void invalidate() {
tileEntity.invalidate();
}
@@ -63,7 +62,7 @@ public class ScriptTileEntity<T extends TileEntity> implements ITileEntity {
tileEntity.validate();
}
public void updateContainingBlockInfo(){
public void updateContainingBlockInfo() {
tileEntity.updateContainingBlockInfo();
}
File diff suppressed because it is too large. Load diff
@@ -1,10 +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;
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;
}
@@ -1,14 +1,14 @@
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;
public static final int ITEM = 6;
public static final int PROJECTILE = 7;
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;
public static final int ITEM = 6;
public static final int PROJECTILE = 7;
public static final int PIXELMON = 8;
public static final int VILLAGER = 9;
}
@@ -1,13 +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;
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;
}
@@ -1,11 +1,11 @@
package noppes.npcs.scripted.constants;
public class RoleType {
public static final int UNKNOWN = 0;
public static final int TRADER = 1;
public static final int FOLLOWER = 2;
public static final int BANK = 3;
public static final int TRANSPORTER = 4;
public static final int POSTMAN = 5;
public static final int COMPANION = 6;
public static final int UNKNOWN = 0;
public static final int TRADER = 1;
public static final int FOLLOWER = 2;
public static final int BANK = 3;
public static final int TRANSPORTER = 4;
public static final int POSTMAN = 5;
public static final int COMPANION = 6;
}
@@ -9,54 +9,54 @@ import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.EntityType;
public class ScriptAnimal<T extends EntityAnimal> extends ScriptLiving<T> implements IAnimal {
protected T entity;
protected T entity;
public ScriptAnimal(T entity) {
super(entity);
this.entity = entity;
}
@Override
public int getType(){
return EntityType.ANIMAL;
}
public ScriptAnimal(T entity) {
super(entity);
this.entity = entity;
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(IItemStack itemStack) {
return this.entity.isBreedingItem(itemStack.getMCItemStack());
}
@Override
public int getType() {
return EntityType.ANIMAL;
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
public boolean interact(IPlayer player) {
return this.entity.interact((EntityPlayer) player.getMCEntity());
}
/**
* Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
* the animal type)
*/
public boolean isBreedingItem(IItemStack itemStack) {
return this.entity.isBreedingItem(itemStack.getMCItemStack());
}
public void setFollowPlayer(IPlayer player) {
this.entity.func_146082_f((EntityPlayer) player.getMCEntity());
}
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
public boolean interact(IPlayer player) {
return this.entity.interact((EntityPlayer) player.getMCEntity());
}
public IPlayer followingPlayer() {
return (IPlayer) NpcAPI.Instance().getIEntity(this.entity.func_146083_cb());
}
public void setFollowPlayer(IPlayer player) {
this.entity.func_146082_f((EntityPlayer) player.getMCEntity());
}
public boolean isInLove() {
return this.entity.isInLove();
}
public IPlayer followingPlayer() {
return (IPlayer) NpcAPI.Instance().getIEntity(this.entity.func_146083_cb());
}
public void resetInLove() {
this.entity.resetInLove();
}
public boolean isInLove() {
return this.entity.isInLove();
}
public boolean canMateWith(IAnimal animal) {
return this.entity.canMateWith((EntityAnimal) animal.getMCEntity());
}
public void resetInLove() {
this.entity.resetInLove();
}
public boolean typeOf(int type){
return type == EntityType.ANIMAL || super.typeOf(type);
}
public boolean canMateWith(IAnimal animal) {
return this.entity.canMateWith((EntityAnimal) animal.getMCEntity());
}
public boolean typeOf(int type) {
return type == EntityType.ANIMAL || super.typeOf(type);
}
}
@@ -12,7 +12,7 @@ import noppes.npcs.scripted.NpcAPI;
public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> implements IDBCPlayer {
public T player;
public ScriptDBCPlayer(T player){
public ScriptDBCPlayer(T player) {
super(player);
this.player = player;
}
@@ -71,7 +71,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
}
throw new CustomNPCsException("Invalid stat name: " + stat + "\nValid stat names are:" +
"\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit",new Object[0]);
"\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit", new Object[0]);
}
private double applyOperator(String method, double n1, double n2) {
@@ -90,33 +90,39 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
return n1;
}
public void addBonusAttribute(String stat, String bonusID, String operation, double attributeValue){
addBonusAttribute(stat,bonusID,operation,attributeValue,true);
public void addBonusAttribute(String stat, String bonusID, String operation, double attributeValue) {
addBonusAttribute(stat, bonusID, operation, attributeValue, true);
}
public void addBonusAttribute(String stat, String bonusID, String operation, double attributeValue, boolean endOfTheList){
bonusAttribute("add",stat,bonusID,operation,attributeValue,endOfTheList);
public void addBonusAttribute(String stat, String bonusID, String operation, double attributeValue, boolean endOfTheList) {
bonusAttribute("add", stat, bonusID, operation, attributeValue, endOfTheList);
}
public void addToBonusAttribute(String stat, String bonusID, String operation, double attributeValue){
bonusAttribute("addto",stat,bonusID,operation,attributeValue,true);
public void addToBonusAttribute(String stat, String bonusID, String operation, double attributeValue) {
bonusAttribute("addto", stat, bonusID, operation, attributeValue, true);
}
public void setBonusAttribute(String stat, String bonusID, String operation, double attributeValue){
bonusAttribute("set",stat,bonusID,operation,attributeValue,true);
public void setBonusAttribute(String stat, String bonusID, String operation, double attributeValue) {
bonusAttribute("set", stat, bonusID, operation, attributeValue, true);
}
public void getBonusAttribute(String stat, String bonusID){
bonusAttribute("get",stat,bonusID,"*",1.0,true);
public void getBonusAttribute(String stat, String bonusID) {
bonusAttribute("get", stat, bonusID, "*", 1.0, true);
}
public void removeBonusAttribute(String stat, String bonusID){
bonusAttribute("remove",stat,bonusID,"*",1.0,true);
public void removeBonusAttribute(String stat, String bonusID) {
bonusAttribute("remove", stat, bonusID, "*", 1.0, true);
}
public void clearBonusAttribute(String stat){
bonusAttribute("clear",stat,"","*",1.0,true);
public void clearBonusAttribute(String stat) {
bonusAttribute("clear", stat, "", "*", 1.0, true);
}
public String bonusAttribute(String action, String stat, String bonusID) {
String[] actions = new String[]{"get", "remove", "clear"};
boolean valid = false;
for(String s : actions){
if(s.equals(action.toLowerCase())){
for (String s : actions) {
if (s.equals(action.toLowerCase())) {
valid = true;
}
}
@@ -124,7 +130,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
throw new CustomNPCsException("Action can be: get/remove/clear", new Object[0]);
}
return bonusAttribute(action,stat,bonusID,"*",1.0,false);
return bonusAttribute(action, stat, bonusID, "*", 1.0, false);
}
public String bonusAttribute(String action, String stat, String bonusID, String operation, double attributeValue, boolean endOfTheList) {
@@ -132,8 +138,8 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
String[] operations = new String[]{"+", "-", "*", "/", "%"};
boolean valid = false;
for(String s : actions){
if(s.equals(action.toLowerCase())){
for (String s : actions) {
if (s.equals(action.toLowerCase())) {
valid = true;
}
}
@@ -141,7 +147,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
throw new CustomNPCsException("Action can be: add/addTo/set/get/remove/clear", new Object[0]);
}
if(!action.equals("remove") && !action.equals("get") && !action.equals("clear")) {
if (!action.equals("remove") && !action.equals("get") && !action.equals("clear")) {
valid = false;
for (String s : operations) {
if (s.equals(operation)) {
@@ -174,16 +180,16 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
stat = "spi";
break;
}
if(!(stat.equals("str") || stat.equals("dex") || stat.equals("con") || stat.equals("wil") || stat.equals("mnd") || stat.equals("spi")))
if (!(stat.equals("str") || stat.equals("dex") || stat.equals("con") || stat.equals("wil") || stat.equals("mnd") || stat.equals("spi")))
throw new CustomNPCsException("Invalid stat name: " + stat + "\nValid stat names are:" +
"\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit",new Object[0]);
"\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit", new Object[0]);
String bonusValueString = operation + attributeValue;
String bonus = player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcAttrBonus"+stat);
String bonus = player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcAttrBonus" + stat);
String bonuses[] = bonus.split("\\|");
String[][] bonusValues = new String[bonuses.length][2];
if (bonuses.length > 0 && bonuses[0].length() > 0) {
for(int i = 0; i < bonuses.length; ++i) {
for (int i = 0; i < bonuses.length; ++i) {
String[] bonusValue = bonuses[i].split("\\;");
bonusValues[i][0] = bonusValue[0];
bonusValues[i][1] = bonusValue[1];
@@ -192,7 +198,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
switch (action) {
case "get":
if(player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus"+stat)) {
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus" + stat)) {
for (String[] s : bonusValues) {
if (s[0].equals(bonusID))
return s[1];
@@ -200,12 +206,12 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
}
return "";
case "clear":
if(player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus"+stat))
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, "");
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus" + stat))
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus" + stat, "");
break;
case "remove":
String newBonusString = "";
if(player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus"+stat)) {
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus" + stat)) {
int num = -1;
boolean number;
boolean run = false;
@@ -218,7 +224,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
number = false;
}
for(int i = 0; i < bonuses.length; ++i) {
for (int i = 0; i < bonuses.length; ++i) {
bonusValue = bonuses[i].split("\\;");
bonusValues[i][0] = bonusValue[0];
if (number && i == num || !number && bonusValues[i][0].equals(bonusID)) {
@@ -237,7 +243,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
}
}
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, startString);
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus" + stat, startString);
}
}
break;
@@ -267,7 +273,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
bonus = bonusID + ";" + bonusValueString + "|" + bonus;
}
}
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, bonus);
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus" + stat, bonus);
}
break;
case "set": {
@@ -307,7 +313,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
}
}
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, startString);
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus" + stat, startString);
}
break;
}
@@ -349,7 +355,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
}
}
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, startString);
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus" + stat, startString);
}
break;
}
@@ -358,80 +364,88 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
return "";
}
public void setRelease(byte release){
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcRelease",release);
public void setRelease(byte release) {
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcRelease", release);
}
public byte getRelease(){
public byte getRelease() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcRelease");
}
public void setBody(int body){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcBdy",body);
public void setBody(int body) {
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcBdy", body);
}
public int getBody(){
public int getBody() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcBdy");
}
public void setHP(int hp){
public void setHP(int hp) {
setBody(hp);
}
public int getHP()
{
public int getHP() {
return getBody();
}
public void setStamina(int stamina){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcStamina",stamina);
public void setStamina(int stamina) {
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcStamina", stamina);
}
public int getStamina(){
public int getStamina() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcStamina");
}
public void setKi(int ki){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcEnrgy",ki);
public void setKi(int ki) {
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcEnrgy", ki);
}
public int getKi(){
public int getKi() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcEnrgy");
}
public void setTP(int tp){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcTpint",tp);
public void setTP(int tp) {
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcTpint", tp);
}
public int getTP(){
public int getTP() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcTpint");
}
public void setGravity(float gravity){
player.getEntityData().getCompoundTag("PlayerPersisted").setFloat("jrmcGravForce",gravity);
public void setGravity(float gravity) {
player.getEntityData().getCompoundTag("PlayerPersisted").setFloat("jrmcGravForce", gravity);
}
public float getGravity(){
public float getGravity() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getFloat("jrmcGravForce");
}
public boolean isBlocking(){
public boolean isBlocking() {
NBTTagCompound compound = new NBTTagCompound();
this.player.writeToNBT(compound);
return compound.getCompoundTag("JRMCEP").getInteger("blocking") == 1;
}
public void setHairCode(String hairCode){
public void setHairCode(String hairCode) {
NBTTagCompound compound = new NBTTagCompound();
this.player.writeToNBT(compound);
compound.getCompoundTag("JRMCEP").setString("haircode",hairCode);
compound.getCompoundTag("JRMCEP").setString("haircode", hairCode);
}
public String getHairCode(){
public String getHairCode() {
NBTTagCompound compound = new NBTTagCompound();
this.player.writeToNBT(compound);
return compound.getCompoundTag("JRMCEP").getString("haircode");
}
public void setExtraCode(String extraCode){
public void setExtraCode(String extraCode) {
NBTTagCompound compound = new NBTTagCompound();
this.player.writeToNBT(compound);
compound.getCompoundTag("JRMCEP").setString("extracode",extraCode);
compound.getCompoundTag("JRMCEP").setString("extracode", extraCode);
}
public String getExtraCode(){
public String getExtraCode() {
NBTTagCompound compound = new NBTTagCompound();
this.player.writeToNBT(compound);
return compound.getCompoundTag("JRMCEP").getString("extracode");
@@ -444,7 +458,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
byte offset = (byte) (vanity ? 10 : 2);
NBTTagList newList = new NBTTagList();
NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10);
NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag", 10);
for (int i = 0; i < list.tagCount(); i++) {
if (offset - list.getCompoundTagAt(i).getByte("Slot") != slot) {
newList.appendTag(list.getCompoundTagAt(i));
@@ -468,7 +482,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
byte offset = (byte) (vanity ? 10 : 2);
NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10);
NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag", 10);
for (int i = 0; i < list.tagCount(); i++) {
if (offset - list.getCompoundTagAt(i).getByte("Slot") == slot) {
return NpcAPI.Instance().getIItemStack(ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i)));
@@ -478,11 +492,11 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
return null;
}
public IItemStack[] getInventory(){
public IItemStack[] getInventory() {
NBTTagCompound compound = new NBTTagCompound();
this.player.writeToNBT(compound);
NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10);
NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag", 10);
IItemStack[] itemList = new IItemStack[list.tagCount()];
for (int i = 0; i < list.tagCount(); i++) {
ItemStack itemStack = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i));
@@ -492,36 +506,39 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
return itemList;
}
public void setForm(byte form){
if(form < 0)
public void setForm(byte form) {
if (form < 0)
return;
switch(getRace()){
switch (getRace()) {
case 0:
case 3:
if(form > 3)
if (form > 3)
return;
break;
case 1:
case 2:
if(form > 15)
if (form > 15)
return;
break;
case 4:
if(form > 7)
if (form > 7)
return;
break;
}
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState",form);
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState", form);
}
public byte getForm(){
public byte getForm() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState");
}
public void setForm2(byte form2){
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState2",form2);
public void setForm2(byte form2) {
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState2", form2);
}
public byte getForm2(){
public byte getForm2() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState2");
}
@@ -530,11 +547,12 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
String formTree = this.getRacialTreeName();
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) {
String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMastery" + formTree).split(";");
getString("jrmcFormMastery" + formTree).split(";");
String masteryString = formMasteries[form];
return Double.parseDouble(masteryString.split(",")[1]);
}
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
return 0.0D;
}
@@ -543,7 +561,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
String formTree = this.getRacialTreeName();
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) {
String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMastery" + formTree).split(";");
getString("jrmcFormMastery" + formTree).split(";");
if (form >= formMasteries.length)
return;
@@ -558,9 +576,10 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
}
player.getEntityData().getCompoundTag("PlayerPersisted").
setString("jrmcFormMastery" + formTree, String.valueOf(masteryString));
setString("jrmcFormMastery" + formTree, String.valueOf(masteryString));
}
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
}
public void addRacialFormMastery(byte form, double value) {
@@ -568,7 +587,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
String formTree = this.getRacialTreeName();
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMastery" + formTree)) {
String[] formMasteries = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMastery" + formTree).split(";");
getString("jrmcFormMastery" + formTree).split(";");
if (form >= formMasteries.length)
return;
@@ -584,9 +603,10 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
}
player.getEntityData().getCompoundTag("PlayerPersisted").
setString("jrmcFormMastery" + formTree, String.valueOf(masteryString));
setString("jrmcFormMastery" + formTree, String.valueOf(masteryString));
}
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
}
private String getRacialTreeName() {
@@ -611,7 +631,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
try {
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) {
String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMasteryNonRacial");
getString("jrmcFormMasteryNonRacial");
if (!masteryData.contains(formName)) {
return 0.0D;
}
@@ -623,7 +643,8 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
}
}
}
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
return 0.0D;
}
@@ -631,7 +652,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
try {
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) {
String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMasteryNonRacial");
getString("jrmcFormMasteryNonRacial");
if (!masteryData.contains(formName)) {
return;
}
@@ -653,16 +674,17 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
}
player.getEntityData().getCompoundTag("PlayerPersisted").
setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString));
setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString));
}
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
}
public void addOtherFormMastery(String formName, double value) {
try {
if (player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcFormMasteryNonRacial")) {
String masteryData = player.getEntityData().getCompoundTag("PlayerPersisted").
getString("jrmcFormMasteryNonRacial");
getString("jrmcFormMasteryNonRacial");
if (!masteryData.contains(formName)) {
return;
}
@@ -685,62 +707,69 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
}
player.getEntityData().getCompoundTag("PlayerPersisted").
setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString));
setString("jrmcFormMasteryNonRacial", String.valueOf(masteryString));
}
} catch (Exception ignored) {}
} catch (Exception ignored) {
}
}
public void setPowerPoints(int points){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcArcRsrv",points);
public void setPowerPoints(int points) {
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcArcRsrv", points);
}
public int getPowerPoints(){
public int getPowerPoints() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcArcRsrv");
}
public void setAuraColor(int color){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcAuraColor",color);
public void setAuraColor(int color) {
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcAuraColor", color);
}
public int getAuraColor(){
public int getAuraColor() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcAuraColor");
}
public void setFormLevel(int level){
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSltX","TR"+level);
public void setFormLevel(int level) {
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSltX", "TR" + level);
}
public int getFormLevel(){
public int getFormLevel() {
String formString = player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcSSltX");
if(formString.length() < 1)
if (formString.length() < 1)
return 0;
StringBuilder digitString = new StringBuilder();
for(char c : formString.toCharArray()){
if(Character.isDigit(c))
for (char c : formString.toCharArray()) {
if (Character.isDigit(c))
digitString.append(c);
}
if(digitString.length() < 1)
if (digitString.length() < 1)
return 0;
return Integer.parseInt(digitString.toString());
}
public void setSkills(String skills){
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSlts",skills);
public void setSkills(String skills) {
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSlts", skills);
}
public String getSkills(){
public String getSkills() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcSSlts");
}
public void setJRMCSE(String statusEffects){
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcStatusEff",statusEffects);
public void setJRMCSE(String statusEffects) {
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcStatusEff", statusEffects);
}
public String getJRMCSE(){
public String getJRMCSE() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcStatusEff");
}
public byte getDBCClass(){
public byte getDBCClass() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcClass");
}
public void setDBCClass(byte dbcClass) {
if (dbcClass < 0 || dbcClass > 2)
return;
@@ -748,9 +777,10 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcClass", dbcClass);
}
public int getRace(){
public int getRace() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcRace");
}
public void setRace(byte race) {
if (race < 0 || race > 1)
return;
@@ -758,9 +788,10 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcRace", race);
}
public int getPowerType(){
public int getPowerType() {
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcPwrtyp");
}
public void setPowerType(byte powerType) {
if (powerType < 0 || powerType > 1)
return;
@@ -768,7 +799,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T> i
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcPwrtyp", powerType);
}
public int getKillCount(String type){
public int getKillCount(String type) {
type = type.toLowerCase().trim();
int evilKills = player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcKillCountEvil");
File diff suppressed because it is too large. Load diff
@@ -49,7 +49,7 @@ public class ScriptEntityItem<T extends EntityItem> extends ScriptEntity<T> impl
public void setAge(long age) {
age = Math.max(Math.min(age, Integer.MAX_VALUE), Integer.MIN_VALUE);
this.entity.age = (int)age;
this.entity.age = (int) age;
}
public int getLifeSpawn() {
@@ -65,7 +65,7 @@ public class ScriptEntityItem<T extends EntityItem> extends ScriptEntity<T> impl
}
public void setItem(IItemStack item) {
ItemStack stack = item == null? null : item.getMCItemStack();
ItemStack stack = item == null ? null : item.getMCItemStack();
this.entity.setEntityItemStack(stack);
}
}
@@ -8,156 +8,145 @@ import noppes.npcs.scripted.NpcAPI;
public class ScriptLiving<T extends EntityLiving> extends ScriptLivingBase<T> implements IEntityLiving {
public ScriptLiving(T entity) {
super(entity);
}
@Override
public boolean isAttacking(){
return super.isAttacking() || entity.getAttackTarget() != null;
}
@Override
public void setAttackTarget(IEntityLivingBase living){
if(living == null)
entity.setAttackTarget(null);
else
entity.setAttackTarget(living.getMCEntity());
super.setAttackTarget(living);
}
@Override
public IEntityLivingBase getAttackTarget(){
IEntityLivingBase base = (IEntityLivingBase) NpcAPI.Instance().getIEntity(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(IEntity entity){
return this.entity.getEntitySenses().canSee(entity.getMCEntity());
}
public void playLivingSound() {
this.entity.playLivingSound();
}
public void spawnExplosionParticle()
{
this.entity.spawnExplosionParticle();
}
public void setMoveForward(float speed)
{
this.entity.setMoveForward(speed);
}
public void faceEntity(IEntity entity, float pitch, float yaw)
{
this.entity.faceEntity(entity.getMCEntity(), pitch, yaw);
}
public boolean canPickUpLoot()
{
return this.entity.canPickUpLoot();
}
public void setCanPickUpLoot(boolean pickUp)
{
this.entity.setCanPickUpLoot(pickUp);
}
public boolean isPersistent()
{
return this.entity.isNoDespawnRequired();
}
public void enablePersistence() {
this.entity.func_110163_bv();
}
public void setCustomNameTag(String text)
{
this.entity.setCustomNameTag(text);
}
public String getCustomNameTag()
{
return this.entity.getCustomNameTag();
}
public boolean hasCustomNameTag()
{
return this.entity.hasCustomNameTag();
}
public void setAlwaysRenderNameTag(boolean alwaysRender)
{
this.entity.setAlwaysRenderNameTag(alwaysRender);
}
public boolean getAlwaysRenderNameTag()
{
return this.entity.getAlwaysRenderNameTag();
}
public void clearLeashed(boolean sendPacket, boolean dropLeash)
{
this.entity.clearLeashed(sendPacket,dropLeash);
}
public boolean allowLeashing() {
return this.entity.allowLeashing();
}
public boolean getLeashed() {
return this.entity.getLeashed();
}
public IEntity getLeashedTo() {
return NpcAPI.Instance().getIEntity(entity.getLeashedToEntity());
}
public void setLeashedTo(IEntity entity, boolean sendPacket) {
this.entity.setLeashedToEntity(entity.getMCEntity(), sendPacket);
}
public boolean canBeSteered() {
return this.entity.canBeSteered();
}
public ScriptLiving(T entity) {
super(entity);
}
@Override
public void setRotation(float rotation){
public boolean isAttacking() {
return super.isAttacking() || entity.getAttackTarget() != null;
}
@Override
public void setAttackTarget(IEntityLivingBase living) {
if (living == null)
entity.setAttackTarget(null);
else
entity.setAttackTarget(living.getMCEntity());
super.setAttackTarget(living);
}
@Override
public IEntityLivingBase getAttackTarget() {
IEntityLivingBase base = (IEntityLivingBase) NpcAPI.Instance().getIEntity(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(IEntity entity) {
return this.entity.getEntitySenses().canSee(entity.getMCEntity());
}
public void playLivingSound() {
this.entity.playLivingSound();
}
public void spawnExplosionParticle() {
this.entity.spawnExplosionParticle();
}
public void setMoveForward(float speed) {
this.entity.setMoveForward(speed);
}
public void faceEntity(IEntity entity, float pitch, float yaw) {
this.entity.faceEntity(entity.getMCEntity(), pitch, yaw);
}
public boolean canPickUpLoot() {
return this.entity.canPickUpLoot();
}
public void setCanPickUpLoot(boolean pickUp) {
this.entity.setCanPickUpLoot(pickUp);
}
public boolean isPersistent() {
return this.entity.isNoDespawnRequired();
}
public void enablePersistence() {
this.entity.func_110163_bv();
}
public void setCustomNameTag(String text) {
this.entity.setCustomNameTag(text);
}
public String getCustomNameTag() {
return this.entity.getCustomNameTag();
}
public boolean hasCustomNameTag() {
return this.entity.hasCustomNameTag();
}
public void setAlwaysRenderNameTag(boolean alwaysRender) {
this.entity.setAlwaysRenderNameTag(alwaysRender);
}
public boolean getAlwaysRenderNameTag() {
return this.entity.getAlwaysRenderNameTag();
}
public void clearLeashed(boolean sendPacket, boolean dropLeash) {
this.entity.clearLeashed(sendPacket, dropLeash);
}
public boolean allowLeashing() {
return this.entity.allowLeashing();
}
public boolean getLeashed() {
return this.entity.getLeashed();
}
public IEntity getLeashedTo() {
return NpcAPI.Instance().getIEntity(entity.getLeashedToEntity());
}
public void setLeashedTo(IEntity entity, boolean sendPacket) {
this.entity.setLeashedToEntity(entity.getMCEntity(), sendPacket);
}
public boolean canBeSteered() {
return this.entity.canBeSteered();
}
@Override
public void setRotation(float rotation) {
super.setRotation(rotation);
entity.getLookHelper().setLookPosition(getX(), getY(), getZ(), rotation, getPitch());
}
@Override
public void setPitch(float rotation){
public void setPitch(float rotation) {
super.setPitch(rotation);
entity.getLookHelper().setLookPosition(getX(), getY(), getZ(), getRotation(), rotation);
}
@@ -21,357 +21,357 @@ import java.util.Collections;
public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T> implements IEntityLivingBase {
public ScriptLivingBase(T entity){
super(entity);
}
public ScriptLivingBase(T entity) {
super(entity);
}
/**
* @return The entity's current health
*/
public float getHealth(){
return entity.getHealth();
}
/**
* @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);
}
/**
* @param health The new health of this entity
*/
public void setHealth(float health) {
entity.setHealth(health);
}
public void hurt(float damage){
entity.attackEntityFrom(DamageSource.generic,damage);
}
public void hurt(float damage) {
entity.attackEntityFrom(DamageSource.generic, damage);
}
public void hurt(float damage, IEntity source) {
if(source.getType() == 1)//if player
entity.attackEntityFrom(new EntityDamageSource("player",source.getMCEntity()),damage);
else
entity.attackEntityFrom(new EntityDamageSource(source.getTypeName(),source.getMCEntity()),damage);
}
public void hurt(float damage, IEntity source) {
if (source.getType() == 1)//if player
entity.attackEntityFrom(new EntityDamageSource("player", source.getMCEntity()), damage);
else
entity.attackEntityFrom(new EntityDamageSource(source.getTypeName(), source.getMCEntity()), damage);
}
public void hurt(float damage, IDamageSource damageSource) {
entity.attackEntityFrom(damageSource.getMCDamageSource(),damage);
}
public void hurt(float damage, IDamageSource damageSource) {
entity.attackEntityFrom(damageSource.getMCDamageSource(), damage);
}
public void setMaxHurtTime(int time) {
entity.maxHurtResistantTime = time;
}
public void setMaxHurtTime(int time) {
entity.maxHurtResistantTime = time;
}
public int setMaxHurtTime() {
return entity.maxHurtResistantTime;
}
public int setMaxHurtTime() {
return entity.maxHurtResistantTime;
}
public double getMaxHealth(){
return entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).getAttributeValue();
}
public double getMaxHealth() {
return entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).getAttributeValue();
}
public double getFollowRange() {
return entity.getEntityAttribute(SharedMonsterAttributes.followRange).getAttributeValue();
}
public double getFollowRange() {
return entity.getEntityAttribute(SharedMonsterAttributes.followRange).getAttributeValue();
}
public double getKnockbackResistance() {
return entity.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue();
}
public double getKnockbackResistance() {
return entity.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue();
}
public double getSpeed() {
return entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
}
public double getSpeed() {
return entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
}
public double getMeleeStrength() {
return entity.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
}
public double getMeleeStrength() {
return entity.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
}
public void setMaxHealth(double health){
entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(health);
}
public void setMaxHealth(double health) {
entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(health);
}
public void setFollowRange(double range) {
entity.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(range);
}
public void setFollowRange(double range) {
entity.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(range);
}
public void setKnockbackResistance(double knockbackResistance) {
entity.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(knockbackResistance);
}
public void setKnockbackResistance(double knockbackResistance) {
entity.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(knockbackResistance);
}
public void setSpeed(double speed) {
entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(speed);
}
public void setSpeed(double speed) {
entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(speed);
}
public void setMeleeStrength(double attackDamage) {
entity.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackDamage);
}
public void setMeleeStrength(double attackDamage) {
entity.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackDamage);
}
/**
* @return Whether or not this entity is attacking something
*/
public boolean isAttacking(){
return entity.getAITarget() != null;
}
/**
* @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(IEntityLivingBase living){
if(living == null)
entity.setRevengeTarget(null);
else
entity.setRevengeTarget(living.getMCEntity());
}
/**
* @param living Entity which this entity will attack
*/
public void setAttackTarget(IEntityLivingBase living) {
if (living == null)
entity.setRevengeTarget(null);
else
entity.setRevengeTarget(living.getMCEntity());
}
/**
* @return The entity which this entity is attacking
*/
public IEntityLivingBase getAttackTarget(){
return (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity.getAITarget());
}
/**
* @return The entity which this entity is attacking
*/
public IEntityLivingBase getAttackTarget() {
return (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity.getAITarget());
}
public int getAttackTargetTime() {
return this.entity.func_142015_aE();
}
public int getAttackTargetTime() {
return this.entity.func_142015_aE();
}
public void setLastAttacker(IEntity p_130011_1_) {
this.entity.setLastAttacker(p_130011_1_.getMCEntity());
}
public void setLastAttacker(IEntity p_130011_1_) {
this.entity.setLastAttacker(p_130011_1_.getMCEntity());
}
public IEntity getLastAttacker() {
return NpcAPI.Instance().getIEntity(this.entity.getLastAttacker());
}
public IEntity getLastAttacker() {
return NpcAPI.Instance().getIEntity(this.entity.getLastAttacker());
}
public int getLastAttackerTime()
{
return this.entity.getLastAttackerTime();
}
public int getLastAttackerTime() {
return this.entity.getLastAttackerTime();
}
public boolean canBreatheUnderwater() {
return this.entity.canBreatheUnderwater();
}
@Override
public int getType(){
return EntityType.LIVING;
}
@Override
public boolean typeOf(int type){
return type == EntityType.LIVING || super.typeOf(type);
}
/**
* @param entity Entity to check
* @return Whether or not this entity can see the given entity
*/
public boolean canSeeEntity(IEntity entity){
return this.entity.canEntityBeSeen(entity.getMCEntity());
}
public IPos getLookVector() {
Vec3 lookVec = entity.getLookVec();
return NpcAPI.Instance().getIPos(lookVec.xCoord,lookVec.yCoord,lookVec.zCoord);
}
public IBlock getLookingAtBlock(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
return NpcAPI.Instance().getIBlock(getWorld(),getLookingAtPos(maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision));
}
public IBlock getLookingAtBlock(int maxDistance) {
return getLookingAtBlock(maxDistance, true, false, false);
}
public IPos getLookingAtPos(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
Vec3 lookVec = entity.getLookVec();
return getWorld().rayCastPos(
new double[] {entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ},
new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord},
maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision);
}
public IPos getLookingAtPos(int maxDistance) {
return getLookingAtPos(maxDistance, true, false, false);
}
public IEntity[] getLookingAtEntities(IEntity[] ignoreEntities, int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
Vec3 lookVec = entity.getLookVec();
double[] startPos = new double[] {entity.posX, entity.posY+entity.getEyeHeight(), entity.posZ};
double[] lookVector = new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord};
if (ignoreEntities == null) {
ignoreEntities = new IEntity<?>[0];
}
ArrayList<IEntity> entities = new ArrayList<>();
entities.add(this);
Collections.addAll(entities, ignoreEntities);
return getWorld().rayCastEntities(entities.toArray(new IEntity[0]),startPos,lookVector,maxDistance,offset,range,stopOnBlock,stopOnLiquid,stopOnCollision);
}
public IEntity[] getLookingAtEntities(int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
return this.getLookingAtEntities(null,maxDistance,offset,range,stopOnBlock,stopOnLiquid,stopOnCollision);
}
public IEntity[] getLookingAtEntities(int maxDistance, double offset, double range) {
return getLookingAtEntities(maxDistance,offset,range,true,false,true);
}
/**
* Expert use only
* @return Returns the minecraft entity object
*/
public T getMCEntity(){
return entity;
}
public T getMinecraftEntity(){
return getMCEntity();
}
public boolean canBreatheUnderwater() {
return this.entity.canBreatheUnderwater();
}
@Override
public float getRotation(){
public int getType() {
return EntityType.LIVING;
}
@Override
public boolean typeOf(int type) {
return type == EntityType.LIVING || super.typeOf(type);
}
/**
* @param entity Entity to check
* @return Whether or not this entity can see the given entity
*/
public boolean canSeeEntity(IEntity entity) {
return this.entity.canEntityBeSeen(entity.getMCEntity());
}
public IPos getLookVector() {
Vec3 lookVec = entity.getLookVec();
return NpcAPI.Instance().getIPos(lookVec.xCoord, lookVec.yCoord, lookVec.zCoord);
}
public IBlock getLookingAtBlock(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
return NpcAPI.Instance().getIBlock(getWorld(), getLookingAtPos(maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision));
}
public IBlock getLookingAtBlock(int maxDistance) {
return getLookingAtBlock(maxDistance, true, false, false);
}
public IPos getLookingAtPos(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
Vec3 lookVec = entity.getLookVec();
return getWorld().rayCastPos(
new double[]{entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ},
new double[]{lookVec.xCoord, lookVec.yCoord, lookVec.zCoord},
maxDistance, stopOnBlock, stopOnLiquid, stopOnCollision);
}
public IPos getLookingAtPos(int maxDistance) {
return getLookingAtPos(maxDistance, true, false, false);
}
public IEntity[] getLookingAtEntities(IEntity[] ignoreEntities, int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
Vec3 lookVec = entity.getLookVec();
double[] startPos = new double[]{entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ};
double[] lookVector = new double[]{lookVec.xCoord, lookVec.yCoord, lookVec.zCoord};
if (ignoreEntities == null) {
ignoreEntities = new IEntity<?>[0];
}
ArrayList<IEntity> entities = new ArrayList<>();
entities.add(this);
Collections.addAll(entities, ignoreEntities);
return getWorld().rayCastEntities(entities.toArray(new IEntity[0]), startPos, lookVector, maxDistance, offset, range, stopOnBlock, stopOnLiquid, stopOnCollision);
}
public IEntity[] getLookingAtEntities(int maxDistance, double offset, double range, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
return this.getLookingAtEntities(null, maxDistance, offset, range, stopOnBlock, stopOnLiquid, stopOnCollision);
}
public IEntity[] getLookingAtEntities(int maxDistance, double offset, double range) {
return getLookingAtEntities(maxDistance, offset, range, true, false, true);
}
/**
* Expert use only
*
* @return Returns the minecraft entity object
*/
public T getMCEntity() {
return entity;
}
public T getMinecraftEntity() {
return getMCEntity();
}
@Override
public float getRotation() {
return entity.renderYawOffset;
}
@Override
public void setRotation(float rotation){
public void setRotation(float rotation) {
entity.renderYawOffset = rotation;
}
/**
* Makes the entity swing its hand
*/
public void swingHand(){
entity.swingItem();
}
/**
* Makes the entity swing its hand
*/
public void swingHand() {
entity.swingItem();
}
/**
* Works the same as the <a href="http://minecraft.wiki/w/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){
/**
* Works the same as the <a href="http://minecraft.wiki/w/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;
return;
if(strength < 0)
strength = 0;
if (strength < 0)
strength = 0;
if(duration < 0)
duration = 0;
if (duration < 0)
duration = 0;
if(!Potion.potionTypes[effect].isInstant())
duration *= 20;
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
}
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();
}
/**
* 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();
}
/**
* @param effect Potion effect to check
* @return Returns -1 if its not active. Otherwise returns the strenght of the potion
* @since 1.7.10c
*/
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 IItemStack getHeldItem(){
return NpcAPI.Instance().getIItemStack(entity.getHeldItem());
}
/**
* Note not all Living Entities support this
*
* @return The item the entity is holding
* @since 1.7.10c
*/
public IItemStack getHeldItem() {
return NpcAPI.Instance().getIItemStack(entity.getHeldItem());
}
/**
* Note not all Living Entities support this
* @since 1.7.10c
* @param item The item to be set
*/
public void setHeldItem(IItemStack item){
entity.setCurrentItemOrArmor(0, item == null?null:item.getMCItemStack());
}
/**
* Note not all Living Entities support this
*
* @param item The item to be set
* @since 1.7.10c
*/
public void setHeldItem(IItemStack item) {
entity.setCurrentItemOrArmor(0, item == null ? null : item.getMCItemStack());
}
/**
* 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 IItemStack getArmor(int slot){
return NpcAPI.Instance().getIItemStack(entity.getEquipmentInSlot(slot + 1));
}
/**
* 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 IItemStack getArmor(int slot) {
return NpcAPI.Instance().getIItemStack(entity.getEquipmentInSlot(slot + 1));
}
/**
* 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, IItemStack item){
entity.setCurrentItemOrArmor(slot + 1, item == null?null:item.getMCItemStack());
}
/**
* Note not all Living Entities support this
*
* @param slot Slot of what armor piece to set, 0:boots, 1:pants, 2:body, 3:head
* @param item Item to be set
* @since 1.7.10c
*/
public void setArmor(int slot, IItemStack item) {
entity.setCurrentItemOrArmor(slot + 1, item == null ? null : item.getMCItemStack());
}
public boolean isChild() {
return this.entity.isChild();
}
public boolean isChild() {
return this.entity.isChild();
}
public void renderBrokenItemStack(IItemStack itemStack)
{
this.entity.renderBrokenItemStack(itemStack.getMCItemStack());
}
public void renderBrokenItemStack(IItemStack itemStack) {
this.entity.renderBrokenItemStack(itemStack.getMCItemStack());
}
public boolean isOnLadder()
{
return this.entity.isOnLadder();
}
public boolean isOnLadder() {
return this.entity.isOnLadder();
}
public int getTotalArmorValue()
{
return this.entity.getTotalArmorValue();
}
public int getTotalArmorValue() {
return this.entity.getTotalArmorValue();
}
public int getArrowCountInEntity() {
return this.entity.getArrowCountInEntity();
}
public int getArrowCountInEntity() {
return this.entity.getArrowCountInEntity();
}
public void setArrowCountInEntity(int count)
{
this.entity.setArrowCountInEntity(count);
}
public void setArrowCountInEntity(int count) {
this.entity.setArrowCountInEntity(count);
}
public void dismountEntity(IEntity entity) {
this.entity.dismountEntity(entity.getMCEntity());
}
public void dismountEntity(IEntity entity) {
this.entity.dismountEntity(entity.getMCEntity());
}
public void setAIMoveSpeed(float speed)
{
this.entity.setAIMoveSpeed(speed);
}
public void setAIMoveSpeed(float speed) {
this.entity.setAIMoveSpeed(speed);
}
public float getAIMoveSpeed() {
return this.entity.getAIMoveSpeed();
}
public float getAIMoveSpeed() {
return this.entity.getAIMoveSpeed();
}
public void setAbsorptionAmount(float amount)
{
this.entity.setAbsorptionAmount(amount);
}
public void setAbsorptionAmount(float amount) {
this.entity.setAbsorptionAmount(amount);
}
public float getAbsorptionAmount() {
return this.entity.getAbsorptionAmount();
}
public float getAbsorptionAmount() {
return this.entity.getAbsorptionAmount();
}
}
@@ -6,18 +6,18 @@ import noppes.npcs.scripted.constants.EntityType;
public class ScriptMonster<T extends EntityMob> extends ScriptLiving<T> implements IMonster {
public ScriptMonster(T entity) {
super(entity);
}
@Override
public int getType(){
return EntityType.MONSTER;
}
public ScriptMonster(T entity) {
super(entity);
}
@Override
public boolean typeOf(int type){
return type == EntityType.MONSTER?true:super.typeOf(type);
}
@Override
public int getType() {
return EntityType.MONSTER;
}
@Override
public boolean typeOf(int type) {
return type == EntityType.MONSTER ? true : super.typeOf(type);
}
}
File diff suppressed because it is too large. Load diff
@@ -8,267 +8,268 @@ import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.util.ValueUtil;
public class ScriptPixelmon<T extends EntityTameable> extends ScriptAnimal<T> implements IPixelmon {
private T pixelmon;
private NBTTagCompound compound = null;
public ScriptPixelmon(T pixelmon){
super(pixelmon);
this.pixelmon = pixelmon;
compound = new NBTTagCompound();
pixelmon.writeEntityToNBT(compound);
}
public ScriptPixelmon(T pixelmon, NBTTagCompound compound){
this(pixelmon);
this.compound = compound;
}
private T pixelmon;
private NBTTagCompound compound = null;
public boolean getIsShiny(){
return compound.getBoolean("IsShiny");
}
public ScriptPixelmon(T pixelmon) {
super(pixelmon);
this.pixelmon = pixelmon;
compound = new NBTTagCompound();
pixelmon.writeEntityToNBT(compound);
}
public void setIsShiny(boolean bo){
compound.setBoolean("IsShiny", bo);
pixelmon.readEntityFromNBT(compound);
}
public ScriptPixelmon(T pixelmon, NBTTagCompound compound) {
this(pixelmon);
this.compound = compound;
}
public int getLevel(){
return compound.getInteger("Level");
}
public boolean getIsShiny() {
return compound.getBoolean("IsShiny");
}
public void setLevel(int level){
compound.setInteger("Level", level);
pixelmon.readEntityFromNBT(compound);
}
public void setIsShiny(boolean bo) {
compound.setBoolean("IsShiny", bo);
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");
public int getLevel() {
return compound.getInteger("Level");
}
return -1;
}
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 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");
/**
* @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;
}
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 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");
/**
* @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;
}
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);
}
/**
* @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");
}
/**
* @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);
}
/**
* @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");
}
/**
* @return 0-255
*/
public int getHapiness() {
return compound.getInteger("Friendship");
}
/**
* @param value 0-255
*/
public void setHapiness(int value){
value = ValueUtil.clamp(value, 0, 255);
compound.setInteger("Friendship", value);
pixelmon.readEntityFromNBT(compound);
}
/**
* @param value 0-255
*/
public void setHapiness(int value) {
value = ValueUtil.clamp(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");
}
/**
* @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);
}
/**
* @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");
}
/**
* @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);
}
/**
* @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 String getNickname() {
return compound.getString("Nickname");
}
public boolean hasNickname(){
return !getNickname().isEmpty();
}
public boolean hasNickname() {
return !getNickname().isEmpty();
}
public void setNickname(String name){
compound.setString("Nickname", name);
pixelmon.readEntityFromNBT(compound);
}
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 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.clamp(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);
public void setMove(int slot, String move) {
slot = ValueUtil.clamp(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);
}
pixelmon.readEntityFromNBT(compound);
}
@Override
public int getType(){
public int getType() {
return EntityType.PIXELMON;
}
@Override
public boolean typeOf(int type){
public boolean typeOf(int type) {
return type == EntityType.PIXELMON || super.typeOf(type);
}
}
File diff suppressed because it is too large. Load diff
@@ -23,7 +23,7 @@ public class ScriptProjectile<T extends EntityProjectile> extends ScriptEntity<T
}
public void setItem(IItemStack item) {
if(item == null)
if (item == null)
entity.setThrownItem(null);
else
entity.setThrownItem(item.getMCItemStack());
@@ -46,7 +46,7 @@ public class ScriptProjectile<T extends EntityProjectile> extends ScriptEntity<T
}
public void setHeading(IEntity entity) {
setHeading(entity.getX(), entity.getMCEntity().boundingBox.minY + (double)(entity.getHeight() / 2.0F), entity.getZ());
setHeading(entity.getX(), entity.getMCEntity().boundingBox.minY + (double) (entity.getHeight() / 2.0F), entity.getZ());
}
public void setHeading(double x, double y, double z) {
@@ -63,9 +63,9 @@ public class ScriptProjectile<T extends EntityProjectile> extends ScriptEntity<T
entity.prevRotationYaw = entity.rotationYaw = yaw;
entity.prevRotationPitch = entity.rotationPitch = pitch;
double varX = (double)(-MathHelper.sin(yaw / 180.0F * (float)Math.PI) * MathHelper.cos(pitch / 180.0F * (float)Math.PI));
double varZ = (double)(MathHelper.cos(yaw / 180.0F * (float)Math.PI) * MathHelper.cos(pitch / 180.0F * (float)Math.PI));
double varY = (double)(-MathHelper.sin(pitch / 180.0F * (float)Math.PI));
double varX = (double) (-MathHelper.sin(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(pitch / 180.0F * (float) Math.PI));
double varZ = (double) (MathHelper.cos(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(pitch / 180.0F * (float) Math.PI));
double varY = (double) (-MathHelper.sin(pitch / 180.0F * (float) Math.PI));
float acc = (float) (20.0F - Math.floor(entity.accuracy / 5.0F));
entity.setThrowableHeading(varX, varY, varZ, -pitch, acc);
@@ -75,7 +75,7 @@ public class ScriptProjectile<T extends EntityProjectile> extends ScriptEntity<T
return EntityType.PROJECTILE;
}
public boolean typeOf(int type){
public boolean typeOf(int type) {
return type == EntityType.PROJECTILE || super.typeOf(type);
}
@@ -84,10 +84,10 @@ public class ScriptProjectile<T extends EntityProjectile> extends ScriptEntity<T
}
public void enableEvents() {
if(ScriptContainer.Current == null)
if (ScriptContainer.Current == null)
throw new CustomNPCsException("Can only be called during scripts");
if(!entity.scripts.contains(ScriptContainer.Current)) {
if (!entity.scripts.contains(ScriptContainer.Current)) {
entity.scripts.add(ScriptContainer.Current);
}
}
@@ -8,9 +8,9 @@ import noppes.npcs.scripted.constants.EntityType;
public class ScriptVillager<T extends EntityVillager> extends ScriptLiving<T> implements IVillager {
public ScriptVillager(T entity) {
super(entity);
}
public ScriptVillager(T entity) {
super(entity);
}
@Override
public int getProfession() {
@@ -23,18 +23,17 @@ public class ScriptVillager<T extends EntityVillager> extends ScriptLiving<T> im
}
@Override
public IEntityLivingBase getCustomer()
{
public IEntityLivingBase getCustomer() {
return (IEntityLivingBase) NpcAPI.Instance().getPlayer(entity.getCustomer().getCommandSenderName());
}
@Override
public int getType(){
return EntityType.VILLAGER;
}
@Override
public int getType() {
return EntityType.VILLAGER;
}
@Override
public boolean typeOf(int type){
public boolean typeOf(int type) {
return type == EntityType.VILLAGER || super.typeOf(type);
}
@@ -68,7 +68,7 @@ public abstract class AnimationEvent extends CustomNPCsEvent implements IAnimati
public FrameEvent(IAnimation animation, IFrame frame) {
super(animation);
this.frame = frame;
this.index = ((Animation)this.getAnimation()).frames.indexOf((Frame) this.frame);
this.index = ((Animation) this.getAnimation()).frames.indexOf((Frame) this.frame);
}
@Override
@@ -13,7 +13,8 @@ import noppes.npcs.scripted.NpcAPI;
public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
public IBlock block;
public BlockEvent(IBlock block){
public BlockEvent(IBlock block) {
this.block = block;
}
@@ -26,10 +27,11 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
* fallenUpon
*/
@Cancelable
public static class EntityFallenUponEvent extends BlockEvent implements IBlockEvent.EntityFallenUponEvent{
public static class EntityFallenUponEvent extends BlockEvent implements IBlockEvent.EntityFallenUponEvent {
public final IEntity entity;
public float distanceFallen;
public EntityFallenUponEvent(IBlock block, Entity entity, float distance){
public EntityFallenUponEvent(IBlock block, Entity entity, float distance) {
super(block);
this.distanceFallen = distance;
this.entity = NpcAPI.Instance().getIEntity(entity);
@@ -55,7 +57,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
* interact
*/
@Cancelable
public static class InteractEvent extends BlockEvent implements IBlockEvent.InteractEvent{
public static class InteractEvent extends BlockEvent implements IBlockEvent.InteractEvent {
public final IPlayer player;
public final float hitX, hitY, hitZ;
@@ -106,8 +108,9 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
/**
* redstone
*/
public static class RedstoneEvent extends BlockEvent implements IBlockEvent.RedstoneEvent{
public static class RedstoneEvent extends BlockEvent implements IBlockEvent.RedstoneEvent {
public final int prevPower, power;
public RedstoneEvent(IBlock block, int prevPower, int power) {
super(block);
this.power = power;
@@ -134,7 +137,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
/**
* broken
*/
public static class BreakEvent extends BlockEvent implements IBlockEvent.BreakEvent{
public static class BreakEvent extends BlockEvent implements IBlockEvent.BreakEvent {
public BreakEvent(IBlock block) {
super(block);
}
@@ -149,7 +152,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
* exploded
*/
@Cancelable
public static class ExplodedEvent extends BlockEvent implements IBlockEvent.ExplodedEvent{
public static class ExplodedEvent extends BlockEvent implements IBlockEvent.ExplodedEvent {
public ExplodedEvent(IBlock block) {
super(block);
}
@@ -163,7 +166,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
/**
* rainFilled
*/
public static class RainFillEvent extends BlockEvent implements IBlockEvent.RainFillEvent{
public static class RainFillEvent extends BlockEvent implements IBlockEvent.RainFillEvent {
public RainFillEvent(IBlock block) {
super(block);
}
@@ -177,8 +180,9 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
/**
* neighborChanged
*/
public static class NeighborChangedEvent extends BlockEvent implements IBlockEvent.NeighborChangedEvent{
public static class NeighborChangedEvent extends BlockEvent implements IBlockEvent.NeighborChangedEvent {
public final IPos changedPos;
public NeighborChangedEvent(IBlock block, IPos changedPos) {
super(block);
this.changedPos = changedPos;
@@ -198,7 +202,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
/**
* init
*/
public static class InitEvent extends BlockEvent implements IBlockEvent.InitEvent{
public static class InitEvent extends BlockEvent implements IBlockEvent.InitEvent {
public InitEvent(IBlock block) {
super(block);
}
@@ -212,7 +216,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
/**
* tick
*/
public static class UpdateEvent extends BlockEvent implements IBlockEvent.UpdateEvent{
public static class UpdateEvent extends BlockEvent implements IBlockEvent.UpdateEvent {
public UpdateEvent(IBlock block) {
super(block);
}
@@ -226,8 +230,9 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
/**
* clicked
*/
public static class ClickedEvent extends BlockEvent implements IBlockEvent.ClickedEvent{
public static class ClickedEvent extends BlockEvent implements IBlockEvent.ClickedEvent {
public final IPlayer player;
public ClickedEvent(IBlock block, EntityPlayer player) {
super(block);
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
@@ -248,8 +253,9 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
* harvested
*/
@Cancelable
public static class HarvestedEvent extends BlockEvent implements IBlockEvent.HarvestedEvent{
public static class HarvestedEvent extends BlockEvent implements IBlockEvent.HarvestedEvent {
public final IPlayer player;
public HarvestedEvent(IBlock block, EntityPlayer player) {
super(block);
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
@@ -269,8 +275,9 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
/**
* collide
*/
public static class CollidedEvent extends BlockEvent implements IBlockEvent.CollidedEvent{
public static class CollidedEvent extends BlockEvent implements IBlockEvent.CollidedEvent {
public final IEntity entity;
public CollidedEvent(IBlock block, Entity entity) {
super(block);
this.entity = NpcAPI.Instance().getIEntity(entity);
@@ -290,7 +297,7 @@ public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
/**
* timer
*/
public static class TimerEvent extends BlockEvent implements IBlockEvent.TimerEvent{
public static class TimerEvent extends BlockEvent implements IBlockEvent.TimerEvent {
public final int id;
public TimerEvent(IBlock block, int id) {
@@ -151,7 +151,7 @@ public class CustomGuiEvent extends CustomNPCsEvent implements ICustomGuiEvent {
public final int clickType;
public SlotClickEvent(IPlayer player, ICustomGui gui, int slotId, IItemSlot slot, IItemStack stack, int dragType, int clickType) {
super(player,gui);
super(player, gui);
this.slotId = slotId;
this.stack = stack;
this.dragType = dragType;
@@ -22,11 +22,13 @@ public class CustomNPCsEvent extends Event implements ICustomNPCsEvent {
public CustomNPCsEvent() {
}
public void setCancelled(boolean bo){
public void setCancelled(boolean bo) {
this.setCanceled(bo);
}
public boolean isCancelled(){return this.isCanceled();}
public boolean isCancelled() {
return this.isCanceled();
}
@Cancelable
public static class CNPCNaturalSpawnEvent extends CustomNPCsEvent implements ICustomNPCsEvent.CNPCNaturalSpawnEvent {
@@ -95,7 +97,7 @@ public class CustomNPCsEvent extends Event implements ICustomNPCsEvent {
public String[] args;
public String replyMessage = "";
public ScriptedCommandEvent(IWorld world, IPos pos, String senderName, String id, String[] args){
public ScriptedCommandEvent(IWorld world, IPos pos, String senderName, String id, String[] args) {
this.world = world;
this.pos = pos;
this.senderName = senderName;
@@ -10,7 +10,7 @@ public class DialogEvent extends CustomNPCsEvent implements IDialogEvent {
public final IDialog dialog;
public final IPlayer player;
public DialogEvent(IPlayer player, IDialog dialog){
public DialogEvent(IPlayer player, IDialog dialog) {
this.dialog = dialog;
this.player = player;
}
@@ -51,7 +51,7 @@ public class DialogEvent extends CustomNPCsEvent implements IDialogEvent {
}
public static class DialogClosed extends DialogEvent implements IDialogEvent.DialogClosed {
public DialogClosed(IPlayer player, IDialog dialog){
public DialogClosed(IPlayer player, IDialog dialog) {
super(player, dialog);
}
@@ -10,7 +10,7 @@ public class FactionEvent extends CustomNPCsEvent implements IFactionEvent {
public final IFaction faction;
public final IPlayer player;
public FactionEvent(IPlayer player, IFaction faction){
public FactionEvent(IPlayer player, IFaction faction) {
this.faction = faction;
this.player = player;
}
@@ -61,7 +61,7 @@ public class ForgeEvent extends CustomNPCsEvent implements IForgeEvent {
public static class InitEvent extends ForgeEvent implements IForgeEvent.InitEvent {
public InitEvent() {
super((Event)null);
super((Event) null);
}
public String getHookName() {
@@ -95,7 +95,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
public static class SpawnEvent extends ItemEvent implements IItemEvent.SpawnEvent {
public final IEntity entity;
public SpawnEvent(IItemCustomizable item, IEntity entity){
public SpawnEvent(IItemCustomizable item, IEntity entity) {
super(item);
this.entity = entity;
}
@@ -208,7 +208,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
public final IPlayer player;
public final int duration;
public StartUsingItem(IItemCustomizable item, IPlayer player, int duration){
public StartUsingItem(IItemCustomizable item, IPlayer player, int duration) {
super(item);
this.player = player;
this.duration = duration;
@@ -232,7 +232,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
public final IPlayer player;
public final int duration;
public UsingItem(IItemCustomizable item, IPlayer player, int duration){
public UsingItem(IItemCustomizable item, IPlayer player, int duration) {
super(item);
this.player = player;
this.duration = duration;
@@ -256,7 +256,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
public final IPlayer player;
public final int duration;
public StopUsingItem(IItemCustomizable item, IPlayer player, int duration){
public StopUsingItem(IItemCustomizable item, IPlayer player, int duration) {
super(item);
this.player = player;
this.duration = duration;
@@ -280,7 +280,7 @@ public class ItemEvent extends CustomNPCsEvent implements IItemEvent {
public final IPlayer player;
public final int duration;
public FinishUsingItem(IItemCustomizable item, IPlayer player, int duration){
public FinishUsingItem(IItemCustomizable item, IPlayer player, int duration) {
super(item);
this.player = player;
this.duration = duration;
@@ -43,7 +43,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
return EnumScriptType.TIMER.function;
}
public int getId(){
public int getId() {
return id;
}
}
@@ -92,38 +92,38 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
/**
* @return The source of the damage
*/
public IEntity getSource(){
public IEntity getSource() {
return source;
}
public IDamageSource getDamageSource(){
public IDamageSource getDamageSource() {
return damageSource;
}
/**
* @return Returns the damage value
*/
public float getDamage(){
public float getDamage() {
return damage;
}
/**
* @param damage The new damage value
*/
public void setDamage(float damage){
public void setDamage(float damage) {
this.damage = damage;
}
public void setClearTarget(boolean bo){
public void setClearTarget(boolean bo) {
this.clearTarget = bo;
this.clear = bo;
}
public boolean getClearTarget(){
public boolean getClearTarget() {
return clearTarget && clear;
}
public String getType(){
public String getType() {
return damageSource.getMCDamageSource().damageType;
}
}
@@ -135,7 +135,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
public RangedLaunchedEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
super(npc);
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
this.damage = damage;
}
@@ -147,14 +147,14 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
* @return The source of the damage
* @deprecated
*/
public IEntityLivingBase getTarget(){
public IEntityLivingBase getTarget() {
return target;
}
/**
* @param damage The new damage value
*/
public void setDamage(float damage){
public void setDamage(float damage) {
this.damage = damage;
}
@@ -162,14 +162,14 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
/**
* @return Returns the damage value
*/
public float getDamage(){
public float getDamage() {
return damage;
}
/**
* @return Returns the damage type
*/
public boolean isRange(){
public boolean isRange() {
return true;
}
}
@@ -181,7 +181,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
public MeleeAttackEvent(ICustomNpc npc, float damage, EntityLivingBase target) {
super(npc);
this.target = (IEntityLivingBase)NpcAPI.Instance().getIEntity(target);
this.target = (IEntityLivingBase) NpcAPI.Instance().getIEntity(target);
this.damage = damage;
}
@@ -193,7 +193,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
* @return The source of the damage
* @deprecated
*/
public IEntityLivingBase getTarget(){
public IEntityLivingBase getTarget() {
return target;
}
@@ -201,21 +201,21 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
/**
* @return Returns the damage value
*/
public float getDamage(){
public float getDamage() {
return damage;
}
/**
* @param damage The new damage value
*/
public void setDamage(float damage){
public void setDamage(float damage) {
this.damage = damage;
}
/**
* @return Returns the damage type
*/
public boolean isRange(){
public boolean isRange() {
return false;
}
}
@@ -226,7 +226,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
public SwingEvent(ICustomNpc npc, ItemStack itemStack) {
super(npc);
this.itemStack = itemStack == null ? null : (IItemStack)NpcAPI.Instance().getIItemStack(itemStack);
this.itemStack = itemStack == null ? null : (IItemStack) NpcAPI.Instance().getIItemStack(itemStack);
}
public String getHookName() {
@@ -246,7 +246,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
public KilledEntityEvent(ICustomNpc npc, EntityLivingBase entity) {
super(npc);
this.entity = (IEntityLivingBase)NpcAPI.Instance().getIEntity(entity);
this.entity = (IEntityLivingBase) NpcAPI.Instance().getIEntity(entity);
}
public String getHookName() {
@@ -288,16 +288,18 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
/**
* @return The source of the damage
*/
public IEntity getSource(){
public IEntity getSource() {
return source;
}
public IDamageSource getDamageSource() { return damageSource; }
public IDamageSource getDamageSource() {
return damageSource;
}
/**
* @return Returns the damage type
*/
public String getType(){
public String getType() {
return damageSource.getMCDamageSource().damageType;
}
@@ -324,7 +326,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
public InteractEvent(ICustomNpc npc, EntityPlayer player) {
super(npc);
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
}
public String getHookName() {
@@ -345,7 +347,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
super(npc);
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
this.id = id;
this.optionId = optionId;
this.dialogObj = dialog;
@@ -374,7 +376,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
/**
* @deprecated
*/
public boolean isClosing(){
public boolean isClosing() {
return true;
}
}
@@ -387,7 +389,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
public DialogClosedEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) {
super(npc);
this.player = (IPlayer)NpcAPI.Instance().getIEntity(player);
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
this.id = id;
this.optionId = optionId;
this.dialogObj = dialog;
@@ -416,7 +418,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
/**
* @deprecated
*/
public boolean isClosing(){
public boolean isClosing() {
return true;
}
}
@@ -458,14 +460,14 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent {
return EnumScriptType.TARGET.function;
}
public void setTarget(IEntityLivingBase entity){
public void setTarget(IEntityLivingBase entity) {
this.entity = entity;
}
/**
* @return The target source
*/
public IEntityLivingBase getTarget(){
public IEntityLivingBase getTarget() {
return entity;
}
}
@@ -117,7 +117,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
public final int mouseWheel;
public final boolean buttonDown;
public MouseClickedEvent(IPlayer player, int button, int mouseWheel, boolean buttonDown, boolean isCtrlPressed, boolean isAltPressed, boolean isShiftPressed, boolean isMetaPressed, int[] heldKeys){
public MouseClickedEvent(IPlayer player, int button, int mouseWheel, boolean buttonDown, boolean isCtrlPressed, boolean isAltPressed, boolean isShiftPressed, boolean isMetaPressed, int[] heldKeys) {
super(player);
this.button = button;
this.mouseWheel = mouseWheel;
@@ -234,7 +234,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
public final int fromDim;
public final int toDim;
public ChangedDimension(IPlayer player, int fromDim, int toDim){
public ChangedDimension(IPlayer player, int fromDim, int toDim) {
super(player);
this.fromDim = fromDim;
this.toDim = toDim;
@@ -376,7 +376,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
public static class FallEvent extends PlayerEvent implements IPlayerEvent.FallEvent {
public final float distance;
public FallEvent(IPlayer player, float distance){
public FallEvent(IPlayer player, float distance) {
super(player);
this.distance = distance;
}
@@ -391,7 +391,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
}
public static class JumpEvent extends PlayerEvent implements IPlayerEvent.JumpEvent {
public JumpEvent(IPlayer player){
public JumpEvent(IPlayer player) {
super(player);
}
@@ -667,7 +667,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
public final IItemStack item;
public final int duration;
public StartUsingItem(IPlayer player, ItemStack item, int duration){
public StartUsingItem(IPlayer player, ItemStack item, int duration) {
super(player);
this.item = NpcAPI.Instance().getIItemStack(item);
@@ -692,7 +692,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
public final IItemStack item;
public final int duration;
public UsingItem(IPlayer player, ItemStack item, int duration){
public UsingItem(IPlayer player, ItemStack item, int duration) {
super(player);
this.item = NpcAPI.Instance().getIItemStack(item);
@@ -717,7 +717,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
public final IItemStack item;
public final int duration;
public StopUsingItem(IPlayer player, ItemStack item, int duration){
public StopUsingItem(IPlayer player, ItemStack item, int duration) {
super(player);
this.item = NpcAPI.Instance().getIItemStack(item);
@@ -741,7 +741,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
public final IItemStack item;
public final int duration;
public FinishUsingItem(IPlayer player, ItemStack item, int duration){
public FinishUsingItem(IPlayer player, ItemStack item, int duration) {
super(player);
this.item = NpcAPI.Instance().getIItemStack(item);
@@ -973,6 +973,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
}
}
public static class Ticked extends PlayerEvent.EffectEvent implements IPlayerEvent.EffectEvent.Ticked {
public Ticked(IPlayer player, IPlayerEffect statusEffect) {
@@ -980,6 +981,7 @@ public class PlayerEvent extends CustomNPCsEvent implements IPlayerEvent {
}
}
public static class Removed extends PlayerEvent.EffectEvent implements IPlayerEvent.EffectEvent.Removed {
private final ExpirationType type;
@@ -34,7 +34,7 @@ public class ProjectileEvent extends CustomNPCsEvent implements IProjectileEvent
/**
* projectileImpact
*/
public static class ImpactEvent extends ProjectileEvent implements IProjectileEvent.ImpactEvent {
public static class ImpactEvent extends ProjectileEvent implements IProjectileEvent.ImpactEvent {
/**
* 0:entity, 1:block
*/
@@ -52,13 +52,13 @@ public class ProjectileEvent extends CustomNPCsEvent implements IProjectileEvent
}
public IEntity getEntity() {
if(type == 0)
if (type == 0)
return (IEntity) target;
return null;
}
public IBlock getBlock() {
if(type == 1)
if (type == 1)
return (IBlock) target;
return null;
}
@@ -135,8 +135,8 @@ public class ScriptGuiButton extends ScriptGuiComponent implements IButton {
nbt.setIntArray("size", new int[]{this.width, this.height});
}
nbt.setFloat("scale",this.scale);
nbt.setBoolean("enabled",this.enabled);
nbt.setFloat("scale", this.scale);
nbt.setBoolean("enabled", this.enabled);
nbt.setString("label", this.label);
if (this.hasTexture()) {
@@ -90,14 +90,14 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent {
nbt.setInteger("id", this.id);
nbt.setIntArray("pos", new int[]{this.posX, this.posY});
nbt.setInteger("color", this.color);
nbt.setFloat("alpha",this.alpha);
nbt.setFloat("rotation",this.rotation);
nbt.setFloat("alpha", this.alpha);
nbt.setFloat("rotation", this.rotation);
if (this.hoverText != null) {
NBTTagList list = new NBTTagList();
String[] var3 = this.hoverText;
int var4 = var3.length;
for(int var5 = 0; var5 < var4; ++var5) {
for (int var5 = 0; var5 < var4; ++var5) {
String s = var3[var5];
if (s != null && !s.isEmpty()) {
list.appendTag(new NBTTagString(s));
@@ -123,7 +123,7 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent {
NBTTagList list = nbt.getTagList("hover", 8);
String[] hoverText = new String[list.tagCount()];
for(int i = 0; i < list.tagCount(); ++i) {
for (int i = 0; i < list.tagCount(); ++i) {
hoverText[i] = list.getStringTagAt(i);
}
@@ -134,7 +134,7 @@ public abstract class ScriptGuiComponent implements ICustomGuiComponent {
}
public static ScriptGuiComponent createFromNBT(NBTTagCompound nbt) {
switch(nbt.getInteger("type")) {
switch (nbt.getInteger("type")) {
case 0:
return (new ScriptGuiButton()).fromNBT(nbt);
case 1:
@@ -60,11 +60,11 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
return this;
}
public boolean getShadow(){
public boolean getShadow() {
return this.shadow;
}
public void setShadow(boolean shadow){
public void setShadow(boolean shadow) {
this.shadow = shadow;
}
@@ -77,7 +77,7 @@ public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
nbt.setString("label", this.label);
nbt.setIntArray("size", new int[]{this.width, this.height});
nbt.setFloat("scale", this.scale);
nbt.setBoolean("shadow",this.shadow);
nbt.setBoolean("shadow", this.shadow);
return nbt;
}
@@ -10,10 +10,10 @@ public class ScriptGuiLine extends ScriptGuiComponent implements ILine {
int y2;
int thickness = 2;
public ScriptGuiLine(){
public ScriptGuiLine() {
}
public ScriptGuiLine(int id, int x1, int y1, int x2, int y2){
public ScriptGuiLine(int id, int x1, int y1, int x2, int y2) {
this.setPos(x1, y1);
this.setID(id);
this.hoverText = new String[]{""};
@@ -24,7 +24,7 @@ public class ScriptGuiLine extends ScriptGuiComponent implements ILine {
this.y2 = y2;
}
public ScriptGuiLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){
public ScriptGuiLine(int id, int x1, int y1, int x2, int y2, int color, int thickness) {
this.setPos(x1, y1);
this.setID(id);
this.hoverText = new String[]{""};
@@ -44,11 +44,11 @@ public class ScriptGuiLine extends ScriptGuiComponent implements ILine {
public NBTTagCompound toNBT(NBTTagCompound nbt) {
super.toNBT(nbt);
nbt.setInteger("X1",x1);
nbt.setInteger("Y1",y1);
nbt.setInteger("X2",x2);
nbt.setInteger("Y2",y2);
nbt.setInteger("Thickness",thickness);
nbt.setInteger("X1", x1);
nbt.setInteger("Y1", y1);
nbt.setInteger("X2", x2);
nbt.setInteger("Y2", y2);
nbt.setInteger("Thickness", thickness);
return nbt;
}
@@ -64,35 +64,43 @@ public class ScriptGuiLine extends ScriptGuiComponent implements ILine {
return this;
}
public int getX1(){
public int getX1() {
return this.x1;
}
public int getY1(){
public int getY1() {
return this.y1;
}
public int getX2(){
public int getX2() {
return this.x2;
}
public int getY2(){
public int getY2() {
return this.y2;
}
public int getThickness(){
public int getThickness() {
return this.thickness;
}
public void setX1(int x1){
public void setX1(int x1) {
this.x1 = x1;
}
public void setY1(int y1){
public void setY1(int y1) {
this.y1 = y1;
}
public void setX2(int x2){
public void setX2(int x2) {
this.x2 = x2;
}
public void setY2(int y2){
public void setY2(int y2) {
this.y2 = y2;
}
public void setThickness(int thickness){
public void setThickness(int thickness) {
this.thickness = thickness;
}
}
@@ -78,7 +78,7 @@ public class ScriptGuiScroll extends ScriptGuiComponent implements IScroll {
String[] var3 = this.list;
int var4 = var3.length;
for(int var5 = 0; var5 < var4; ++var5) {
for (int var5 = 0; var5 < var4; ++var5) {
String s = var3[var5];
list.appendTag(new NBTTagString(s));
}
@@ -98,7 +98,7 @@ public class ScriptGuiScroll extends ScriptGuiComponent implements IScroll {
NBTTagList tagList = nbt.getTagList("list", 8);
String[] list = new String[tagList.tagCount()];
for(int i = 0; i < tagList.tagCount(); ++i) {
for (int i = 0; i < tagList.tagCount(); ++i) {
list[i] = tagList.getStringTagAt(i);
}
@@ -79,10 +79,10 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus
this.loaded = true;
}
if(!this.isEnabled())
if (!this.isEnabled())
return;
if(ScriptController.Instance.lastLoaded > lastInited){
if (ScriptController.Instance.lastLoaded > lastInited) {
lastInited = ScriptController.Instance.lastLoaded;
if (!Objects.equals(hookName, EnumScriptType.INIT.function)) {
EventHooks.onScriptItemInit(this);
@@ -92,7 +92,7 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus
for (int i = 0; i < this.scripts.size(); i++) {
ScriptContainer script = this.scripts.get(i);
if (!this.errored.contains(i)) {
if(script == null || script.errored || !script.hasCode())
if (script == null || script.errored || !script.hasCode())
continue;
script.run(hookName, event);
@@ -152,35 +152,35 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus
saveItemData();
}
public int getArmorType(){
public int getArmorType() {
return this.armorType;
}
public void setIsTool(boolean isTool){
public void setIsTool(boolean isTool) {
this.isTool = isTool;
saveItemData();
}
public boolean isTool(){
public boolean isTool() {
return this.isTool;
}
public void setIsNormalItem(boolean normalItem){
public void setIsNormalItem(boolean normalItem) {
this.isNormalItem = normalItem;
saveItemData();
}
public boolean isNormalItem(){
public boolean isNormalItem() {
return this.isNormalItem;
}
public void setDigSpeed(int digSpeed){
public void setDigSpeed(int digSpeed) {
this.digSpeed = digSpeed;
saveItemData();
}
public int getDigSpeed(){
public int getDigSpeed() {
return this.digSpeed;
}
@@ -198,11 +198,11 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus
}
public void setDurabilityValue(float value) {
this.durabilityValue = (double)value;
this.durabilityValue = (double) value;
saveItemData();
}
public int getMaxItemUseDuration(){
public int getMaxItemUseDuration() {
return this.maxItemUseDuration;
}
@@ -220,11 +220,11 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus
return this.itemUseAction;
}
public int getEnchantability(){
public int getEnchantability() {
return this.enchantability;
}
public void setEnchantability(int enchantability){
public void setEnchantability(int enchantability) {
this.enchantability = enchantability;
saveItemData();
}
@@ -258,8 +258,8 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus
public NBTTagCompound getItemNBT(NBTTagCompound compound) {
super.getItemNBT(compound);
compound.setDouble("DurabilityValue",this.durabilityValue);
compound.setInteger("MaxStackSize",this.stackSize);
compound.setDouble("DurabilityValue", this.durabilityValue);
compound.setInteger("MaxStackSize", this.stackSize);
compound.setBoolean("IsTool", this.isTool);
compound.setBoolean("IsNormalItem", this.isNormalItem);
@@ -35,8 +35,8 @@ public abstract class ScriptCustomizableItem extends ScriptItemStack implements
return this.itemDisplay.texture == null ? "" : this.itemDisplay.texture;
}
public void setTexture(String texture){
if(texture == null)
public void setTexture(String texture) {
if (texture == null)
texture = "";
this.itemDisplay.texture = texture;
saveItemData();
@@ -70,28 +70,28 @@ public abstract class ScriptCustomizableItem extends ScriptItemStack implements
}
public void setRotation(Float rotationX, Float rotationY, Float rotationZ){
public void setRotation(Float rotationX, Float rotationY, Float rotationZ) {
this.itemDisplay.rotationX = rotationX;
this.itemDisplay.rotationY = rotationY;
this.itemDisplay.rotationZ = rotationZ;
saveItemData();
}
public void setRotationRate(Float rotationXRate, Float rotationYRate, Float rotationZRate){
public void setRotationRate(Float rotationXRate, Float rotationYRate, Float rotationZRate) {
this.itemDisplay.rotationXRate = rotationXRate;
this.itemDisplay.rotationYRate = rotationYRate;
this.itemDisplay.rotationZRate = rotationZRate;
saveItemData();
}
public void setScale(Float scaleX, Float scaleY, Float scaleZ){
public void setScale(Float scaleX, Float scaleY, Float scaleZ) {
this.itemDisplay.scaleX = scaleX;
this.itemDisplay.scaleY = scaleY;
this.itemDisplay.scaleZ = scaleZ;
saveItemData();
}
public void setTranslate(Float translateX, Float translateY, Float translateZ){
public void setTranslate(Float translateX, Float translateY, Float translateZ) {
this.itemDisplay.translateX = translateX;
this.itemDisplay.translateY = translateY;
this.itemDisplay.translateZ = translateZ;
@@ -167,7 +167,7 @@ public abstract class ScriptCustomizableItem extends ScriptItemStack implements
public void loadItemData() {
NBTTagCompound c = this.item.getTagCompound();
if (c != null && !c.getCompoundTag("ItemData").hasNoTags()){
if (c != null && !c.getCompoundTag("ItemData").hasNoTags()) {
this.setItemNBT(c.getCompoundTag("ItemData"));
}
}
@@ -19,11 +19,11 @@ public class ScriptItemBook extends ScriptItemStack implements IItemBook {
List<String> list = new ArrayList<String>();
NBTTagList pages = this.getTag().getTagList("pages", 8);
for(int i = 0; i < pages.tagCount(); ++i) {
for (int i = 0; i < pages.tagCount(); ++i) {
list.add(pages.getStringTagAt(i));
}
return (String[])list.toArray(new String[list.size()]);
return (String[]) list.toArray(new String[list.size()]);
}
public void setText(String[] pages) {
@@ -32,7 +32,7 @@ public class ScriptItemBook extends ScriptItemStack implements IItemBook {
String[] var3 = pages;
int var4 = pages.length;
for(int var5 = 0; var5 < var4; ++var5) {
for (int var5 = 0; var5 < var4; ++var5) {
String page = var3[var5];
list.appendTag(new NBTTagString(page));
}
@@ -46,7 +46,7 @@ public class ScriptItemBook extends ScriptItemStack implements IItemBook {
}
public void setAuthor(String author) {
this.getTag().setString("author",author);
this.getTag().setString("author", author);
}
public String getTitle() {
@@ -54,7 +54,7 @@ public class ScriptItemBook extends ScriptItemStack implements IItemBook {
}
public void setTitle(String title) {
this.getTag().setString("title",title);
this.getTag().setString("title", title);
}
private NBTTagCompound getTag() {
@@ -28,301 +28,301 @@ import java.util.List;
import java.util.Map;
public class ScriptItemStack implements IItemStack {
public ItemStack item;
public ItemStack item;
public ScriptItemStack(ItemStack item){
this.item = item;
}
public ScriptItemStack(ItemStack item) {
this.item = item;
}
public int getType() {
if (this.item.getItem() instanceof IPlantable) {
return 5;
} else {
return this.item.getItem() instanceof ItemSword ? 4 : 0;
}
}
public int getType() {
if (this.item.getItem() instanceof IPlantable) {
return 5;
} else {
return this.item.getItem() instanceof ItemSword ? 4 : 0;
}
}
/**
* @return The minecraft name for this item
*/
public String getName(){
return Item.itemRegistry.getNameForObject(item.getItem());
}
/**
* @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 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();
}
/**
* @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);
}
/**
* @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 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);
}
/**
* @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);
}
public int getMaxStackSize() {
return this.item.getMaxStackSize();
}
public int getMaxStackSize() {
return this.item.getMaxStackSize();
}
/**
* @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;
}
/**
* @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();
}
/**
* @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 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 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){
if(item.stackTagCompound == null)
return false;
return getTag().hasKey(key);
}
/**
* @param key The key of the NBTTag
* @return Returns whether or not the key exists
*/
public boolean hasTag(String key) {
if (item.stackTagCompound == null)
return false;
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){
if(item.stackTagCompound == null)
return null;
/**
* @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) {
if (item.stackTagCompound == null)
return null;
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;
}
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 INbt removeTags() {
ScriptNbt nbt = (ScriptNbt) NpcAPI.Instance().getINbt(item.stackTagCompound);
item.stackTagCompound = null;
return nbt;
}
public INbt removeTags() {
ScriptNbt nbt = (ScriptNbt) NpcAPI.Instance().getINbt(item.stackTagCompound);
item.stackTagCompound = null;
return nbt;
}
public boolean isEnchanted(){
return item.isItemEnchanted();
}
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;
}
/**
* @param id The enchantment id
* @return
* @since 1.7.10d
*/
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;
}
public void addEnchant(int id, int strength) {
Enchantment ench = Enchantment.enchantmentsList[id];
if (ench == null) {
throw new CustomNPCsException("Unknown enchant id:" + id, new Object[0]);
} else {
this.item.addEnchantment(ench, strength);
}
}
public void addEnchant(int id, int strength) {
Enchantment ench = Enchantment.enchantmentsList[id];
if (ench == null) {
throw new CustomNPCsException("Unknown enchant id:" + id, new Object[0]);
} else {
this.item.addEnchantment(ench, strength);
}
}
public void setAttribute(String name, double value) {
NBTTagCompound compound = this.item.getTagCompound();
if (compound == null) {
this.item.setTagCompound(compound = new NBTTagCompound());
}
public void setAttribute(String name, double value) {
NBTTagCompound compound = this.item.getTagCompound();
if (compound == null) {
this.item.setTagCompound(compound = new NBTTagCompound());
}
NBTTagList nbttaglist = compound.getTagList("AttributeModifiers", 10);
NBTTagList newList = new NBTTagList();
NBTTagList nbttaglist = compound.getTagList("AttributeModifiers", 10);
NBTTagList newList = new NBTTagList();
NBTTagCompound nbttagcompound;
for(int i = 0; i < nbttaglist.tagCount(); ++i) {
nbttagcompound = nbttaglist.getCompoundTagAt(i);
if (!nbttagcompound.getString("AttributeName").equals(name)) {
newList.appendTag(nbttagcompound);
}
}
NBTTagCompound nbttagcompound;
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
nbttagcompound = nbttaglist.getCompoundTagAt(i);
if (!nbttagcompound.getString("AttributeName").equals(name)) {
newList.appendTag(nbttagcompound);
}
}
if (value != 0.0D) {
AttributeModifier attributeModifier = new AttributeModifier(name, value, 0);
nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("Name", attributeModifier.getName());
nbttagcompound.setDouble("Amount", attributeModifier.getAmount());
nbttagcompound.setInteger("Operation", attributeModifier.getOperation());
nbttagcompound.setLong("UUIDMost", attributeModifier.getID().getMostSignificantBits());
nbttagcompound.setLong("UUIDLeast", attributeModifier.getID().getLeastSignificantBits());
nbttagcompound.setString("AttributeName", name);
newList.appendTag(nbttagcompound);
}
if (value != 0.0D) {
AttributeModifier attributeModifier = new AttributeModifier(name, value, 0);
nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("Name", attributeModifier.getName());
nbttagcompound.setDouble("Amount", attributeModifier.getAmount());
nbttagcompound.setInteger("Operation", attributeModifier.getOperation());
nbttagcompound.setLong("UUIDMost", attributeModifier.getID().getMostSignificantBits());
nbttagcompound.setLong("UUIDLeast", attributeModifier.getID().getLeastSignificantBits());
nbttagcompound.setString("AttributeName", name);
newList.appendTag(nbttagcompound);
}
compound.setTag("AttributeModifiers", newList);
}
compound.setTag("AttributeModifiers", newList);
}
public double getAttribute(String name) {
NBTTagCompound compound = this.item.getTagCompound();
if (compound == null) {
return 0.0D;
} else {
Multimap<String, AttributeModifier> map = this.item.getAttributeModifiers();
Iterator var4 = map.entries().iterator();
public double getAttribute(String name) {
NBTTagCompound compound = this.item.getTagCompound();
if (compound == null) {
return 0.0D;
} else {
Multimap<String, AttributeModifier> map = this.item.getAttributeModifiers();
Iterator var4 = map.entries().iterator();
while(var4.hasNext()) {
Map.Entry entry = (Map.Entry)var4.next();
if (((String)entry.getKey()).equals(name)) {
AttributeModifier mod = (AttributeModifier)entry.getValue();
return mod.getAmount();
}
}
while (var4.hasNext()) {
Map.Entry entry = (Map.Entry) var4.next();
if (((String) entry.getKey()).equals(name)) {
AttributeModifier mod = (AttributeModifier) entry.getValue();
return mod.getAmount();
}
}
return 0.0D;
}
}
return 0.0D;
}
}
public String[] getLore() {
if (this.item.getTagCompound() != null) {
NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display");
if(compound != null && compound.func_150299_b("Lore") == 9) {
NBTTagList nbttaglist = compound.getTagList("Lore", 8);
if (nbttaglist.tagCount() > 0) {
List<String> lore = new ArrayList();
public String[] getLore() {
if (this.item.getTagCompound() != null) {
NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display");
if (compound != null && compound.func_150299_b("Lore") == 9) {
NBTTagList nbttaglist = compound.getTagList("Lore", 8);
if (nbttaglist.tagCount() > 0) {
List<String> lore = new ArrayList();
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
lore.add(nbttaglist.getStringTagAt(i));
}
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
lore.add(nbttaglist.getStringTagAt(i));
}
return (String[]) ((String[]) lore.toArray(new String[lore.size()]));
}
}
}
return new String[0];
}
return (String[]) ((String[]) lore.toArray(new String[lore.size()]));
}
}
}
return new String[0];
}
public boolean hasLore() {
if (this.item.getTagCompound() != null) {
NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display");
if (compound != null && compound.func_150299_b("Lore") == 9) {
NBTTagList nbttaglist = compound.getTagList("Lore", 8);
return nbttaglist.tagCount() > 0;
}
}
return false;
}
public boolean hasLore() {
if (this.item.getTagCompound() != null) {
NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display");
if (compound != null && compound.func_150299_b("Lore") == 9) {
NBTTagList nbttaglist = compound.getTagList("Lore", 8);
return nbttaglist.tagCount() > 0;
}
}
return false;
}
public void setLore(String[] lore) {
NBTTagCompound compound = this.item.getTagCompound();
if (compound == null) {
this.item.setTagCompound(compound = new NBTTagCompound());
}
public void setLore(String[] lore) {
NBTTagCompound compound = this.item.getTagCompound();
if (compound == null) {
this.item.setTagCompound(compound = new NBTTagCompound());
}
NBTTagCompound display = compound.getCompoundTag("display");
if(lore == null || lore.length == 0) {
if (lore == null || lore.length == 0) {
display.removeTag("Lore");
return;
}
NBTTagList nbtlist = new NBTTagList();
for(String s : lore) {
for (String s : lore) {
nbtlist.appendTag(new NBTTagString(s));
}
display.setTag("Lore", nbtlist);
compound.setTag("display", display);
}
}
public boolean hasAttribute(String name) {
NBTTagCompound compound = this.item.getTagCompound();
if (compound == null) {
return false;
} else {
NBTTagList nbttaglist = compound.getTagList("AttributeModifiers", 10);
public boolean hasAttribute(String name) {
NBTTagCompound compound = this.item.getTagCompound();
if (compound == null) {
return false;
} else {
NBTTagList nbttaglist = compound.getTagList("AttributeModifiers", 10);
for(int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound c = nbttaglist.getCompoundTagAt(i);
if (c.getString("AttributeName").equals(name)) {
return true;
}
}
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound c = nbttaglist.getCompoundTagAt(i);
if (c.getString("AttributeName").equals(name)) {
return true;
}
}
return false;
}
}
return false;
}
}
private static ScriptItemStack createNew(ItemStack item){
if(item == null)
private static ScriptItemStack createNew(ItemStack item) {
if (item == null)
return null;
if (item.getItem() instanceof ItemLinked) {
return new ScriptLinkedItem(item);
}
if(item.getItem() instanceof ItemScripted) {
if (item.getItem() instanceof ItemScripted) {
return new ScriptCustomItem(item);
}
if(item.getItem() == Items.written_book || item.getItem() == Items.writable_book || item.getItem() instanceof ItemWritableBook || item.getItem() instanceof ItemEditableBook)
if (item.getItem() == Items.written_book || item.getItem() == Items.writable_book || item.getItem() instanceof ItemWritableBook || item.getItem() instanceof ItemEditableBook)
return new ScriptItemBook(item);
if(item.getItem() instanceof ItemArmor)
if (item.getItem() instanceof ItemArmor)
return new ScriptItemArmor(item);
if (item.getItem() instanceof ItemBlock)
return new ScriptItemBlock(item);
@@ -336,112 +336,114 @@ public class ScriptItemStack implements IItemStack {
}
@Override
public int getMaxItemDamage(){
public int getMaxItemDamage() {
return item.getMaxDamage();
}
/**
* @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;
}
/**
* @return Returns whether this item is a book
* @since 1.7.10d
*/
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");
}
/**
* @return Returns the books title
* @since 1.7.10d
*/
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");
}
/**
* @return Returns the books author
* @since 1.7.10d
*/
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>();
/**
* @return If the item is a book, returns a string array with book pages
* @since 1.7.10d
*/
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));
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;
}
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;
}
/**
* @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;
}
public boolean isFood() {
return item.getItem() instanceof ItemFood;
}
public boolean isFood() {
return item.getItem() instanceof ItemFood;
}
public int getFoodPoints() {
if (isFood()) return ((ItemFood)item.getItem()).func_150905_g(item);
return -1;
}
public int getFoodPoints() {
if (isFood()) return ((ItemFood) item.getItem()).func_150905_g(item);
return -1;
}
public INbt getNbt() {
NBTTagCompound compound = this.item.getTagCompound();
if(compound == null) {
this.item.setTagCompound(compound = new NBTTagCompound());
}
public INbt getNbt() {
NBTTagCompound compound = this.item.getTagCompound();
if (compound == null) {
this.item.setTagCompound(compound = new NBTTagCompound());
}
return NpcAPI.Instance().getINbt(compound);
}
return NpcAPI.Instance().getINbt(compound);
}
public INbt getItemNbt() {
NBTTagCompound compound = new NBTTagCompound();
this.item.writeToNBT(compound);
return NpcAPI.Instance().getINbt(compound);
}
public INbt getItemNbt() {
NBTTagCompound compound = new NBTTagCompound();
this.item.writeToNBT(compound);
return NpcAPI.Instance().getINbt(compound);
}
public NBTTagCompound getMCNbt() {
NBTTagCompound compound = new NBTTagCompound();
this.item.writeToNBT(compound);
return compound;
}
public NBTTagCompound getMCNbt() {
NBTTagCompound compound = new NBTTagCompound();
this.item.writeToNBT(compound);
return compound;
}
public void setMCNbt(NBTTagCompound compound) {}
public void setMCNbt(NBTTagCompound compound) {
}
/**
* 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;
}
/**
* 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;
}
public int itemHash() {
return item.hashCode();
}
public int itemHash() {
return item.hashCode();
}
public boolean equals(Object object) {
return object instanceof ScriptItemStack && ((ScriptItemStack) object).getMCItemStack().equals(this.getMCItemStack());
}
public boolean equals(Object object) {
return object instanceof ScriptItemStack && ((ScriptItemStack) object).getMCItemStack().equals(this.getMCItemStack());
}
@Override
public boolean compare(IItemStack item, boolean ignoreNBT) {
@@ -11,6 +11,7 @@ public class ScriptLinkedItem extends ScriptCustomizableItem implements IItemLin
public LinkedItem linkedItem = new LinkedItem();
public double durabilityValue = 1.0D;
public int linkedVersion = 1;
public ScriptLinkedItem(ItemStack item) {
super(item);
setDefaults();
@@ -26,7 +27,7 @@ public class ScriptLinkedItem extends ScriptCustomizableItem implements IItemLin
saveItemData();
}
public void setDefaults(){
public void setDefaults() {
this.itemDisplay.texture = null;
this.itemDisplay.translateX = null;
this.itemDisplay.translateY = null;
@@ -51,7 +52,7 @@ public class ScriptLinkedItem extends ScriptCustomizableItem implements IItemLin
@Override
public INpcScriptHandler getScriptHandler() {
if(this.getLinkedItem() == null)
if (this.getLinkedItem() == null)
return null;
return this.getLinkedItem().getScriptHandler();
}
@@ -192,7 +193,7 @@ public class ScriptLinkedItem extends ScriptCustomizableItem implements IItemLin
public void loadItemData() {
NBTTagCompound c = this.item.getTagCompound();
if (c != null && !c.getCompoundTag("ItemData").hasNoTags()){
if (c != null && !c.getCompoundTag("ItemData").hasNoTags()) {
this.setItemNBT(c.getCompoundTag("ItemData"));
}
}
@@ -16,10 +16,10 @@ public class ScriptOverlay implements ICustomOverlay {
int defaultAlignment = 0;
List<ICustomOverlayComponent> components = new ArrayList();
public ScriptOverlay(){
public ScriptOverlay() {
}
public ScriptOverlay(int id){
public ScriptOverlay(int id) {
this.id = id;
}
@@ -31,7 +31,7 @@ public class ScriptOverlay implements ICustomOverlay {
return this.components;
}
public int getDefaultAlignment(){
public int getDefaultAlignment() {
return this.defaultAlignment;
}
@@ -42,25 +42,25 @@ public class ScriptOverlay implements ICustomOverlay {
public IOverlayTexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height) {
ScriptOverlayTexturedRect component = new ScriptOverlayTexturedRect(id, texture, x, y, width, height);
this.components.add(component);
return (IOverlayTexturedRect)this.components.get(this.components.size() - 1);
return (IOverlayTexturedRect) this.components.get(this.components.size() - 1);
}
public IOverlayTexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
ScriptOverlayTexturedRect component = new ScriptOverlayTexturedRect(id, texture, x, y, width, height, textureX, textureY);
this.components.add(component);
return (IOverlayTexturedRect)this.components.get(this.components.size() - 1);
return (IOverlayTexturedRect) this.components.get(this.components.size() - 1);
}
public IOverlayLabel addLabel(int id, String label, int x, int y, int width, int height) {
ScriptOverlayLabel component = new ScriptOverlayLabel(id, label, x, y, width, height);
this.components.add(component);
return (IOverlayLabel)this.components.get(this.components.size() - 1);
return (IOverlayLabel) this.components.get(this.components.size() - 1);
}
public IOverlayLabel addLabel(int id, String label, int x, int y, int width, int height, int color) {
ScriptOverlayLabel component = new ScriptOverlayLabel(id, label, x, y, width, height, color);
this.components.add(component);
return (IOverlayLabel)this.components.get(this.components.size() - 1);
return (IOverlayLabel) this.components.get(this.components.size() - 1);
}
public IOverlayLine addLine(int id, int x1, int y1, int x2, int y2, int color, int thickness) {
@@ -84,15 +84,15 @@ public class ScriptOverlay implements ICustomOverlay {
return null;
}
component = (ICustomOverlayComponent)var2.next();
} while(component.getID() != componentID);
component = (ICustomOverlayComponent) var2.next();
} while (component.getID() != componentID);
return component;
}
public void removeComponent(int componentID) {
for(int i = 0; i < this.components.size(); ++i) {
if (((ICustomOverlayComponent)this.components.get(i)).getID() == componentID) {
for (int i = 0; i < this.components.size(); ++i) {
if (((ICustomOverlayComponent) this.components.get(i)).getID() == componentID) {
this.components.remove(i);
return;
}
@@ -101,8 +101,8 @@ public class ScriptOverlay implements ICustomOverlay {
}
public void updateComponent(ICustomOverlayComponent component) {
for(int i = 0; i < this.components.size(); ++i) {
ICustomOverlayComponent c = (ICustomOverlayComponent)this.components.get(i);
for (int i = 0; i < this.components.size(); ++i) {
ICustomOverlayComponent c = (ICustomOverlayComponent) this.components.get(i);
if (c.getID() == component.getID()) {
this.components.set(i, component);
return;
@@ -120,9 +120,9 @@ public class ScriptOverlay implements ICustomOverlay {
List<ICustomOverlayComponent> components = new ArrayList();
NBTTagList list = tag.getTagList("components", 10);
for(int i = 0; i < list.tagCount(); i++){
for (int i = 0; i < list.tagCount(); i++) {
NBTBase b = list.getCompoundTagAt(i);
ScriptOverlayComponent component = ScriptOverlayComponent.createFromNBT((NBTTagCompound)b);
ScriptOverlayComponent component = ScriptOverlayComponent.createFromNBT((NBTTagCompound) b);
components.add(component);
}
@@ -139,9 +139,9 @@ public class ScriptOverlay implements ICustomOverlay {
Iterator var3 = this.components.iterator();
ICustomOverlayComponent c;
while(var3.hasNext()) {
c = (ICustomOverlayComponent)var3.next();
list.appendTag(((ScriptOverlayComponent)c).toNBT(new NBTTagCompound()));
while (var3.hasNext()) {
c = (ICustomOverlayComponent) var3.next();
list.appendTag(((ScriptOverlayComponent) c).toNBT(new NBTTagCompound()));
}
tag.setTag("components", list);
@@ -19,7 +19,7 @@ public abstract class ScriptOverlayComponent implements ICustomOverlayComponent
6 7 8
*/
public ScriptOverlayComponent(){
public ScriptOverlayComponent() {
}
public int getID() {
@@ -83,10 +83,10 @@ public abstract class ScriptOverlayComponent implements ICustomOverlayComponent
public NBTTagCompound toNBT(NBTTagCompound nbt) {
nbt.setInteger("id", this.id);
nbt.setIntArray("pos", new int[]{this.posX, this.posY});
nbt.setInteger("alignment",this.alignment);
nbt.setInteger("alignment", this.alignment);
nbt.setInteger("color", this.color);
nbt.setFloat("alpha",this.alpha);
nbt.setFloat("rotation",this.rotation);
nbt.setFloat("alpha", this.alpha);
nbt.setFloat("rotation", this.rotation);
nbt.setInteger("type", this.getType());
return nbt;
@@ -104,7 +104,7 @@ public abstract class ScriptOverlayComponent implements ICustomOverlayComponent
}
public static ScriptOverlayComponent createFromNBT(NBTTagCompound nbt) {
switch(nbt.getInteger("type")) {
switch (nbt.getInteger("type")) {
case 0:
return (new ScriptOverlayTexturedRect()).fromNBT(nbt);
case 1:
@@ -62,11 +62,11 @@ public class ScriptOverlayLabel extends ScriptOverlayComponent implements IOverl
return this;
}
public boolean getShadow(){
public boolean getShadow() {
return this.shadow;
}
public void setShadow(boolean shadow){
public void setShadow(boolean shadow) {
this.shadow = shadow;
}
@@ -80,7 +80,7 @@ public class ScriptOverlayLabel extends ScriptOverlayComponent implements IOverl
nbt.setString("label", this.label);
nbt.setIntArray("size", new int[]{this.width, this.height});
nbt.setFloat("scale", this.scale);
nbt.setBoolean("shadow",this.shadow);
nbt.setBoolean("shadow", this.shadow);
return nbt;
}
@@ -10,10 +10,10 @@ public class ScriptOverlayLine extends ScriptOverlayComponent implements IOverla
int y2;
int thickness = 2;
public ScriptOverlayLine(){
public ScriptOverlayLine() {
}
public ScriptOverlayLine(int id, int x1, int y1, int x2, int y2){
public ScriptOverlayLine(int id, int x1, int y1, int x2, int y2) {
this.setPos(x1, y1);
this.setID(id);
@@ -23,7 +23,7 @@ public class ScriptOverlayLine extends ScriptOverlayComponent implements IOverla
this.y2 = y2;
}
public ScriptOverlayLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){
public ScriptOverlayLine(int id, int x1, int y1, int x2, int y2, int color, int thickness) {
this.setPos(x1, y1);
this.setID(id);
@@ -42,11 +42,11 @@ public class ScriptOverlayLine extends ScriptOverlayComponent implements IOverla
public NBTTagCompound toNBT(NBTTagCompound nbt) {
super.toNBT(nbt);
nbt.setInteger("X1",x1);
nbt.setInteger("Y1",y1);
nbt.setInteger("X2",x2);
nbt.setInteger("Y2",y2);
nbt.setInteger("Thickness",thickness);
nbt.setInteger("X1", x1);
nbt.setInteger("Y1", y1);
nbt.setInteger("X2", x2);
nbt.setInteger("Y2", y2);
nbt.setInteger("Thickness", thickness);
return nbt;
}
@@ -62,35 +62,43 @@ public class ScriptOverlayLine extends ScriptOverlayComponent implements IOverla
return this;
}
public int getX1(){
public int getX1() {
return this.x1;
}
public int getY1(){
public int getY1() {
return this.y1;
}
public int getX2(){
public int getX2() {
return this.x2;
}
public int getY2(){
public int getY2() {
return this.y2;
}
public int getThickness(){
public int getThickness() {
return this.thickness;
}
public void setX1(int x1){
public void setX1(int x1) {
this.x1 = x1;
}
public void setY1(int y1){
public void setY1(int y1) {
this.y1 = y1;
}
public void setX2(int x2){
public void setX2(int x2) {
this.x2 = x2;
}
public void setY2(int y2){
public void setY2(int y2) {
this.y2 = y2;
}
public void setThickness(int thickness){
public void setThickness(int thickness) {
this.thickness = thickness;
}
}
@@ -6,74 +6,79 @@ import noppes.npcs.roles.JobBard;
import noppes.npcs.scripted.constants.JobType;
public class ScriptJobBard extends ScriptJobInterface implements IJobBard {
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;
}
private JobBard job;
/**
*
* @param i The id of the instrument. IDs:
* 0 - None,
* 1 - Banjo,
* 2 - Violin,
* 3 - Guitar,
* 4 - Harp,
* 5 - FrenchHorn
*/
public void setInstrument(int i) {
this.job.setInstrument(i);
}
public ScriptJobBard(EntityNPCInterface npc) {
super(npc);
this.job = (JobBard) npc.jobInterface;
}
public int getInstrumentId() {
return this.job.getInstrument().ordinal();
}
@Override
public int getType() {
return JobType.BARD;
}
public void setMinRange(int range) {
this.job.minRange = range;
}
public int getMinRange() {
return this.job.minRange;
}
/**
* @return The song the bard is playing
*/
public String getSong() {
return job.song;
}
public void setMaxRange(int range) {
this.job.maxRange = range;
}
public int getMaxRange() {
return this.job.maxRange;
}
/**
* @param song The song you want the bard to play
*/
public void setSong(String song) {
job.song = song;
npc.script.clientNeedsUpdate = true;
}
public void setStreaming(boolean streaming) {
this.job.isStreamer = streaming;
}
public boolean getStreaming() {
return this.job.isStreamer;
}
/**
* @param i The id of the instrument. IDs:
* 0 - None,
* 1 - Banjo,
* 2 - Violin,
* 3 - Guitar,
* 4 - Harp,
* 5 - FrenchHorn
*/
public void setInstrument(int i) {
this.job.setInstrument(i);
}
public void hasOffRange(boolean value) {
this.job.hasOffRange = value;
}
public boolean hasOffRange() {
return this.job.hasOffRange;
}
public int getInstrumentId() {
return this.job.getInstrument().ordinal();
}
public void setMinRange(int range) {
this.job.minRange = range;
}
public int getMinRange() {
return this.job.minRange;
}
public void setMaxRange(int range) {
this.job.maxRange = range;
}
public int getMaxRange() {
return this.job.maxRange;
}
public void setStreaming(boolean streaming) {
this.job.isStreamer = streaming;
}
public boolean getStreaming() {
return this.job.isStreamer;
}
public void hasOffRange(boolean value) {
this.job.hasOffRange = value;
}
public boolean hasOffRange() {
return this.job.hasOffRange;
}
}
@@ -6,15 +6,16 @@ import noppes.npcs.roles.JobConversation;
import noppes.npcs.scripted.constants.JobType;
public class ScriptJobConversation extends ScriptJobInterface implements IJobConversation {
private JobConversation job;
public ScriptJobConversation(EntityNPCInterface npc){
super(npc);
this.job = (JobConversation) npc.jobInterface;
}
@Override
public int getType(){
return JobType.SPAWNER;
}
private JobConversation job;
public ScriptJobConversation(EntityNPCInterface npc) {
super(npc);
this.job = (JobConversation) npc.jobInterface;
}
@Override
public int getType() {
return JobType.SPAWNER;
}
}
@@ -7,33 +7,34 @@ import noppes.npcs.roles.JobFollower;
import noppes.npcs.scripted.constants.JobType;
public class ScriptJobFollower extends ScriptJobInterface implements IJobFollower {
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 ICustomNpc getFollowingNpc() {
if(!isFollowing())
return null;
return job.following.script.dummyNpc;
}
public boolean isFollowing(){
return job.isFollowing();
}
@Override
public int getType(){
return JobType.FOLLOWER;
}
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 ICustomNpc getFollowingNpc() {
if (!isFollowing())
return null;
return job.following.script.dummyNpc;
}
public boolean isFollowing() {
return job.isFollowing();
}
@Override
public int getType() {
return JobType.FOLLOWER;
}
}
@@ -6,36 +6,40 @@ import noppes.npcs.roles.JobGuard;
import noppes.npcs.scripted.constants.JobType;
public class ScriptJobGuard extends ScriptJobInterface implements IJobGuard {
private JobGuard job;
public ScriptJobGuard(EntityNPCInterface npc){
super(npc);
this.job = (JobGuard) npc.jobInterface;
}
private JobGuard job;
public boolean attackCreepers() {
return job.attackCreepers;
}
public void attackCreepers(boolean value) {
job.attackCreepers = value;
}
public ScriptJobGuard(EntityNPCInterface npc) {
super(npc);
this.job = (JobGuard) npc.jobInterface;
}
public boolean attacksAnimals() {
return job.attacksAnimals;
}
public void attacksAnimals(boolean value) {
job.attacksAnimals = value;
}
public boolean attackCreepers() {
return job.attackCreepers;
}
public void attackCreepers(boolean value) {
job.attackCreepers = value;
}
public boolean attacksAnimals() {
return job.attacksAnimals;
}
public void attacksAnimals(boolean value) {
job.attacksAnimals = value;
}
public boolean attackHostileMobs() {
return job.attackHostileMobs;
}
public void attackHostileMobs(boolean value) {
job.attackHostileMobs = value;
}
@Override
public int getType() {
return JobType.GUARD;
}
public boolean attackHostileMobs() {
return job.attackHostileMobs;
}
public void attackHostileMobs(boolean value) {
job.attackHostileMobs = value;
}
@Override
public int getType(){
return JobType.GUARD;
}
}
@@ -7,33 +7,36 @@ import noppes.npcs.roles.JobHealer;
import noppes.npcs.scripted.constants.JobType;
public class ScriptJobHealer extends ScriptJobInterface implements IJobHealer {
private JobHealer job;
public ScriptJobHealer(EntityNPCInterface npc){
super(npc);
this.job = (JobHealer) npc.jobInterface;
}
public void heal(IEntityLivingBase entity, float amount){
job.heal(entity.getMCEntity(), amount);
}
private JobHealer job;
public void setRange(int range) {
this.job.range = range;
}
public int getRange() {
return this.job.range;
}
public ScriptJobHealer(EntityNPCInterface npc) {
super(npc);
this.job = (JobHealer) npc.jobInterface;
}
public void heal(IEntityLivingBase entity, float amount) {
job.heal(entity.getMCEntity(), amount);
}
public void setRange(int range) {
this.job.range = range;
}
public int getRange() {
return this.job.range;
}
public void setSpeed(int speed) {
this.job.speed = speed;
}
public int getSpeed() {
return this.job.speed;
}
@Override
public int getType() {
return JobType.HEALER;
}
public void setSpeed(int speed) {
this.job.speed = speed;
}
public int getSpeed() {
return this.job.speed;
}
@Override
public int getType(){
return JobType.HEALER;
}
}
@@ -8,32 +8,33 @@ import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.JobType;
public class ScriptJobInterface implements IJob {
public final EntityNPCInterface npc;
public final JobInterface jobInterface;
public final EntityNPCInterface npc;
public final JobInterface jobInterface;
public ScriptJobInterface(JobInterface jobInterface) {
this.npc = null;
this.jobInterface = jobInterface;
}
public ScriptJobInterface(JobInterface jobInterface) {
this.npc = null;
this.jobInterface = jobInterface;
}
public ScriptJobInterface(EntityNPCInterface npc){
this.npc = npc;
this.jobInterface = npc.jobInterface;
}
/**
* @see noppes.npcs.scripted.constants.JobType
* @return Returns the JobType
*/
public int getType(){
return JobType.UNKNOWN;
}
public ScriptJobInterface(EntityNPCInterface npc) {
this.npc = npc;
this.jobInterface = npc.jobInterface;
}
public JobInterface getJobInterface() {
return jobInterface;
}
/**
* @return Returns the JobType
* @see noppes.npcs.scripted.constants.JobType
*/
public int getType() {
return JobType.UNKNOWN;
}
public ICustomNpc getNpc() {
return (ICustomNpc) NpcAPI.Instance().getIEntity(npc);
}
public JobInterface getJobInterface() {
return jobInterface;
}
public ICustomNpc getNpc() {
return (ICustomNpc) NpcAPI.Instance().getIEntity(npc);
}
}
@@ -16,97 +16,97 @@ import java.util.ArrayList;
import java.util.Arrays;
public class ScriptJobItemGiver extends ScriptJobInterface implements IJobItemGiver {
private JobItemGiver job;
private JobItemGiver job;
public ScriptJobItemGiver(JobItemGiver job) {
super(job);
this.job = job;
}
public ScriptJobItemGiver(JobItemGiver job) {
super(job);
this.job = job;
}
public ScriptJobItemGiver(EntityNPCInterface npc){
super(npc);
this.job = (JobItemGiver) npc.jobInterface;
}
@Override
public int getType(){
return JobType.ITEMGIVER;
}
public ScriptJobItemGiver(EntityNPCInterface npc) {
super(npc);
this.job = (JobItemGiver) npc.jobInterface;
}
public void setCooldown(int cooldown) {
if (cooldown < 0)
cooldown = 0;
@Override
public int getType() {
return JobType.ITEMGIVER;
}
job.cooldown = cooldown;
}
public void setCooldown(int cooldown) {
if (cooldown < 0)
cooldown = 0;
public void setCooldownType(int type) {
if (type < 0) {
type = 0;
} else if (type > 2) {
type = 2;
}
job.cooldownType = type;
}
job.cooldown = cooldown;
}
public int getCooldownType() {
return job.cooldownType;
}
public void setCooldownType(int type) {
if (type < 0) {
type = 0;
} else if (type > 2) {
type = 2;
}
job.cooldownType = type;
}
public void setGivingMethod(int method) {
if (method < 0) {
method = 0;
} else if (method > 4) {
method = 4;
}
job.givingMethod = method;
}
public int getCooldownType() {
return job.cooldownType;
}
public int getGivingMethod() {
return job.givingMethod;
}
public void setGivingMethod(int method) {
if (method < 0) {
method = 0;
} else if (method > 4) {
method = 4;
}
job.givingMethod = method;
}
public void setLines(String[] lines) {
job.lines = new ArrayList<>(Arrays.asList(lines));
}
public int getGivingMethod() {
return job.givingMethod;
}
public String[] getLines() {
return job.lines.toArray(new String[0]);
}
public void setLines(String[] lines) {
job.lines = new ArrayList<>(Arrays.asList(lines));
}
public void setAvailability(IAvailability availability) {
job.availability = (Availability) availability;
}
public String[] getLines() {
return job.lines.toArray(new String[0]);
}
public IAvailability getAvailability() {
return job.availability;
}
public void setAvailability(IAvailability availability) {
job.availability = (Availability) availability;
}
public void setItem(int slot, IItemStack item) {
if (slot < 0) {
slot = 0;
} else if (slot > 8) {
slot = 8;
}
public IAvailability getAvailability() {
return job.availability;
}
job.inventory.items.put(slot, item.getMCItemStack());
}
public void setItem(int slot, IItemStack item) {
if (slot < 0) {
slot = 0;
} else if (slot > 8) {
slot = 8;
}
public IItemStack[] getItems() {
ArrayList<IItemStack> items = new ArrayList<>();
job.inventory.items.put(slot, item.getMCItemStack());
}
for (int i = 0; i < job.inventory.getSizeInventory(); i++) {
items.add(NpcAPI.Instance().getIItemStack(job.inventory.getStackInSlot(i)));
}
public IItemStack[] getItems() {
ArrayList<IItemStack> items = new ArrayList<>();
return items.toArray(new IItemStack[0]);
}
for (int i = 0; i < job.inventory.getSizeInventory(); i++) {
items.add(NpcAPI.Instance().getIItemStack(job.inventory.getStackInSlot(i)));
}
public boolean giveItems(IPlayer player) {
return job.giveItems((EntityPlayer) player.getMCEntity());
}
return items.toArray(new IItemStack[0]);
}
public boolean canPlayerInteract(IPlayer player) {
return job.canPlayerInteract((PlayerItemGiverData) player.getData().getItemGiverData());
}
public boolean giveItems(IPlayer player) {
return job.giveItems((EntityPlayer) player.getMCEntity());
}
public boolean canPlayerInteract(IPlayer player) {
return job.canPlayerInteract((PlayerItemGiverData) player.getData().getItemGiverData());
}
}
@@ -20,80 +20,82 @@ import java.util.ArrayList;
import java.util.List;
public class ScriptJobSpawner extends ScriptJobInterface implements IJobSpawner {
private final 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 IEntityLivingBase<?> spawnEntity(int number){
EntityLivingBase base = job.spawnEntity(number);
if(base == null)
return null;
return (IEntityLivingBase<?>) NpcAPI.Instance().getIEntity(base);
}
private final JobSpawner job;
public IEntityLivingBase<?> getEntity(int number, int x, int y, int z, IWorld world) {
NBTTagCompound compound = this.job.getCompound(number);
if(compound == null || !compound.hasKey("id"))
return null;
Entity entity = NoppesUtilServer.getEntityFromNBT(compound,x,y,z,world.getMCWorld());
if (!(entity instanceof EntityLivingBase)) {
return null;
}
return (IEntityLivingBase<?>) NpcAPI.Instance().getIEntity(entity);
}
public ScriptJobSpawner(EntityNPCInterface npc) {
super(npc);
this.job = (JobSpawner) npc.jobInterface;
}
public IEntityLivingBase<?> getEntity(int number, IPos pos, IWorld world) {
return this.getEntity(number,pos.getX(),pos.getY(),pos.getZ(),world);
}
@Override
public int getType() {
return JobType.SPAWNER;
}
public void setEntity(int number, IEntityLivingBase<?> entityLivingBase){
INbt nbt = entityLivingBase.getNbtOptional();
if (nbt == null)
return;
this.job.setJobCompound(number,nbt.getMCNBT());
}
/**
* 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 IEntityLivingBase<?> spawnEntity(int number) {
EntityLivingBase base = job.spawnEntity(number);
if (base == null)
return null;
/**
* Removes all spawned entities
*/
public void removeAllSpawned(){
for(EntityLivingBase entity : job.spawned){
entity.isDead = true;
}
job.spawned = new ArrayList<>();
}
return (IEntityLivingBase<?>) NpcAPI.Instance().getIEntity(base);
}
public IEntityLivingBase<?>[] getNearbySpawned() {
List<EntityLivingBase> nearbySpawned = this.job.getNearbySpawned();
List<IEntityLivingBase<?>> list = new ArrayList<>();
for (EntityLivingBase entity : nearbySpawned) {
list.add((IEntityLivingBase<?>) NpcAPI.Instance().getIEntity(entity));
}
return list.toArray(new IEntityLivingBase[0]);
}
public IEntityLivingBase<?> getEntity(int number, int x, int y, int z, IWorld world) {
NBTTagCompound compound = this.job.getCompound(number);
if (compound == null || !compound.hasKey("id"))
return null;
Entity entity = NoppesUtilServer.getEntityFromNBT(compound, x, y, z, world.getMCWorld());
if (!(entity instanceof EntityLivingBase)) {
return null;
}
return (IEntityLivingBase<?>) NpcAPI.Instance().getIEntity(entity);
}
public boolean hasPixelmon() {
return this.job.hasPixelmon();
}
public IEntityLivingBase<?> getEntity(int number, IPos pos, IWorld world) {
return this.getEntity(number, pos.getX(), pos.getY(), pos.getZ(), world);
}
public boolean isEmpty() {
return this.job.isEmpty();
}
public void setEntity(int number, IEntityLivingBase<?> entityLivingBase) {
INbt nbt = entityLivingBase.getNbtOptional();
if (nbt == null)
return;
this.job.setJobCompound(number, nbt.getMCNBT());
}
public boolean isOnCooldown(IPlayer<EntityPlayerMP> player) {
return this.job.isOnCooldown(player.getName());
}
/**
* Removes all spawned entities
*/
public void removeAllSpawned() {
for (EntityLivingBase entity : job.spawned) {
entity.isDead = true;
}
job.spawned = new ArrayList<>();
}
public IEntityLivingBase<?>[] getNearbySpawned() {
List<EntityLivingBase> nearbySpawned = this.job.getNearbySpawned();
List<IEntityLivingBase<?>> list = new ArrayList<>();
for (EntityLivingBase entity : nearbySpawned) {
list.add((IEntityLivingBase<?>) NpcAPI.Instance().getIEntity(entity));
}
return list.toArray(new IEntityLivingBase[0]);
}
public boolean hasPixelmon() {
return this.job.hasPixelmon();
}
public boolean isEmpty() {
return this.job.isEmpty();
}
public boolean isOnCooldown(IPlayer<EntityPlayerMP> player) {
return this.job.isOnCooldown(player.getName());
}
}
@@ -6,12 +6,12 @@ import noppes.npcs.scripted.constants.RoleType;
public class ScriptRoleBank extends ScriptRoleInterface implements IRoleBank {
public ScriptRoleBank(EntityNPCInterface npc) {
super(npc);
}
public ScriptRoleBank(EntityNPCInterface npc) {
super(npc);
}
@Override
public int getType(){
return RoleType.BANK;
}
@Override
public int getType() {
return RoleType.BANK;
}
}
@@ -6,12 +6,12 @@ import noppes.npcs.scripted.constants.RoleType;
public class ScriptRoleCompanion extends ScriptRoleInterface implements IRoleMailman {
public ScriptRoleCompanion(EntityNPCInterface npc) {
super(npc);
}
public ScriptRoleCompanion(EntityNPCInterface npc) {
super(npc);
}
@Override
public int getType(){
return RoleType.COMPANION;
}
@Override
public int getType() {
return RoleType.COMPANION;
}
}
@@ -9,111 +9,112 @@ import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.RoleType;
public class ScriptRoleFollower extends ScriptRoleInterface implements IRoleFollower {
private RoleFollower role;
public ScriptRoleFollower(EntityNPCInterface npc) {
super(npc);
role = (RoleFollower) npc.roleInterface;
}
private RoleFollower role;
public void setOwner(IPlayer player){
if(player == null || player.getMCEntity() == null){
role.setOwner(null);
return;
}
EntityPlayer mcplayer = (EntityPlayer) player.getMCEntity();
role.setOwner(mcplayer);
}
public ScriptRoleFollower(EntityNPCInterface npc) {
super(npc);
role = (RoleFollower) npc.roleInterface;
}
public IPlayer getOwner(){
if(role.owner == null)
return null;
return (IPlayer) NpcAPI.Instance().getIEntity(role.owner);
}
public void setOwner(IPlayer player) {
if (player == null || player.getMCEntity() == null) {
role.setOwner(null);
return;
}
EntityPlayer mcplayer = (EntityPlayer) player.getMCEntity();
role.setOwner(mcplayer);
}
public boolean hasOwner(){
return role.owner != null;
}
public boolean isFollowing() {
return role.isFollowing();
}
public void setIsFollowing(boolean following) {
if (role.owner != null && role.getDaysLeft() > 0) role.isFollowing = following;
}
public IPlayer getOwner() {
if (role.owner == null)
return null;
public int getDaysLeft(){
return role.getDaysLeft();
}
return (IPlayer) NpcAPI.Instance().getIEntity(role.owner);
}
public void addDaysLeft(int days){
role.addDays(days);
}
public boolean hasOwner() {
return role.owner != null;
}
public boolean getInfiniteDays(){
return role.infiniteDays;
}
public boolean isFollowing() {
return role.isFollowing();
}
public void setInfiniteDays(boolean infinite){
role.infiniteDays = infinite;
}
public void setIsFollowing(boolean following) {
if (role.owner != null && role.getDaysLeft() > 0) role.isFollowing = following;
}
public boolean getGuiDisabled(){
return role.disableGui;
}
public int getDaysLeft() {
return role.getDaysLeft();
}
public void setGuiDisabled(boolean disabled){
role.disableGui = disabled;
}
public void addDaysLeft(int days) {
role.addDays(days);
}
public boolean getInfiniteDays() {
return role.infiniteDays;
}
public void setInfiniteDays(boolean infinite) {
role.infiniteDays = infinite;
}
public boolean getGuiDisabled() {
return role.disableGui;
}
public void setGuiDisabled(boolean disabled) {
role.disableGui = disabled;
}
/**
* @param index Index of Rate [0 - 2]
* @param amount Amount hired for
*/
public void setRate(int index, int amount){
role.setRate(index, amount);
}
/**
* @param index Index of Rate [0 - 2]
* @param amount Amount hired for
*/
public void setRate(int index, int amount) {
role.setRate(index, amount);
}
/**
* @param index Index of Rate [0 - 2]
* @return amount fired for
*/
public int getRate(int index){
return role.getRate(index);
}
/**
* @param index Index of Rate [0 - 2]
* @return amount fired for
*/
public int getRate(int index) {
return role.getRate(index);
}
/**
* @param dialogHire New dialog hire string
*/
public void setDialogHire(String dialogHire){
role.setDialogHire(dialogHire);
}
/**
* @param dialogHire New dialog hire string
*/
public void setDialogHire(String dialogHire) {
role.setDialogHire(dialogHire);
}
/**
* @return dialog hire string
*/
public String getDialogHire(){
return role.getDialogHire();
}
/**
* @return dialog hire string
*/
public String getDialogHire() {
return role.getDialogHire();
}
/**
* @param dialogFarewell New dialog farewell string
*/
public void setDialogFarewell(String dialogFarewell){
role.setDialogFarewell(dialogFarewell);
}
/**
* @param dialogFarewell New dialog farewell string
*/
public void setDialogFarewell(String dialogFarewell) {
role.setDialogFarewell(dialogFarewell);
}
/**
* @return dialog farewell string
*/
public String getDialogFarewell(){
return role.getDialogFarewell();
}
/**
* @return dialog farewell string
*/
public String getDialogFarewell() {
return role.getDialogFarewell();
}
@Override
public int getType(){
return RoleType.FOLLOWER;
}
@Override
public int getType() {
return RoleType.FOLLOWER;
}
}
@@ -8,23 +8,23 @@ import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.RoleType;
public class ScriptRoleInterface implements IRole {
public final EntityNPCInterface npc;
public final RoleInterface role;
public final EntityNPCInterface npc;
public final RoleInterface role;
public ScriptRoleInterface(EntityNPCInterface npc){
this.npc = npc;
this.role = npc.roleInterface;
}
public ScriptRoleInterface(EntityNPCInterface npc) {
this.npc = npc;
this.role = npc.roleInterface;
}
public INpc getNpc() {
return (INpc) NpcAPI.Instance().getIEntity(npc);
}
public INpc getNpc() {
return (INpc) NpcAPI.Instance().getIEntity(npc);
}
/**
* @see noppes.npcs.scripted.constants.RoleType
* @return The RoleType of this role
*/
public int getType(){
return RoleType.UNKNOWN;
}
/**
* @return The RoleType of this role
* @see noppes.npcs.scripted.constants.RoleType
*/
public int getType() {
return RoleType.UNKNOWN;
}
}
@@ -6,12 +6,12 @@ import noppes.npcs.scripted.constants.RoleType;
public class ScriptRoleMailman extends ScriptRoleInterface implements IRoleMailman {
public ScriptRoleMailman(EntityNPCInterface npc) {
super(npc);
}
public ScriptRoleMailman(EntityNPCInterface npc) {
super(npc);
}
@Override
public int getType(){
return RoleType.POSTMAN;
}
@Override
public int getType() {
return RoleType.POSTMAN;
}
}
@@ -10,125 +10,126 @@ import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.RoleType;
public class ScriptRoleTrader extends ScriptRoleInterface implements IRoleTrader {
private RoleTrader role;
public ScriptRoleTrader(EntityNPCInterface npc) {
super(npc);
role = (RoleTrader) npc.roleInterface;
}
private RoleTrader role;
public void setSellOption(int slot, IItemStack currency, IItemStack currency2, IItemStack sold){
if(sold == null || slot >= 18 || slot < 0)
return;
if(currency == null)
currency = currency2;
public ScriptRoleTrader(EntityNPCInterface npc) {
super(npc);
role = (RoleTrader) npc.roleInterface;
}
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);
public void setSellOption(int slot, IItemStack currency, IItemStack currency2, IItemStack sold) {
if (sold == null || slot >= 18 || slot < 0)
return;
if (currency == null)
currency = currency2;
role.inventorySold.items.put(slot, sold.getMCItemStack());
}
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);
public void setSellOption(int slot, IItemStack currency, IItemStack sold){
setSellOption(slot, currency, null, sold);
}
role.inventorySold.items.put(slot, sold.getMCItemStack());
}
public IItemStack getSellOption(int slot) {
if (slot >= 18 || slot < 0) return null;
if (role.inventorySold.items.get(slot) == null) return null;
return NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot));
}
public void setSellOption(int slot, IItemStack currency, IItemStack sold) {
setSellOption(slot, currency, null, sold);
}
public IItemStack[] getCurrency(int slot) {
if (slot >= 18 || slot < 0) return null;
IItemStack[] currency = new IItemStack[2];
if (role.inventoryCurrency.items.get(slot) != null) {
currency[0] = NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot));
}
if (role.inventoryCurrency.items.get(slot + 18) != null) {
currency[1] = NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot + 18));
}
return currency;
}
public IItemStack getSellOption(int slot) {
if (slot >= 18 || slot < 0) return null;
if (role.inventorySold.items.get(slot) == null) return null;
return NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot));
}
public IItemStack[] getCurrency(int slot) {
if (slot >= 18 || slot < 0) return null;
IItemStack[] currency = new IItemStack[2];
if (role.inventoryCurrency.items.get(slot) != null) {
currency[0] = NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot));
}
if (role.inventoryCurrency.items.get(slot + 18) != null) {
currency[1] = NpcAPI.Instance().getIItemStack(role.inventoryCurrency.items.get(slot + 18));
}
return currency;
}
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);
}
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);
}
public void setMarket(String name){
role.marketName = name;
Market.getMarket(role, name);
}
public void setMarket(String name) {
role.marketName = name;
Market.getMarket(role, name);
}
public String getMarket(){
return role.marketName;
}
public String getMarket() {
return role.marketName;
}
public int getPurchaseNum(int slot) {
if(slot >= 18 || slot < 0) return -1;
return role.purchases[slot];
}
public int getPurchaseNum(int slot) {
if (slot >= 18 || slot < 0) return -1;
return role.purchases[slot];
}
public int getPurchaseNum(int slot, IPlayer player) {
if(slot >= 18 || slot < 0) return -1;
return role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot];
}
public int getPurchaseNum(int slot, IPlayer player) {
if (slot >= 18 || slot < 0) return -1;
return role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot];
}
public void resetPurchaseNum() {
for (int i = 0; i < role.purchases.length; ++i) role.purchases[i] = 0;
}
public void resetPurchaseNum() {
for (int i = 0; i < role.purchases.length; ++i) role.purchases[i] = 0;
}
public void resetPurchaseNum(int slot) {
if(slot >= 18 || slot < 0) return;
role.purchases[slot] = 0;
}
public void resetPurchaseNum(int slot) {
if (slot >= 18 || slot < 0) return;
role.purchases[slot] = 0;
}
public void resetPurchaseNum(int slot, IPlayer player) {
if(slot >= 18 || slot < 0) return;
role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot] = 0;
}
public void resetPurchaseNum(int slot, IPlayer player) {
if (slot >= 18 || slot < 0) return;
role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot] = 0;
}
public boolean isSlotEnabled(int slot) {
if(slot >= 18 || slot < 0) return false;
return role.disableSlot[slot] > 0;
}
public boolean isSlotEnabled(int slot) {
if (slot >= 18 || slot < 0) return false;
return role.disableSlot[slot] > 0;
}
public boolean isSlotEnabled(int slot, IPlayer player) {
if(slot >= 18 || slot < 0) return false;
return role.isSlotEnabled(slot, player.getDisplayName());
}
public boolean isSlotEnabled(int slot, IPlayer player) {
if (slot >= 18 || slot < 0) return false;
return role.isSlotEnabled(slot, player.getDisplayName());
}
public void disableSlot(int slot) {
if(slot >= 18 || slot < 0) return;
role.disableSlot[slot] = 1;
}
public void disableSlot(int slot) {
if (slot >= 18 || slot < 0) return;
role.disableSlot[slot] = 1;
}
public void disableSlot(int slot, IPlayer player) {
if(slot >= 18 || slot < 0) return;
role.getArrayByName(player.getDisplayName(), role.playerDisableSlot)[slot] = 1;
}
public void disableSlot(int slot, IPlayer player) {
if (slot >= 18 || slot < 0) return;
role.getArrayByName(player.getDisplayName(), role.playerDisableSlot)[slot] = 1;
}
public void enableSlot(int slot) {
if(slot >= 18 || slot < 0) return;
role.disableSlot[slot] = 0;
}
public void enableSlot(int slot) {
if (slot >= 18 || slot < 0) return;
role.disableSlot[slot] = 0;
}
public void enableSlot(int slot, IPlayer player) {
if(slot >= 18 || slot < 0) return;
role.getArrayByName(player.getDisplayName(), role.playerDisableSlot)[slot] = 0;
}
public void enableSlot(int slot, IPlayer player) {
if (slot >= 18 || slot < 0) return;
role.getArrayByName(player.getDisplayName(), role.playerDisableSlot)[slot] = 0;
}
@Override
public int getType(){
return RoleType.TRADER;
}
@Override
public int getType() {
return RoleType.TRADER;
}
}
@@ -9,40 +9,40 @@ import noppes.npcs.roles.RoleTransporter;
import noppes.npcs.scripted.constants.RoleType;
public class ScriptRoleTransporter extends ScriptRoleInterface implements IRoleTransporter {
private final RoleTransporter role;
private final RoleTransporter role;
public ScriptRoleTransporter(EntityNPCInterface npc) {
super(npc);
role = (RoleTransporter) npc.roleInterface;
public ScriptRoleTransporter(EntityNPCInterface npc) {
super(npc);
role = (RoleTransporter) npc.roleInterface;
}
}
public String getName() {
return role.name;
}
public String getName() {
return role.name;
}
public int getTransportId() {
return role.transportId;
}
public int getTransportId() {
return role.transportId;
}
public void unlock(IPlayer<EntityPlayerMP> player, ITransportLocation location) {
this.role.unlock(player.getMCEntity(), location);
}
public void unlock(IPlayer<EntityPlayerMP> player, ITransportLocation location) {
this.role.unlock(player.getMCEntity(), location);
}
public ITransportLocation getTransport(){
return this.role.getLocation();
}
public ITransportLocation getTransport() {
return this.role.getLocation();
}
public boolean hasTransport(){
return this.role.hasTransport();
}
public boolean hasTransport() {
return this.role.hasTransport();
}
public void setTransport(ITransportLocation location) {
this.role.setTransport(location);
}
public void setTransport(ITransportLocation location) {
this.role.setTransport(location);
}
@Override
public int getType(){
return RoleType.TRANSPORTER;
}
@Override
public int getType() {
return RoleType.TRANSPORTER;
}
}
@@ -14,190 +14,190 @@ import java.util.List;
* @author Karel
*/
public class ScriptScoreboard implements IScoreboard {
private Scoreboard board;
private Scoreboard board;
public ScriptScoreboard(){
board = MinecraftServer.getServer().worldServerForDimension(0).getScoreboard();
}
/**
* @return Returns an array with all ScoreboardObjectives
*/
public IScoreboardObjective[] getObjectives(){
public ScriptScoreboard() {
board = MinecraftServer.getServer().worldServerForDimension(0).getScoreboard();
}
/**
* @return Returns an array with all ScoreboardObjectives
*/
public IScoreboardObjective[] getObjectives() {
List<ScoreObjective> collection = new ArrayList<ScoreObjective>(board.getScoreObjectives());
IScoreboardObjective[] objectives = new IScoreboardObjective[collection.size()];
for(int i = 0; i < collection.size(); i++){
objectives[i] = new ScriptScoreboardObjective(collection.get(i));
IScoreboardObjective[] objectives = new IScoreboardObjective[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 IScoreboardObjective 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){
}
/**
* @param name Name of the objective
* @return Returns the ScoreboardObjective
*/
public IScoreboardObjective 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.wiki/w/Scoreboard#Objectives
* @return Returns the created ScoreboardObjective, returns null if it failed to create
*/
public IScoreboardObjective 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;
}
/**
* @param objective Objective to remove
*/
public void removeObjective(String objective) {
ScoreObjective obj = board.getObjective(objective);
if (obj != null)
board.func_96519_k(obj);
}
/**
* @param objective Scoreboard objective name (1-16 chars)
* @param criteria The criteria see http://minecraft.wiki/w/Scoreboard#Objectives
* @return Returns the created ScoreboardObjective, returns null if it failed to create
* @version 1.8
*/
public IScoreboardObjective 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;
/**
* @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
* @since 1.7.10c
*/
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);
}
}
public void setPlayerScore(IPlayer player, String objective, int score, String datatag){
this.setPlayerScore(player.getName(),objective,score,datatag);
}
public void setPlayerScore(IPlayer player, String objective, int score, String datatag) {
this.setPlayerScore(player.getName(), objective, score, datatag);
}
/**
* @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;
/**
* @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
* @since 1.7.10c
*/
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();
}
return board.func_96529_a(player, objec).getScorePoints();
}
public int getPlayerScore(IPlayer player, String objective, String datatag){
return this.getPlayerScore(player.getName(),objective,datatag);
}
public int getPlayerScore(IPlayer player, String objective, String datatag) {
return this.getPlayerScore(player.getName(), objective, datatag);
}
/**
* @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;
}
/**
* @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
* @version 1.8
*/
public boolean hasPlayerObjective(String player, String objective, String datatag) {
ScoreObjective objec = board.getObjective(objective);
if (objec == null)
return false;
public boolean hasPlayerObjective(IPlayer player, String objective, String datatag){
return this.hasPlayerObjective(player.getName(),objective,datatag);
}
/**
* @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;
return board.func_96510_d(player).get(objec) != null;
}
if(board.func_96510_d(player).remove(objec) != null)
board.func_96516_a(player);
}
public boolean hasPlayerObjective(IPlayer player, String objective, String datatag) {
return this.hasPlayerObjective(player.getName(), objective, datatag);
}
public void deletePlayerScore(IPlayer player, String objective, String datatag){
this.deletePlayerScore(player.getName(),objective,datatag);
}
public IScoreboardTeam[] getTeams(){
List<ScorePlayerTeam> list = new ArrayList<ScorePlayerTeam>(board.getTeams());
IScoreboardTeam[] teams = new IScoreboardTeam[list.size()];
for(int i = 0; i < list.size(); i++){
teams[i] = new ScriptScoreboardTeam(list.get(i), board);
}
return teams;
}
public IScoreboardTeam getTeamByName(String name) {
IScoreboardTeam[] teams = getTeams();
for (int i = 0; i < teams.length; i++) {
if (teams[i].getName().equals(name)) {
return teams[i];
}
}
return null;
}
public boolean hasTeam(String name){
return board.getPlayersTeam(name) != null;
}
public IScoreboardTeam addTeam(String name){
if(hasTeam(name))
return null;
return new ScriptScoreboardTeam(board.createTeam(name), board);
}
public IScoreboardTeam 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);
}
/**
* @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
* @version 1.8
*/
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 void deletePlayerScore(IPlayer player, String objective, String datatag) {
this.deletePlayerScore(player.getName(), objective, datatag);
}
public IScoreboardTeam[] getTeams() {
List<ScorePlayerTeam> list = new ArrayList<ScorePlayerTeam>(board.getTeams());
IScoreboardTeam[] teams = new IScoreboardTeam[list.size()];
for (int i = 0; i < list.size(); i++) {
teams[i] = new ScriptScoreboardTeam(list.get(i), board);
}
return teams;
}
public IScoreboardTeam getTeamByName(String name) {
IScoreboardTeam[] teams = getTeams();
for (int i = 0; i < teams.length; i++) {
if (teams[i].getName().equals(name)) {
return teams[i];
}
}
return null;
}
public boolean hasTeam(String name) {
return board.getPlayersTeam(name) != null;
}
public IScoreboardTeam addTeam(String name) {
if (hasTeam(name))
return null;
return new ScriptScoreboardTeam(board.createTeam(name), board);
}
public IScoreboardTeam 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);
}
}
@@ -4,48 +4,48 @@ import net.minecraft.scoreboard.ScoreObjective;
import noppes.npcs.api.scoreboard.IScoreboardObjective;
public class ScriptScoreboardObjective implements IScoreboardObjective {
private ScoreObjective objective;
public 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();
}
private ScoreObjective objective;
public 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();
}
/**
* @param name Name used for display (1-32 chars)
* @since 1.7.10c
*/
public void setDisplayName(String name) {
if (name.length() > 0 && name.length() <= 32)
objective.setDisplayName(name);
}
/**
* @return Returns the criteria string
* @since 1.7.10c
*/
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();
}
}
@@ -10,101 +10,102 @@ import java.util.ArrayList;
import java.util.List;
public class ScriptScoreboardTeam implements IScoreboardTeam {
private ScorePlayerTeam team;
private Scoreboard board;
public 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());
}
private ScorePlayerTeam team;
private Scoreboard board;
public void addPlayer(IPlayer player) {
this.addPlayer(player.getName());
}
public void removePlayer(String player){
board.removePlayerFromTeam(player, team);
}
public ScriptScoreboardTeam(ScorePlayerTeam team, Scoreboard board) {
this.team = team;
this.board = board;
}
public void removePlayer(IPlayer player) {
this.removePlayer(player.getName());
}
public String[] getPlayers(){
List<String> list = new ArrayList<String>(team.getMembershipCollection());
return list.toArray(new String[list.size()]);
}
public int getTeamsize() {
return team.getMembershipCollection().size();
}
public void clearPlayers(){
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 addPlayer(IPlayer player) {
this.addPlayer(player.getName());
}
public void removePlayer(String player) {
board.removePlayerFromTeam(player, team);
}
public void removePlayer(IPlayer player) {
this.removePlayer(player.getName());
}
public String[] getPlayers() {
List<String> list = new ArrayList<String>(team.getMembershipCollection());
for(String player : list){
board.removePlayerFromTeam(player, team);
return list.toArray(new String[list.size()]);
}
public int getTeamsize() {
return team.getMembershipCollection().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){
}
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;
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();
}
}
/**
* @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();
}
}