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