Search in sources :

Example 1 with TileInventoryPanel

use of crazypants.enderio.machine.invpanel.TileInventoryPanel in project EnderIO by SleepyTrousers.

the class ClientRemoteGuiManager method getServerGuiElement.

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int posLow, int dim, int posHigh) {
    long posl = ((long) posHigh << 32) | (posLow & 0xffffffffL);
    BlockPos pos = BlockPos.fromLong(posl);
    World targetWorld = world;
    if (world.provider.getDimension() != dim) {
        targetWorld = DimensionManager.getWorld(dim);
        if (targetWorld == null) {
            Log.warn("Unexpected failure to get dimension " + dim + " for the Inventory Panel Remote");
            return null;
        }
    }
    TileEntity te = targetWorld.getTileEntity(pos);
    if (te instanceof TileInventoryPanel) {
        return new InventoryPanelContainer(player.inventory, (TileInventoryPanel) te);
    }
    Log.warn("Unexpected failure to get tileentity at " + pos + " in dimension " + dim + " for the Inventory Panel Remote. Got: " + te);
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileInventoryPanel(crazypants.enderio.machine.invpanel.TileInventoryPanel) InventoryPanelContainer(crazypants.enderio.machine.invpanel.InventoryPanelContainer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Example 2 with TileInventoryPanel

use of crazypants.enderio.machine.invpanel.TileInventoryPanel in project EnderIO by SleepyTrousers.

the class ClientRemoteGuiManager method getClientGuiElement.

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    TileInventoryPanel te;
    if (targetTE != null && targetTEtime >= EnderIO.proxy.getTickCount()) {
        te = targetTE;
        targetTE = null;
    } else {
        te = new TileInventoryPanel();
    }
    return new GuiInventoryPanel(te, new InventoryPanelContainer(player.inventory, te));
}
Also used : TileInventoryPanel(crazypants.enderio.machine.invpanel.TileInventoryPanel) InventoryPanelContainer(crazypants.enderio.machine.invpanel.InventoryPanelContainer) GuiInventoryPanel(crazypants.enderio.machine.invpanel.GuiInventoryPanel)

Example 3 with TileInventoryPanel

use of crazypants.enderio.machine.invpanel.TileInventoryPanel in project EnderIO by SleepyTrousers.

the class PacketRemoteInvPanel method onMessage.

@Override
public IMessage onMessage(PacketRemoteInvPanel message, MessageContext ctx) {
    EntityPlayerMP player = ctx.getServerHandler().player;
    ItemStack heldItem = player.getHeldItem(message.hand);
    if (heldItem == null || !(heldItem.getItem() instanceof ItemRemoteInvAccess)) {
        return null;
    }
    if (!REMOTE_X.hasTag(heldItem)) {
        return null;
    }
    int x = REMOTE_X.getInt(heldItem);
    int y = REMOTE_Y.getInt(heldItem);
    int z = REMOTE_Z.getInt(heldItem);
    int d = REMOTE_D.getInt(heldItem);
    ItemRemoteInvAccessType type = ItemRemoteInvAccessType.fromStack(heldItem);
    if (!type.inRange(d, x, y, z, player.getEntityWorld().provider.getDimension(), (int) player.posX, (int) player.posY, (int) player.posZ)) {
        player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.outofrange")), true);
        return null;
    }
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    if (server == null) {
        return null;
    }
    WorldServer world = server.getWorld(d);
    if (world == null) {
        player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.invalidtarget")), true);
        return null;
    }
    final BlockPos pos = new BlockPos(x, y, z);
    if (!world.isBlockLoaded(pos)) {
        player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.notloaded")), true);
        return null;
    }
    TileEntity tileEntity = player.getEntityWorld().getTileEntity(pos);
    if (!(tileEntity instanceof TileInventoryPanel)) {
        player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.invalidtarget")), true);
        return null;
    }
    Container c = player.openContainer;
    player.interactionManager.processRightClickBlock(player, player.world, null, EnumHand.MAIN_HAND, pos, EnumFacing.UP, 0f, 0f, 0f);
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileInventoryPanel(crazypants.enderio.machine.invpanel.TileInventoryPanel) Container(net.minecraft.inventory.Container) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) TextComponentString(net.minecraft.util.text.TextComponentString) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 4 with TileInventoryPanel

use of crazypants.enderio.machine.invpanel.TileInventoryPanel in project EnderIO by SleepyTrousers.

the class ServerRemoteGuiManager method openGui.

public static void openGui(EntityPlayerMP player, World world, BlockPos pos) {
    long posl = pos.toLong();
    int x = (int) posl;
    int y = world.provider.getDimension();
    int z = (int) (posl >>> 32);
    TileEntity te = world.getTileEntity(pos);
    if (te instanceof TileInventoryPanel) {
        PacketHandler.INSTANCE.sendTo(new PacketPrimeInventoryPanelRemote((TileInventoryPanel) te), player);
    }
    InvpanelObject.blockInventoryPanel.openGui(player.world, player, x, y, z);
    Ticker.create();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileInventoryPanel(crazypants.enderio.machine.invpanel.TileInventoryPanel)

Example 5 with TileInventoryPanel

use of crazypants.enderio.machine.invpanel.TileInventoryPanel in project EnderIO by SleepyTrousers.

the class ItemRemoteInvAccess method onItemUseFirst.

@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
    if (world.isRemote || !player.isSneaking()) {
        return EnumActionResult.PASS;
    }
    TileEntity te = world.getTileEntity(pos);
    ItemStack stack = player.getHeldItem(hand);
    if (te instanceof TileInventoryPanel) {
        REMOTE_X.setInt(stack, te.getPos().getX());
        REMOTE_Y.setInt(stack, te.getPos().getY());
        REMOTE_Z.setInt(stack, te.getPos().getZ());
        REMOTE_D.setInt(stack, te.getWorld().provider.getDimension());
        player.sendStatusMessage(new TextComponentString(EnderIO.lang.localize("remoteinv.chat.set")), true);
        return EnumActionResult.SUCCESS;
    }
    return EnumActionResult.PASS;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileInventoryPanel(crazypants.enderio.machine.invpanel.TileInventoryPanel) ItemStack(net.minecraft.item.ItemStack) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

TileInventoryPanel (crazypants.enderio.machine.invpanel.TileInventoryPanel)5 TileEntity (net.minecraft.tileentity.TileEntity)4 InventoryPanelContainer (crazypants.enderio.machine.invpanel.InventoryPanelContainer)2 ItemStack (net.minecraft.item.ItemStack)2 BlockPos (net.minecraft.util.math.BlockPos)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 GuiInventoryPanel (crazypants.enderio.machine.invpanel.GuiInventoryPanel)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 Container (net.minecraft.inventory.Container)1 MinecraftServer (net.minecraft.server.MinecraftServer)1 World (net.minecraft.world.World)1 WorldServer (net.minecraft.world.WorldServer)1