mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-26 15:03:30 +00:00
Added implementations for ScriptItemArmor, ScriptItemBlock, and ScriptItemBook, which all extend ScriptItemStack.
This commit is contained in:
1 parent
cf33b90b26
commit
b20babbb35
5 files changed
+97
-23
No files matched your search
@@ -1,19 +1,26 @@
|
||||
package noppes.npcs.scripted.item;
|
||||
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemArmor;
|
||||
|
||||
public class ScriptItemArmor extends ScriptItemStack implements IItemArmor {
|
||||
protected ItemArmor armor;
|
||||
|
||||
public ScriptItemArmor(ItemStack item) {
|
||||
super(item);
|
||||
this.armor = (ItemArmor) item.getItem();
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public int getArmorSlot() {
|
||||
return 0;
|
||||
return armor.armorType;
|
||||
}
|
||||
|
||||
public String getArmorMaterial() {
|
||||
return null;
|
||||
return armor.getArmorMaterial().toString();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,23 @@
|
||||
package noppes.npcs.scripted.item;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemBlock;
|
||||
|
||||
public class ScriptItemBlock extends ScriptItemStack implements IItemBlock {
|
||||
protected String blockName;
|
||||
|
||||
public ScriptItemBlock(ItemStack item) {
|
||||
super(item);
|
||||
Block b = Block.getBlockFromItem(item.getItem());
|
||||
this.blockName = Block.blockRegistry.getNameForObject(b);
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String getBlockName() {
|
||||
return null;
|
||||
return blockName;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,14 @@
|
||||
package noppes.npcs.scripted.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemBook;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ScriptItemBook extends ScriptItemStack implements IItemBook {
|
||||
|
||||
public ScriptItemBook(ItemStack item) {
|
||||
@@ -10,26 +16,57 @@ public class ScriptItemBook extends ScriptItemStack implements IItemBook {
|
||||
}
|
||||
|
||||
public String[] getText() {
|
||||
return new String[0];
|
||||
List<String> list = new ArrayList<String>();
|
||||
NBTTagList pages = this.getTag().getTagList("pages", 8);
|
||||
|
||||
for(int i = 0; i < pages.tagCount(); ++i) {
|
||||
list.add(pages.getStringTagAt(i));
|
||||
}
|
||||
|
||||
return (String[])list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
public void setText(String[] var1) {
|
||||
public void setText(String[] pages) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
if (pages != null && pages.length > 0) {
|
||||
String[] var3 = pages;
|
||||
int var4 = pages.length;
|
||||
|
||||
for(int var5 = 0; var5 < var4; ++var5) {
|
||||
String page = var3[var5];
|
||||
list.appendTag(new NBTTagString(page));
|
||||
}
|
||||
}
|
||||
|
||||
this.getTag().setTag("pages", list);
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return null;
|
||||
return this.getTag().getString("author");
|
||||
}
|
||||
|
||||
public void setAuthor(String var1) {
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.getTag().setString("author",author);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return null;
|
||||
return this.getTag().getString("title");
|
||||
}
|
||||
|
||||
public void setTitle(String var1) {
|
||||
public void setTitle(String title) {
|
||||
this.getTag().setString("title",title);
|
||||
}
|
||||
|
||||
private NBTTagCompound getTag() {
|
||||
NBTTagCompound comp = this.item.getTagCompound();
|
||||
if (comp == null) {
|
||||
this.item.setTagCompound(comp = new NBTTagCompound());
|
||||
}
|
||||
|
||||
return comp;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,13 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTBase.NBTPrimitive;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.ScriptNbt;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
@@ -30,7 +32,15 @@ public class ScriptItemStack implements IItemStack {
|
||||
public ScriptItemStack(ItemStack item){
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
|
||||
public int getType() {
|
||||
if (this.item.getItem() instanceof IPlantable) {
|
||||
return 5;
|
||||
} else {
|
||||
return this.item.getItem() instanceof ItemSword ? 4 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The minecraft name for this item
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user