use of mcjty.rftools.blocks.storagemonitor.StorageScannerContainer in project RFTools by McJty.
the class StorageTerminalBlock method createServerContainer.
@Override
public Container createServerContainer(EntityPlayer entityPlayer, TileEntity tileEntity) {
if (!entityPlayer.isSneaking()) {
if (tileEntity instanceof StorageTerminalTileEntity) {
StorageTerminalTileEntity terminalTileEntity = (StorageTerminalTileEntity) tileEntity;
ItemStack module = terminalTileEntity.getStackInSlot(StorageTerminalContainer.SLOT_MODULE);
if (!module.isEmpty()) {
int dimension = RFToolsTools.getDimensionFromModule(module);
BlockPos pos = RFToolsTools.getPositionFromModule(module);
WorldServer world = DimensionManager.getWorld(dimension);
if (!RFToolsTools.chunkLoaded(world, pos)) {
entityPlayer.sendStatusMessage(new TextComponentString(TextFormatting.YELLOW + "Storage scanner out of range!"), false);
return null;
}
TileEntity scannerTE = world.getTileEntity(pos);
if (!(scannerTE instanceof StorageScannerTileEntity)) {
entityPlayer.sendStatusMessage(new TextComponentString(TextFormatting.YELLOW + "Storage scanner is missing!"), false);
return null;
}
return new StorageScannerContainer(entityPlayer, (IInventory) scannerTE, terminalTileEntity);
}
}
}
return super.createServerContainer(entityPlayer, tileEntity);
}
use of mcjty.rftools.blocks.storagemonitor.StorageScannerContainer in project RFTools by McJty.
the class StorageTools method clearGrid.
public static void clearGrid(EntityPlayer player) {
ItemStack mainhand = player.getHeldItemMainhand();
if (!mainhand.isEmpty() && mainhand.getItem() == ModularStorageSetup.storageModuleTabletItem) {
if (player.openContainer instanceof ModularStorageItemContainer) {
ModularStorageItemContainer storageItemContainer = (ModularStorageItemContainer) player.openContainer;
storageItemContainer.clearGrid();
mainhand.getTagCompound().removeTag("grid");
} else if (player.openContainer instanceof RemoteStorageItemContainer) {
RemoteStorageItemContainer storageItemContainer = (RemoteStorageItemContainer) player.openContainer;
storageItemContainer.clearGrid();
mainhand.getTagCompound().removeTag("grid");
} else if (player.openContainer instanceof StorageScannerContainer) {
StorageScannerContainer storageItemContainer = (StorageScannerContainer) player.openContainer;
storageItemContainer.clearGrid();
mainhand.getTagCompound().removeTag("grid");
}
}
}
use of mcjty.rftools.blocks.storagemonitor.StorageScannerContainer in project RFTools by McJty.
the class StorageCraftingTools method craftFromGrid.
public static void craftFromGrid(EntityPlayer player, int count, boolean test, BlockPos pos) {
player.addStat(StatList.CRAFTING_TABLE_INTERACTION);
int[] testResult = new int[0];
if (pos == null) {
// Handle tablet version
ItemStack mainhand = player.getHeldItemMainhand();
if (!mainhand.isEmpty() && mainhand.getItem() == ModularStorageSetup.storageModuleTabletItem) {
if (player.openContainer instanceof ModularStorageItemContainer) {
ModularStorageItemContainer storageItemContainer = (ModularStorageItemContainer) player.openContainer;
testResult = storageItemContainer.getCraftingGridProvider().craft(player, count, test);
} else if (player.openContainer instanceof RemoteStorageItemContainer) {
RemoteStorageItemContainer storageItemContainer = (RemoteStorageItemContainer) player.openContainer;
testResult = storageItemContainer.getCraftingGridProvider().craft(player, count, test);
} else if (player.openContainer instanceof StorageScannerContainer) {
StorageScannerContainer storageItemContainer = (StorageScannerContainer) player.openContainer;
testResult = storageItemContainer.getStorageScannerTileEntity().craft(player, count, test);
}
}
} else {
TileEntity te = player.getEntityWorld().getTileEntity(pos);
if (te instanceof CraftingGridProvider) {
testResult = ((CraftingGridProvider) te).craft(player, count, test);
}
}
if (testResult.length > 0) {
RFToolsMessages.INSTANCE.sendTo(new PacketCraftTestResultToClient(testResult), (EntityPlayerMP) player);
}
}
use of mcjty.rftools.blocks.storagemonitor.StorageScannerContainer in project RFTools by McJty.
the class StorageTerminalBlock method createClientGui.
@SideOnly(Side.CLIENT)
@Override
public GuiContainer createClientGui(EntityPlayer entityPlayer, TileEntity tileEntity) {
if (!entityPlayer.isSneaking()) {
ItemStack module = getModule(tileEntity);
if (!module.isEmpty()) {
int monitordim = RFToolsTools.getDimensionFromModule(module);
BlockPos pos = RFToolsTools.getPositionFromModule(module);
StorageScannerTileEntity te = new StorageScannerTileEntity(entityPlayer, monitordim) {
@Override
public BlockPos getCraftingGridContainerPos() {
// for this terminal itself.
return tileEntity.getPos();
}
@Override
public CraftingGridProvider getCraftingGridProvider() {
return (CraftingGridProvider) tileEntity;
}
@Override
public boolean isOpenWideView() {
TileEntity realTe = RFTools.proxy.getClientWorld().getTileEntity(pos);
if (realTe instanceof StorageScannerTileEntity) {
return ((StorageScannerTileEntity) realTe).isOpenWideView();
}
return true;
}
@Override
public BlockPos getStorageScannerPos() {
return pos;
}
};
// The position of the actual storage scanner is set on the dummy te
te.setPos(pos);
return new GuiStorageScanner(te, new StorageScannerContainer(entityPlayer, te, (CraftingGridProvider) tileEntity));
}
}
return super.createClientGui(entityPlayer, tileEntity);
}
use of mcjty.rftools.blocks.storagemonitor.StorageScannerContainer in project RFTools by McJty.
the class PacketGridSync method handleMessage.
protected CraftingGridProvider handleMessage(World world, EntityPlayer player) {
CraftingGridProvider provider = null;
if (pos == null) {
// Handle tablet version
ItemStack mainhand = player.getHeldItemMainhand();
if (!mainhand.isEmpty() && mainhand.getItem() == ModularStorageSetup.storageModuleTabletItem) {
if (player.openContainer instanceof ModularStorageItemContainer) {
ModularStorageItemContainer storageItemContainer = (ModularStorageItemContainer) player.openContainer;
provider = storageItemContainer.getCraftingGridProvider();
} else if (player.openContainer instanceof RemoteStorageItemContainer) {
RemoteStorageItemContainer storageItemContainer = (RemoteStorageItemContainer) player.openContainer;
provider = storageItemContainer.getCraftingGridProvider();
} else if (player.openContainer instanceof StorageScannerContainer) {
StorageScannerContainer storageItemContainer = (StorageScannerContainer) player.openContainer;
provider = storageItemContainer.getStorageScannerTileEntity();
}
}
} else {
TileEntity te = world.getTileEntity(pos);
if (te instanceof CraftingGridProvider) {
provider = ((CraftingGridProvider) te);
}
}
if (provider != null) {
for (int i = 0; i < recipes.size(); i++) {
provider.setRecipe(i, recipes.get(i));
}
}
return provider;
}
Aggregations