mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 04:57:27 +00:00
Merge pull request #51 from 1whohears/dev
Added various things to the API and other small changes
This commit is contained in:
26 files changed
+684
-36
No files matched your search
+2
-1
@@ -8,4 +8,5 @@ eclipse
|
||||
.project
|
||||
.settings
|
||||
bin
|
||||
.metadata
|
||||
.metadata
|
||||
*.bak
|
||||
@@ -27,6 +27,7 @@ public class DataStats {
|
||||
public int spawnCycle = 0;
|
||||
public boolean hideKilledBody = false;
|
||||
public boolean canDespawn = false;
|
||||
public boolean playerSetCanDespawn = false;
|
||||
|
||||
public Resistances resistances = new Resistances();
|
||||
|
||||
@@ -47,6 +48,7 @@ public class DataStats {
|
||||
public int pEffAmp = 0;
|
||||
public String fireSound = "random.bow";
|
||||
public boolean aimWhileShooting = false;
|
||||
public boolean projectilesKeepTerrain = false;
|
||||
|
||||
public EnumCreatureAttribute creatureType = EnumCreatureAttribute.UNDEFINED;
|
||||
|
||||
@@ -102,14 +104,16 @@ public class DataStats {
|
||||
compound.setInteger("pEffAmp", pEffAmp);
|
||||
compound.setString("FiringSound", fireSound);
|
||||
compound.setBoolean("AimWhileShooting", aimWhileShooting);
|
||||
compound.setBoolean("ProjectilesKeepTerrain", projectilesKeepTerrain);
|
||||
|
||||
compound.setBoolean("ImmuneToFire", immuneToFire);
|
||||
compound.setBoolean("PotionImmune", potionImmune);
|
||||
compound.setBoolean("CanDrown", canDrown);
|
||||
compound.setBoolean("BurnInSun", burnInSun);
|
||||
compound.setBoolean("NoFallDamage", noFallDamage);
|
||||
compound.setBoolean("CanDespawn", canDespawn);
|
||||
compound.setBoolean("AttackInvisible", attackInvisible);
|
||||
compound.setBoolean("CanDespawn", canDespawn);
|
||||
compound.setBoolean("PlayerSetCanDespawn", playerSetCanDespawn);
|
||||
|
||||
return compound;
|
||||
}
|
||||
@@ -160,14 +164,16 @@ public class DataStats {
|
||||
pEffAmp = compound.getInteger("pEffAmp");
|
||||
fireSound = compound.getString("FiringSound");
|
||||
aimWhileShooting = compound.getBoolean("AimWhileShooting");
|
||||
projectilesKeepTerrain = compound.getBoolean("ProjectilesKeepTerrain");
|
||||
|
||||
immuneToFire = compound.getBoolean("ImmuneToFire");
|
||||
potionImmune = compound.getBoolean("PotionImmune");
|
||||
canDrown = compound.getBoolean("CanDrown");
|
||||
burnInSun = compound.getBoolean("BurnInSun");
|
||||
noFallDamage = compound.getBoolean("NoFallDamage");
|
||||
canDespawn = compound.getBoolean("CanDespawn");
|
||||
attackInvisible = compound.getBoolean("AttackInvisible");
|
||||
canDespawn = compound.getBoolean("CanDespawn");
|
||||
playerSetCanDespawn = compound.getBoolean("PlayerSetCanDespawn");
|
||||
|
||||
npc.setImmuneToFire(immuneToFire);
|
||||
}
|
||||
|
||||
@@ -131,6 +131,34 @@ public class NBTTags {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static HashMap<String, int[]> getStringIntegerArrayMap(NBTTagList tagList) {
|
||||
HashMap<String, int[]> list = new HashMap<String, int[]>();
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
list.put(nbttagcompound.getString("Slot"), nbttagcompound.getIntArray("Value"));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tagList
|
||||
* @param arraySize if an int array is not this length a new int array with this length is made
|
||||
* @return
|
||||
*/
|
||||
public static HashMap<String, int[]> getStringIntegerArrayMap(NBTTagList tagList, int arrayLength) {
|
||||
HashMap<String, int[]> list = new HashMap<String, int[]>();
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
|
||||
int[] a = nbttagcompound.getIntArray("Value");
|
||||
if (a.length != arrayLength) a = new int[arrayLength];
|
||||
list.put(nbttagcompound.getString("Slot"), a);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static HashMap<String, Vector<String>> getVectorMap(NBTTagList tagList) {
|
||||
HashMap<String, Vector<String>> map = new HashMap<String, Vector<String>>();
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
@@ -336,6 +364,21 @@ public class NBTTags {
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTTagList nbtStringIntegerArrayMap(HashMap<String, int[]> map) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
if(map == null)
|
||||
return nbttaglist;
|
||||
for(String slot : map.keySet())
|
||||
{
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setString("Slot", slot);
|
||||
nbttagcompound.setIntArray("Value", map.get(slot));
|
||||
|
||||
nbttaglist.appendTag(nbttagcompound);
|
||||
}
|
||||
return nbttaglist;
|
||||
}
|
||||
|
||||
public static NBTBase nbtIntegerStringMap(HashMap<Integer, String> map) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
@@ -658,6 +658,8 @@ public class NoppesUtilServer {
|
||||
if(entity instanceof EntityNPCInterface){
|
||||
EntityNPCInterface npc = (EntityNPCInterface) entity;
|
||||
npc.ai.startPos = new int[]{MathHelper.floor_double(npc.posX),MathHelper.floor_double(npc.posY),MathHelper.floor_double(npc.posZ)};
|
||||
npc.ticksExisted = 0;
|
||||
npc.totalTicksAlive = 0;
|
||||
}
|
||||
worldObj.spawnEntityInWorld(entity);
|
||||
return entity;
|
||||
|
||||
@@ -55,6 +55,7 @@ public class SubGuiNpcRespawn extends SubGuiInterface implements ITextfieldListe
|
||||
}
|
||||
else if(button.id == 1){
|
||||
stats.canDespawn = button.getValue() == 1;
|
||||
stats.playerSetCanDespawn = stats.canDespawn;
|
||||
}
|
||||
else if(button.id == 4){
|
||||
stats.hideKilledBody = button.getValue() == 1;
|
||||
|
||||
@@ -117,6 +117,10 @@ public class GuiNPCTrader extends GuiContainerNPCInterface{
|
||||
this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title))/2, 131, 0xDD0000);
|
||||
GL11.glTranslatef(0, 0, -300);
|
||||
}
|
||||
else if (!container.isSlotEnabled(slot, player)) {
|
||||
String title = StatCollector.translateToLocal("trader.slotdisabled");
|
||||
this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title))/2, 131, 0x00DD00);
|
||||
}
|
||||
else{
|
||||
String title = StatCollector.translateToLocal("trader.sufficient");
|
||||
this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title))/2, 131, 0x00DD00);
|
||||
|
||||
@@ -62,19 +62,24 @@ public class ContainerNPCTrader extends ContainerNpcInterface{
|
||||
return null;
|
||||
if(!canBuy(i, entityplayer))
|
||||
return null;
|
||||
if (!isSlotEnabled(i, entityplayer))
|
||||
return null;
|
||||
NoppesUtilPlayer.consumeItem(entityplayer, role.inventoryCurrency.getStackInSlot(i), role.ignoreDamage, role.ignoreNBT);
|
||||
NoppesUtilPlayer.consumeItem(entityplayer, role.inventoryCurrency.getStackInSlot(i + 18), role.ignoreDamage, role.ignoreNBT);
|
||||
ItemStack soldItem = item.copy();
|
||||
givePlayer(soldItem, entityplayer);
|
||||
role.addPurchase(i, entityplayer);
|
||||
return soldItem;
|
||||
|
||||
}
|
||||
public boolean isSlotEnabled(int slot, EntityPlayer player) {
|
||||
return role.isSlotEnabled(slot, player);
|
||||
}
|
||||
public boolean canBuy(int slot, EntityPlayer player) {
|
||||
ItemStack currency = role.inventoryCurrency.getStackInSlot(slot);
|
||||
ItemStack currency2 = role.inventoryCurrency.getStackInSlot(slot + 18);
|
||||
if(currency == null && currency2 == null)
|
||||
return true;
|
||||
|
||||
if(currency == null){
|
||||
currency = currency2;
|
||||
currency2 = null;
|
||||
|
||||
@@ -139,7 +139,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
|
||||
public boolean updateClient = false;
|
||||
public boolean updateAI = false;
|
||||
|
||||
|
||||
public FlyingMoveHelper flyMoveHelper = new FlyingMoveHelper(this);
|
||||
public PathNavigate flyNavigator = new PathNavigateFlying(this, worldObj);
|
||||
|
||||
@@ -956,6 +956,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
totalTicksAlive = compound.getLong("TotalTicksAlive");
|
||||
|
||||
linkedName = compound.getString("LinkedNpcName");
|
||||
|
||||
if(!isRemote())
|
||||
LinkedNpcController.Instance.loadNpcData(this);
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ public class EntityProjectile extends EntityThrowable {
|
||||
public boolean accelerate = false;
|
||||
public boolean explosive = false;
|
||||
public boolean explosiveDamage = true;
|
||||
public boolean destroyTerrain = true;
|
||||
public int explosiveRadius = 0;
|
||||
public EnumPotionType effect = EnumPotionType.None;
|
||||
public int duration = 5;
|
||||
@@ -138,6 +139,7 @@ public class EntityProjectile extends EntityThrowable {
|
||||
if (isNPC) {
|
||||
this.npc = (EntityNPCInterface) this.thrower;
|
||||
this.getStatProperties(this.npc.stats);
|
||||
this.destroyTerrain = !this.npc.stats.projectilesKeepTerrain;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -562,7 +564,7 @@ public class EntityProjectile extends EntityThrowable {
|
||||
|
||||
if (explosive){
|
||||
if (this.explosiveRadius != 0 || this.effect == EnumPotionType.None){
|
||||
boolean terraindamage = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing") && explosiveDamage;
|
||||
boolean terraindamage = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing") && explosiveDamage && destroyTerrain;
|
||||
Explosion explosion = new Explosion(worldObj, this, posX, posY, posZ, explosiveRadius);
|
||||
explosion.isFlaming = this.effect == EnumPotionType.Fire;
|
||||
explosion.isSmoking = terraindamage;
|
||||
|
||||
@@ -104,6 +104,7 @@ public class RoleFollower extends RoleInterface{
|
||||
daysHired = 0;
|
||||
hiredTime = 0;
|
||||
isFollowing = true;
|
||||
npc.stats.canDespawn = npc.stats.playerSetCanDespawn;
|
||||
}
|
||||
|
||||
public int getDaysLeft(){
|
||||
@@ -150,6 +151,7 @@ public class RoleFollower extends RoleInterface{
|
||||
if(ownerUUID == null || id == null || !ownerUUID.equals(id))
|
||||
killed();
|
||||
ownerUUID = id.toString();
|
||||
npc.stats.canDespawn = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package noppes.npcs.roles;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import foxz.utils.Market;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.NpcMiscInventory;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import foxz.utils.Market;
|
||||
|
||||
public class RoleTrader extends RoleInterface{
|
||||
|
||||
@@ -24,10 +26,19 @@ public class RoleTrader extends RoleInterface{
|
||||
|
||||
public boolean toSave = false;
|
||||
|
||||
public int[] purchases;
|
||||
public int[] disableSlot;
|
||||
public HashMap<String, int[]> playerPurchases;
|
||||
public HashMap<String, int[]> playerDisableSlot;
|
||||
|
||||
public RoleTrader(EntityNPCInterface npc) {
|
||||
super(npc);
|
||||
inventoryCurrency = new NpcMiscInventory(36);
|
||||
inventorySold = new NpcMiscInventory(18);
|
||||
purchases = new int[18];
|
||||
disableSlot = new int[18];
|
||||
playerPurchases = new HashMap<String, int[]>();
|
||||
playerDisableSlot = new HashMap<String, int[]>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,6 +57,10 @@ public class RoleTrader extends RoleInterface{
|
||||
nbttagcompound.setTag("TraderSold", inventorySold.getToNBT());
|
||||
nbttagcompound.setBoolean("TraderIgnoreDamage", ignoreDamage);
|
||||
nbttagcompound.setBoolean("TraderIgnoreNBT", ignoreNBT);
|
||||
nbttagcompound.setIntArray("Purchases", purchases);
|
||||
nbttagcompound.setIntArray("DisableSlot", disableSlot);
|
||||
nbttagcompound.setTag("PlayerPurchases", NBTTags.nbtStringIntegerArrayMap(playerPurchases));
|
||||
nbttagcompound.setTag("PlayerDisableSlot", NBTTags.nbtStringIntegerArrayMap(playerDisableSlot));
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@@ -67,7 +82,18 @@ public class RoleTrader extends RoleInterface{
|
||||
inventorySold.setFromNBT(nbttagcompound.getCompoundTag("TraderSold"));
|
||||
ignoreDamage = nbttagcompound.getBoolean("TraderIgnoreDamage");
|
||||
ignoreNBT = nbttagcompound.getBoolean("TraderIgnoreNBT");
|
||||
|
||||
purchases = nbttagcompound.getIntArray("Purchases");
|
||||
if (purchases == null || purchases.length != 18) {
|
||||
purchases = new int[18];
|
||||
for (int i = 0; i < purchases.length; ++i) purchases[i] = 0;
|
||||
}
|
||||
disableSlot = nbttagcompound.getIntArray("DisableSlot");
|
||||
if (disableSlot == null || disableSlot.length != 18) {
|
||||
disableSlot = new int[18];
|
||||
for (int i = 0; i < disableSlot.length; ++i) disableSlot[i] = 0;
|
||||
}
|
||||
playerPurchases = NBTTags.getStringIntegerArrayMap(nbttagcompound.getTagList("PlayerPurchases", 10), 18);
|
||||
playerDisableSlot = NBTTags.getStringIntegerArrayMap(nbttagcompound.getTagList("PlayerDisableSlot", 10), 18);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,5 +117,24 @@ public class RoleTrader extends RoleInterface{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addPurchase(int slot, EntityPlayer player) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
++purchases[slot];
|
||||
++getArrayByName(player.getDisplayName(), playerPurchases)[slot];
|
||||
}
|
||||
|
||||
public boolean isSlotEnabled(int slot, EntityPlayer player) {
|
||||
if(slot >= 18 || slot < 0) return false;
|
||||
if (disableSlot[slot] > 0) return false;
|
||||
if (getArrayByName(player.getDisplayName(), playerDisableSlot)[slot] > 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public int[] getArrayByName(String name, HashMap<String, int[]> map) {
|
||||
int[] a = map.get(name);
|
||||
if (a == null) a = map.put(name, new int[18]);
|
||||
return a;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,17 @@
|
||||
package noppes.npcs.scripted;
|
||||
|
||||
import noppes.npcs.controllers.Faction;
|
||||
import noppes.npcs.controllers.FactionController;
|
||||
import noppes.npcs.scripted.entity.ScriptNpc;
|
||||
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||
|
||||
public class ScriptFaction {
|
||||
|
||||
private Faction faction;
|
||||
|
||||
public void saveFaction() {
|
||||
FactionController.getInstance().saveFaction(faction);
|
||||
}
|
||||
|
||||
public ScriptFaction(Faction faction){
|
||||
this.faction = faction;
|
||||
@@ -25,14 +31,58 @@ public class ScriptFaction {
|
||||
return faction.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
faction.name = name;
|
||||
}
|
||||
|
||||
public int getDefaultPoints(){
|
||||
return faction.defaultPoints;
|
||||
}
|
||||
|
||||
public void setDefaultPoints(int p) {
|
||||
faction.defaultPoints = p;
|
||||
}
|
||||
|
||||
public int getFriendlyPoints() {
|
||||
return faction.friendlyPoints;
|
||||
}
|
||||
|
||||
public void setFriendlyPoints(int p) {
|
||||
faction.friendlyPoints = p;
|
||||
}
|
||||
|
||||
public int getNeutralPoints() {
|
||||
return faction.neutralPoints;
|
||||
}
|
||||
|
||||
public void setNeutralPoints(int p) {
|
||||
faction.neutralPoints = p;
|
||||
}
|
||||
|
||||
public boolean getHideFaction() {
|
||||
return faction.hideFaction;
|
||||
}
|
||||
|
||||
public void setHideFaction(boolean b) {
|
||||
faction.hideFaction = b;
|
||||
}
|
||||
|
||||
public boolean getGetsAttacked() {
|
||||
return faction.getsAttacked;
|
||||
}
|
||||
|
||||
public void setGetsAttacked(boolean b) {
|
||||
faction.getsAttacked = b;
|
||||
}
|
||||
|
||||
public int getColor(){
|
||||
return faction.color;
|
||||
}
|
||||
|
||||
public void setColor(int c) {
|
||||
faction.color = c;
|
||||
}
|
||||
|
||||
public boolean isFriendlyToPlayer(ScriptPlayer player){
|
||||
return faction.isFriendlyToPlayer(player.player);
|
||||
}
|
||||
@@ -48,4 +98,27 @@ public class ScriptFaction {
|
||||
public boolean isAggressiveToNpc(ScriptNpc npc){
|
||||
return faction.isAggressiveToNpc(npc.npc);
|
||||
}
|
||||
|
||||
public Integer[] getEnemyFactionIds() {
|
||||
if (faction.attackFactions == null) return new Integer[0];
|
||||
return faction.attackFactions.toArray(new Integer[faction.attackFactions.size()]);
|
||||
}
|
||||
|
||||
public boolean isEnemyFaction(int id) {
|
||||
if (faction.attackFactions == null) return false;
|
||||
Integer[] enemies = getEnemyFactionIds();
|
||||
for (int i = 0; i < enemies.length; ++i) {
|
||||
if (enemies[i] == id) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addFactionEnemy(int id) {
|
||||
if (!faction.attackFactions.contains(id)) faction.attackFactions.add(id);
|
||||
}
|
||||
|
||||
public void removeFactionEnemy(int id) {
|
||||
faction.attackFactions.remove(id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,12 +6,14 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTBase.NBTPrimitive;
|
||||
@@ -346,6 +348,15 @@ public class ScriptItemStack implements IItemStack {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isFood() {
|
||||
return item.getItem() instanceof ItemFood;
|
||||
}
|
||||
|
||||
public int getFoodPoints() {
|
||||
if (isFood()) return ((ItemFood)item.getItem()).func_150905_g(item);
|
||||
return -1;
|
||||
}
|
||||
|
||||
public INbt getNbt() {
|
||||
NBTTagCompound compound = this.item.getTagCompound();
|
||||
|
||||
@@ -152,6 +152,16 @@ public class ScriptScoreboard {
|
||||
return teams;
|
||||
}
|
||||
|
||||
public ScriptScoreboardTeam getTeamByName(String name) {
|
||||
ScriptScoreboardTeam[] 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;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,10 @@ public class ScriptScoreboardTeam {
|
||||
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){
|
||||
|
||||
@@ -18,8 +18,8 @@ import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntitySign;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.blocks.tiles.TileBigSign;
|
||||
@@ -28,6 +28,7 @@ import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.scripted.entity.ScriptEntity;
|
||||
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||
import noppes.npcs.scripted.interfaces.IBlock;
|
||||
import noppes.npcs.scripted.interfaces.IPos;
|
||||
import noppes.npcs.scripted.interfaces.IWorld;
|
||||
|
||||
public class ScriptWorld implements IWorld {
|
||||
@@ -67,6 +68,14 @@ public class ScriptWorld implements IWorld {
|
||||
return null;
|
||||
return new ScriptBlock(world, block, new BlockPos(x,y,z));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pos
|
||||
* @return The block at the given position. Returns null if there isn't a block
|
||||
*/
|
||||
public IBlock getBlock(IPos pos){
|
||||
return getBlock(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x World position x
|
||||
@@ -93,6 +102,14 @@ public class ScriptWorld implements IWorld {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setBlock(int x, int y, int z, IBlock block){
|
||||
if(block == null || block.getMCBlock().isAir(world, x, y, z)){
|
||||
removeBlock(x, y, z);
|
||||
return;
|
||||
}
|
||||
world.setBlock(x, y, z, block.getMCBlock());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x World position x
|
||||
* @param y World position y
|
||||
@@ -119,6 +136,82 @@ public class ScriptWorld implements IWorld {
|
||||
world.setBlock(x, y, z, Blocks.air);
|
||||
}
|
||||
|
||||
/**
|
||||
* starting at the start position, draw a line in the lookVector direction until a block is detected
|
||||
* @param startPos
|
||||
* @param lookVector should be a normalized direction vector
|
||||
* @param maxDistance
|
||||
* @return the first detected block but null if maxDistance is reached
|
||||
*/
|
||||
public IBlock rayCastBlock(double[] startPos, double[] lookVector, int maxDistance) {
|
||||
if (startPos.length != 3 || lookVector.length != 3) return null;
|
||||
Vec3 currentPos = Vec3.createVectorHelper(startPos[0], startPos[1], startPos[2]); int rep = 0;
|
||||
while (rep++ < maxDistance + 10) {
|
||||
currentPos = currentPos.addVector(lookVector[0], lookVector[1], lookVector[2]);
|
||||
IBlock block = getBlock((int)currentPos.xCoord, (int)currentPos.yCoord, (int)currentPos.zCoord);
|
||||
//System.out.println("Checking block at ["+(int)currentPos.xCoord+","+(int)currentPos.yCoord+","+(int)currentPos.zCoord+"]");
|
||||
if (block == null) continue;
|
||||
double distance = Math.pow(
|
||||
Math.pow(currentPos.xCoord-startPos[0],2)
|
||||
+Math.pow(currentPos.yCoord-startPos[1],2)
|
||||
+Math.pow(currentPos.zCoord-startPos[2],2)
|
||||
, 0.5);
|
||||
//System.out.println("current distance check: "+distance+" on rep "+rep);
|
||||
if (distance > maxDistance) return null;
|
||||
return block;
|
||||
}
|
||||
//System.out.println("ScriptWorld:WARNING: Repeated a ray cast to many times");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* starting at the start position, draw a line in the lookVector direction until a block is detected
|
||||
* @param startPos
|
||||
* @param lookVector will normalize x, y, z to get a direction vector
|
||||
* @param maxDistance
|
||||
* @return the first detected block but null if maxDistance is reached
|
||||
*/
|
||||
public IBlock rayCastBlock(IPos startPos, IPos lookVector, int maxDistance) {
|
||||
return rayCastBlock(new double[] {startPos.getX(), startPos.getY(), startPos.getZ()}, lookVector.normalize(), maxDistance);
|
||||
}
|
||||
|
||||
public IPos getNearestAir(IPos pos, int maxHeight) {
|
||||
if (pos == null) return null;
|
||||
IPos currentPos = pos;
|
||||
IBlock block = null; int rep = 0;
|
||||
while (rep++ < maxHeight) {
|
||||
//check +x
|
||||
currentPos = currentPos.add(1, 0, 0);
|
||||
block = getBlock(currentPos);
|
||||
if (block == null) break;
|
||||
//check -x
|
||||
currentPos = currentPos.add(-2, 0, 0);
|
||||
block = getBlock(currentPos);
|
||||
if (block == null) break;
|
||||
//check +z
|
||||
currentPos = currentPos.add(1, 0, 1);
|
||||
block = getBlock(currentPos);
|
||||
if (block == null) break;
|
||||
//check -z
|
||||
currentPos = currentPos.add(0, 0, -2);
|
||||
block = getBlock(currentPos);
|
||||
if (block == null) break;
|
||||
//check up 1
|
||||
currentPos = currentPos.add(0, 1, 1);
|
||||
block = getBlock(currentPos);
|
||||
if (block == null) break;
|
||||
}
|
||||
return currentPos;
|
||||
}
|
||||
|
||||
public boolean canSeeSky(int x, int y, int z) {
|
||||
return world.canBlockSeeTheSky(x, y, z);
|
||||
}
|
||||
|
||||
public boolean canSeeSky(IPos pos) {
|
||||
return canSeeSky(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name The name of the player to be returned
|
||||
* @return The Player with name. Null is returned when the player isnt found
|
||||
@@ -317,6 +410,13 @@ public class ScriptWorld implements IWorld {
|
||||
return arr;
|
||||
}
|
||||
|
||||
public String[] getPlayerNames() {
|
||||
ScriptPlayer[] players = getAllServerPlayers();
|
||||
String[] names = new String[players.length];
|
||||
for (int i = 0; i < names.length; ++i) names[i] = players[i].getDisplayName();
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @param x Position x
|
||||
|
||||
@@ -15,8 +15,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTBase.NBTPrimitive;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagIntArray;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
@@ -24,7 +24,12 @@ import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.ServerCloneController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.*;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptBlockPos;
|
||||
import noppes.npcs.scripted.ScriptEntityParticle;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.ScriptWorld;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.interfaces.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.INbt;
|
||||
@@ -413,6 +418,8 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
NBTBase base = compound.getTag(key);
|
||||
if(base instanceof NBTPrimitive)
|
||||
return ((NBTPrimitive)base).func_150286_g();
|
||||
else if (base instanceof NBTTagIntArray)
|
||||
return ((NBTTagIntArray)base).func_150302_c();
|
||||
return ((NBTTagString)base).func_150285_a_();
|
||||
}
|
||||
|
||||
@@ -430,6 +437,12 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
compound.setString(key, (String)value);
|
||||
saveStoredCompound(compound);
|
||||
}
|
||||
|
||||
public void setStoredData(String key, int[] array){
|
||||
NBTTagCompound compound = getStoredCompound();
|
||||
compound.setIntArray(key, array);
|
||||
saveStoredCompound(compound);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key of the data to be checked
|
||||
@@ -528,6 +541,10 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
public String getTypeName(){
|
||||
return EntityList.getEntityString(entity);
|
||||
}
|
||||
|
||||
public void playSound(String name, float volume, float pitch) {
|
||||
entity.playSound(name, volume, pitch);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item Item to be dropped
|
||||
|
||||
@@ -269,6 +269,16 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
npc.shoot(target.entity, accuracy, item.item, false);
|
||||
}
|
||||
|
||||
public void setProjectilesKeepTerrain(boolean t) {
|
||||
npc.stats.projectilesKeepTerrain = t;
|
||||
}
|
||||
|
||||
public boolean getProjectilesKeepTerrain() {
|
||||
return npc.stats.projectilesKeepTerrain;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param message The message the npc will say
|
||||
*/
|
||||
@@ -524,7 +534,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
* @param item The item the drop list slot will be changed to
|
||||
*/
|
||||
public void setLootItem(int slot, ScriptItemStack item) {
|
||||
npc.inventory.setInventorySlotContents(slot+7, item.item);
|
||||
if (item == null) npc.inventory.setInventorySlotContents(slot+7, null);
|
||||
else npc.inventory.setInventorySlotContents(slot+7, item.item);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -856,6 +867,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
|
||||
public void setNaturallyDespawns(boolean canDespawn) {
|
||||
npc.stats.canDespawn = canDespawn;
|
||||
npc.stats.playerSetCanDespawn = canDespawn;
|
||||
}
|
||||
|
||||
public void giveItem(ScriptPlayer player, ScriptItemStack item){
|
||||
@@ -1000,6 +1012,13 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
npc.stats.healthRegen = (float)(Math.floor(regen));
|
||||
}
|
||||
|
||||
public boolean getCanDrown() {
|
||||
return npc.stats.canDrown;
|
||||
}
|
||||
public void setCanDrown(boolean d) {
|
||||
npc.stats.canDrown = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAge(){
|
||||
return npc.totalTicksAlive;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package noppes.npcs.scripted.entity;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -9,31 +13,46 @@ import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.stats.StatBase;
|
||||
import net.minecraft.stats.StatList;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import noppes.npcs.*;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.NoppesStringUtils;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.containers.ContainerCustomGui;
|
||||
import noppes.npcs.controllers.*;
|
||||
import noppes.npcs.controllers.CustomGuiController;
|
||||
import noppes.npcs.controllers.Dialog;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.PixelmonHelper;
|
||||
import noppes.npcs.controllers.PlayerData;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.PlayerDialogData;
|
||||
import noppes.npcs.controllers.PlayerQuestData;
|
||||
import noppes.npcs.controllers.Quest;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.QuestData;
|
||||
import noppes.npcs.entity.EntityDialogNpc;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.ScriptPixelmonPlayerData;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.event.FactionEvent;
|
||||
import noppes.npcs.scripted.gui.ScriptGui;
|
||||
import noppes.npcs.scripted.handler.data.IQuest;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.scripted.interfaces.IBlock;
|
||||
import noppes.npcs.scripted.interfaces.IContainer;
|
||||
import noppes.npcs.scripted.interfaces.ICustomGui;
|
||||
import noppes.npcs.scripted.interfaces.ICustomOverlay;
|
||||
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.ITimers;
|
||||
import noppes.npcs.scripted.overlay.ScriptOverlay;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T> implements IPlayer {
|
||||
public T player;
|
||||
private PlayerData data;
|
||||
@@ -120,6 +139,14 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
PlayerDialogData data = PlayerDataController.instance.getPlayerData(player).dialogData;
|
||||
return data.dialogsRead.contains(id);
|
||||
}
|
||||
|
||||
public void readDialog(int id) {
|
||||
PlayerDataController.instance.getPlayerData(player).dialogData.dialogsRead.add(id);
|
||||
}
|
||||
|
||||
public void unreadDialog(int id) {
|
||||
PlayerDataController.instance.getPlayerData(player).dialogData.dialogsRead.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the quest from active quest list
|
||||
@@ -192,6 +219,14 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
data.factionData.increasePoints(faction, points, player);
|
||||
}
|
||||
/**
|
||||
* @param faction The faction id
|
||||
* @param points The new point value for this faction
|
||||
*/
|
||||
public void setFactionPoints(int faction, int points) {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
data.factionData.increasePoints(faction, points-getFactionPoints(faction), player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param faction The faction id
|
||||
@@ -209,6 +244,36 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
player.addChatMessage(new ChatComponentTranslation(NoppesStringUtils.formatText(message,player)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message The message you want to send
|
||||
*/
|
||||
public void sendMessage(String message, EnumChatFormatting color, boolean bold, boolean italic, boolean underlined) {
|
||||
ChatComponentTranslation chat = new ChatComponentTranslation(NoppesStringUtils.formatText(message,player));
|
||||
ChatStyle style = new ChatStyle();
|
||||
style.setColor(color);
|
||||
style.setBold(bold);
|
||||
style.setItalic(italic);
|
||||
style.setUnderlined(underlined);
|
||||
chat.setChatStyle(style);
|
||||
player.addChatMessage(chat);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message The message you want to send
|
||||
*/
|
||||
public void sendMessage(String message, EnumChatFormatting color, boolean bold, boolean italic, boolean obfuscated, boolean strikethrough, boolean underlined) {
|
||||
ChatComponentTranslation chat = new ChatComponentTranslation(NoppesStringUtils.formatText(message,player));
|
||||
ChatStyle style = new ChatStyle();
|
||||
style.setColor(color);
|
||||
style.setBold(bold);
|
||||
style.setItalic(italic);
|
||||
style.setObfuscated(obfuscated);
|
||||
style.setStrikethrough(strikethrough);
|
||||
style.setUnderlined(underlined);
|
||||
chat.setChatStyle(style);
|
||||
player.addChatMessage(chat);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return gamemode. 0: Survival, 1: Creative, 2: Adventure
|
||||
*/
|
||||
@@ -352,6 +417,11 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
player.inventory.mainInventory[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void clearInventory() {
|
||||
for(int i = 0; i < player.inventory.mainInventory.length; i++) player.inventory.mainInventory[i] = null;
|
||||
for(int i = 0; i < player.inventory.armorInventory.length; i++) player.inventory.armorInventory[i] = null;
|
||||
}
|
||||
|
||||
public void setRotation(float rotationYaw){
|
||||
NoppesUtilPlayer.teleportPlayer(player, player.posX, player.posY, player.posZ, rotationYaw, player.rotationPitch, player.dimension);
|
||||
@@ -407,6 +477,14 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
return null;
|
||||
return new ScriptPixelmonPlayerData(player);
|
||||
}
|
||||
|
||||
public IBlock getLookingAtBlock(int maxDistance) {
|
||||
Vec3 lookVec = player.getLookVec();
|
||||
return getWorld().rayCastBlock(
|
||||
new double[] {player.posX, player.posY+player.getEyeHeight(), player.posZ},
|
||||
new double[] {lookVec.xCoord, lookVec.yCoord, lookVec.zCoord},
|
||||
maxDistance);
|
||||
}
|
||||
|
||||
public ITimers getTimers() {
|
||||
return PlayerDataController.instance.getPlayerData(player).timers;
|
||||
|
||||
@@ -162,6 +162,10 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
|
||||
* @param accuracy Accuracy of the shot (0-100)
|
||||
*/
|
||||
public void shootItem(ScriptLivingBase target, ScriptItemStack item, int accuracy);
|
||||
|
||||
public void setProjectilesKeepTerrain(boolean b);
|
||||
|
||||
public boolean getProjectilesKeepTerrain();
|
||||
|
||||
/**
|
||||
* @param message The message the npc will say
|
||||
@@ -343,7 +347,11 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
|
||||
* @return The maximum XP gained from killing the NPC.
|
||||
*/
|
||||
public int getMaxLootXP();
|
||||
|
||||
|
||||
public boolean getCanDrown();
|
||||
|
||||
public void setCanDrown(boolean b);
|
||||
|
||||
/**
|
||||
* @param type The AnimationType
|
||||
*/
|
||||
|
||||
@@ -130,7 +130,6 @@ public interface IEntity<T extends Entity> {
|
||||
*/
|
||||
public void setPosition(double x, double y, double z);
|
||||
|
||||
|
||||
/**
|
||||
* @param range The search range for entities around this entity
|
||||
* @return Array of entities within range
|
||||
@@ -190,6 +189,8 @@ public interface IEntity<T extends Entity> {
|
||||
* @param value The data stored. This data can be either a Number or a String. Other data is not stored
|
||||
*/
|
||||
public void setStoredData(String key, Object value);
|
||||
|
||||
public void setStoredData(String key, int[] array);
|
||||
|
||||
/**
|
||||
* @param key The key of the data to be checked
|
||||
@@ -251,6 +252,8 @@ public interface IEntity<T extends Entity> {
|
||||
* @return Name as which it's registered in minecraft
|
||||
*/
|
||||
public String getTypeName();
|
||||
|
||||
public void playSound(String name, float volume, float pitch);
|
||||
|
||||
/**
|
||||
* @param item Item to be dropped
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.Vec3;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.ScriptPixelmonPlayerData;
|
||||
|
||||
@@ -26,6 +28,10 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
|
||||
public void showDialog(int id);
|
||||
|
||||
public boolean hasReadDialog(int id);
|
||||
|
||||
public void readDialog(int id);
|
||||
|
||||
public void unreadDialog(int id);
|
||||
|
||||
/**
|
||||
* Add the quest from active quest list
|
||||
@@ -58,7 +64,11 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
|
||||
* @param points The points to increase. Use negative values to decrease
|
||||
*/
|
||||
public void addFactionPoints(int faction, int points);
|
||||
|
||||
/**
|
||||
* @param faction The faction id
|
||||
* @param points The new point value for this faction
|
||||
*/
|
||||
public void setFactionPoints(int faction, int points);
|
||||
/**
|
||||
* @param faction The faction id
|
||||
* @return points
|
||||
@@ -69,7 +79,11 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
|
||||
* @param message The message you want to send
|
||||
*/
|
||||
public void sendMessage(String message);
|
||||
|
||||
|
||||
public void sendMessage(String message, EnumChatFormatting color, boolean bold, boolean italic, boolean underlined);
|
||||
|
||||
public void sendMessage(String message, EnumChatFormatting color, boolean bold, boolean italic, boolean obfuscated, boolean strikethrough, boolean underlined);
|
||||
|
||||
/**
|
||||
* @return Return gamemode. 0: Survival, 1: Creative, 2: Adventure
|
||||
*/
|
||||
@@ -139,6 +153,8 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
|
||||
* @param item The item to be removed from the players inventory
|
||||
*/
|
||||
public void removeAllItems(ScriptItemStack item);
|
||||
|
||||
public void clearInventory();
|
||||
|
||||
|
||||
/**
|
||||
@@ -170,6 +186,8 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
|
||||
* @since 1.7.10d
|
||||
*/
|
||||
public ScriptPixelmonPlayerData getPixelmonData();
|
||||
|
||||
public IBlock getLookingAtBlock(int maxDistance);
|
||||
|
||||
public ITimers getTimers();
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.scripted.*;
|
||||
import noppes.npcs.scripted.ScriptEntityParticle;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.ScriptScoreboard;
|
||||
import noppes.npcs.scripted.entity.ScriptEntity;
|
||||
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||
|
||||
@@ -25,6 +26,12 @@ public interface IWorld {
|
||||
* @return The block at the given position. Returns null if there isn't a block
|
||||
*/
|
||||
public IBlock getBlock(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @param pos
|
||||
* @return The block at the given position. Returns null if there isn't a block
|
||||
*/
|
||||
public IBlock getBlock(IPos pos);
|
||||
|
||||
/**
|
||||
* @param x World position x
|
||||
@@ -42,13 +49,60 @@ public interface IWorld {
|
||||
* @param item The block to be set
|
||||
*/
|
||||
public void setBlock(int x, int y, int z, ScriptItemStack item);
|
||||
|
||||
|
||||
/**
|
||||
* @param x World position x
|
||||
* @param y World position y
|
||||
* @param z World position z
|
||||
* @param block The block to be set
|
||||
*/
|
||||
public void setBlock(int x, int y, int z, IBlock block);
|
||||
|
||||
/**
|
||||
* @param x World position x
|
||||
* @param y World position y
|
||||
* @param z World position z
|
||||
*/
|
||||
public void removeBlock(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* starting at the start position, draw a line in the lookVector direction until a block is detected
|
||||
* @param startPos
|
||||
* @param lookVector should be a normalized direction vector
|
||||
* @param maxDistance
|
||||
* @return the first detected block but null if maxDistance is reached
|
||||
*/
|
||||
public IBlock rayCastBlock(double[] startPos, double[] lookVector, int maxDistance);
|
||||
|
||||
/**
|
||||
* starting at the start position, draw a line in the lookVector direction until a block is detected
|
||||
* @param startPos
|
||||
* @param lookVector will normalize x, y, z to get a direction vector
|
||||
* @param maxDistance
|
||||
* @return the first detected block but null if maxDistance is reached
|
||||
*/
|
||||
public IBlock rayCastBlock(IPos startPos, IPos lookVector, int maxDistance);
|
||||
|
||||
/**
|
||||
* @param startPos
|
||||
* @param maxHeight
|
||||
* @return the position of the closest block of air to startPos
|
||||
*/
|
||||
public IPos getNearestAir(IPos startPos, int maxHeight);
|
||||
|
||||
/**
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return can the block at this position see the sky or are there no blocks above this one
|
||||
*/
|
||||
public boolean canSeeSky(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @param pos
|
||||
* @return can the block at this position see the sky or are there no blocks above this one
|
||||
*/
|
||||
public boolean canSeeSky(IPos pos);
|
||||
|
||||
/**
|
||||
* @param name The name of the player to be returned
|
||||
@@ -180,6 +234,8 @@ public interface IWorld {
|
||||
public void explode(double x, double y, double z, float range, boolean fire, boolean grief);
|
||||
|
||||
public ScriptPlayer[] getAllServerPlayers();
|
||||
|
||||
public String[] getPlayerNames();
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
@@ -199,7 +255,7 @@ public interface IWorld {
|
||||
* @return Returns the entity which was spawned
|
||||
*/
|
||||
public ScriptEntity spawnClone(int x, int y, int z, int tab, String name);
|
||||
|
||||
|
||||
public ScriptScoreboard getScoreboard();
|
||||
|
||||
BlockPos getMCBlockPos(int x, int y, int z);
|
||||
|
||||
@@ -46,6 +46,14 @@ public class ScriptRoleFollower extends ScriptRoleInterface{
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.7.10c
|
||||
* @return Returns days left
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import foxz.utils.Market;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleTrader;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
import foxz.utils.Market;
|
||||
import noppes.npcs.scripted.interfaces.IItemStack;
|
||||
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||
|
||||
public class ScriptRoleTrader extends ScriptRoleInterface{
|
||||
private RoleTrader role;
|
||||
@@ -19,7 +22,7 @@ public class ScriptRoleTrader extends ScriptRoleInterface{
|
||||
* @param currency2 Currency item number two
|
||||
* @param sold Item to be sold by this npc
|
||||
*/
|
||||
public void setSellOption(int slot, ScriptItemStack currency, ScriptItemStack currency2, ScriptItemStack sold){
|
||||
public void setSellOption(int slot, IItemStack currency, IItemStack currency2, IItemStack sold){
|
||||
if(sold == null || slot >= 18 || slot < 0)
|
||||
return;
|
||||
if(currency == null)
|
||||
@@ -42,16 +45,41 @@ public class ScriptRoleTrader extends ScriptRoleInterface{
|
||||
* @param currency Currency item
|
||||
* @param sold Item to be sold by this npc
|
||||
*/
|
||||
public void setSellOption(int slot, ScriptItemStack currency, ScriptItemStack sold){
|
||||
public void setSellOption(int slot, IItemStack currency, IItemStack sold){
|
||||
setSellOption(slot, currency, null, sold);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @return The item being sold in this slot.
|
||||
*/
|
||||
public IItemStack getSellOption(int slot) {
|
||||
if (slot >= 18 || slot < 0) return null;
|
||||
if (role.inventorySold.items.get(slot) == null) return null;
|
||||
return new ScriptItemStack(role.inventorySold.items.get(slot));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @return a ScriptItemStack array of size 2 which contains the currency of this trade
|
||||
*/
|
||||
public IItemStack[] getCurrency(int slot) {
|
||||
if (slot >= 18 || slot < 0) return null;
|
||||
ScriptItemStack[] currency = new ScriptItemStack[2];
|
||||
if (role.inventoryCurrency.items.get(slot) != null) {
|
||||
currency[0] = new ScriptItemStack(role.inventoryCurrency.items.get(slot));
|
||||
}
|
||||
if (role.inventoryCurrency.items.get(slot + 18) != null) {
|
||||
currency[1] = new ScriptItemStack(role.inventoryCurrency.items.get(slot + 18));
|
||||
}
|
||||
return currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot Slot number 0-17
|
||||
*/
|
||||
public void removeSellOption(int slot){
|
||||
if(slot >= 18 || slot < 0)
|
||||
return;
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
role.inventoryCurrency.items.remove(slot);
|
||||
role.inventoryCurrency.items.remove(slot + 18);
|
||||
role.inventorySold.items.remove(slot);
|
||||
@@ -70,6 +98,108 @@ public class ScriptRoleTrader extends ScriptRoleInterface{
|
||||
public String getMarket(){
|
||||
return role.marketName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @return the number of times an item has been sold on that slot
|
||||
*/
|
||||
public int getPurchaseNum(int slot) {
|
||||
if(slot >= 18 || slot < 0) return -1;
|
||||
return role.purchases[slot];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @param player
|
||||
* @return the number of times this player has purchased from this trader
|
||||
*/
|
||||
public int getPurchaseNum(int slot, IPlayer player) {
|
||||
if(slot >= 18 || slot < 0) return -1;
|
||||
return role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the purchase count of all slots to 0
|
||||
*/
|
||||
public void resetPurchaseNum() {
|
||||
for (int i = 0; i < role.purchases.length; ++i) role.purchases[i] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the purchase num for that slot to 0
|
||||
* @param slot
|
||||
*/
|
||||
public void resetPurchaseNum(int slot) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
role.purchases[slot] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the purchase num for that slot and player to 0
|
||||
* @param slot
|
||||
* @param player
|
||||
*/
|
||||
public void resetPurchaseNum(int slot, IPlayer player) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
role.getArrayByName(player.getDisplayName(), role.playerPurchases)[slot] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @return if this slot is enabled
|
||||
*/
|
||||
public boolean isSlotEnabled(int slot) {
|
||||
if(slot >= 18 || slot < 0) return false;
|
||||
return role.disableSlot[slot] > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slot
|
||||
* @param player
|
||||
* @return if this slot is enabled for this player
|
||||
*/
|
||||
public boolean isSlotEnabled(int slot, IPlayer player) {
|
||||
if(slot >= 18 || slot < 0) return false;
|
||||
return role.isSlotEnabled(slot, (EntityPlayer)player.getMCEntity());
|
||||
}
|
||||
|
||||
/**
|
||||
* prevent an item from being sold on that slot
|
||||
* @param slot
|
||||
*/
|
||||
public void disableSlot(int slot) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
role.disableSlot[slot] = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* disables the slot for this player
|
||||
* @param slot
|
||||
* @param player
|
||||
*/
|
||||
public void disableSlot(int slot, IPlayer player) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
role.getArrayByName(player.getDisplayName(), role.playerDisableSlot)[slot] = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* allow an item to be sold on that slot
|
||||
* @param slot
|
||||
*/
|
||||
public void enableSlot(int slot) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
role.disableSlot[slot] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* enables the slot for this player
|
||||
* @param slot
|
||||
* @param player
|
||||
*/
|
||||
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(){
|
||||
|
||||
@@ -222,6 +222,7 @@ role.companion=Companion
|
||||
|
||||
trader.insufficient=Insufficient Currency
|
||||
trader.sufficient=Sufficient Currency
|
||||
trader.slotdisabled=Slot Disabled
|
||||
|
||||
job.name=Job
|
||||
job.none=No Job
|
||||
|
||||
Reference in new issue
Block a user