clearing crafting matrix
This commit is contained in:
@@ -15,7 +15,7 @@ public class ContainerGrid extends ContainerBase
|
||||
|
||||
if (grid.isCrafting())
|
||||
{
|
||||
int x = 44;
|
||||
int x = 25;
|
||||
int y = 106;
|
||||
|
||||
for (int i = 0; i < 9; ++i)
|
||||
@@ -27,11 +27,11 @@ public class ContainerGrid extends ContainerBase
|
||||
if ((i + 1) % 3 == 0)
|
||||
{
|
||||
y += 18;
|
||||
x = 44;
|
||||
x = 25;
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(new SlotGridCraftingResult(player, grid.getCraftingMatrix(), grid.getCraftingResult(), grid, 0, 125, 124));
|
||||
addSlotToContainer(new SlotGridCraftingResult(player, grid.getCraftingMatrix(), grid.getCraftingResult(), grid, 0, 137, 124));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,8 +4,10 @@ import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import storagecraft.StorageCraft;
|
||||
@@ -13,6 +15,7 @@ import storagecraft.container.ContainerGrid;
|
||||
import storagecraft.gui.sidebutton.SideButtonGridSortingDirection;
|
||||
import storagecraft.gui.sidebutton.SideButtonGridSortingType;
|
||||
import storagecraft.gui.sidebutton.SideButtonRedstoneMode;
|
||||
import storagecraft.network.MessageGridCraftingClear;
|
||||
import storagecraft.network.MessageStoragePull;
|
||||
import storagecraft.network.MessageStoragePush;
|
||||
import storagecraft.storage.StorageItem;
|
||||
@@ -114,6 +117,11 @@ public class GuiGrid extends GuiBase
|
||||
return hoveringSlotId >= 0;
|
||||
}
|
||||
|
||||
public boolean isHoveringOverClear(int mouseX, int mouseY)
|
||||
{
|
||||
return mouseX >= 81 && mouseX <= 87 && mouseY >= 105 && mouseY <= 111;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY)
|
||||
{
|
||||
@@ -192,6 +200,11 @@ public class GuiGrid extends GuiBase
|
||||
{
|
||||
drawTooltip(mouseX, mouseY, items.get(hoveringSlotId).toItemStack());
|
||||
}
|
||||
|
||||
if (grid.isCrafting() && isHoveringOverClear(mouseX, mouseY))
|
||||
{
|
||||
drawTooltip(mouseX, mouseY, t("misc.storagecraft:clear"));
|
||||
}
|
||||
}
|
||||
|
||||
public List<StorageItem> getItems()
|
||||
@@ -282,6 +295,12 @@ public class GuiGrid extends GuiBase
|
||||
{
|
||||
StorageCraft.NETWORK.sendToServer(new MessageStoragePull(controller.xCoord, controller.yCoord, controller.zCoord, hoveringId, clickedButton == 1, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
|
||||
}
|
||||
else if (clickedButton == 0 && grid.isCrafting() && isHoveringOverClear(mouseX - guiLeft, mouseY - guiTop))
|
||||
{
|
||||
StorageCraft.NETWORK.sendToServer(new MessageGridCraftingClear(grid));
|
||||
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Slot slot : container.getPlayerInventorySlots())
|
||||
|
@@ -0,0 +1,75 @@
|
||||
package storagecraft.network;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import storagecraft.tile.TileGrid;
|
||||
|
||||
public class MessageGridCraftingClear implements IMessage, IMessageHandler<MessageGridCraftingClear, IMessage>
|
||||
{
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
public MessageGridCraftingClear()
|
||||
{
|
||||
}
|
||||
|
||||
public MessageGridCraftingClear(TileGrid grid)
|
||||
{
|
||||
this.x = grid.xCoord;
|
||||
this.y = grid.yCoord;
|
||||
this.z = grid.zCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MessageGridCraftingClear message, MessageContext context)
|
||||
{
|
||||
EntityPlayerMP player = context.getServerHandler().playerEntity;
|
||||
|
||||
TileEntity tile = player.worldObj.getTileEntity(message.x, message.y, message.z);
|
||||
|
||||
if (tile instanceof TileGrid)
|
||||
{
|
||||
TileGrid grid = (TileGrid) tile;
|
||||
|
||||
if (grid.isConnected())
|
||||
{
|
||||
for (int i = 0; i < grid.getCraftingMatrix().getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack slot = grid.getCraftingMatrix().getStackInSlot(i);
|
||||
|
||||
if (slot != null)
|
||||
{
|
||||
if (grid.getController().push(slot))
|
||||
{
|
||||
grid.getCraftingMatrix().setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -15,6 +15,7 @@ import storagecraft.item.ItemBlockGrid;
|
||||
import storagecraft.network.MessageCompareUpdate;
|
||||
import storagecraft.network.MessageDetectorAmountUpdate;
|
||||
import storagecraft.network.MessageDetectorModeUpdate;
|
||||
import storagecraft.network.MessageGridCraftingClear;
|
||||
import storagecraft.network.MessageGridCraftingUpdate;
|
||||
import storagecraft.network.MessageImporterModeUpdate;
|
||||
import storagecraft.network.MessageRedstoneModeUpdate;
|
||||
@@ -43,6 +44,7 @@ public class CommonProxy
|
||||
StorageCraft.NETWORK.registerMessage(MessageDetectorModeUpdate.class, MessageDetectorModeUpdate.class, 6, Side.SERVER);
|
||||
StorageCraft.NETWORK.registerMessage(MessageDetectorAmountUpdate.class, MessageDetectorAmountUpdate.class, 7, Side.SERVER);
|
||||
StorageCraft.NETWORK.registerMessage(MessageGridCraftingUpdate.class, MessageGridCraftingUpdate.class, 8, Side.CLIENT);
|
||||
StorageCraft.NETWORK.registerMessage(MessageGridCraftingClear.class, MessageGridCraftingClear.class, 9, Side.SERVER);
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(StorageCraft.INSTANCE, new GuiHandler());
|
||||
|
||||
|
@@ -19,6 +19,8 @@ misc.storagecraft:wirelessGrid.notFound=Grid not found.
|
||||
misc.storagecraft:wirelessGrid.notSet=Grid not set yet.
|
||||
misc.storagecraft:wirelessGrid.outOfRange=Grid is out of range.
|
||||
|
||||
misc.storagecraft:clear=Clear
|
||||
|
||||
sidebutton.storagecraft:compare.1=Compare Damage
|
||||
sidebutton.storagecraft:compare.2=Compare NBT
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.0 KiB |
Reference in New Issue
Block a user