Used interfaces in implementations instead of the real classes for most scripted classes.

This commit is contained in:
Luis C.M committed 2022-05-11 22:08:31 -05:00
1 parent 6896cec417
commit cf33b90b26
63 files changed
+466 -551

No files matched your search

@@ -0,0 +1,98 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.interfaces;
import java.io.File;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.EventBus;
import net.minecraft.entity.Entity;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.item.IItemStack;
public abstract class AbstractNpcAPI {
private static AbstractNpcAPI instance = null;
public AbstractNpcAPI() {
}
public abstract ICustomNpc createNPC(World var1);
public abstract ICustomNpc spawnNPC(World var1, int var2, int var3, int var4);
public abstract IEntity getIEntity(Entity var1);
public abstract IBlock getIBlock(World var1, BlockPos var2);
public abstract IBlock getIBlock(World world, int x, int y, int z);
public abstract IContainer getIContainer(IInventory var1);
public abstract IContainer getIContainer(Container var1);
public abstract IItemStack getIItemStack(ItemStack var1);
public abstract IWorld getIWorld(WorldServer var1);
public abstract IWorld getIWorld(int var1);
public abstract IWorld[] getIWorlds();
public abstract IDamageSource getIDamageSource(DamageSource var1);
public abstract EventBus events();
public abstract File getGlobalDir();
public abstract File getWorldDir();
public static boolean IsAvailable() {
return Loader.isModLoaded("customnpcs");
}
public static AbstractNpcAPI Instance() {
if (instance != null) {
return instance;
} else if (!IsAvailable()) {
return null;
} else {
try {
Class c = Class.forName("noppes.npcs.scripted.NpcAPI");
instance = (AbstractNpcAPI) c.getMethod("Instance").invoke((Object) null);
} catch (Exception var1) {
var1.printStackTrace();
}
return instance;
}
}
public abstract void executeCommand(IWorld var1, String var2);
public abstract String getRandomName(int var1, int var2);
public abstract INbt getINbt(NBTTagCompound entityData);
public abstract IPlayer[] getAllServerPlayers();
public abstract IItemStack createItem(String id, int damage, int size);
public abstract IParticle createParticle(String directory);
public abstract IParticle createEntityParticle(String directory);
public abstract int getServerTime();
}
@@ -7,9 +7,8 @@ package noppes.npcs.scripted.interfaces;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.item.ScriptItemStack;
import noppes.npcs.scripted.entity.ScriptPlayer;
public interface IContainer {
int getSize();
@@ -30,7 +29,7 @@ public interface IContainer {
void detectAndSendChanges();
void putStackInSlot(int slot, ScriptItemStack itemStack);
void putStackInSlot(int slot, IItemStack itemStack);
boolean isPlayerNotUsingContainer(ScriptPlayer player);
boolean isPlayerNotUsingContainer(IPlayer player);
}
@@ -2,11 +2,11 @@ package noppes.npcs.scripted.interfaces;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.scripted.ScriptWorld;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.interfaces.entity.IEntity;
public interface IParticle {
void spawnOnEntity(ScriptEntity entity);
void spawnOnEntity(IEntity entity);
void spawnInWorld(ScriptWorld world);
@@ -3,11 +3,9 @@ package noppes.npcs.scripted.interfaces;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import noppes.npcs.scripted.*;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.item.ScriptItemStack;
public interface IWorld {
/**
@@ -58,25 +56,25 @@ public interface IWorld {
int getBlockLightValue(int x, int y, int z);
void playSoundAtEntity(ScriptEntity entity, String sound, float volume, float pitch);
void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch);
void playSoundToNearExcept(ScriptPlayer player, String sound, float volume, float pitch);
void playSoundToNearExcept(IPlayer player, String sound, float volume, float pitch);
IEntity getEntityByID(int id);
boolean spawnEntityInWorld(ScriptEntity entity);
boolean spawnEntityInWorld(IEntity entity);
ScriptPlayer getClosestPlayerToEntity(ScriptEntity entity, double range);
IPlayer getClosestPlayerToEntity(IEntity entity, double range);
ScriptPlayer getClosestPlayer(double x, double y, double z, double range);
IPlayer getClosestPlayer(double x, double y, double z, double range);
ScriptPlayer getClosestVulnerablePlayerToEntity(ScriptEntity entity, double range);
IPlayer getClosestVulnerablePlayerToEntity(IEntity entity, double range);
ScriptPlayer getClosestVulnerablePlayer(double x, double y, double z, double range);
IPlayer getClosestVulnerablePlayer(double x, double y, double z, double range);
int countEntities(ScriptEntity entity);
int countEntities(IEntity entity);
void setTileEntity(int x, int y, int z, ScriptTileEntity tileEntity);
void setTileEntity(int x, int y, int z, ITileEntity tileEntity);
void removeTileEntity(int x, int y, int z);
@@ -105,7 +103,7 @@ public interface IWorld {
* @param z World position z
* @param item The block to be set
*/
void setBlock(int x, int y, int z, ScriptItemStack item);
void setBlock(int x, int y, int z, IItemStack item);
/**
* @param x World position x
@@ -118,9 +116,9 @@ public interface IWorld {
* @param name The name of the player to be returned
* @return The Player with name. Null is returned when the player isnt found
*/
ScriptPlayer getPlayer(String name);
IPlayer getPlayer(String name);
ScriptPlayer getPlayerByUUID(String uuid);
IPlayer getPlayerByUUID(String uuid);
/**
* @param time The world time to be set
@@ -173,9 +171,9 @@ public interface IWorld {
/**
* @param directory The particle's texture directory. Use only forward slashes when writing a directory. Example: "customnpcs:textures/particle/tail.png"
* @return Returns ScriptEntityParticle object
* @return Returns IEntityParticle object
*/
ScriptParticle createEntityParticle(String directory);
IParticle createEntityParticle(String directory);
/**
* @param key Get temp data for this key
@@ -245,7 +243,7 @@ public interface IWorld {
*/
void explode(double x, double y, double z, float range, boolean fire, boolean grief);
ScriptPlayer[] getAllServerPlayers();
IPlayer[] getAllServerPlayers();
/**
* @since 1.7.10c
@@ -264,7 +262,7 @@ public interface IWorld {
* @param name Name of the cloned entity
* @return Returns the entity which was spawned
*/
ScriptEntity spawnClone(int x, int y, int z, int tab, String name);
IEntity spawnClone(int x, int y, int z, int tab, String name);
ScriptScoreboard getScoreboard();
@@ -9,9 +9,6 @@ import net.minecraft.entity.EntityCreature;
import noppes.npcs.scripted.ScriptFaction;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.interfaces.ITimers;
import noppes.npcs.scripted.item.ScriptItemStack;
import noppes.npcs.scripted.entity.ScriptLivingBase;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.roles.*;
public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
@@ -167,7 +164,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* @param item The item you want to shoot
* @param accuracy Accuracy of the shot (0-100)
*/
void shootItem(ScriptLivingBase target, ScriptItemStack item, int accuracy);
void shootItem(IEntityLivingBase target, IItemStack item, int accuracy);
/**
* @param message The message the npc will say
@@ -177,7 +174,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
/**
* @param message The message the npc will say
*/
void say(ScriptPlayer player, String message);
void say(IPlayer player, String message);
/**
* Kill the npc, doesnt't despawn it
@@ -211,7 +208,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
/**
* @param item Item to be held in the right hand
*/
void setRightItem(ScriptItemStack item);
void setRightItem(IItemStack item);
/**
* @return The item held in the left hand
@@ -221,7 +218,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
/**
* @param item Item to be held in the left hand
*/
void setLeftItem(ScriptItemStack item);
void setLeftItem(IItemStack item);
/**
* @return Returns the projectile the npc uses
@@ -231,7 +228,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
/**
* @param item Item to be used as projectile
*/
void setProjectileItem(ScriptItemStack item);
void setProjectileItem(IItemStack item);
/**
*
@@ -288,7 +285,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* @param slot The armor slot to set. 0:head, 1:body, 2:legs, 3:boots
* @param item Item to be set as armor
*/
void setArmor(int slot, ScriptItemStack item);
void setArmor(int slot, IItemStack item);
/**
*
@@ -302,7 +299,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* @param slot The slot from the NPC's drop list to change
* @param item The item the drop list slot will be changed to
*/
void setLootItem(int slot, ScriptItemStack item);
void setLootItem(int slot, IItemStack item);
/**
*
@@ -488,7 +485,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* @param player The player this NPC becomes visible/invisible to
* @param visible True if you want the NPC to be invisible to the player, false otherwise
*/
void setVisibleTo(ScriptPlayer player, boolean visible);
void setVisibleTo(IPlayer player, boolean visible);
/**
*
@@ -497,7 +494,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* If setVisibleTo(player,visible) was not called to make this NPC invisible to the player at any point
* in the NPC's life, this function will return true regardless of the value of isVisible().
*/
boolean isVisibleTo(ScriptPlayer player);
boolean isVisibleTo(IPlayer player);
/**
* @param type The visibility type of the name, 0:visible, 1:invisible, 2:when-attacking
@@ -621,7 +618,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* @param player The player to give the item to
* @param item The item given to the player
*/
void giveItem(ScriptPlayer player, ScriptItemStack item);
void giveItem(IPlayer player, IItemStack item);
/**
@@ -8,10 +8,9 @@ package noppes.npcs.scripted.interfaces.entity;
import net.minecraft.entity.Entity;
import noppes.npcs.scripted.ScriptParticle;
import noppes.npcs.scripted.ScriptWorld;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.interfaces.INbt;
import noppes.npcs.scripted.interfaces.IPos;
import noppes.npcs.scripted.item.ScriptItemStack;
import noppes.npcs.scripted.interfaces.item.IItemStack;
public interface IEntity<T extends Entity> {
@@ -129,14 +128,14 @@ public interface IEntity<T extends Entity> {
* @param range The search range for entities around this entity
* @return Array of entities within range
*/
ScriptEntity[] getSurroundingEntities(int range);
IEntity[] getSurroundingEntities(int range);
/**
* @param range The search range for entities around this entity
* @param type The EntityType you want to find
* @return Array of entities within range
*/
ScriptEntity[] getSurroundingEntities(int range, int type);
IEntity[] getSurroundingEntities(int range, int type);
/**
* @return Whether the entity is alive or not
@@ -249,27 +248,27 @@ public interface IEntity<T extends Entity> {
/**
* @param item Item to be dropped
*/
void dropItem(ScriptItemStack item);
void dropItem(IItemStack item);
/**
* @return Return the rider
*/
ScriptEntity getRider();
IEntity getRider();
/**
* @param entity The entity to ride this entity
*/
void setRider(ScriptEntity entity);
void setRider(IEntity entity);
/**
* @return Return the entity, this entity is riding
*/
ScriptEntity getMount();
IEntity getMount();
/**
* @param entity The entity this entity will mount
*/
void setMount(ScriptEntity entity);
void setMount(IEntity entity);
/**
* @see noppes.npcs.scripted.constants.EntityType
@@ -1,11 +1,8 @@
package noppes.npcs.scripted.interfaces.entity;
import net.minecraft.entity.EntityLivingBase;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.item.ScriptItemStack;
import noppes.npcs.scripted.entity.ScriptLivingBase;
import noppes.npcs.scripted.wrapper.ScriptDamageSource;
import noppes.npcs.scripted.ScriptDamageSource;
public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T> {
/**
@@ -20,7 +17,7 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
void hurt(float damage);
void hurt(float damage, ScriptEntity source);
void hurt(float damage, IEntity source);
void hurt(float damage, ScriptDamageSource damageSource);
@@ -36,12 +33,12 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
/**
* @param living Entity which this entity will attack
*/
void setAttackTarget(ScriptLivingBase living);
void setAttackTarget(IEntityLivingBase living);
/**
* @return The entity which this entity is attacking
*/
ScriptLivingBase getAttackTarget();
IEntityLivingBase getAttackTarget();
int getType();
@@ -51,7 +48,7 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
* @param entity Entity to check
* @return Whether or not this entity can see the given entity
*/
boolean canSeeEntity(ScriptEntity entity);
boolean canSeeEntity(IEntity entity);
/**
* Expert use only
@@ -97,7 +94,7 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
* @since 1.7.10c
* @param item The item to be set
*/
void setHeldItem(ScriptItemStack item);
void setHeldItem(IItemStack item);
/**
* Note not all Living Entities support this
@@ -112,5 +109,5 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
* @param slot Slot of what armor piece to set, 0:boots, 1:pants, 2:body, 3:head
* @param item Item to be set
*/
void setArmor(int slot, ScriptItemStack item);
void setArmor(int slot, IItemStack item);
}
@@ -4,13 +4,11 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.scripted.ScriptBlock;
import noppes.npcs.scripted.entity.ScriptDBCPlayer;
import noppes.npcs.scripted.entity.ScriptEntity;
import noppes.npcs.scripted.interfaces.handler.data.IQuest;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.gui.ICustomGui;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.interfaces.overlay.ICustomOverlay;
import noppes.npcs.scripted.item.ScriptItemStack;
import noppes.npcs.scripted.ScriptPixelmonPlayerData;
public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T> {
@@ -103,7 +101,7 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
* @param item The item to be checked
* @return How many of this item the player has
*/
int inventoryItemCount(ScriptItemStack item);
int inventoryItemCount(IItemStack item);
/**
* @since 1.7.10d
@@ -116,7 +114,7 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
* @param amount How many will be removed
* @return Returns true if the items were removed succesfully. Returns false incase a bigger amount than what the player has was given
*/
boolean removeItem(ScriptItemStack item, int amount);
boolean removeItem(IItemStack item, int amount);
/**
* @since 1.7.10c
@@ -133,7 +131,7 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
* @param amount The amount of the item to be added
* @return Returns whether or not it gave the item succesfully
*/
boolean giveItem(ScriptItemStack item, int amount);
boolean giveItem(IItemStack item, int amount);
/**
* @since 1.7.10c
@@ -157,7 +155,7 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
/**
* @param item The item to be removed from the players inventory
*/
void removeAllItems(ScriptItemStack item);
void removeAllItems(IItemStack item);
void setRotation(float rotationYaw, float rotationPitch);
@@ -169,11 +167,11 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
void mountEntity(Entity ridingEntity);
ScriptEntity dropOneItem(boolean dropStack);
IEntity dropOneItem(boolean dropStack);
boolean canHarvestBlock(ScriptBlock block);
boolean interactWith(ScriptEntity entity);
boolean interactWith(IEntity entity);
/**
* @param achievement The achievement id. For a complete list see http://minecraft.gamepedia.com/Achievements
@@ -1,6 +1,36 @@
package noppes.npcs.scripted.interfaces.item;
import cpw.mods.fml.common.eventhandler.Event;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.ScriptContainer;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public interface IItemCustom extends IItemStack {
void callScript(EnumScriptType type, Event event);
boolean isClient();
boolean getEnabled();
void setEnabled(boolean bo);
String getLanguage();
void setLanguage(String lang);
List<ScriptContainer> getScripts();
String noticeString();
Map<Long, String> getConsoleText();
void clearConsole();
String getTexture();
void setTexture(String var2);