mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 19:42:19 +00:00
Implemented Scripted Custom Items.
This commit is contained in:
1 parent
5520fc5f2b
commit
26f5f86dca
34 files changed
+1476
-137
No files matched your search
@@ -5,11 +5,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import noppes.npcs.scripted.interfaces.IItemStack;
|
||||
import noppes.npcs.scripted.item.ScriptItemStack;
|
||||
|
||||
public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T>{
|
||||
public T player;
|
||||
@@ -430,7 +427,7 @@ public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T>{
|
||||
return compound.getCompoundTag("JRMCEP").getString("extracode");
|
||||
}
|
||||
|
||||
public ScriptItemStack[] getInventory(){
|
||||
public IItemStack[] getInventory(){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
this.player.writeToNBT(compound);
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.interfaces.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.INbt;
|
||||
import noppes.npcs.scripted.interfaces.IPos;
|
||||
import noppes.npcs.scripted.item.ScriptItemStack;
|
||||
|
||||
public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
protected T entity;
|
||||
|
||||
@@ -7,12 +7,13 @@ import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EntityDamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.interfaces.IItemStack;
|
||||
import noppes.npcs.scripted.item.ScriptItemStack;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.interfaces.IEntityLivingBase;
|
||||
import noppes.npcs.scripted.wrapper.ScriptDamageSource;
|
||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||
|
||||
public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T> implements IEntityLivingBase {
|
||||
protected T entity;
|
||||
@@ -173,11 +174,8 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
||||
* @since 1.7.10c
|
||||
* @return The item the entity is holding
|
||||
*/
|
||||
public ScriptItemStack getHeldItem(){
|
||||
ItemStack item = entity.getHeldItem();
|
||||
if(item == null)
|
||||
return null;
|
||||
return new ScriptItemStack(item);
|
||||
public IItemStack getHeldItem(){
|
||||
return WrapperNpcAPI.Instance().getIItemStack(entity.getHeldItem());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,11 +192,8 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
||||
* @param slot Slot of what armor piece to get, 0:boots, 1:pants, 2:body, 3:head
|
||||
* @return The item in the given slot
|
||||
*/
|
||||
public ScriptItemStack getArmor(int slot){
|
||||
ItemStack item = entity.getEquipmentInSlot(slot + 1);
|
||||
if(item == null)
|
||||
return null;
|
||||
return new ScriptItemStack(item);
|
||||
public IItemStack getArmor(int slot){
|
||||
return WrapperNpcAPI.Instance().getIItemStack(entity.getEquipmentInSlot(slot + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,8 @@ import noppes.npcs.controllers.Line;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.ScriptFaction;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.interfaces.IItemStack;
|
||||
import noppes.npcs.scripted.item.ScriptItemStack;
|
||||
import noppes.npcs.scripted.constants.AnimationType;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.interfaces.ICustomNpc;
|
||||
@@ -28,6 +29,7 @@ import noppes.npcs.scripted.roles.ScriptRoleInterface;
|
||||
import noppes.npcs.scripted.roles.ScriptRoleMailman;
|
||||
import noppes.npcs.scripted.roles.ScriptRoleTrader;
|
||||
import noppes.npcs.scripted.roles.ScriptRoleTransporter;
|
||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -358,11 +360,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
/**
|
||||
* @return The item held in the right hand
|
||||
*/
|
||||
public ScriptItemStack getRightItem(){
|
||||
ItemStack item = npc.inventory.getWeapon();
|
||||
if(item == null || item.getItem() == null)
|
||||
return null;
|
||||
return new ScriptItemStack(item);
|
||||
public IItemStack getRightItem(){
|
||||
return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getWeapon());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -379,11 +378,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
/**
|
||||
* @return The item held in the left hand
|
||||
*/
|
||||
public ScriptItemStack getLefttItem(){
|
||||
ItemStack item = npc.getOffHand();
|
||||
if(item == null || item.getItem() == null)
|
||||
return null;
|
||||
return new ScriptItemStack(item);
|
||||
public IItemStack getLefttItem(){
|
||||
return WrapperNpcAPI.Instance().getIItemStack(npc.getOffHand());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,11 +396,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
/**
|
||||
* @return Returns the projectile the npc uses
|
||||
*/
|
||||
public ScriptItemStack getProjectileItem(){
|
||||
ItemStack item = npc.inventory.getProjectile();
|
||||
if(item == null || item.getItem() == null)
|
||||
return null;
|
||||
return new ScriptItemStack(item);
|
||||
public IItemStack getProjectileItem(){
|
||||
return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getProjectile());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -488,11 +481,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
* @return Returns the worn armor in slot
|
||||
*/
|
||||
@Override
|
||||
public ScriptItemStack getArmor(int slot){
|
||||
ItemStack item = npc.inventory.armor.get(slot);
|
||||
if(item == null)
|
||||
return null;
|
||||
return new ScriptItemStack(item);
|
||||
public IItemStack getArmor(int slot){
|
||||
return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.armor.get(slot));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -514,8 +504,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
* @param slot The slot from the NPC's drop list to return (0-8)
|
||||
* @return
|
||||
*/
|
||||
public ScriptItemStack getLootItem(int slot) {
|
||||
return new ScriptItemStack(npc.inventory.getStackInSlot(slot+7));
|
||||
public IItemStack getLootItem(int slot) {
|
||||
return WrapperNpcAPI.Instance().getIItemStack(npc.inventory.getStackInSlot(slot+7));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package noppes.npcs.scripted.entity;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -20,11 +19,12 @@ import noppes.npcs.controllers.*;
|
||||
import noppes.npcs.entity.EntityDialogNpc;
|
||||
import noppes.npcs.scripted.*;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.event.FactionEvent;
|
||||
import noppes.npcs.scripted.gui.ScriptGui;
|
||||
import noppes.npcs.scripted.handler.data.IQuest;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.scripted.item.ScriptItemStack;
|
||||
import noppes.npcs.scripted.overlay.ScriptOverlay;
|
||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -238,12 +238,12 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
* @since 1.7.10d
|
||||
* @return Returns a IItemStack array size 36
|
||||
*/
|
||||
public ScriptItemStack[] getInventory(){
|
||||
ScriptItemStack[] items = new ScriptItemStack[36];
|
||||
public IItemStack[] getInventory(){
|
||||
IItemStack[] items = new IItemStack[36];
|
||||
for(int i = 0; i < player.inventory.mainInventory.length; i++){
|
||||
ItemStack item = player.inventory.mainInventory[i];
|
||||
if(item != null)
|
||||
items[i] = new ScriptItemStack(item);
|
||||
items[i] = WrapperNpcAPI.Instance().getIItemStack(item);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user