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

@@ -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
*/
@@ -129,7 +129,8 @@ public interface IEntity<T extends Entity> {
* @param z The z position
*/
public void setPosition(double x, double y, double z);
public int getDimension();
/**
* @param range The search range for entities around this entity
@@ -190,6 +191,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 +254,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 Vec3 getLookingAtBlock(int maxDistance);
public ITimers getTimers();
@@ -1,5 +1,8 @@
package noppes.npcs.scripted.interfaces;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.util.Vec3;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
@@ -42,13 +45,27 @@ 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, Block 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);
public Vec3 rayCastBlockPos(Vec3 pos, Vec3 look, int maxDistance);
public Vec3 getNearestAir(Vec3 pos, int maxHeight);
public boolean canSeeSky(int x, int y, int z);
/**
* @param name The name of the player to be returned
@@ -180,6 +197,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 +218,20 @@ public interface IWorld {
* @return Returns the entity which was spawned
*/
public ScriptEntity spawnClone(int x, int y, int z, int tab, String name);
public boolean spawnEntity(Entity e);
/**
* Create a new default faction
* @param name The name of the new faction. If the name already exists an '_' will be added at the end
* @return The faction object which was created
*/
public ScriptFaction createFaction(String name);
public ScriptFaction getFactionFromName(String name);
public ScriptFaction getFactionFromId(int id);
public ScriptScoreboard getScoreboard();
BlockPos getMCBlockPos(int x, int y, int z);