mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-23 20:39:39 +00:00
More linked item changes
This commit is contained in:
1 parent
d394174108
commit
4a1a092757
15 files changed
+338
-436
No files matched your search
@@ -470,8 +470,14 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
if (scriptItemCache.containsKey(itemstack)) {
|
||||
scriptStack = scriptItemCache.get(itemstack).getObject();
|
||||
} else {
|
||||
String linkedItemName = itemstack.getTagCompound().getString(LinkedItem.LINKED_NBT_TAG);
|
||||
LinkedItem linkedItem = LinkedItemController.Instance().get(linkedItemName);
|
||||
LinkedItem linkedItem;
|
||||
if (itemstack.hasTagCompound()) {
|
||||
int linkedItemId = itemstack.getTagCompound().getInteger(LinkedItem.LINKED_NBT_TAG);
|
||||
linkedItem = LinkedItemController.Instance().get(linkedItemId);
|
||||
} else {
|
||||
linkedItem = null;
|
||||
}
|
||||
|
||||
if (linkedItem != null && itemstack.getItem() instanceof ItemLinked) {
|
||||
scriptStack = new ScriptLinkedItem(itemstack);
|
||||
} else if (itemstack.getItem() instanceof ItemScripted) {
|
||||
|
||||
@@ -63,6 +63,11 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus
|
||||
return this.enabled && ScriptController.HasStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INpcScriptHandler getScriptHandler() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void callScript(EnumScriptType type, Event event) {
|
||||
this.callScript(type.function, event);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ import net.minecraftforge.common.IPlantable;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.api.INbt;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.controllers.LinkedItemController;
|
||||
import noppes.npcs.controllers.data.LinkedItem;
|
||||
import noppes.npcs.items.ItemLinked;
|
||||
import noppes.npcs.items.ItemScripted;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
@@ -313,6 +316,16 @@ public class ScriptItemStack implements IItemStack {
|
||||
if(item == null)
|
||||
return null;
|
||||
|
||||
if (item.getItem() instanceof ItemLinked) {
|
||||
LinkedItem linkedItem;
|
||||
if (item.hasTagCompound()) {
|
||||
int linkedItemId = item.getTagCompound().getInteger(LinkedItem.LINKED_NBT_TAG);
|
||||
linkedItem = LinkedItemController.Instance().get(linkedItemId);
|
||||
if (linkedItem != null) {
|
||||
return new ScriptLinkedItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(item.getItem() instanceof ItemScripted) {
|
||||
return new ScriptCustomItem(item);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs.scripted.item;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.controllers.LinkedItemController;
|
||||
import noppes.npcs.controllers.data.INpcScriptHandler;
|
||||
import noppes.npcs.controllers.data.LinkedItem;
|
||||
|
||||
public class ScriptLinkedItem extends ScriptCustomizableItem {
|
||||
@@ -9,8 +10,8 @@ public class ScriptLinkedItem extends ScriptCustomizableItem {
|
||||
|
||||
public ScriptLinkedItem(ItemStack item) {
|
||||
super(item);
|
||||
String linkedItemName = item.getTagCompound().getString(LinkedItem.LINKED_NBT_TAG);
|
||||
this.linkedItem = LinkedItemController.Instance().get(linkedItemName);
|
||||
int linkedItemId = item.getTagCompound().getInteger(LinkedItem.LINKED_NBT_TAG);
|
||||
this.linkedItem = LinkedItemController.Instance().get(linkedItemId);
|
||||
|
||||
this.itemDisplay.texture = null;
|
||||
this.itemDisplay.translateX = null;
|
||||
@@ -34,6 +35,11 @@ public class ScriptLinkedItem extends ScriptCustomizableItem {
|
||||
return this.linkedItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INpcScriptHandler getScriptHandler() {
|
||||
return this.getLinkedItem().getScriptHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return this.linkedItem.stackSize;
|
||||
|
||||
Reference in new issue
Block a user