Beispiel #1
0
 /* SMP */
 public void handleDescriptionPacket(PipeRenderStatePacket packet) {
   if (worldObj.isRemote) {
     if (pipe == null && packet.getPipeId() != 0) {
       initialize(BlockGenericPipe.createPipe(packet.getPipeId()));
     }
     renderState = packet.getRenderState();
     worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
   }
   return;
 }
Beispiel #2
0
  @Override
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);

    coreState.pipeId = nbttagcompound.getInteger("pipeId");
    pipe = BlockGenericPipe.createPipe(coreState.pipeId);

    if (pipe != null) {
      pipe.readFromNBT(nbttagcompound);
    }

    for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
      facadeBlocks[i] = nbttagcompound.getInteger("facadeBlocks[" + i + "]");
      facadeMeta[i] = nbttagcompound.getInteger("facadeMeta[" + i + "]");
    }
  }
Beispiel #3
0
  @Override
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);

    key = nbttagcompound.getInteger("pipeId");
    pipe = BlockGenericPipe.createPipe(key);

    if (pipe != null) {
      pipe.readFromNBT(nbttagcompound);
    }

    for (int i = 0; i < Orientations.dirs().length; i++) {
      facadeBlocks[i] = nbttagcompound.getInteger("facadeBlocks[" + i + "]");
      facadeMeta[i] = nbttagcompound.getInteger("facadeMeta[" + i + "]");
    }
  }
Beispiel #4
0
  @Override
  public void afterStateUpdated(byte stateId) {
    if (!worldObj.isRemote) return;

    switch (stateId) {
      case 0:
        if (pipe == null && coreState.pipeId != 0) {
          initialize(BlockGenericPipe.createPipe(coreState.pipeId));
        }
        if (pipe != null) {
          if (pipe.gate == null) {
            pipe.gate = new GateVanilla(pipe);
          }
          pipe.gate.kind = GateKind.values()[coreState.gateKind];
        }
        break;
    }
    worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord);
  }
Beispiel #5
0
  @Override
  public boolean tryPlaceIntoWorld(
      ItemStack itemstack,
      EntityPlayer entityplayer,
      World world,
      int i,
      int j,
      int k,
      int l,
      float par8,
      float par9,
      float par10) {
    int blockID = BuildCraftTransport.genericPipeBlock.blockID;

    if (world.getBlockId(i, j, k) == Block.snow.blockID) l = 0;
    else {
      if (l == 0) j--;
      if (l == 1) j++;
      if (l == 2) k--;
      if (l == 3) k++;
      if (l == 4) i--;
      if (l == 5) i++;
    }

    if (itemstack.stackSize == 0) return false;
    if (entityplayer.canPlayerEdit(i, j, k)) {
      //		if (world.canBlockBePlacedAt(blockID, i, j, k, false, l)) {

      Pipe pipe = BlockGenericPipe.createPipe(shiftedIndex);
      if (BlockGenericPipe.placePipe(pipe, world, i, j, k, blockID, 0)) {

        // Block.blocksList[blockID].onBlockPlaced(world, i, j, k, l);
        Block.blocksList[blockID].onBlockPlacedBy(world, i, j, k, entityplayer);
        // To move to a proxt
        // world.playSoundEffect((float)i + 0.5F, (float)j + 0.5F,
        // (float)k + 0.5F, block.stepSound.func_1145_d(),
        // (block.stepSound.getVolume() + 1.0F) / 2.0F,
        // block.stepSound.getPitch() * 0.8F);
        itemstack.stackSize--;
      }
      return true;
    } else return false;
  }
Beispiel #6
0
  @Override
  public boolean onItemUse(
      ItemStack itemstack,
      EntityPlayer entityplayer,
      World world,
      int i,
      int j,
      int k,
      int side,
      float par8,
      float par9,
      float par10) {
    int blockID = BuildCraftTransport.genericPipeBlock.blockID;
    Block block = BuildCraftTransport.genericPipeBlock;

    int id = world.getBlockId(i, j, k);

    if (id == Block.snow.blockID) {
      side = 1;
    } else if (id != Block.vine.blockID
        && id != Block.tallGrass.blockID
        && id != Block.deadBush.blockID
        && (Block.blocksList[id] == null
            || !Block.blocksList[id].isBlockReplaceable(world, i, j, k))) {
      if (side == 0) {
        j--;
      }
      if (side == 1) {
        j++;
      }
      if (side == 2) {
        k--;
      }
      if (side == 3) {
        k++;
      }
      if (side == 4) {
        i--;
      }
      if (side == 5) {
        i++;
      }
    }

    if (itemstack.stackSize == 0) return false;
    if (entityplayer.canCurrentToolHarvestBlock(i, j, k)
        && world.canPlaceEntityOnSide(blockID, i, j, k, false, side, entityplayer, itemstack)) {

      Pipe pipe = BlockGenericPipe.createPipe(itemID);
      if (pipe == null) {
        BuildCraftCore.bcLog.log(
            Level.WARNING,
            "Pipe failed to create during placement at {0},{1},{2}",
            new Object[] {i, j, k});
        return true;
      }
      if (BlockGenericPipe.placePipe(pipe, world, i, j, k, blockID, 0)) {

        Block.blocksList[blockID].onBlockPlacedBy(world, i, j, k, entityplayer, itemstack);
        world.playSoundEffect(
            i + 0.5F,
            j + 0.5F,
            k + 0.5F,
            block.stepSound.getPlaceSound(),
            (block.stepSound.getVolume() + 1.0F) / 2.0F,
            block.stepSound.getPitch() * 0.8F);
        itemstack.stackSize--;
      }
      return true;
    } else return false;
  }