improvements to the importer
This commit is contained in:
@@ -1,13 +1,19 @@
|
|||||||
package storagecraft.block;
|
package storagecraft.block;
|
||||||
|
|
||||||
import net.minecraft.block.ITileEntityProvider;
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import storagecraft.SC;
|
import storagecraft.SC;
|
||||||
import storagecraft.tile.TileImporter;
|
import storagecraft.tile.TileImporter;
|
||||||
|
|
||||||
public class BlockImporter extends BlockSC implements ITileEntityProvider {
|
public class BlockImporter extends BlockSC implements ITileEntityProvider {
|
||||||
|
private IIcon frontIcon;
|
||||||
|
private IIcon sideIcon;
|
||||||
|
|
||||||
public BlockImporter() {
|
public BlockImporter() {
|
||||||
super("importer");
|
super("importer");
|
||||||
}
|
}
|
||||||
@@ -25,4 +31,30 @@ public class BlockImporter extends BlockSC implements ITileEntityProvider {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerBlockIcons(IIconRegister register) {
|
||||||
|
frontIcon = register.registerIcon("storagecraft:importer");
|
||||||
|
sideIcon = register.registerIcon("storagecraft:generic");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||||
|
TileImporter tile = (TileImporter) world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if (side == tile.getDirection().ordinal()) {
|
||||||
|
return frontIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sideIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IIcon getIcon(int side, int meta) {
|
||||||
|
if (side == 3) {
|
||||||
|
return frontIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sideIcon;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,8 +9,8 @@ import org.lwjgl.input.Keyboard;
|
|||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import storagecraft.SC;
|
import storagecraft.SC;
|
||||||
import storagecraft.inventory.ContainerGrid;
|
import storagecraft.inventory.ContainerGrid;
|
||||||
import storagecraft.network.MessagePullFromStorage;
|
import storagecraft.network.MessageStoragePull;
|
||||||
import storagecraft.network.MessagePushToStorage;
|
import storagecraft.network.MessageStoragePush;
|
||||||
import storagecraft.tile.TileController;
|
import storagecraft.tile.TileController;
|
||||||
import storagecraft.tile.TileGrid;
|
import storagecraft.tile.TileGrid;
|
||||||
|
|
||||||
@@ -99,16 +99,16 @@ public class GuiGrid extends GuiContainer {
|
|||||||
TileController controller = grid.getController();
|
TileController controller = grid.getController();
|
||||||
|
|
||||||
if (isHoveringOverSlot() && container.getPlayer().inventory.getItemStack() != null) {
|
if (isHoveringOverSlot() && container.getPlayer().inventory.getItemStack() != null) {
|
||||||
SC.NETWORK.sendToServer(new MessagePushToStorage(controller.xCoord, controller.yCoord, controller.zCoord, -1, clickedButton == 1));
|
SC.NETWORK.sendToServer(new MessageStoragePush(controller.xCoord, controller.yCoord, controller.zCoord, -1, clickedButton == 1));
|
||||||
} else if (isHoveringOverValidSlot() && container.getPlayer().inventory.getItemStack() == null) {
|
} else if (isHoveringOverValidSlot() && container.getPlayer().inventory.getItemStack() == null) {
|
||||||
SC.NETWORK.sendToServer(new MessagePullFromStorage(controller.xCoord, controller.yCoord, controller.zCoord, hoveringSlot, clickedButton == 1, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
|
SC.NETWORK.sendToServer(new MessageStoragePull(controller.xCoord, controller.yCoord, controller.zCoord, hoveringSlot, clickedButton == 1, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < container.inventorySlots.size(); ++i) {
|
for (int i = 0; i < container.inventorySlots.size(); ++i) {
|
||||||
Slot slot = (Slot) container.inventorySlots.get(i);
|
Slot slot = (Slot) container.inventorySlots.get(i);
|
||||||
|
|
||||||
if (func_146978_c(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX, mouseY)) {
|
if (func_146978_c(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX, mouseY)) {
|
||||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
|
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
|
||||||
SC.NETWORK.sendToServer(new MessagePushToStorage(controller.xCoord, controller.yCoord, controller.zCoord, slot.slotNumber, clickedButton == 1));
|
SC.NETWORK.sendToServer(new MessageStoragePush(controller.xCoord, controller.yCoord, controller.zCoord, slot.slotNumber, clickedButton == 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,7 @@ import net.minecraft.util.StatCollector;
|
|||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
import storagecraft.SC;
|
import storagecraft.SC;
|
||||||
import storagecraft.inventory.ContainerImporter;
|
import storagecraft.inventory.ContainerImporter;
|
||||||
import storagecraft.network.MessageImporterSettingsUpdate;
|
import storagecraft.network.MessageImporterUpdate;
|
||||||
import storagecraft.tile.TileImporter;
|
import storagecraft.tile.TileImporter;
|
||||||
import storagecraft.util.InventoryUtils;
|
import storagecraft.util.InventoryUtils;
|
||||||
|
|
||||||
@@ -37,8 +37,8 @@ public class GuiImporter extends GuiContainer {
|
|||||||
int x = (this.width - xSize) / 2;
|
int x = (this.width - xSize) / 2;
|
||||||
int y = (this.height - ySize) / 2;
|
int y = (this.height - ySize) / 2;
|
||||||
|
|
||||||
buttonList.add(compareNBT = new GuiButton(0, x + 7, y + 40, 100, 20, "..."));
|
buttonList.add(compareNBT = new GuiButton(0, x + 7, y + 41, 100, 20, "..."));
|
||||||
buttonList.add(compareDamage = new GuiButton(1, x + 7, y + 64, 120, 20, "..."));
|
buttonList.add(compareDamage = new GuiButton(1, x + 7, y + 63, 120, 20, "..."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,6 +82,6 @@ public class GuiImporter extends GuiContainer {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SC.NETWORK.sendToServer(new MessageImporterSettingsUpdate(importer.xCoord, importer.yCoord, importer.zCoord, flags));
|
SC.NETWORK.sendToServer(new MessageImporterUpdate(importer.xCoord, importer.yCoord, importer.zCoord, flags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,16 +8,16 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import storagecraft.tile.TileImporter;
|
import storagecraft.tile.TileImporter;
|
||||||
|
|
||||||
public class MessageImporterSettingsUpdate implements IMessage, IMessageHandler<MessageImporterSettingsUpdate, IMessage> {
|
public class MessageImporterUpdate implements IMessage, IMessageHandler<MessageImporterUpdate, IMessage> {
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
private int z;
|
private int z;
|
||||||
private int compareFlags;
|
private int compareFlags;
|
||||||
|
|
||||||
public MessageImporterSettingsUpdate() {
|
public MessageImporterUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageImporterSettingsUpdate(int x, int y, int z, int compareFlags) {
|
public MessageImporterUpdate(int x, int y, int z, int compareFlags) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
@@ -41,7 +41,7 @@ public class MessageImporterSettingsUpdate implements IMessage, IMessageHandler<
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMessage onMessage(MessageImporterSettingsUpdate message, MessageContext context) {
|
public IMessage onMessage(MessageImporterUpdate message, MessageContext context) {
|
||||||
EntityPlayerMP player = context.getServerHandler().playerEntity;
|
EntityPlayerMP player = context.getServerHandler().playerEntity;
|
||||||
|
|
||||||
TileEntity tile = player.worldObj.getTileEntity(message.x, message.y, message.z);
|
TileEntity tile = player.worldObj.getTileEntity(message.x, message.y, message.z);
|
@@ -10,7 +10,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import storagecraft.storage.StorageItem;
|
import storagecraft.storage.StorageItem;
|
||||||
import storagecraft.tile.TileController;
|
import storagecraft.tile.TileController;
|
||||||
|
|
||||||
public class MessagePullFromStorage implements IMessage, IMessageHandler<MessagePullFromStorage, IMessage> {
|
public class MessageStoragePull implements IMessage, IMessageHandler<MessageStoragePull, IMessage> {
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
private int z;
|
private int z;
|
||||||
@@ -19,10 +19,10 @@ public class MessagePullFromStorage implements IMessage, IMessageHandler<Message
|
|||||||
private boolean half;
|
private boolean half;
|
||||||
private boolean shift;
|
private boolean shift;
|
||||||
|
|
||||||
public MessagePullFromStorage() {
|
public MessageStoragePull() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessagePullFromStorage(int x, int y, int z, int slot, boolean half, boolean shift) {
|
public MessageStoragePull(int x, int y, int z, int slot, boolean half, boolean shift) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
@@ -52,7 +52,7 @@ public class MessagePullFromStorage implements IMessage, IMessageHandler<Message
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMessage onMessage(MessagePullFromStorage message, MessageContext context) {
|
public IMessage onMessage(MessageStoragePull message, MessageContext context) {
|
||||||
EntityPlayerMP player = context.getServerHandler().playerEntity;
|
EntityPlayerMP player = context.getServerHandler().playerEntity;
|
||||||
|
|
||||||
TileEntity tile = player.worldObj.getTileEntity(message.x, message.y, message.z);
|
TileEntity tile = player.worldObj.getTileEntity(message.x, message.y, message.z);
|
@@ -9,17 +9,17 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import storagecraft.tile.TileController;
|
import storagecraft.tile.TileController;
|
||||||
|
|
||||||
public class MessagePushToStorage implements IMessage, IMessageHandler<MessagePushToStorage, IMessage> {
|
public class MessageStoragePush implements IMessage, IMessageHandler<MessageStoragePush, IMessage> {
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
private int z;
|
private int z;
|
||||||
private int slot;
|
private int slot;
|
||||||
private boolean one;
|
private boolean one;
|
||||||
|
|
||||||
public MessagePushToStorage() {
|
public MessageStoragePush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessagePushToStorage(int x, int y, int z, int slot, boolean one) {
|
public MessageStoragePush(int x, int y, int z, int slot, boolean one) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
@@ -46,7 +46,7 @@ public class MessagePushToStorage implements IMessage, IMessageHandler<MessagePu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMessage onMessage(MessagePushToStorage message, MessageContext context) {
|
public IMessage onMessage(MessageStoragePush message, MessageContext context) {
|
||||||
EntityPlayerMP player = context.getServerHandler().playerEntity;
|
EntityPlayerMP player = context.getServerHandler().playerEntity;
|
||||||
|
|
||||||
TileEntity tile = player.worldObj.getTileEntity(message.x, message.y, message.z);
|
TileEntity tile = player.worldObj.getTileEntity(message.x, message.y, message.z);
|
@@ -10,9 +10,9 @@ import storagecraft.SC;
|
|||||||
import storagecraft.SCBlocks;
|
import storagecraft.SCBlocks;
|
||||||
import storagecraft.SCItems;
|
import storagecraft.SCItems;
|
||||||
import storagecraft.gui.GuiHandler;
|
import storagecraft.gui.GuiHandler;
|
||||||
import storagecraft.network.MessageImporterSettingsUpdate;
|
import storagecraft.network.MessageImporterUpdate;
|
||||||
import storagecraft.network.MessagePullFromStorage;
|
import storagecraft.network.MessageStoragePull;
|
||||||
import storagecraft.network.MessagePushToStorage;
|
import storagecraft.network.MessageStoragePush;
|
||||||
import storagecraft.network.MessageTileUpdate;
|
import storagecraft.network.MessageTileUpdate;
|
||||||
import storagecraft.tile.TileCable;
|
import storagecraft.tile.TileCable;
|
||||||
import storagecraft.tile.TileController;
|
import storagecraft.tile.TileController;
|
||||||
@@ -24,9 +24,9 @@ import storagecraft.tile.TileStorageProxy;
|
|||||||
public class CommonProxy {
|
public class CommonProxy {
|
||||||
public void preInit(FMLPreInitializationEvent e) {
|
public void preInit(FMLPreInitializationEvent e) {
|
||||||
SC.NETWORK.registerMessage(MessageTileUpdate.class, MessageTileUpdate.class, 0, Side.CLIENT);
|
SC.NETWORK.registerMessage(MessageTileUpdate.class, MessageTileUpdate.class, 0, Side.CLIENT);
|
||||||
SC.NETWORK.registerMessage(MessagePushToStorage.class, MessagePushToStorage.class, 1, Side.SERVER);
|
SC.NETWORK.registerMessage(MessageStoragePush.class, MessageStoragePush.class, 1, Side.SERVER);
|
||||||
SC.NETWORK.registerMessage(MessagePullFromStorage.class, MessagePullFromStorage.class, 2, Side.SERVER);
|
SC.NETWORK.registerMessage(MessageStoragePull.class, MessageStoragePull.class, 2, Side.SERVER);
|
||||||
SC.NETWORK.registerMessage(MessageImporterSettingsUpdate.class, MessageImporterSettingsUpdate.class, 3, Side.SERVER);
|
SC.NETWORK.registerMessage(MessageImporterUpdate.class, MessageImporterUpdate.class, 3, Side.SERVER);
|
||||||
|
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler(SC.INSTANCE, new GuiHandler());
|
NetworkRegistry.INSTANCE.registerGuiHandler(SC.INSTANCE, new GuiHandler());
|
||||||
|
|
||||||
|
@@ -10,12 +10,9 @@ import storagecraft.inventory.InventorySC;
|
|||||||
import storagecraft.util.InventoryUtils;
|
import storagecraft.util.InventoryUtils;
|
||||||
|
|
||||||
public class TileImporter extends TileMachine implements IInventory {
|
public class TileImporter extends TileMachine implements IInventory {
|
||||||
public static final int DEFAULT_COMPARE_FLAGS = InventoryUtils.COMPARE_NBT | InventoryUtils.COMPARE_DAMAGE;
|
|
||||||
|
|
||||||
private InventorySC inventory = new InventorySC("importer", 9);
|
private InventorySC inventory = new InventorySC("importer", 9);
|
||||||
private IInventory connectedInventory;
|
|
||||||
|
|
||||||
private int compareFlags = DEFAULT_COMPARE_FLAGS;
|
private int compareFlags = InventoryUtils.COMPARE_NBT | InventoryUtils.COMPARE_DAMAGE;
|
||||||
|
|
||||||
private int currentSlot = 0;
|
private int currentSlot = 0;
|
||||||
|
|
||||||
@@ -27,12 +24,18 @@ public class TileImporter extends TileMachine implements IInventory {
|
|||||||
TileEntity tile = worldObj.getTileEntity(xCoord + getDirection().offsetX, yCoord + getDirection().offsetY, zCoord + getDirection().offsetZ);
|
TileEntity tile = worldObj.getTileEntity(xCoord + getDirection().offsetX, yCoord + getDirection().offsetY, zCoord + getDirection().offsetZ);
|
||||||
|
|
||||||
if (tile instanceof IInventory) {
|
if (tile instanceof IInventory) {
|
||||||
connectedInventory = (IInventory) tile;
|
IInventory connectedInventory = (IInventory) tile;
|
||||||
}
|
|
||||||
|
|
||||||
if (connectedInventory != null) {
|
|
||||||
if (ticks % 5 == 0) {
|
if (ticks % 5 == 0) {
|
||||||
ItemStack slot = connectedInventory.getStackInSlot(currentSlot);
|
ItemStack slot;
|
||||||
|
|
||||||
|
while ((slot = connectedInventory.getStackInSlot(currentSlot)) == null) {
|
||||||
|
currentSlot++;
|
||||||
|
|
||||||
|
if (currentSlot > connectedInventory.getSizeInventory() - 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (slot != null && canImport(slot)) {
|
if (slot != null && canImport(slot)) {
|
||||||
if (getController().push(slot.copy())) {
|
if (getController().push(slot.copy())) {
|
||||||
@@ -47,8 +50,6 @@ public class TileImporter extends TileMachine implements IInventory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
connectedInventory = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ public class TileImporter extends TileMachine implements IInventory {
|
|||||||
if (slot != null) {
|
if (slot != null) {
|
||||||
slots++;
|
slots++;
|
||||||
|
|
||||||
if (InventoryUtils.compareStack(slot, stack, compareFlags)) {
|
if (InventoryUtils.compareStack(stack, slot, compareFlags)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,6 +148,10 @@ public class TileImporter extends TileMachine implements IInventory {
|
|||||||
public void readFromNBT(NBTTagCompound nbt) {
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
|
if (nbt.hasKey("CompareFlags")) {
|
||||||
|
compareFlags = nbt.getInteger("CompareFlags");
|
||||||
|
}
|
||||||
|
|
||||||
InventoryUtils.restoreInventory(this, nbt);
|
InventoryUtils.restoreInventory(this, nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,6 +159,8 @@ public class TileImporter extends TileMachine implements IInventory {
|
|||||||
public void writeToNBT(NBTTagCompound nbt) {
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
|
nbt.setInteger("CompareFlags", compareFlags);
|
||||||
|
|
||||||
InventoryUtils.saveInventory(this, nbt);
|
InventoryUtils.saveInventory(this, nbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,8 +14,8 @@ misc.storagecraft:storageCellStoredWithCapacity=Opgeslagen: %d / %d
|
|||||||
misc.storagecraft:compareNBT=NBT vergelijken
|
misc.storagecraft:compareNBT=NBT vergelijken
|
||||||
misc.storagecraft:compareDamage=Damage vergelijken
|
misc.storagecraft:compareDamage=Damage vergelijken
|
||||||
|
|
||||||
misc.storagecraft.on=Aan
|
misc.storagecraft:on=Aan
|
||||||
misc.storagecraft.off=Uit
|
misc.storagecraft:off=Uit
|
||||||
|
|
||||||
block.storagecraft:controller.name=Controleur
|
block.storagecraft:controller.name=Controleur
|
||||||
block.storagecraft:cable.name=Kabel
|
block.storagecraft:cable.name=Kabel
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 280 B |
Reference in New Issue
Block a user