Added various things to the API and other small changes

This adds some useful functions to the api and a few other changes.
I had been creating a custom build of this mod while working on stuff because I couldn't figure out how to do certain things without changing the mod. So this is a collection api features that I think everyone would find useful.

Api additions:
-purchase counting, and disabling trades for the trader role. (if a trade is disabled the gui still says insufficient funds, maybe allow a custom message to appear) added get the traders currency items and sell items.
-if an npc's projectile does explosive damage, you can disable it destroying blocks even if mob griefing is on
-int arrays as stored data for entities
-entity.playSound(...)
-get set if npcs can drown
-player read and unread dialog
-player set faction points
-extra player.sendMessage functions to add custom colors/bold/underline
-player clear inventory
-get set if a follower npc is following a player or waiting
-a bunch of stuff to script faction
-is an item food and how many food points?
-get scoreboard team by it's name
-get and create factions from the script world
-world.rayCastBlockPos is used for getting what block a player is looking at.
-world.getNearestAir is meant to get the block of air above or around the result of world.rayCastBlockPos, or at least that's how I've been using it.

Changes:
-in NoppesUtilServer I feel like if an npc is cloned it's ticksExisted or age should bee zero
-follower npcs should have the canDespawn field automatically set to false...? maybe make it an option
This commit is contained in:
1whohears committed 2022-05-24 03:06:16 -05:00
1 parent 6fe16d1929
commit a4361b8420
21 files changed
+468 -13

No files matched your search

@@ -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,31 @@ public class ScriptFaction {
public boolean isAggressiveToNpc(ScriptNpc npc){
return faction.isAggressiveToNpc(npc.npc);
}
public int[] getFactionEnemies() {
if (faction.attackFactions == null) return null;
int[] r = new int[faction.attackFactions.size()];
Object[] objects = faction.attackFactions.toArray();
for (int i = 0; i < r.length; ++i) {
r[i] = (Integer)objects[i];
}
return r;
}
public boolean isEnemyFaction(int id) {
if (faction.attackFactions == null) return false;
int[] enemies = getFactionEnemies();
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);
}
}