66
77import net .minecraft .item .ItemStack ;
88import net .minecraft .network .PacketBuffer ;
9+ import net .minecraftforge .fml .relauncher .Side ;
910import net .minecraftforge .items .ItemHandlerHelper ;
1011
1112import org .jetbrains .annotations .ApiStatus ;
@@ -87,7 +88,7 @@ public void readOnServer(int id, PacketBuffer buf) throws IOException {
8788 setEnabled (buf .readBoolean (), false );
8889 } else if (id == 5 ) {
8990 if (!isPhantom ()) return ;
90- phantomClick (MouseData . create ( 0 ), buf .readItemStack ());
91+ phantomClick (new MouseData ( Side . SERVER , 0 , false , false , false ), buf .readItemStack ());
9192 }
9293 }
9394
@@ -99,6 +100,7 @@ protected void phantomClick(MouseData mouseData, ItemStack cursorStack) {
99100 ItemStack slotStack = getSlot ().getStack ();
100101 ItemStack stackToPut ;
101102 if (!cursorStack .isEmpty () && !slotStack .isEmpty () && !ItemHandlerHelper .canItemStacksStack (cursorStack , slotStack )) {
103+ if (!isItemValid (cursorStack )) return ;
102104 stackToPut = cursorStack .copy ();
103105 if (mouseData .mouseButton == 1 ) {
104106 stackToPut .setCount (1 );
@@ -114,6 +116,7 @@ protected void phantomClick(MouseData mouseData, ItemStack cursorStack) {
114116 return ;
115117 }
116118 } else {
119+ if (!isItemValid (cursorStack )) return ;
117120 stackToPut = cursorStack .copy ();
118121 }
119122 if (mouseData .mouseButton == 1 ) {
0 commit comments