mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 12:42:19 +00:00
Fixed null pointer exceptions from new custom gui slot commit.
This commit is contained in:
1 parent
586c451f06
commit
e3405d22e9
4 files changed
+25
-10
No files matched your search
@@ -123,7 +123,11 @@ public class CustomGuiEvent extends CustomNPCsEvent implements ICustomGuiEvent {
|
||||
super(player, gui);
|
||||
this.slotId = slotId;
|
||||
this.stack = stack;
|
||||
this.slot = (IItemSlot) gui.getComponent(((CustomGuiSlot)(((EntityPlayerMP)player.getMCEntity()).openContainer.getSlot(slotId))).guiSlotId);
|
||||
if ((((EntityPlayerMP)player.getMCEntity()).openContainer.getSlot(slotId) instanceof CustomGuiSlot)) {
|
||||
this.slot = (IItemSlot) gui.getComponent(((CustomGuiSlot) (((EntityPlayerMP) player.getMCEntity()).openContainer.getSlot(slotId))).guiSlotId);
|
||||
} else {
|
||||
this.slot = null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
@@ -150,13 +154,17 @@ public class CustomGuiEvent extends CustomNPCsEvent implements ICustomGuiEvent {
|
||||
*/
|
||||
public final int clickType;
|
||||
|
||||
public SlotClickEvent(IPlayer player, ICustomGui gui, int slotId, int guiSlotId, IItemStack stack, int dragType, int clickType) {
|
||||
public SlotClickEvent(IPlayer player, ICustomGui gui, int slotId, CustomGuiSlot guiSlot, IItemStack stack, int dragType, int clickType) {
|
||||
super(player,gui);
|
||||
this.slotId = slotId;
|
||||
this.stack = stack;
|
||||
this.dragType = dragType;
|
||||
this.clickType = clickType;
|
||||
this.slot = (IItemSlot) gui.getComponent(guiSlotId);
|
||||
if (guiSlot != null) {
|
||||
this.slot = (IItemSlot) gui.getComponent(guiSlot.guiSlotId);
|
||||
} else {
|
||||
this.slot = null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
|
||||
@@ -143,13 +143,13 @@ public class ScriptGui implements ICustomGui {
|
||||
}
|
||||
|
||||
public IItemSlot addItemSlot(int x, int y) {
|
||||
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(this.getMaxId() + 1, x, y);
|
||||
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(-1, x, y);
|
||||
this.slots.add(slot);
|
||||
return (IItemSlot)this.slots.get(this.slots.size() - 1);
|
||||
}
|
||||
|
||||
public IItemSlot addItemSlot(int x, int y, IItemStack stack) {
|
||||
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(this.getMaxId() + 1, x, y, stack);
|
||||
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(-1, x, y, stack);
|
||||
this.slots.add(slot);
|
||||
return (IItemSlot)this.slots.get(this.slots.size() - 1);
|
||||
}
|
||||
@@ -308,6 +308,9 @@ public class ScriptGui implements ICustomGui {
|
||||
|
||||
while(var3.hasNext()) {
|
||||
c = (ICustomGuiComponent)var3.next();
|
||||
if (c.getID() == -1) {
|
||||
c.setID(this.getMaxId()+1);
|
||||
}
|
||||
list.appendTag(((ScriptGuiComponent)c).toNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user