Package cofh.lib.util

Examples of cofh.lib.util.BlockWrapper


    event.setResult(Result.ALLOW);
  }

  public static boolean registerBucket(Block block, int bMeta, ItemStack bucket) {

    if (block == null || bMeta < 0 || bucket == null || buckets.containsKey(new BlockWrapper(block, bMeta))) {
      return false;
    }
    buckets.put(new BlockWrapper(block, bMeta), new ItemWrapper(bucket));
    return true;
  }
View Full Code Here


  public static ItemStack fillBucket(World world, int x, int y, int z) {

    Block block = world.getBlock(x, y, z);
    int bMeta = world.getBlockMetadata(x, y, z);

    if (!buckets.containsKey(new BlockWrapper(block, bMeta))) {
      if (block.equals(Blocks.water) || block.equals(Blocks.flowing_water)) {
        if (world.getBlockMetadata(x, y, z) == 0) {
          world.setBlockToAir(x, y, z);
          return new ItemStack(Items.water_bucket);
        }
        return null;
      } else if (block.equals(Blocks.lava) || block.equals(Blocks.flowing_lava)) {
        if (world.getBlockMetadata(x, y, z) == 0) {
          world.setBlockToAir(x, y, z);
          return new ItemStack(Items.lava_bucket);
        }
        return null;
      }
      if (block instanceof IFluidBlock) {
        IFluidBlock flBlock = (IFluidBlock) block;

        if (flBlock.canDrain(world, x, y, z)) {
          ItemStack stack = new ItemStack(Items.bucket);
          stack = FluidContainerRegistry.fillFluidContainer(flBlock.drain(world, x, y, z, false), stack);

          if (stack != null) {
            flBlock.drain(world, x, y, z, true);
            return stack;
          }
        }
      }
      return null;
    }
    if (!world.setBlockToAir(x, y, z)) {
      return null;
    }
    ItemWrapper result = buckets.get(new BlockWrapper(block, bMeta));
    return new ItemStack(result.item, 1, result.metadata);
  }
View Full Code Here

        r = ((ItemBucket) bucket.getItem()).tryPlaceContainedLiquid(world, x, y, z);
        world.markBlockForUpdate(x, y, z);
      }
      return r;
    }
    BlockWrapper result = buckets.inverse().get(new ItemWrapper(bucket));

    Material material = world.getBlock(x, y, z).getMaterial();
    boolean solid = !material.isSolid();
    if (world.isAirBlock(x, y, z) || solid) {
      if (!world.isRemote && solid && !material.isLiquid()) {
View Full Code Here

  public static void refreshMap() {

    BiMap<BlockWrapper, ItemWrapper> tempMap = HashBiMap.create(buckets.size());

    for (Entry<BlockWrapper, ItemWrapper> entry : buckets.entrySet()) {
      BlockWrapper tempBlock = new BlockWrapper(entry.getKey().block, entry.getKey().metadata);
      ItemWrapper tempItem = new ItemWrapper(entry.getValue().item, entry.getValue().metadata);
      tempMap.put(tempBlock, tempItem);
    }
    buckets.clear();
    buckets = tempMap;
View Full Code Here

    if (preBlock == null || postBlock == null || postMeta < 0) {
      return false;
    }
    if (preMeta < 0) {
      collisionMap.put(new BlockWrapper(preBlock, preMeta), new BlockWrapper(postBlock, postMeta));
    } else {
      collisionMap.put(new BlockWrapper(preBlock, preMeta), new BlockWrapper(postBlock, postMeta));
    }
    return true;
  }
View Full Code Here

    return addInteraction(preBlock, preMeta, postBlock, 0);
  }

  public boolean hasInteraction(Block preBlock, int preMeta) {

    return collisionMap.containsKey(new BlockWrapper(preBlock, preMeta)) || collisionMap.containsKey(new BlockWrapper(preBlock, -1));
  }
View Full Code Here

    return collisionMap.containsKey(new BlockWrapper(preBlock, preMeta)) || collisionMap.containsKey(new BlockWrapper(preBlock, -1));
  }

  public BlockWrapper getInteraction(Block preBlock, int preMeta) {

    if (collisionMap.containsKey(new BlockWrapper(preBlock, preMeta))) {
      return collisionMap.get(new BlockWrapper(preBlock, preMeta));
    }
    return collisionMap.get(new BlockWrapper(preBlock, -1));
  }
View Full Code Here

TOP

Related Classes of cofh.lib.util.BlockWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.