Fix Crafting with items that randomly add NBT Data when you look at them.
This commit is contained in:
@@ -7,7 +7,6 @@ import net.minecraft.entity.player.InventoryPlayer;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.storage.ITerminalHost;
|
import appeng.api.storage.ITerminalHost;
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
|
||||||
import appeng.client.gui.AEBaseGui;
|
import appeng.client.gui.AEBaseGui;
|
||||||
import appeng.client.gui.widgets.GuiNumberBox;
|
import appeng.client.gui.widgets.GuiNumberBox;
|
||||||
import appeng.client.gui.widgets.GuiTabButton;
|
import appeng.client.gui.widgets.GuiTabButton;
|
||||||
@@ -118,9 +117,7 @@ public class GuiCraftAmount extends AEBaseGui
|
|||||||
|
|
||||||
if ( btn == next )
|
if ( btn == next )
|
||||||
{
|
{
|
||||||
IAEItemStack what = AEApi.instance().storage().createItemStack( inventorySlots.getSlot( 0 ).getStack() );
|
NetworkHandler.instance.sendToServer( new PacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), isShiftKeyDown() ) );
|
||||||
if ( what != null )
|
|
||||||
NetworkHandler.instance.sendToServer( new PacketCraftRequest( what, Integer.parseInt( this.amountToCraft.getText() ), isShiftKeyDown() ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ public class ContainerCraftAmount extends AEBaseContainer
|
|||||||
{
|
{
|
||||||
|
|
||||||
ITerminalHost priHost;
|
ITerminalHost priHost;
|
||||||
IAEItemStack stack;
|
|
||||||
|
|
||||||
|
public IAEItemStack whatToMake;
|
||||||
public Slot craftingItem;
|
public Slot craftingItem;
|
||||||
|
|
||||||
public ContainerCraftAmount(InventoryPlayer ip, ITerminalHost te) {
|
public ContainerCraftAmount(InventoryPlayer ip, ITerminalHost te) {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import appeng.api.networking.IGridHost;
|
|||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
import appeng.api.networking.crafting.ICraftingGrid;
|
import appeng.api.networking.crafting.ICraftingGrid;
|
||||||
import appeng.api.networking.crafting.ICraftingJob;
|
import appeng.api.networking.crafting.ICraftingJob;
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
|
||||||
import appeng.container.ContainerOpenContext;
|
import appeng.container.ContainerOpenContext;
|
||||||
import appeng.container.implementations.ContainerCraftAmount;
|
import appeng.container.implementations.ContainerCraftAmount;
|
||||||
import appeng.container.implementations.ContainerCraftConfirm;
|
import appeng.container.implementations.ContainerCraftConfirm;
|
||||||
@@ -23,18 +22,17 @@ import appeng.core.sync.AppEngPacket;
|
|||||||
import appeng.core.sync.GuiBridge;
|
import appeng.core.sync.GuiBridge;
|
||||||
import appeng.core.sync.network.INetworkInfo;
|
import appeng.core.sync.network.INetworkInfo;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.item.AEItemStack;
|
|
||||||
|
|
||||||
public class PacketCraftRequest extends AppEngPacket
|
public class PacketCraftRequest extends AppEngPacket
|
||||||
{
|
{
|
||||||
|
|
||||||
final public IAEItemStack slotItem;
|
final public long amount;
|
||||||
final public boolean heldShift;
|
final public boolean heldShift;
|
||||||
|
|
||||||
// automatic.
|
// automatic.
|
||||||
public PacketCraftRequest(ByteBuf stream) throws IOException {
|
public PacketCraftRequest(ByteBuf stream) throws IOException {
|
||||||
heldShift = stream.readBoolean();
|
heldShift = stream.readBoolean();
|
||||||
slotItem = AEItemStack.loadItemStackFromPacket( stream );
|
amount = stream.readLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -52,15 +50,17 @@ public class PacketCraftRequest extends AppEngPacket
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
IGrid g = gn.getGrid();
|
IGrid g = gn.getGrid();
|
||||||
if ( g == null )
|
if ( g == null || cca.whatToMake == null )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Future<ICraftingJob> futureJob = null;
|
Future<ICraftingJob> futureJob = null;
|
||||||
|
|
||||||
|
cca.whatToMake.setStackSize( amount );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ICraftingGrid cg = g.getCache( ICraftingGrid.class );
|
ICraftingGrid cg = g.getCache( ICraftingGrid.class );
|
||||||
futureJob = cg.beginCraftingJob( cca.getWorld(), cca.getGrid(), cca.getActionSrc(), slotItem, null );
|
futureJob = cg.beginCraftingJob( cca.getWorld(), cca.getGrid(), cca.getActionSrc(), cca.whatToMake, null );
|
||||||
|
|
||||||
ContainerOpenContext context = cca.openContext;
|
ContainerOpenContext context = cca.openContext;
|
||||||
if ( context != null )
|
if ( context != null )
|
||||||
@@ -88,16 +88,16 @@ public class PacketCraftRequest extends AppEngPacket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketCraftRequest(IAEItemStack stack, int parseInt, boolean shift) throws IOException {
|
public PacketCraftRequest(int craftAmt, boolean shift) throws IOException {
|
||||||
this.slotItem = stack;
|
|
||||||
this.slotItem.setStackSize( parseInt );
|
this.amount = craftAmt;
|
||||||
this.heldShift = shift;
|
this.heldShift = shift;
|
||||||
|
|
||||||
ByteBuf data = Unpooled.buffer();
|
ByteBuf data = Unpooled.buffer();
|
||||||
|
|
||||||
data.writeInt( getPacketID() );
|
data.writeInt( getPacketID() );
|
||||||
data.writeBoolean( shift );
|
data.writeBoolean( shift );
|
||||||
slotItem.writeToPacket( data );
|
data.writeLong( amount );
|
||||||
|
|
||||||
configureWrite( data );
|
configureWrite( data );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,8 +58,13 @@ public class PacketInventoryAction extends AppEngPacket
|
|||||||
if ( sender.openContainer instanceof ContainerCraftAmount )
|
if ( sender.openContainer instanceof ContainerCraftAmount )
|
||||||
{
|
{
|
||||||
ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer;
|
ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer;
|
||||||
|
|
||||||
if ( aebc.getTargetStack() != null )
|
if ( aebc.getTargetStack() != null )
|
||||||
|
{
|
||||||
cca.craftingItem.putStack( aebc.getTargetStack().getItemStack() );
|
cca.craftingItem.putStack( aebc.getTargetStack().getItemStack() );
|
||||||
|
cca.whatToMake = aebc.getTargetStack();
|
||||||
|
}
|
||||||
|
|
||||||
cca.detectAndSendChanges();
|
cca.detectAndSendChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user