net.minecraft.tileentity.TileEntityEnderChest Java Examples

The following examples show how to use net.minecraft.tileentity.TileEntityEnderChest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ItemPickupManager.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos,
        EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (world.isRemote == false)
    {
        TileEntity te = world.getTileEntity(pos);

        // When sneak-right-clicking on an inventory or an Ender Chest, and the installed Link Crystal is a block type crystal,
        // then bind the crystal to the block clicked on.
        if (player.isSneaking() && te != null &&
            (te.getClass() == TileEntityEnderChest.class || te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)))
        {
            ItemStack stack = player.getHeldItem(hand);
            UtilItemModular.setTarget(stack, player,pos, side, hitX, hitY, hitZ, false, false);
        }
    }

    return EnumActionResult.SUCCESS;
}
 
Example #2
Source File: ItemEnderSword.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos,
        EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
    ItemStack stack = player.getHeldItem(hand);
    TileEntity te = world.getTileEntity(pos);

    // When sneak-right-clicking on an inventory or an Ender Chest, and the installed Link Crystal is a block type crystal,
    // then bind the crystal to the block clicked on.
    if (player.isSneaking() && te != null &&
        (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) || te.getClass() == TileEntityEnderChest.class) &&
        UtilItemModular.getSelectedModuleTier(stack, ModuleType.TYPE_LINKCRYSTAL) == ItemLinkCrystal.TYPE_BLOCK)
    {
        if (world.isRemote == false)
        {
            UtilItemModular.setTarget(stack, player, pos, side, hitX, hitY, hitZ, false, false);
        }

        return EnumActionResult.SUCCESS;
    }

    return EnumActionResult.PASS;
}
 
Example #3
Source File: StorageESPMod.java    From ForgeHax with MIT License 5 votes vote down vote up
private int getTileEntityColor(TileEntity tileEntity) {
  if (tileEntity instanceof TileEntityChest
      || tileEntity instanceof TileEntityDispenser
      || tileEntity instanceof TileEntityShulkerBox) {
    return Colors.ORANGE.toBuffer();
  } else if (tileEntity instanceof TileEntityEnderChest) {
    return Colors.PURPLE.toBuffer();
  } else if (tileEntity instanceof TileEntityFurnace) {
    return Colors.GRAY.toBuffer();
  } else if (tileEntity instanceof TileEntityHopper) {
    return Colors.DARK_RED.toBuffer();
  } else {
    return -1;
  }
}
 
Example #4
Source File: ItemEnderBag.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos,
        EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
    TileEntity te = world.getTileEntity(pos);

    if (player.isSneaking() && te != null && te.getClass() == TileEntityEnderChest.class)
    {
        return super.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ);
    }

    return EnumActionResult.PASS;
}
 
Example #5
Source File: CraftEnderChest.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftEnderChest(final Block block) {
    super(block, TileEntityEnderChest.class);
}
 
Example #6
Source File: CraftEnderChest.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftEnderChest(final Material material, final TileEntityEnderChest te) {
    super(material, te);
}
 
