Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/main/java/noppes/npcs/scripted/NpcAPI.java
#	src/main/java/noppes/npcs/scripted/ScriptWorld.java
#	src/main/java/noppes/npcs/scripted/interfaces/AbstractNpcAPI.java
This commit is contained in:
Luis C.M committed 2022-11-06 01:00:47 -06:00
commit 66edbcea80
58 files changed
+283 -779

No files matched your search

@@ -30,7 +30,7 @@ public class ScriptBlock implements IBlock {
this.world = NpcAPI.Instance().getIWorld(world);
this.block = block;
this.pos = pos;
this.bPos = NpcAPI.Instance().getIPos(pos);
this.bPos = new ScriptBlockPos(pos);
this.tile = new ScriptTileEntity<>(world.getTileEntity(pos.getX(),pos.getY(), pos.getZ()));
}
@@ -64,13 +64,13 @@ public class ScriptBlock implements IBlock {
return this;
} else {
this.world.getMCWorld().setBlock(getX(),getY(),getZ(),block);
return NpcAPI.Instance().getIBlock(world, getX(),getY(),getZ());
return NpcAPI.Instance().getIBlock(world.getMCWorld(), block, new BlockPos(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());
return NpcAPI.Instance().getIBlock(world.getMCWorld(), block.getMCBlock(), new BlockPos(getX(),getY(),getZ()));
}
public boolean isContainer() {
@@ -10,7 +10,7 @@ import net.minecraft.util.math.BlockPos;
import noppes.npcs.scripted.interfaces.IPos;
public class ScriptBlockPos implements IPos {
public BlockPos blockPos;
private BlockPos blockPos;
public ScriptBlockPos(BlockPos pos) {
this.blockPos = pos;
@@ -29,75 +29,75 @@ public class ScriptBlockPos implements IPos {
}
public IPos up() {
return NpcAPI.Instance().getIPos(this.blockPos.up());
return new ScriptBlockPos(this.blockPos.up());
}
public IPos up(int n) {
return NpcAPI.Instance().getIPos(this.blockPos.up(n));
return new ScriptBlockPos(this.blockPos.up(n));
}
public IPos down() {
return NpcAPI.Instance().getIPos(this.blockPos.down());
return new ScriptBlockPos(this.blockPos.down());
}
public IPos down(int n) {
return NpcAPI.Instance().getIPos(this.blockPos.down(n));
return new ScriptBlockPos(this.blockPos.down(n));
}
public IPos north() {
return NpcAPI.Instance().getIPos(this.blockPos.north());
return new ScriptBlockPos(this.blockPos.north());
}
public IPos north(int n) {
return NpcAPI.Instance().getIPos(this.blockPos.north(n));
return new ScriptBlockPos(this.blockPos.north(n));
}
public IPos east() {
return NpcAPI.Instance().getIPos(this.blockPos.east());
return new ScriptBlockPos(this.blockPos.east());
}
public IPos east(int n) {
return NpcAPI.Instance().getIPos(this.blockPos.east(n));
return new ScriptBlockPos(this.blockPos.east(n));
}
public IPos south() {
return NpcAPI.Instance().getIPos(this.blockPos.south());
return new ScriptBlockPos(this.blockPos.south());
}
public IPos south(int n) {
return NpcAPI.Instance().getIPos(this.blockPos.south(n));
return new ScriptBlockPos(this.blockPos.south(n));
}
public IPos west() {
return NpcAPI.Instance().getIPos(this.blockPos.west());
return new ScriptBlockPos(this.blockPos.west());
}
public IPos west(int n) {
return NpcAPI.Instance().getIPos(this.blockPos.west(n));
return new ScriptBlockPos(this.blockPos.west(n));
}
public IPos add(int x, int y, int z) {
return NpcAPI.Instance().getIPos(this.blockPos.add(x, y, z));
return new ScriptBlockPos(this.blockPos.add(x, y, z));
}
public IPos add(IPos pos) {
return NpcAPI.Instance().getIPos(this.blockPos.add(this.blockPos));
return new ScriptBlockPos(this.blockPos.add(this.blockPos));
}
public IPos subtract(int x, int y, int z) {
return NpcAPI.Instance().getIPos(this.blockPos.add(-x, -y, -z));
return new ScriptBlockPos(this.blockPos.add(-x, -y, -z));
}
public IPos subtract(IPos pos) {
return NpcAPI.Instance().getIPos(this.blockPos.add(-pos.getX(), -pos.getY(), -pos.getZ()));
return new ScriptBlockPos(this.blockPos.add(-pos.getX(), -pos.getY(), -pos.getZ()));
}
public IPos offset(int direction) {
return NpcAPI.Instance().getIPos(this.blockPos.offset(EnumFacing.values()[direction]));
return new ScriptBlockPos(this.blockPos.offset(EnumFacing.values()[direction]));
}
public IPos offset(int direction, int n) {
return NpcAPI.Instance().getIPos(this.blockPos.offset(EnumFacing.values()[direction], n));
return new ScriptBlockPos(this.blockPos.offset(EnumFacing.values()[direction], n));
}
public double[] normalize() {
@@ -111,8 +111,4 @@ public class ScriptBlockPos implements IPos {
double d2 = (double)(this.getZ() - pos.getZ());
return Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
}
public BlockPos getMCPos() {
return this.blockPos;
}
}
@@ -3,7 +3,6 @@ package noppes.npcs.scripted;
import net.minecraft.nbt.*;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.scripted.interfaces.IParticle;
import noppes.npcs.scripted.interfaces.IPos;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.interfaces.entity.IEntity;
@@ -231,13 +230,6 @@ public class ScriptParticle implements IParticle {
return z;
}
public void setPosition(IPos pos) {
this.setPosition(pos.getX(),pos.getY(),pos.getZ());
}
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;
@@ -1,4 +1,4 @@
package noppes.npcs.scripted.scoreboard;
package noppes.npcs.scripted;
import java.util.ArrayList;
import java.util.List;
@@ -15,8 +15,8 @@ import net.minecraft.server.MinecraftServer;
*/
public class ScriptScoreboard {
private Scoreboard board;
public ScriptScoreboard(){
protected ScriptScoreboard(){
board = MinecraftServer.getServer().worldServerForDimension(0).getScoreboard();
}
@@ -1,4 +1,4 @@
package noppes.npcs.scripted.scoreboard;
package noppes.npcs.scripted;
import net.minecraft.scoreboard.ScoreObjective;
@@ -1,4 +1,4 @@
package noppes.npcs.scripted.scoreboard;
package noppes.npcs.scripted;
import java.util.ArrayList;
import java.util.List;
@@ -156,7 +156,7 @@ public class ScriptSound implements ISound {
}
public IPos getPos() {
return NpcAPI.Instance().getIPos(xPosF, yPosF, zPosF);
return new ScriptBlockPos(new BlockPos(xPosF,yPosF,zPosF));
}
public float getX() {
@@ -4,39 +4,27 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.scripted.interfaces.IBlock;
import noppes.npcs.scripted.interfaces.INbt;
import noppes.npcs.scripted.interfaces.ITileEntity;
public class ScriptTileEntity<T extends TileEntity> implements ITileEntity {
protected T tileEntity;
protected IWorld world;
public ScriptTileEntity(T tileEntity) {
this.tileEntity = tileEntity;
this.world = NpcAPI.Instance().getIWorld(tileEntity.getWorldObj());
}
public ScriptTileEntity(T tileEntity) { this.tileEntity = tileEntity; }
public int getBlockMetadata(){
return tileEntity.getBlockMetadata();
}
public IWorld getWorld(){
return world;
}
public void setWorld(IWorld world) {
this.tileEntity.setWorldObj(world.getMCWorld());
this.world = world;
public ScriptWorld getWorld(){
return (ScriptWorld) NpcAPI.Instance().getIWorld((WorldServer) tileEntity.getWorldObj());
}
public TileEntity getMCTileEntity() {
return this.tileEntity;
}
public void markDirty()
{
this.tileEntity.markDirty();
}
public void readFromNBT(INbt nbt){
this.tileEntity.readFromNBT(nbt.getMCNBT());
}
@@ -45,12 +33,8 @@ public class ScriptTileEntity<T extends TileEntity> implements ITileEntity {
return this.tileEntity.getDistanceFrom(x,y,z);
}
public double getDistanceFrom(IPos pos){
return this.getDistanceFrom(pos.getX(),pos.getY(),pos.getZ());
}
public IBlock getBlockType(){
return NpcAPI.Instance().getIBlock(world, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
return NpcAPI.Instance().getIBlock(tileEntity.getWorldObj(), tileEntity.getBlockType(), new BlockPos(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
}
public boolean isInvalid(){
@@ -1,19 +1,13 @@
package noppes.npcs.scripted.entity;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.interfaces.entity.IAnimal;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.item.IItemStack;
public class ScriptAnimal<T extends EntityAnimal> extends ScriptLiving<T> implements IAnimal {
protected T entity;
public ScriptAnimal(T entity) {
super(entity);
this.entity = entity;
}
@Override
@@ -21,35 +15,8 @@ public class ScriptAnimal<T extends EntityAnimal> extends ScriptLiving<T> implem
return EntityType.ANIMAL;
}
/**
* 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());
}
/**
* 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 boolean isInLove() {
return this.entity.isInLove();
}
public void resetInLove() {
this.entity.resetInLove();
}
public boolean canMateWith(IAnimal animal) {
return this.entity.canMateWith((EntityAnimal) animal.getMCEntity());
}
@Override
public boolean typeOf(int type){
return type == EntityType.ANIMAL || super.typeOf(type);
return type == EntityType.ANIMAL?true:super.typeOf(type);
}
}
@@ -363,14 +363,6 @@ public class ScriptEntity<T extends Entity> implements IEntity {
this.setMotionZ(z);
}
public void setMotion(IPos pos) {
this.setMotion(pos.getX(),pos.getY(),pos.getZ());
}
public IPos getMotion() {
return NpcAPI.Instance().getIPos(entity.motionX,entity.motionY,entity.motionZ);
}
public boolean isAirborne(){
return entity.isAirBorne;
}
@@ -406,21 +398,13 @@ public class ScriptEntity<T extends Entity> implements IEntity {
}
public IPos getPos() {
return NpcAPI.Instance().getIPos(entity.posX, entity.posY, entity.posZ);
}
public IPos getPosition() {
return getPos();
return new ScriptBlockPos(new BlockPos(entity.posX,entity.posY,entity.posZ));
}
public void setPos(IPos pos) {
this.entity.setPosition((double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F));
}
public void setPosition(IPos pos) {
this.setPos(pos);
}
public int getDimension(){
return entity.dimension;
}
@@ -746,10 +730,6 @@ public class ScriptEntity<T extends Entity> implements IEntity {
entity.velocityChanged = true;
}
public void knockback(IPos pos, float direction){
this.knockback(pos.getX(),pos.getY(),pos.getZ(),direction);
}
public void setImmune(int ticks) {
entity.hurtResistantTime = ticks;
};
@@ -809,11 +789,6 @@ public class ScriptEntity<T extends Entity> implements IEntity {
this.entity.readFromNBT(nbt.getMCNBT());
}
public INbt getNbtOptional() {
NBTTagCompound compound = new NBTTagCompound();
return this.entity.writeToNBTOptional(compound) ? NpcAPI.Instance().getINbt(compound) : null;
}
public void storeAsClone(int tab, String name) {
NBTTagCompound compound = new NBTTagCompound();
if (!this.entity.writeToNBTOptional(compound)) {
@@ -63,88 +63,4 @@ public class ScriptLiving<T extends EntityLiving> extends ScriptLivingBase<T> im
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);
}
}
@@ -1,5 +1,6 @@
package noppes.npcs.scripted.entity;
import net.minecraft.block.BlockLiquid;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.potion.Potion;
@@ -7,14 +8,18 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.Vec3;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.ScriptDamageSource;
import noppes.npcs.scripted.constants.EntityType;
import net.minecraft.util.math.BlockPos;
import noppes.npcs.scripted.ScriptBlockPos;
import noppes.npcs.scripted.interfaces.IBlock;
import noppes.npcs.scripted.interfaces.IPos;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.ScriptDamageSource;
import java.util.ArrayList;
public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T> implements IEntityLivingBase {
protected T entity;
@@ -103,7 +108,7 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
public IPos getLookVector() {
Vec3 lookVec = entity.getLookVec();
return NpcAPI.Instance().getIPos(lookVec.xCoord,lookVec.yCoord,lookVec.zCoord);
return new ScriptBlockPos(new BlockPos(lookVec.xCoord,lookVec.yCoord,lookVec.zCoord));
}
public IBlock getLookingAtBlock(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
@@ -243,54 +248,4 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
public void setArmor(int slot, IItemStack item){
entity.setCurrentItemOrArmor(slot + 1, item == null?null:item.getMCItemStack());
}
public boolean isChild() {
return this.entity.isChild();
}
public void renderBrokenItemStack(IItemStack itemStack)
{
this.entity.renderBrokenItemStack(itemStack.getMCItemStack());
}
public boolean isOnLadder()
{
return this.entity.isOnLadder();
}
public int getTotalArmorValue()
{
return this.entity.getTotalArmorValue();
}
public int getArrowCountInEntity() {
return this.entity.getArrowCountInEntity();
}
public void setArrowCountInEntity(int count)
{
this.entity.setArrowCountInEntity(count);
}
public void dismountEntity(IEntity entity) {
this.entity.dismountEntity(entity.getMCEntity());
}
public void setAIMoveSpeed(float speed)
{
this.entity.setAIMoveSpeed(speed);
}
public float getAIMoveSpeed() {
return this.entity.getAIMoveSpeed();
}
public void setAbsorptionAmount(float amount)
{
this.entity.setAbsorptionAmount(amount);
}
public float getAbsorptionAmount() {
return this.entity.getAbsorptionAmount();
}
}
@@ -18,7 +18,6 @@ import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.AnimationType;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.interfaces.IPos;
import noppes.npcs.scripted.interfaces.ITimers;
import noppes.npcs.scripted.interfaces.entity.ICustomNpc;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
@@ -152,10 +151,6 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
npc.script.clientNeedsUpdate = true;
}
public IPos getHome() {
return NpcAPI.Instance().getIPos(npc.ai.startPos[0],npc.ai.startPos[1],npc.ai.startPos[2]);
}
/**
* @return Home position x
*/
@@ -206,11 +201,6 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
public void setHome(int x, int y, int z){
npc.ai.startPos = new int[]{x, y, z};
}
public void setHome(IPos pos){
npc.ai.startPos = new int[]{pos.getX(), pos.getY(), pos.getZ()};
}
/**
* @param health New max health
*/
@@ -1143,7 +1133,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
public void setSkinType(byte type) {
npc.display.skinType = type;
npc.script.clientNeedsUpdate = true;
npc.updateClient = true;
}
public byte getSkinType() {
@@ -1156,7 +1146,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
this.npc.display.url = url;
npc.textureLocation = null;
npc.display.skinType = 2;
npc.script.clientNeedsUpdate = true;
npc.updateClient = true;
}
public String getSkinUrl() {
@@ -1165,7 +1155,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
public void setCloakTexture(String cloakTexture) {
npc.display.cloakTexture = cloakTexture;
npc.script.clientNeedsUpdate = true;
npc.updateClient = true;
}
public String getCloakTexture() {
@@ -1178,7 +1168,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
}
this.getOverlays().add(0, NpcAPI.Instance().createSkinOverlay(overlayTexture));
npc.script.clientNeedsUpdate = true;
npc.updateClient = true;
}
public String getOverlayTexture() {
@@ -1200,6 +1190,4 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
}
public void updateClient() { this.npc.updateClient(); }
public void updateAI() { this.npc.updateTasks(); }
}
@@ -86,10 +86,6 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
NoppesUtilPlayer.teleportPlayer(player, x, y, z, player.dimension);
}
public void setPosition(IPos pos) {
this.setPosition(pos.getX(),pos.getY(),pos.getZ());
}
public void setPosition(double x, double y, double z, int dimensionId){
if (NpcAPI.Instance().getIWorld(dimensionId) == null)
return;
@@ -97,10 +93,6 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
NoppesUtilPlayer.teleportPlayer(player, x, y, z, dimensionId);
}
public void setPosition(IPos pos, int dimensionId) {
this.setPosition(pos.getX(),pos.getY(),pos.getZ(), dimensionId);
}
public int getHunger(){
return player.getFoodStats().getFoodLevel();
}
@@ -513,10 +505,6 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
y = ValueUtil.CorrectInt(y, 0, 256);
player.setSpawnChunk(new ChunkCoordinates(x, y, z), true);
}
public void setSpawnpoint(IPos pos){
this.setSpawnpoint(pos.getX(),pos.getY(),pos.getZ());
}
public void resetSpawnpoint(){
player.setSpawnChunk(null, false);
@@ -459,7 +459,7 @@ public class PlayerEvent extends CustomNPCsEvent {
public Bonemeal(IPlayer player, int x, int y, int z, World world) {
super(player);
this.block = API.getIBlock(NpcAPI.Instance().getIWorld(world), x, y, z);
this.block = API.getIBlock(world, x, y, z);
this.x = x;
this.y = y;
this.z = z;
@@ -137,9 +137,6 @@ public interface IParticle {
double getY();
double getZ();
void setPosition(IPos pos);
void getPos();
void setMotion(double motionX, double motionY, double motionZ, float gravity);
double getMotionX();
double getMotionY();
@@ -5,8 +5,6 @@
package noppes.npcs.scripted.interfaces;
import net.minecraft.util.math.BlockPos;
public interface IPos {
int getX();
@@ -158,6 +156,4 @@ public interface IPos {
* @return The distance between this IPos object and the other.
*/
double distanceTo(IPos pos);
BlockPos getMCPos();
}
@@ -16,9 +16,7 @@ public interface ITileEntity {
*
* @return The world this tile entity is in.
*/
IWorld getWorld();
void setWorld(IWorld world);
ScriptWorld getWorld();
/**
*
@@ -26,8 +24,6 @@ public interface ITileEntity {
*/
TileEntity getMCTileEntity();
void markDirty();
/**
* Reads an INbt compound tag, creates a tile entity based on the data, and replaces this entity with the new one.
*/
@@ -37,7 +33,6 @@ public interface ITileEntity {
* @return The distance of this tile entity from the point given by the x, y, and z parameters.
*/
double getDistanceFrom(double x, double y, double z);
double getDistanceFrom(IPos pos);
/**
* @return A new IBlock object based on this tile entity's type.
@@ -1,7 +1,7 @@
package noppes.npcs.scripted.interfaces;
import net.minecraft.world.WorldServer;
import noppes.npcs.scripted.scoreboard.ScriptScoreboard;
import noppes.npcs.scripted.ScriptScoreboard;
import noppes.npcs.scripted.interfaces.entity.IEntity;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.handler.data.ISound;
@@ -39,65 +39,41 @@ public interface IWorld {
* @return The top-most block in the world as an IBlock object.
*/
IBlock getTopBlock(int x, int z);
IBlock getTopBlock(IPos pos);
boolean isBlockFreezable(IPos pos);
boolean isBlockFreezable(int x, int y, int z);
boolean isBlockFreezableNaturally(IPos pos);
boolean isBlockFreezableNaturally(int x, int y, int z);
boolean canBlockFreeze(IPos pos, boolean adjacentToWater);
boolean canBlockFreeze(int x, int y, int z, boolean adjacentToWater);
boolean canBlockFreezeBody(IPos pos, boolean adjacentToWater);
boolean canBlockFreezeBody(int x, int y, int z, boolean adjacentToWater);
boolean canSnowAt(IPos pos, boolean checkLight);
boolean canSnowAt(int x, int y, int z, boolean checkLight);
boolean canSnowAtBody(IPos pos, boolean checkLight);
boolean canSnowAtBody(int x, int y, int z, boolean checkLight);
/**
* @return The Y-value of the world at this x & z value based on the height map of the world.
*/
int getHeightValue(int x, int z);
int getHeightValue(IPos pos);
/**
* @return The minimum Y-value of the world at this x & z value based on the height map of the world.
*/
int getChunkHeightMapMinimum(int x, int z);
int getChunkHeightMapMinimum(IPos pos);
/**
* @return The metadata of the block at this position.
*/
int getBlockMetadata(int x, int y, int z);
int getBlockMetadata(IPos pos);
boolean setBlockMetadataWithNotify(int x, int y, int z, int metadata, int flag);
boolean setBlockMetadataWithNotify(IPos pos, int metadata, int flag);
/**
* @param x
* @param y
* @param z
* @return can the block at this position see the sky or are there no blocks above this one
*/
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
*/
boolean canSeeSky(IPos pos);
boolean canBlockSeeTheSky(int x, int y, int z);
int getFullBlockLightValue(int x, int y, int z);
int getFullBlockLightValue(IPos pos);
int getBlockLightValue(int x, int y, int z);
int getBlockLightValue(IPos pos);
void playSoundAtEntity(IEntity entity, String sound, float volume, float pitch);
@@ -120,12 +96,10 @@ public interface IWorld {
IPlayer getClosestPlayerToEntity(IEntity entity, double range);
IPlayer getClosestPlayer(double x, double y, double z, double range);
IPlayer getClosestPlayer(IPos pos, double range);
IPlayer getClosestVulnerablePlayerToEntity(IEntity entity, double range);
IPlayer getClosestVulnerablePlayer(double x, double y, double z, double range);
IPlayer getClosestVulnerablePlayer(IPos pos, double range);
/**
*
@@ -144,31 +118,25 @@ public interface IWorld {
* Sets the block's tile entity at the given position.
*/
void setTileEntity(int x, int y, int z, ITileEntity tileEntity);
void setTileEntity(IPos pos, ITileEntity tileEntity);
/**
* Removes the block's tile entity at the given position.
*/
void removeTileEntity(int x, int y, int z);
void removeTileEntity(IPos pos);
/**
*
* @return True if the block at this position is of cubic shape. (Not a stair, slab, etc.)
*/
boolean isBlockFullCube(int x, int y, int z);
boolean isBlockFullCube(IPos pos);
long getSeed();
void setSpawnLocation(int x, int y, int z);
void setSpawnLocation(IPos pos);
boolean canLightningStrikeAt(int x, int y, int z);
boolean canLightningStrikeAt(IPos pos);
boolean isBlockHighHumidity(int x, int y, int z);
boolean isBlockHighHumidity(IPos pos);
/**
* @param x World position x
@@ -178,7 +146,6 @@ public interface IWorld {
* @since 1.7.10d
*/
String getSignText(int x, int y, int z);
String getSignText(IPos pos);
/**
* @param x World position x
@@ -186,8 +153,7 @@ public interface IWorld {
* @param z World position z
* @param item The block to be set
*/
void setBlock(int x, int y, int z, IItemStack item);
void setBlock(IPos pos, IItemStack item);
public void setBlock(int x, int y, int z, IItemStack item);
/**
* @param x World position x
@@ -195,16 +161,14 @@ public interface IWorld {
* @param z World position z
* @param block The block to be set
*/
void setBlock(int x, int y, int z, IBlock block);
void setBlock(IPos pos, IBlock block);
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
*/
void removeBlock(int x, int y, int z);
void removeBlock(IPos pos);
public void removeBlock(int x, int y, int z);
IPos rayCastPos(double[] startPos, double[] lookVector, int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision);
@@ -244,6 +208,20 @@ public interface IWorld {
IEntity[] rayCastEntities(IPos startPos, IPos lookVector, int maxDistance, double offset, double range);
/**
* @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
* @return The Player with name. Null is returned when the player isnt found
@@ -278,7 +256,6 @@ public interface IWorld {
* @param z The z position
*/
void thunderStrike(double x, double y, double z);
void thunderStrike(IPos pos);
/**
* Sends a packet from the server to the client everytime its called. Probably should not use this too much.
@@ -293,7 +270,6 @@ public interface IWorld {
* @param count Particle count
*/
void spawnParticle(String particle, double x, double y, double z, double dx, double dy, double dz, double speed, int count);
void spawnParticle(String particle, IPos pos, double dx, double dy, double dz, double speed, int count);
/**
* @param id The items name
@@ -377,7 +353,6 @@ public interface IWorld {
* @param grief Whether or not the explosion does damage to blocks
*/
void explode(double x, double y, double z, float range, boolean fire, boolean grief);
void explode(IPos pos, float range, boolean fire, boolean grief);
IPlayer[] getAllServerPlayers();
@@ -390,7 +365,6 @@ public interface IWorld {
* @return Returns the name of the biome
*/
String getBiomeName(int x, int z);
String getBiomeName(IPos pos);
/**
* Lets you spawn a server side cloned entity
@@ -403,10 +377,8 @@ public interface IWorld {
* @return Returns the entity which was spawned
*/
IEntity spawnClone(int x, int y, int z, int tab, String name, boolean ignoreProtection);
IEntity spawnClone(IPos pos, int tab, String name, boolean ignoreProtection);
IEntity spawnClone(int x, int y, int z, int tab, String name);
IEntity spawnClone(IPos pos, int tab, String name);
ScriptScoreboard getScoreboard();
@@ -6,23 +6,6 @@
package noppes.npcs.scripted.interfaces.entity;
import net.minecraft.entity.passive.EntityAnimal;
import noppes.npcs.scripted.interfaces.item.IItemStack;
public interface IAnimal<T extends EntityAnimal> extends IEntityLiving<T> {
/**
* 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)
*/
boolean isBreedingItem(IItemStack itemStack);
/**
* Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
*/
boolean interact(IPlayer player);
boolean isInLove();
void resetInLove();
boolean canMateWith(IAnimal animal);
}
@@ -6,7 +6,6 @@
package noppes.npcs.scripted.interfaces.entity;
import net.minecraft.entity.EntityCreature;
import noppes.npcs.scripted.interfaces.IPos;
import noppes.npcs.scripted.interfaces.ITimers;
import noppes.npcs.scripted.interfaces.handler.IOverlayHandler;
import noppes.npcs.scripted.interfaces.handler.data.IFaction;
@@ -73,8 +72,6 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
*/
void setTexture(String texture);
IPos getHome();
/**
* @return Home position x
*/
@@ -111,9 +108,6 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
* @param z The home z position
*/
void setHome(int x, int y, int z);
void setHome(IPos pos);
/**
* @param health New max health
*/
@@ -814,6 +808,4 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
int getCollisionType();
void updateClient();
void updateAI();
}
@@ -95,10 +95,6 @@ public interface IEntity<T extends Entity> {
void setMotion(double x, double y, double z);
void setMotion(IPos pos);
IPos getMotion();
boolean isAirborne();
/**
@@ -123,9 +119,9 @@ public interface IEntity<T extends Entity> {
*/
void setPosition(double x, double y, double z);
void setPosition(IPos pos);
IPos getPos();
IPos getPosition();
void setPos(IPos pos);
int getDimension();
@@ -309,7 +305,6 @@ public interface IEntity<T extends Entity> {
void knockback(int power, float direction);
void knockback(int xpower, int ypower, int zpower, float direction);
void knockback(IPos pos, float direction);
void setImmune(int ticks);
@@ -346,8 +341,6 @@ public interface IEntity<T extends Entity> {
public void setNbt(INbt nbt);
INbt getNbtOptional();
void storeAsClone(int tab, String name);
IWorld getWorld();
@@ -15,40 +15,4 @@ public interface IEntityLiving<T extends EntityLiving> extends IEntityLivingBase
void navigateTo(double var1, double var3, double var5, double var7);
T getMCEntity();
void playLivingSound();
void spawnExplosionParticle();
void setMoveForward(float speed);
void faceEntity(IEntity entity, float pitch, float yaw);
boolean canPickUpLoot();
void setCanPickUpLoot(boolean pickUp);
boolean isPersistent();
void enablePersistence();
void setCustomNameTag(String text);
String getCustomNameTag();
boolean hasCustomNameTag();
void setAlwaysRenderNameTag(boolean alwaysRender);
boolean getAlwaysRenderNameTag();
void clearLeashed(boolean sendPacket, boolean dropLeash);
boolean allowLeashing();
boolean getLeashed();
IEntity getLeashedTo();
void setLeashedTo(IEntity entity, boolean sendPacket);
}
@@ -146,12 +146,4 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
* @param item Item to be set
*/
void setArmor(int slot, IItemStack item);
void setAIMoveSpeed(float speed);
float getAIMoveSpeed();
void setAbsorptionAmount(float amount);
float getAbsorptionAmount();
}
@@ -29,10 +29,8 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
void kick(String reason);
void setPosition(double x, double y, double z);
void setPosition(IPos pos);
void setPosition(double x, double y, double z, int dimensionId);
void setPosition(IPos pos, int dimensionId);
int getHunger();
@@ -212,7 +210,6 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
* @param z The z position
*/
void setSpawnpoint(int x, int y, int z);
void setSpawnpoint(IPos pos);
void resetSpawnpoint();
@@ -5,17 +5,14 @@
package noppes.npcs.scripted.interfaces.handler;
import noppes.npcs.scripted.interfaces.IPos;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.interfaces.entity.IEntity;
public interface ICloneHandler {
IEntity spawn(double x, double y, double z, int tab, String name, IWorld world, boolean ignoreProtection);
IEntity spawn(IPos pos, int tab, String name, IWorld world, boolean ignoreProtection);
IEntity spawn(double x, double y, double z, int tab, String name, IWorld world);
IEntity spawn(IPos pos, int tab, String name, IWorld world);
IEntity[] getTab(int tab, IWorld world);
@@ -1,7 +1,5 @@
package noppes.npcs.scripted.interfaces.handler.data;
import noppes.npcs.scripted.interfaces.IPos;
public interface ITransportLocation {
int getId();
@@ -20,8 +18,6 @@ public interface ITransportLocation {
void setPosition(int x, int y, int z);
void setPosition(IPos pos);
double getX();
double getY();
@@ -5,20 +5,4 @@ public interface IJobBard extends IJob {
String getSong();
void setSong(String song);
void setInstrument(int i);
int getInstrumentId();
void setMinRange(int range);
int getMinRange();
void setMaxRange(int range);
int getMaxRange();
void setStreaming(boolean streaming);
boolean getStreaming();
void hasOffRange(boolean value);
boolean hasOffRange();
}
@@ -1,12 +1,4 @@
package noppes.npcs.scripted.interfaces.jobs;
public interface IJobGuard extends IJob {
boolean attackCreepers();
void attackCreepers(boolean value);
boolean attacksAnimals();
void attacksAnimals(boolean value);
boolean attackHostileMobs();
void attackHostileMobs(boolean value);
}
@@ -5,10 +5,4 @@ import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
public interface IJobHealer extends IJob {
void heal(IEntityLivingBase entity, float amount);
void setRange(int range);
int getRange();
void setSpeed(int speed);
int getSpeed();
}
@@ -1,31 +1,10 @@
package noppes.npcs.scripted.interfaces.jobs;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.scripted.interfaces.IPos;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
public interface IJobSpawner extends IJob {
IEntityLivingBase<?> spawnEntity(int number);
IEntityLivingBase spawnEntity(int number);
IEntityLivingBase<?> getEntity(int number, int x, int y, int z, IWorld world);
IEntityLivingBase<?> getEntity(int number, IPos pos, IWorld world);
void setEntity(int number, IEntityLivingBase<?> entityLivingBase);
/**
* Removes all spawned entities
*/
void removeAllSpawned();
IEntityLivingBase<?>[] getNearbySpawned();
boolean hasPixelmon();
boolean isEmpty();
boolean isOnCooldown(IPlayer<EntityPlayerMP> player);
}
@@ -1,10 +1,6 @@
package noppes.npcs.scripted.interfaces.roles;
import net.minecraft.entity.INpc;
public interface IRole {
INpc getNpc();
int getType();
}
@@ -1,19 +1,5 @@
package noppes.npcs.scripted.interfaces.roles;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.handler.data.ITransportLocation;
public interface IRoleTransporter extends IRole {
String getName();
int getTransportId();
void unlock(IPlayer<EntityPlayerMP> player, ITransportLocation location);
ITransportLocation getTransport();
boolean hasTransport();
void setTransport(ITransportLocation location);
}
@@ -30,50 +30,4 @@ public class ScriptJobBard extends ScriptJobInterface implements IJobBard {
job.song = song;
npc.script.clientNeedsUpdate = true;
}
/**
*
* @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 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;
}
}
@@ -11,27 +11,6 @@ public class ScriptJobGuard extends ScriptJobInterface implements IJobGuard {
super(npc);
this.job = (JobGuard) npc.jobInterface;
}
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(){
@@ -16,20 +16,6 @@ public class ScriptJobHealer extends ScriptJobInterface implements IJobHealer {
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(){
@@ -1,26 +1,17 @@
package noppes.npcs.scripted.roles;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.JobSpawner;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.JobType;
import noppes.npcs.scripted.interfaces.INbt;
import noppes.npcs.scripted.interfaces.IPos;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.interfaces.entity.IEntityLivingBase;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.jobs.IJobSpawner;
public class ScriptJobSpawner extends ScriptJobInterface implements IJobSpawner {
private final JobSpawner job;
private JobSpawner job;
public ScriptJobSpawner(EntityNPCInterface npc){
super(npc);
this.job = (JobSpawner) npc.jobInterface;
@@ -36,64 +27,21 @@ public class ScriptJobSpawner extends ScriptJobInterface implements IJobSpawner
* @param number The entity going to be spawned (1-6)
* @return Returns spawned entity
*/
public IEntityLivingBase<?> spawnEntity(int number){
public IEntityLivingBase spawnEntity(int number){
EntityLivingBase base = job.spawnEntity(number);
if(base == null)
return null;
return (IEntityLivingBase<?>) NpcAPI.Instance().getIEntity(base);
return (IEntityLivingBase) NpcAPI.Instance().getIEntity(base);
}
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 IEntityLivingBase<?> getEntity(int number, IPos pos, IWorld world) {
return this.getEntity(number,pos.getX(),pos.getY(),pos.getZ(),world);
}
public void setEntity(int number, IEntityLivingBase<?> entityLivingBase){
INbt nbt = entityLivingBase.getNbtOptional();
if (nbt == null)
return;
this.job.setJobCompound(number,nbt.getMCNBT());
}
/**
* Removes all spawned entities
*/
/**
* 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());
job.spawned = new ArrayList<EntityLivingBase>();
}
}
@@ -1,9 +1,7 @@
package noppes.npcs.scripted.roles;
import net.minecraft.entity.INpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.constants.RoleType;
import noppes.npcs.scripted.interfaces.roles.IRole;
@@ -16,10 +14,6 @@ public class ScriptRoleInterface implements IRole {
this.role = npc.roleInterface;
}
public INpc getNpc() {
return (INpc) NpcAPI.Instance().getIEntity(npc);
}
/**
* @see noppes.npcs.scripted.constants.RoleType
* @return The RoleType of this role
@@ -1,44 +1,13 @@
package noppes.npcs.scripted.roles;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleTransporter;
import noppes.npcs.scripted.constants.RoleType;
import noppes.npcs.scripted.interfaces.entity.IPlayer;
import noppes.npcs.scripted.interfaces.handler.data.ITransportLocation;
import noppes.npcs.scripted.interfaces.roles.IRoleTransporter;
public class ScriptRoleTransporter extends ScriptRoleInterface implements IRoleTransporter {
private final RoleTransporter role;
public ScriptRoleTransporter(EntityNPCInterface npc) {
super(npc);
role = (RoleTransporter) npc.roleInterface;
}
public String getName() {
return role.name;
}
public int getTransportId() {
return role.transportId;
}
public void unlock(IPlayer<EntityPlayerMP> player, ITransportLocation location) {
this.role.unlock(player.getMCEntity(), location);
}
public ITransportLocation getTransport(){
return this.role.getLocation();
}
public boolean hasTransport(){
return this.role.hasTransport();
}
public void setTransport(ITransportLocation location) {
this.role.setTransport(location);
}
@Override