@Override
 public boolean isAlreadyBuilt(IBuilderContext context, int x, int y, int z) {
   if (isConcrete) {
     return !BuildCraftAPI.getWorldProperty("replaceable").get(context.world(), x, y, z);
   } else {
     return BuildCraftAPI.getWorldProperty("replaceable").get(context.world(), x, y, z);
   }
 }
Example #2
0
  @Mod.EventHandler
  public void postInit(FMLPostInitializationEvent event) {
    BCLog.logger.info(
        "BuildCraft's fake player: UUID = "
            + gameProfile.getId().toString()
            + ", name = '"
            + gameProfile.getName()
            + "'!");

    for (Object o : Block.blockRegistry) {
      Block block = (Block) o;

      if (block instanceof BlockFluidBase
          || block instanceof BlockLiquid
          || block instanceof IPlantable) {
        BuildCraftAPI.softBlocks.add(block);
      }
    }

    BuildCraftAPI.softBlocks.add(Blocks.snow);
    BuildCraftAPI.softBlocks.add(Blocks.vine);
    BuildCraftAPI.softBlocks.add(Blocks.fire);

    FMLCommonHandler.instance().bus().register(new TickHandlerCore());

    CropManager.setDefaultHandler(new CropHandlerPlantable());
    CropManager.registerHandler(new CropHandlerReeds());

    BuildCraftAPI.registerWorldProperty("replaceable", new WorldPropertyIsReplaceable());
    BuildCraftAPI.registerWorldProperty("soft", new WorldPropertyIsSoft());
    BuildCraftAPI.registerWorldProperty("wood", new WorldPropertyIsWood());
    BuildCraftAPI.registerWorldProperty("leaves", new WorldPropertyIsLeaf());
    for (int i = 0; i < 4; i++) {
      BuildCraftAPI.registerWorldProperty("ore@hardness=" + i, new WorldPropertyIsOre(i));
    }
    BuildCraftAPI.registerWorldProperty("harvestable", new WorldPropertyIsHarvestable());
    BuildCraftAPI.registerWorldProperty("farmland", new WorldPropertyIsFarmland());
    BuildCraftAPI.registerWorldProperty("shoveled", new WorldPropertyIsShoveled());
    BuildCraftAPI.registerWorldProperty("dirt", new WorldPropertyIsDirt());
    BuildCraftAPI.registerWorldProperty("fluidSource", new WorldPropertyIsFluidSource());

    ColorUtils.initialize();

    actionControl = new IActionExternal[IControllable.Mode.values().length];
    for (IControllable.Mode mode : IControllable.Mode.values()) {
      if (mode != IControllable.Mode.Unknown && mode != IControllable.Mode.Mode) {
        actionControl[mode.ordinal()] = new ActionMachineControl(mode);
      }
    }
  }
  @Override
  public void placeInWorld(
      IBuilderContext context, int x, int y, int z, LinkedList<ItemStack> stacks) {
    if (isConcrete) {
      if (stacks.size() == 0 || !BuildCraftAPI.isSoftBlock(context.world(), x, y, z)) {
        return;
      } else {
        ItemStack stack = stacks.getFirst();
        EntityPlayer player =
            BuildCraftAPI.proxy.getBuildCraftPlayer((WorldServer) context.world()).get();

        // force the block to be air block, in case it's just a soft
        // block which replacement is not straightforward
        context.world().setBlock(x, y, z, Blocks.air, 0, 3);

        // Find nearest solid surface to place on
        ForgeDirection dir = ForgeDirection.DOWN;
        while (dir != ForgeDirection.UNKNOWN
            && BuildCraftAPI.isSoftBlock(
                context.world(), x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ)) {
          dir = ForgeDirection.getOrientation(dir.ordinal() + 1);
        }

        stack.tryPlaceItemIntoWorld(
            player,
            context.world(),
            x + dir.offsetX,
            y + dir.offsetY,
            z + dir.offsetZ,
            dir.getOpposite().ordinal(),
            0.0f,
            0.0f,
            0.0f);
      }
    } else {
      context.world().setBlock(x, y, z, Blocks.air, 0, 3);
    }
  }
Example #4
0
 private boolean isQuarriableBlock(int blockID, int bx, int by, int bz) {
   return !isUnquarriableBlock(blockID, bx, by, bz) && !BuildCraftAPI.softBlock(blockID);
 }