Example #7
Source File: InventoryCommandsImplementation.java    From malmo with MIT License 4 votes vote down vote up
private boolean getParameters(String parameter, List<Object> parsedParams)
{
    String[] params = parameter.split(" ");
    if (params.length != 2)
    {
        System.out.println("Malformed parameter string (" + parameter + ") - expected <x> <y>");
        return false;   // Error - incorrect number of parameters.
    }
    String[] lhsParams = params[0].split(":");
    String[] rhsParams = params[1].split(":");
    Integer lhsIndex, rhsIndex;
    String lhsName, rhsName, lhsStrIndex, rhsStrIndex;
    boolean checkContainers = false;
    if (lhsParams.length == 2)
    {
        lhsName = lhsParams[0];
        lhsStrIndex = lhsParams[1];
        checkContainers = true;
    }
    else if (lhsParams.length == 1)
    {
        lhsName = "inventory";
        lhsStrIndex = lhsParams[0];
    }
    else
    {
        System.out.println("Malformed parameter string (" + params[0] + ")");
        return false;
    }
    if (rhsParams.length == 2)
    {
        rhsName = rhsParams[0];
        rhsStrIndex = rhsParams[1];
        checkContainers = true;
    }
    else if (rhsParams.length == 1)
    {
        rhsName = "inventory";
        rhsStrIndex = rhsParams[0];
    }
    else
    {
        System.out.println("Malformed parameter string (" + params[1] + ")");
        return false;
    }

    try
    {
        lhsIndex = Integer.valueOf(lhsStrIndex);
        rhsIndex = Integer.valueOf(rhsStrIndex);
    }
    catch (NumberFormatException e)
    {
        System.out.println("Malformed parameter string (" + parameter + ") - " + e.getMessage());
        return false;
    }
    if (lhsIndex == null || rhsIndex == null)
    {
        System.out.println("Malformed parameter string (" + parameter + ")");
        return false;   // Error - incorrect parameters.
    }
    BlockPos containerPos = null;
    if (checkContainers)
    {
        String containerName = "";
        RayTraceResult rtr = Minecraft.getMinecraft().objectMouseOver;
        if (rtr != null && rtr.typeOfHit == RayTraceResult.Type.BLOCK)
        {
            containerPos = rtr.getBlockPos();
            TileEntity te = Minecraft.getMinecraft().world.getTileEntity(containerPos);
            if (te instanceof TileEntityLockableLoot)
                containerName = ObservationFromFullInventoryImplementation.getInventoryName((IInventory)te);
            else if (te instanceof TileEntityEnderChest)
                containerName = ObservationFromFullInventoryImplementation.getInventoryName(Minecraft.getMinecraft().player.getInventoryEnderChest());
        }
        boolean containerMatches = (lhsName.equals("inventory") || lhsName.equals(containerName)) && (rhsName.equals("inventory") || rhsName.equals(containerName));
        if (!containerMatches)
        {
            System.out.println("Missing container requested in parameter string (" + parameter + ")");
            return false;
        }
    }

    parsedParams.add(lhsName);
    parsedParams.add(lhsIndex);
    parsedParams.add(rhsName);
    parsedParams.add(rhsIndex);
    if (containerPos != null)
        parsedParams.add(containerPos);
    return true;
}
 
Example #8
Source File: ItemEnderTool.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos,
        EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
    ItemStack stack = player.getHeldItem(hand);
    TileEntity te = world.getTileEntity(pos);

    // When sneak-right-clicking on an inventory or an Ender Chest, and the installed Link Crystal is a block type crystal,
    // then bind the crystal to the block clicked on.
    if (player.isSneaking() && te != null &&
        (te.getClass() == TileEntityEnderChest.class || te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))
        && UtilItemModular.getSelectedModuleTier(stack, ModuleType.TYPE_LINKCRYSTAL) == ItemLinkCrystal.TYPE_BLOCK)
    {
        if (world.isRemote == false)
        {
            UtilItemModular.setTarget(stack, player,pos, side, hitX, hitY, hitZ, false, false);
        }

        return EnumActionResult.SUCCESS;
    }
    // Hoe
    else if (ToolType.fromStack(stack) == ToolType.HOE)
    {
        if (world.isRemote == false)
        {
            if (PowerStatus.fromStack(stack) == PowerStatus.POWERED)
            {
                // Didn't till any soil; try to plant stuff from the player inventory or a remote inventory
                if (this.useHoeArea(stack, player, world, pos, side, 1, 1) == false)
                {
                    this.useHoeToPlantArea(stack, player, hand, world, pos, side, hitX, hitY, hitZ, 1, 1);
                }
            }
            else
            {
                // Didn't till any soil; try to plant stuff from the player inventory or a remote inventory
                if (this.useHoe(stack, player, world, pos, side) == false)
                {
                    this.useHoeToPlant(stack, player, hand, world, pos, side, hitX, hitY, hitZ);
                }
            }
        }

        return EnumActionResult.SUCCESS;
    }
    // Try to place a block from the slot right to the currently selected tool (or from slot 1 if tool is in slot 9)
    else
    {
        return this.placeBlock(stack, player, hand, world, pos, side, hitX, hitY, hitZ);
    }
}
 
