示例#1
0
 @Override
 public boolean onBlockActivated(
     EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
   if (ToolUtil.isToolEquipped(player)) {
     if (!getBundle().getEntity().getWorldObj().isRemote) {
       if (res != null && res.component != null) {
         ForgeDirection connDir = res.component.dir;
         ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit);
         if (connDir == ForgeDirection.UNKNOWN || connDir == faceHit) {
           if (getConnectionMode(faceHit) == ConnectionMode.DISABLED) {
             setConnectionMode(faceHit, ConnectionMode.IN_OUT);
             return true;
           }
           return ConduitUtil.joinConduits(this, faceHit);
         } else if (externalConnections.contains(connDir)) {
           setConnectionMode(connDir, getNextConnectionMode(connDir));
           return true;
         } else if (containsConduitConnection(connDir)) {
           ConduitUtil.disconectConduits(this, connDir);
           return true;
         }
       }
     }
   }
   return false;
 }
示例#2
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer entityPlayer,
      int side,
      float par7,
      float par8,
      float par9) {

    if (ConduitUtil.isToolEquipped(entityPlayer)) {
      if (entityPlayer.isSneaking()
          && entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
        IToolWrench wrench = (IToolWrench) entityPlayer.getCurrentEquippedItem().getItem();
        if (wrench.canWrench(entityPlayer, x, y, z)) {
          removedByPlayer(world, entityPlayer, x, y, z, false);
          if (entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
            ((IToolWrench) entityPlayer.getCurrentEquippedItem().getItem())
                .wrenchUsed(entityPlayer, x, y, z);
          }
          return true;
        }
      }
    }
    if (entityPlayer.isSneaking()) {
      return false;
    }
    entityPlayer.openGui(EnderIO.instance, GuiHandler.GUI_ID_ENCHANTER, world, x, y, z);
    return true;
  }
示例#3
0
 @Override
 public void onAddedToBundle() {
   for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
     TileEntity te = getLocation().getLocation(dir).getTileEntity(getBundle().getWorld());
     if (te instanceof TileConduitBundle) {
       IMEConduit cond = ((TileConduitBundle) te).getConduit(IMEConduit.class);
       if (cond != null) {
         cond.setConnectionMode(dir.getOpposite(), ConnectionMode.IN_OUT);
         ConduitUtil.joinConduits(cond, dir.getOpposite());
       }
     }
   }
 }
示例#4
0
  @Override
  public boolean onItemUse(
      ItemStack itemStack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float par8,
      float par9,
      float par10) {

    if (world.isRemote) {
      return true;
    }

    ForgeDirection dir = ForgeDirection.values()[side];
    int placeX = x + dir.offsetX;
    int placeY = y + dir.offsetY;
    int placeZ = z + dir.offsetZ;

    if (player.canPlayerEdit(placeX, placeY, placeZ, side, itemStack)
        && world.isAirBlock(placeX, placeY, placeZ)
        && PainterUtil.getSourceBlock(itemStack) != null) {

      world.setBlock(placeX, placeY, placeZ, EnderIO.blockConduitBundle);
      IConduitBundle bundle = (IConduitBundle) world.getTileEntity(placeX, placeY, placeZ);
      Block facadeID = PainterUtil.getSourceBlock(itemStack);
      int facadeMeta = PainterUtil.getSourceBlockMetadata(itemStack);
      facadeMeta = PainterUtil.adjustFacadeMetadata(facadeID, facadeMeta, side);
      bundle.setFacadeId(facadeID);
      bundle.setFacadeMetadata(facadeMeta);
      bundle.setFacadeType(FacadeType.values()[itemStack.getItemDamage()]);
      ConduitUtil.playStepSound(facadeID.stepSound, world, x, y, z);
      if (!player.capabilities.isCreativeMode) {
        itemStack.stackSize--;
      }
      return true;
    }

    return false;
  }
示例#5
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer entityPlayer,
      int par6,
      float par7,
      float par8,
      float par9) {

    if (ConduitUtil.isToolEquipped(entityPlayer) && entityPlayer.isSneaking()) {
      if (entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
        IToolWrench wrench = (IToolWrench) entityPlayer.getCurrentEquippedItem().getItem();
        if (wrench.canWrench(entityPlayer, x, y, z)) {
          removeBlockByPlayer(world, entityPlayer, x, y, z);
          if (entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
            ((IToolWrench) entityPlayer.getCurrentEquippedItem().getItem())
                .wrenchUsed(entityPlayer, x, y, z);
          }
          return true;
        }
      }
    }

    if (entityPlayer.isSneaking()) {
      return false;
    }
    TileEntity te = world.getBlockTileEntity(x, y, z);
    if (!(te instanceof TileCapacitorBank)) {
      return false;
    }
    entityPlayer.openGui(EnderIO.instance, GuiHandler.GUI_ID_CAPACITOR_BANK, world, x, y, z);
    return true;
  }
示例#6
0
 private ILiquidConduit getFluidConduit(ForgeDirection dir) {
   TileEntity ent = getBundle().getEntity();
   return ConduitUtil.getConduit(ent.getWorldObj(), ent, dir, ILiquidConduit.class);
 }