mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 11:59:26 +00:00
Added several more functions to pre-existing classes:
-Spawner, Transport, Healer, Guard, Bard jobs received more functions. -Added more functions to the transporter role. -IRole: Added getNpc() function. -IAnimal, IEntityLiving, and IEntityLivingBase received more functions from their MC counterparts. -Nearly every function with that takes position/vector parameters now has an equivalent with IPos as a parameter instead.
This commit is contained in:
1 parent
112e82a09d
commit
e9a8f8cebc
51 files changed
+1025
-227
No files matched your search
@@ -1,13 +1,19 @@
|
||||
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
|
||||
@@ -15,8 +21,35 @@ 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?true:super.typeOf(type);
|
||||
return type == EntityType.ANIMAL || super.typeOf(type);
|
||||
}
|
||||
}
|
||||
@@ -363,6 +363,14 @@ 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;
|
||||
}
|
||||
@@ -398,13 +406,21 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
}
|
||||
|
||||
public IPos getPos() {
|
||||
return new ScriptBlockPos(new BlockPos(entity.posX,entity.posY,entity.posZ));
|
||||
return NpcAPI.Instance().getIPos(entity.posX, entity.posY, entity.posZ);
|
||||
}
|
||||
|
||||
public IPos getPosition() {
|
||||
return getPos();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -730,6 +746,10 @@ 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;
|
||||
};
|
||||
@@ -789,6 +809,11 @@ 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,4 +63,88 @@ 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,6 +1,5 @@
|
||||
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;
|
||||
@@ -8,18 +7,14 @@ import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EntityDamageSource;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import noppes.npcs.scripted.ScriptBlockPos;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptDamageSource;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.interfaces.IBlock;
|
||||
import noppes.npcs.scripted.interfaces.IPos;
|
||||
import noppes.npcs.scripted.interfaces.entity.IEntity;
|
||||
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;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
|
||||
public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T> implements IEntityLivingBase {
|
||||
protected T entity;
|
||||
@@ -108,7 +103,7 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
||||
|
||||
public IPos getLookVector() {
|
||||
Vec3 lookVec = entity.getLookVec();
|
||||
return new ScriptBlockPos(new BlockPos(lookVec.xCoord,lookVec.yCoord,lookVec.zCoord));
|
||||
return NpcAPI.Instance().getIPos(lookVec.xCoord,lookVec.yCoord,lookVec.zCoord);
|
||||
}
|
||||
|
||||
public IBlock getLookingAtBlock(int maxDistance, boolean stopOnBlock, boolean stopOnLiquid, boolean stopOnCollision) {
|
||||
@@ -248,4 +243,54 @@ 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,6 +18,7 @@ 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;
|
||||
@@ -151,6 +152,10 @@ 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
|
||||
*/
|
||||
@@ -201,6 +206,11 @@ 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
|
||||
*/
|
||||
@@ -1133,7 +1143,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
|
||||
public void setSkinType(byte type) {
|
||||
npc.display.skinType = type;
|
||||
npc.updateClient = true;
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
public byte getSkinType() {
|
||||
@@ -1146,7 +1156,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
this.npc.display.url = url;
|
||||
npc.textureLocation = null;
|
||||
npc.display.skinType = 2;
|
||||
npc.updateClient = true;
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
public String getSkinUrl() {
|
||||
@@ -1155,7 +1165,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
|
||||
public void setCloakTexture(String cloakTexture) {
|
||||
npc.display.cloakTexture = cloakTexture;
|
||||
npc.updateClient = true;
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
public String getCloakTexture() {
|
||||
@@ -1168,7 +1178,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
}
|
||||
|
||||
this.getOverlays().add(0, NpcAPI.Instance().createSkinOverlay(overlayTexture));
|
||||
npc.updateClient = true;
|
||||
npc.script.clientNeedsUpdate = true;
|
||||
}
|
||||
|
||||
public String getOverlayTexture() {
|
||||
@@ -1190,4 +1200,6 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
}
|
||||
|
||||
public void updateClient() { this.npc.updateClient(); }
|
||||
|
||||
public void updateAI() { this.npc.updateTasks(); }
|
||||
}
|
||||
@@ -86,6 +86,10 @@ 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;
|
||||
@@ -93,6 +97,10 @@ 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();
|
||||
}
|
||||
@@ -505,6 +513,10 @@ 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);
|
||||
|
||||
Reference in new issue
Block a user