mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 04:35:03 +00:00
push something??
This commit is contained in:
1 parent
f51c636b79
commit
e316946915
3 files changed
+16
-8
No files matched your search
+7
-5
@@ -19,6 +19,7 @@ import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.controllers.LinkedItemController;
|
||||
import noppes.npcs.controllers.data.LinkedItem;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.item.ScriptLinkedItem;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -63,15 +64,16 @@ public final class LinkedItemBuildPacket extends AbstractPacket {
|
||||
return;
|
||||
|
||||
int id = in.readInt();
|
||||
LinkedItem linkedItem = LinkedItemController.getInstance().get(id);
|
||||
if(linkedItem == null)
|
||||
LinkedItem original = LinkedItemController.getInstance().get(id);
|
||||
if(original == null)
|
||||
return;
|
||||
|
||||
LinkedItem copy = original.clone();
|
||||
EntityPlayerMP playerMP = (EntityPlayerMP) player;
|
||||
ItemStack stack = new ItemStack(CustomItems.linked_item, 1);
|
||||
ScriptLinkedItem scriptLinkedItem = new ScriptLinkedItem(stack, linkedItem.writeToNBT());
|
||||
scriptLinkedItem.linkedVersion = linkedItem.version;
|
||||
ScriptLinkedItem scriptLinkedItem = new ScriptLinkedItem(stack, copy);
|
||||
scriptLinkedItem.linkedVersion = copy.version;
|
||||
scriptLinkedItem.saveItemData();
|
||||
playerMP.inventory.addItemStackToInventory(stack.copy());
|
||||
playerMP.inventory.addItemStackToInventory(stack);
|
||||
}
|
||||
}
|
||||
@@ -207,6 +207,13 @@ public class LinkedItem implements ILinkedItem {
|
||||
this.enchantability = enchantability;
|
||||
}
|
||||
|
||||
public LinkedItem clone() {
|
||||
NBTTagCompound nbt = this.writeToNBT();
|
||||
LinkedItem clone = new LinkedItem(this.name);
|
||||
clone.readFromNBT(nbt, false);
|
||||
return clone;
|
||||
}
|
||||
|
||||
// ADD / GET SETS FOR LINKED ITEM DISPLAY THINGS
|
||||
|
||||
}
|
||||
@@ -17,11 +17,10 @@ public class ScriptLinkedItem extends ScriptCustomizableItem implements IItemLin
|
||||
}
|
||||
|
||||
// For Building
|
||||
public ScriptLinkedItem(ItemStack item, NBTTagCompound linkedData) {
|
||||
public ScriptLinkedItem(ItemStack item, LinkedItem original) {
|
||||
super(item);
|
||||
setDefaults();
|
||||
this.linkedItem = new LinkedItem();
|
||||
this.linkedItem.readFromNBT(linkedData, false);
|
||||
this.linkedItem = original.clone();
|
||||
}
|
||||
|
||||
public void setDefaults(){
|
||||
|
||||
Reference in new issue
Block a user