Example #9
Source File: ItemBuildersWand.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos,
        EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
    ItemStack stack = player.getHeldItem(hand);
    TileEntity te = world.getTileEntity(pos);

    if (te != null && (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) || te.getClass() == TileEntityEnderChest.class))
    {
        return super.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ);
    }

    Mode mode = Mode.getMode(stack);

    if (mode.hasTwoPlacableCorners())
    {
        if (world.isRemote == false)
        {
            if (mode == Mode.REPLACE_3D && player.isSneaking() && WandOption.BIND_MODE.isEnabled(stack, mode))
            {
                this.setSelectedFixedBlockType(stack, player, world, pos, true);
            }
            else
            {
                BlockPosEU posEU = new BlockPosEU(player.isSneaking() ? pos : pos.offset(side), world.provider.getDimension(), side);
                this.setPosition(posEU, POS_END, stack, player);
            }
        }

        return EnumActionResult.SUCCESS;
    }

    // Don't allow targeting the top face of blocks while sneaking
    // This should make sneak building a platform a lot less annoying
    if (world.isRemote == false && (player.isSneaking() == false || side != EnumFacing.UP || mode == Mode.REPLACE))
    {
        // Don't offset the position in Replace mode
        if (mode != Mode.REPLACE)
        {
            pos = pos.offset(side);
        }

        return this.useWand(stack, world, player, new BlockPosEU(pos, world.provider.getDimension(), side));
    }

    return EnumActionResult.SUCCESS;
}
 
Example #10
Source File: TileRequest.java    From HoloInventory with MIT License 4 votes vote down vote up
@Override
public ResponseMessage onMessage(TileRequest message, MessageContext ctx)
{
    World world = DimensionManager.getWorld(message.dim);
    if (world == null) return null;
    TileEntity te = world.getTileEntity(message.pos);
    if (te == null) return null;

    if (Helper.banned.contains(te.getClass().getCanonicalName())) return null;
    if (te instanceof ILockableContainer && !ctx.getServerHandler().player.canOpen(((ILockableContainer) te).getLockCode())) return null;

    if (te instanceof TileEntityEnderChest)
    {
        return new PlainInventory(message.pos, ctx.getServerHandler().player.getInventoryEnderChest());
    }
    else if (te instanceof BlockJukebox.TileEntityJukebox)
    {
        InventoryBasic ib = new InventoryBasic("minecraft:jukebox", false, 1);
        ib.setInventorySlotContents(0, ((BlockJukebox.TileEntityJukebox) te).getRecord());
        return new PlainInventory(message.pos, ib).setName(Blocks.JUKEBOX.getUnlocalizedName());
    }
    else if (te instanceof TileEntityChest)
    {
        Block b = world.getBlockState(message.pos).getBlock();
        if (b instanceof BlockChest)
        {
            IInventory i = ((BlockChest) b).getLockableContainer(world, message.pos);
            if (i != null) return new PlainInventory(message.pos, i);
            return null;
        }
        return new PlainInventory(message.pos, ((TileEntityChest) te));
    }
    else if (te instanceof IInventory)
    {
        return new PlainInventory(message.pos, (IInventory) te);
    }
    else if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
    {
        IItemHandler iih = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
        if (iih == null)
        {
            HoloInventory.getLogger().warn("Error: Block at {} (Class: {} Te: {} Block: {}) returned null after indicating the capability is available.", message.pos, te.getClass().getName(), te, te.getBlockType());
            return null;
        }
        if (te instanceof INamedItemHandler) {
        	INamedItemHandler namedHandler = (INamedItemHandler) te;
        	return new PlainInventory(message.pos, namedHandler.getItemHandlerName(), iih);
        }
        return new PlainInventory(message.pos, te.getBlockType().getUnlocalizedName(), iih);
    }

    return null;
}
 
Example #11
Source File: Helper.java    From HoloInventory with MIT License 4 votes vote down vote up
public static boolean accept(TileEntity te)
{
    return te != null && (te instanceof IInventory || te instanceof BlockJukebox.TileEntityJukebox || te instanceof TileEntityEnderChest || te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null));
}