Exemplo n.º 1
0
 @Override
 public void updateTick(World world, int i, int j, int k, Random random) {
   world.setBlockMetadataWithNotify(i, j, k, 1, 2);
   world.notifyBlocksOfNeighborChange(i, j, k, blockID);
   world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
   world.markBlockRangeForRenderUpdate(i, j, k, i, j, k);
   world.scheduleBlockUpdate(i, j, k, blockID, this.tickRate(world));
 }
Exemplo n.º 2
0
 @Override
 public void breakBlock(World world, int i, int j, int k, int oldID, int oldMeta) {
   world.notifyBlocksOfNeighborChange(i, j, k, this.blockID);
   world.notifyBlocksOfNeighborChange(i + 1, j, k, this.blockID);
   world.notifyBlocksOfNeighborChange(i - 1, j, k, this.blockID);
   world.notifyBlocksOfNeighborChange(i, j, k + 1, this.blockID);
   world.notifyBlocksOfNeighborChange(i, j, k - 1, this.blockID);
   world.notifyBlocksOfNeighborChange(i, j + 1, k, this.blockID);
   world.notifyBlocksOfNeighborChange(i, j - 1, k, this.blockID);
   super.breakBlock(world, i, j, k, oldID, oldMeta);
 }
Exemplo n.º 3
0
 /**
  * Calls World.notifyBlocksOfNeighborChange() for all neighboring blocks, but only if the given
  * block is a redstone wire.
  */
 private void notifyWireNeighborsOfNeighborChange(World par1World, int par2, int par3, int par4) {
   if (par1World.getBlockId(par2, par3, par4) == this.blockID) {
     par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
     par1World.notifyBlocksOfNeighborChange(par2 - 1, par3, par4, this.blockID);
     par1World.notifyBlocksOfNeighborChange(par2 + 1, par3, par4, this.blockID);
     par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - 1, this.blockID);
     par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + 1, this.blockID);
     par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
     par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID);
   }
 }
 private void notifyWireNeighborsOfNeighborChange(World world, int i, int j, int k) {
   if (world.getBlock(i, j, k) == this) {
     world.notifyBlocksOfNeighborChange(i, j, k, this);
     world.notifyBlocksOfNeighborChange(i - 1, j, k, this);
     world.notifyBlocksOfNeighborChange(i + 1, j, k, this);
     world.notifyBlocksOfNeighborChange(i, j, k - 1, this);
     world.notifyBlocksOfNeighborChange(i, j, k + 1, this);
     world.notifyBlocksOfNeighborChange(i, j - 1, k, this);
     world.notifyBlocksOfNeighborChange(i, j + 1, k, this);
   }
 }
 @Override
 public void breakBlock(World worldObj, int xCoord, int yCoord, int zCoord, int par5, int par6) {
   int blockId = OpenCCSensors.Config.basicSensorBlockID;
   worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, blockId);
   worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, blockId);
   worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, blockId);
   worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, blockId);
   worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, blockId);
   worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, blockId);
   worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, blockId);
   super.breakBlock(worldObj, xCoord, yCoord, zCoord, par5, par6);
 }
 public static void unpath(World world, int i, int j, int k) {
   List<ChunkCoordinates> blocks = Lists.newLinkedList();
   List<ChunkCoordinates> notify = Lists.newLinkedList();
   blocks.add(new ChunkCoordinates(i, j, k));
   while (blocks.size() > 0) {
     ChunkCoordinates coords = blocks.remove(0);
     depolarize(world, coords.posX + 1, coords.posY, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY + 1, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY, coords.posZ + 1, blocks);
     depolarize(world, coords.posX - 1, coords.posY, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY - 1, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY, coords.posZ - 1, blocks);
     notify.add(coords);
   }
   for (ChunkCoordinates coords : notify) {
     if (world.blockExists(coords.posX, coords.posY, coords.posZ)) {
       world.markBlockForUpdate(coords.posX, coords.posY, coords.posZ);
       world.notifyBlocksOfNeighborChange(
           coords.posX,
           coords.posY,
           coords.posZ,
           world.getBlock(coords.posX, coords.posY, coords.posZ));
     }
   }
 }
Exemplo n.º 7
0
 /** Switches active state of button or lever at x/y/z to and notifies neighbors */
 public static void activateButton(World world, Block block, int x, int y, int z) {
   int meta = world.getBlockMetadata(x, y, z);
   world.setBlockMetadataWithNotify(x, y, z, (meta < 8 ? meta | 8 : meta & ~8), 3);
   // func_147479_m is markBlockForRenderUpdate
   world.func_147479_m(x, y, z);
   world.playSoundEffect(
       (double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D, Sounds.CLICK, 0.3F, 0.6F);
   world.scheduleBlockUpdate(x, y, z, block, block.tickRate(world));
   world.notifyBlocksOfNeighborChange(x, y, z, block);
   switch (meta & 7) {
     case 0: // 0 and 7 are ceiling levers
     case 7:
       world.notifyBlocksOfNeighborChange(x, y + 1, z, block);
       break;
     case 1:
       world.notifyBlocksOfNeighborChange(x - 1, y, z, block);
       break;
     case 2:
       world.notifyBlocksOfNeighborChange(x + 1, y, z, block);
       break;
     case 3:
       world.notifyBlocksOfNeighborChange(x, y, z - 1, block);
       break;
     case 4:
       world.notifyBlocksOfNeighborChange(x, y, z + 1, block);
       break;
     default:
       world.notifyBlocksOfNeighborChange(x, y - 1, z, block);
   }
 }
Exemplo n.º 8
0
  /**
   * Sets the strength of the wire current (0-15) for this block based on neighboring blocks and
   * propagates to neighboring redstone wires
   */
  private void updateAndPropagateCurrentStrength(World par1World, int par2, int par3, int par4) {
    this.calculateCurrentChanges(par1World, par2, par3, par4, par2, par3, par4);
    ArrayList var5 = new ArrayList(this.blocksNeedingUpdate);
    this.blocksNeedingUpdate.clear();

    for (int var6 = 0; var6 < var5.size(); ++var6) {
      ChunkPosition var7 = (ChunkPosition) var5.get(var6);
      par1World.notifyBlocksOfNeighborChange(var7.x, var7.y, var7.z, this.blockID);
    }
  }
Exemplo n.º 9
0
  @Override
  public void updateTick(World var1, int var2, int var3, int var4, Random var5) {

    if (var1.isRemote) return;

    // var1.getBlockMetadata(var2, var3, var4);
    // List var7 = var1.getEntitiesWithinAABB(EntTornado.class,
    // AxisAlignedBB.getBoundingBoxFromPool((double)var2, (double)var3, (double)var4, (double)var2 +
    // 1.0D, (double)var3 + 1.0D, (double)var4 + 1.0D).expand(140.0D, 140.0D, 140.0D));

    boolean enable = false;

    WeatherManagerServer wms =
        ServerTickHandler.lookupDimToWeatherMan.get(var1.provider.dimensionId);
    if (wms != null) {
      StormObject so =
          wms.getClosestStorm(
              Vec3.createVectorHelper(var2, var3, var4),
              ConfigMisc.sensorActivateDistance,
              StormObject.STATE_FORMING);
      if (so != null /* && so.attrib_tornado_severity > 0*/) {
        enable = true;
      }
    }

    if (enable) {
      var1.setBlockMetadataWithNotify(var2, var3, var4, 15, 2);
    } else {
      var1.setBlockMetadataWithNotify(var2, var3, var4, 0, 2);
    }

    /*if(var7.size() > 0) {
       var1.setBlockMetadataWithNotify(var2, var3, var4, 15);
    } else {
       var1.setBlockMetadataWithNotify(var2, var3, var4, 0);
    }*/
    var1.notifyBlocksOfNeighborChange(var2, var3 - 1, var4, this);
    var1.notifyBlocksOfNeighborChange(var2, var3 + 1, var4, this);
    var1.notifyBlocksOfNeighborChange(var2, var3, var4, this);
    var1.markBlockRangeForRenderUpdate(var2, var3, var4, var2, var3, var4);
    var1.scheduleBlockUpdate(var2, var3, var4, this, this.tickRate(var1));
  }
  /** ======================REDSTONE LOGIC START============================ */
  private void updateAndPropagateCurrentStrength(World world, int x, int y, int z) {
    this.calculateCurrentChanges(world, x, y, z);
    ArrayList<ChunkPosition> arraylist = new ArrayList<ChunkPosition>(this.blocksNeedingUpdate);
    this.blocksNeedingUpdate.clear();

    for (int index = 0; index < arraylist.size(); ++index) {
      ChunkPosition chunkposition = (ChunkPosition) arraylist.get(index);
      world.notifyBlocksOfNeighborChange(
          chunkposition.chunkPosX, chunkposition.chunkPosY, chunkposition.chunkPosZ, this);
    }
  }
  @Override
  public void breakBlock(World world, int i, int j, int k, Block block, int l) {
    super.breakBlock(world, i, j, k, block, l);

    if (!world.isRemote) {
      world.notifyBlocksOfNeighborChange(i, j + 1, k, this);
      world.notifyBlocksOfNeighborChange(i, j - 1, k, this);
      world.notifyBlocksOfNeighborChange(i + 1, j, k, this);
      world.notifyBlocksOfNeighborChange(i - 1, j, k, this);
      world.notifyBlocksOfNeighborChange(i, j, k + 1, this);
      world.notifyBlocksOfNeighborChange(i, j, k - 1, this);
      this.updateAndPropagateCurrentStrength(world, i, j, k);
      this.notifyWireNeighborsOfNeighborChange(world, i - 1, j, k);
      this.notifyWireNeighborsOfNeighborChange(world, i + 1, j, k);
      this.notifyWireNeighborsOfNeighborChange(world, i, j, k - 1);
      this.notifyWireNeighborsOfNeighborChange(world, i, j, k + 1);
      this.notifyWireNeighborsOfNeighborChange(world, i, j - 1, k);
      this.notifyWireNeighborsOfNeighborChange(world, i, j + 1, k);
    }
  }
Exemplo n.º 12
0
  /** ejects contained items into the world, and notifies neighbours of an update, as appropriate */
  public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
    super.breakBlock(par1World, par2, par3, par4, par5, par6);

    if (!par1World.isRemote) {
      par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2 + 1, par3, par4, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2 - 1, par3, par4, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + 1, this.blockID);
      par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - 1, this.blockID);
      this.updateAndPropagateCurrentStrength(par1World, par2, par3, par4);
      this.notifyWireNeighborsOfNeighborChange(par1World, par2 - 1, par3, par4);
      this.notifyWireNeighborsOfNeighborChange(par1World, par2 + 1, par3, par4);
      this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3, par4 - 1);
      this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3, par4 + 1);

      if (par1World.isBlockNormalCube(par2 - 1, par3, par4)) {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2 - 1, par3 + 1, par4);
      } else {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2 - 1, par3 - 1, par4);
      }

      if (par1World.isBlockNormalCube(par2 + 1, par3, par4)) {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2 + 1, par3 + 1, par4);
      } else {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2 + 1, par3 - 1, par4);
      }

      if (par1World.isBlockNormalCube(par2, par3, par4 - 1)) {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 + 1, par4 - 1);
      } else {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 - 1, par4 - 1);
      }

      if (par1World.isBlockNormalCube(par2, par3, par4 + 1)) {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 + 1, par4 + 1);
      } else {
        this.notifyWireNeighborsOfNeighborChange(par1World, par2, par3 - 1, par4 + 1);
      }
    }
  }
Exemplo n.º 13
0
 private static void pathto(World world, int i, int j, int k) {
   List<ChunkCoordinates> blocks = Lists.newLinkedList();
   List<ChunkCoordinates> portals = Lists.newLinkedList();
   List<ChunkCoordinates> repath = Lists.newLinkedList();
   List<ChunkCoordinates> redraw = Lists.newLinkedList();
   blocks.add(new ChunkCoordinates(i, j, k));
   while ((portals.size() > 0) || (blocks.size() > 0)) {
     while (blocks.size() > 0) {
       ChunkCoordinates coords = blocks.remove(0);
       directPortal(world, coords.posX + 1, coords.posY, coords.posZ, 5, blocks, portals);
       directPortal(world, coords.posX, coords.posY + 1, coords.posZ, 1, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ + 1, 3, blocks, portals);
       directPortal(world, coords.posX - 1, coords.posY, coords.posZ, 6, blocks, portals);
       directPortal(world, coords.posX, coords.posY - 1, coords.posZ, 2, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ - 1, 4, blocks, portals);
       redraw.add(coords);
     }
     if (portals.size() > 0) {
       ChunkCoordinates coords = portals.remove(0);
       directPortal(world, coords.posX + 1, coords.posY, coords.posZ, 5, blocks, portals);
       directPortal(world, coords.posX, coords.posY + 1, coords.posZ, 1, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ + 1, 3, blocks, portals);
       directPortal(world, coords.posX - 1, coords.posY, coords.posZ, 6, blocks, portals);
       directPortal(world, coords.posX, coords.posY - 1, coords.posZ, 2, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ - 1, 4, blocks, portals);
       if (world.getBlock(coords.posX, coords.posY, coords.posZ) == NailedBlocks.portal) {
         repath.add(coords);
       }
     }
   }
   while (repath.size() > 0) {
     ChunkCoordinates coords = repath.remove(0);
     if (world.getBlock(coords.posX, coords.posY, coords.posZ) == NailedBlocks.portal) {
       if (!BlockPortal.isValidPortal(world, coords.posX, coords.posY, coords.posZ)) {
         repathNeighbors(world, coords.posX, coords.posY, coords.posZ);
         world.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.air, 0, 0);
         addSurrounding(repath, coords.posX, coords.posY, coords.posZ);
       } else {
         redraw.add(coords);
       }
     }
   }
   for (ChunkCoordinates coords : redraw) {
     if (world.blockExists(coords.posX, coords.posY, coords.posZ)) {
       world.markBlockForUpdate(coords.posX, coords.posY, coords.posZ);
       world.notifyBlocksOfNeighborChange(
           coords.posX,
           coords.posY,
           coords.posZ,
           world.getBlock(coords.posX, coords.posY, coords.posZ));
     }
   }
 }
Exemplo n.º 14
0
    public void setupStructure(World w, EntityPlayer player, int x, int y, int z) {

      for (Entry<String, Coord4> entry : mapStructure.entrySet()) {
        int xT = entry.getValue().x + x;
        int yT = entry.getValue().y + y;
        int zT = entry.getValue().z + z;
        TileEntity tb = w.getTileEntity(xT, yT, zT);

        if (tb != null && tb instanceof TileMasterPillar && ((TileMasterPillar) tb).hasMaster())
          continue;

        if (tb != null && tb instanceof TileRenderPillarModel) {
          w.removeTileEntity(xT, yT, zT);
          w.setBlockMetadataWithNotify(xT, yT, zT, 0, 4);
          w.markBlockForUpdate(xT, yT, zT);
        }

        if (interfaces.containsKey(entry.getKey())) {
          w.setBlockMetadataWithNotify(xT, yT, zT, 2, 4);
          TileEntity te = (TileEntity) w.getTileEntity(xT, yT, zT);
          TileInterfacePillar tip;
          if (te != null && te instanceof TileInterfacePillar) {
            tip = (TileInterfacePillar) te;
            tip.master = new Coord4(x, y, z);
            for (int k = 0; k < interfaces.get(entry.getKey()).length; k++) {
              tip.extractSides.add(
                  ForgeDirection.getOrientation(interfaces.get(entry.getKey())[k]));
              tip.recieveSides.add(
                  ForgeDirection.getOrientation(interfaces.get(entry.getKey())[k]));
            }
            tip.updateRenderTick = 2;
            tip.init();
            tip.isRenderingPillarModel = -1;
          }
        } else {
          w.setBlockMetadataWithNotify(xT, yT, zT, 1, 4);
          TileEntity te = (TileEntity) w.getTileEntity(xT, yT, zT);
          TileBlockPillar tbp;
          if (te != null && te instanceof TileBlockPillar) {
            tbp = (TileBlockPillar) te;
            tbp.master = new Coord4(x, y, z);
            tbp.updateRenderTick = 2;
            tbp.isRenderingPillarModel = -1;
          }
        }
        w.notifyBlocksOfNeighborChange(xT, yT, zT, w.getBlock(xT, yT, zT));
        w.markBlockForUpdate(xT, yT, zT);
      }
    }
  @Override
  public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection side) {
    if (!world.isRemote) {
      TileEntity te = world.getTileEntity(x, y, z);
      if (te instanceof TileElectricPump) {
        if (side.equals(ForgeDirection.UP) || side.equals(ForgeDirection.DOWN)) {
          TileElectricPump e = (TileElectricPump) te;
          ForgeDirection facing = e.getFacing();
          e.setFacing(facing.getRotation(side));
          e.getHandler().updateBlock();
          world.notifyBlocksOfNeighborChange(x, y, z, this);
        }
      }
    }

    return true;
  }
Exemplo n.º 16
0
 protected void updateNeighbors(boolean needSelf) {
   if (needSelf) {
     worldObj.notifyBlocksOfNeighborChange(
         xCoord, yCoord, zCoord, BuildCraftTransport.genericPipeBlock.blockID);
   }
   worldObj.notifyBlocksOfNeighborChange(
       xCoord, yCoord - 1, zCoord, BuildCraftTransport.genericPipeBlock.blockID);
   worldObj.notifyBlocksOfNeighborChange(
       xCoord, yCoord + 1, zCoord, BuildCraftTransport.genericPipeBlock.blockID);
   worldObj.notifyBlocksOfNeighborChange(
       xCoord - 1, yCoord, zCoord, BuildCraftTransport.genericPipeBlock.blockID);
   worldObj.notifyBlocksOfNeighborChange(
       xCoord + 1, yCoord, zCoord, BuildCraftTransport.genericPipeBlock.blockID);
   worldObj.notifyBlocksOfNeighborChange(
       xCoord, yCoord, zCoord - 1, BuildCraftTransport.genericPipeBlock.blockID);
   worldObj.notifyBlocksOfNeighborChange(
       xCoord, yCoord, zCoord + 1, BuildCraftTransport.genericPipeBlock.blockID);
 }
  /** Ticks the block if it's been scheduled */
  public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    int var6 = this.getFlowDecay(par1World, par2, par3, par4);
    byte var7 = 1;

    if (this.blockMaterial == Material.lava && !par1World.provider.isHellWorld) {
      var7 = 2;
    }

    boolean var8 = true;
    int var10;

    if (var6 > 0) {
      byte var9 = -100;
      this.numAdjacentSources = 0;
      int var12 = this.getSmallestFlowDecay(par1World, par2 - 1, par3, par4, var9);
      var12 = this.getSmallestFlowDecay(par1World, par2 + 1, par3, par4, var12);
      var12 = this.getSmallestFlowDecay(par1World, par2, par3, par4 - 1, var12);
      var12 = this.getSmallestFlowDecay(par1World, par2, par3, par4 + 1, var12);
      var10 = var12 + var7;

      if (var10 >= 8 || var12 < 0) {
        var10 = -1;
      }

      if (this.getFlowDecay(par1World, par2, par3 + 1, par4) >= 0) {
        int var11 = this.getFlowDecay(par1World, par2, par3 + 1, par4);

        if (var11 >= 8) {
          var10 = var11;
        } else {
          var10 = var11 + 8;
        }
      }

      if (this.numAdjacentSources >= 2 && this.blockMaterial == Material.water) {
        if (par1World.getBlockMaterial(par2, par3 - 1, par4).isSolid()) {
          var10 = 0;
        } else if (par1World.getBlockMaterial(par2, par3 - 1, par4) == this.blockMaterial
            && par1World.getBlockMetadata(par2, par3, par4) == 0) {
          var10 = 0;
        }
      }

      if (this.blockMaterial == Material.lava
          && var6 < 8
          && var10 < 8
          && var10 > var6
          && par5Random.nextInt(4) != 0) {
        var10 = var6;
        var8 = false;
      }

      if (var10 == var6) {
        if (var8) {
          this.updateFlow(par1World, par2, par3, par4);
        }
      } else {
        var6 = var10;

        if (var10 < 0) {
          par1World.setBlockWithNotify(par2, par3, par4, 0);
        } else {
          par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
          par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate());
          par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
        }
      }
    } else {
      this.updateFlow(par1World, par2, par3, par4);
    }

    if (this.liquidCanDisplaceBlock(par1World, par2, par3 - 1, par4)) {
      if (this.blockMaterial == Material.lava
          && par1World.getBlockMaterial(par2, par3 - 1, par4) == Material.water) {
        par1World.setBlockWithNotify(par2, par3 - 1, par4, Block.stone.blockID);
        this.triggerLavaMixEffects(par1World, par2, par3 - 1, par4);
        return;
      }

      if (var6 >= 8) {
        this.flowIntoBlock(par1World, par2, par3 - 1, par4, var6);
      } else {
        this.flowIntoBlock(par1World, par2, par3 - 1, par4, var6 + 8);
      }
    } else if (var6 >= 0 && (var6 == 0 || this.blockBlocksFlow(par1World, par2, par3 - 1, par4))) {
      boolean[] var13 = this.getOptimalFlowDirections(par1World, par2, par3, par4);
      var10 = var6 + var7;

      if (var6 >= 8) {
        var10 = 1;
      }

      if (var10 >= 8) {
        return;
      }

      if (var13[0]) {
        this.flowIntoBlock(par1World, par2 - 1, par3, par4, var10);
      }

      if (var13[1]) {
        this.flowIntoBlock(par1World, par2 + 1, par3, par4, var10);
      }

      if (var13[2]) {
        this.flowIntoBlock(par1World, par2, par3, par4 - 1, var10);
      }

      if (var13[3]) {
        this.flowIntoBlock(par1World, par2, par3, par4 + 1, var10);
      }
    }
  }
Exemplo n.º 18
0
 private void updateTeaapn(World world, int x, int y, int z) {
   world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
   world.notifyBlocksOfNeighborChange(x, y, z, this);
 }
  @Override
  public void updateTick(World world, int x, int y, int z, Random rand) {

    int quantaRemaining = quantaPerBlock - world.getBlockMetadata(x, y, z);
    int expQuanta = -101;

    // check adjacent block levels if non-source
    if (quantaRemaining < quantaPerBlock) {
      int y2 = y - densityDir;

      if ((world.getBlockId(x, y2, z) == blockID)
          || (world.getBlockId(x - 1, y2, z) == blockID)
          || (world.getBlockId(x + 1, y2, z) == blockID)
          || (world.getBlockId(x, y2, z - 1) == blockID)
          || (world.getBlockId(x, y2, z + 1) == blockID)) {
        expQuanta = quantaPerBlock - 1;

      } else {
        int maxQuanta = -100;
        maxQuanta = getLargerQuanta(world, x - 1, y, z, maxQuanta);
        maxQuanta = getLargerQuanta(world, x + 1, y, z, maxQuanta);
        maxQuanta = getLargerQuanta(world, x, y, z - 1, maxQuanta);
        maxQuanta = getLargerQuanta(world, x, y, z + 1, maxQuanta);

        expQuanta = maxQuanta - 1;
      }
      // decay calculation
      if (expQuanta != quantaRemaining) {
        quantaRemaining = expQuanta;

        if (expQuanta <= 0) {
          world.setBlockToAir(x, y, z);
        } else {
          world.setBlockMetadataWithNotify(x, y, z, quantaPerBlock - expQuanta, 3);
          world.scheduleBlockUpdate(x, y, z, blockID, tickRate);
          world.notifyBlocksOfNeighborChange(x, y, z, blockID);
        }
      }
    } else if (quantaRemaining > quantaPerBlock) {
      world.setBlockMetadataWithNotify(x, y, z, 0, 3);
    }
    // Flow vertically if possible
    if (canDisplace(world, x, y + densityDir, z)) {
      flowIntoBlock(world, x, y + densityDir, z, 1);
      return;
    }
    // Flow outward if possible
    int flowMeta = (quantaPerBlock - quantaRemaining) + 1;
    if (flowMeta >= quantaPerBlock) {
      return;
    }

    if (isSourceBlock(world, x, y, z) || !isFlowingVertically(world, x, y, z)) {

      if (world.getBlockId(x, y - densityDir, z) == blockID) {
        flowMeta = 1;
      }
      boolean flowTo[] = getOptimalFlowDirections(world, x, y, z);

      if (flowTo[0]) {
        flowIntoBlock(world, x - 1, y, z, flowMeta);
      }
      if (flowTo[1]) {
        flowIntoBlock(world, x + 1, y, z, flowMeta);
      }
      if (flowTo[2]) {
        flowIntoBlock(world, x, y, z - 1, flowMeta);
      }
      if (flowTo[3]) {
        flowIntoBlock(world, x, y, z + 1, flowMeta);
      }
    }
  }
 @Override
 public void updateTick(World world, int x, int y, int z, Random random) {
   // System.out.println("x: "+x+", y: "+y+", z: "+z);
   int tex = ((LiquidTextureLogic) world.getBlockTileEntity(x, y, z)).getLiquidType();
   int l = getFlowDecay(world, x, y, z);
   byte byte0 = 1;
   boolean flag = true;
   if (l > 0) {
     int i1 = -100;
     i1 = getSmallestFlowDecay(world, x - 1, y, z, i1);
     i1 = getSmallestFlowDecay(world, x + 1, y, z, i1);
     i1 = getSmallestFlowDecay(world, x, y, z - 1, i1);
     i1 = getSmallestFlowDecay(world, x, y, z + 1, i1);
     int j1 = i1 + byte0;
     if (j1 >= 8 || i1 < 0) {
       j1 = -1;
     }
     if (getFlowDecay(world, x, y + 1, z) >= 0) {
       int l1 = getFlowDecay(world, x, y + 1, z);
       if (l1 >= 8) {
         j1 = l1;
       } else {
         j1 = l1 + 8;
       }
     }
     if (j1 != l) {
       l = j1;
       if (l < 0) {
         world.setBlockWithNotify(x, y, z, 0);
       } else {
         world.setBlockMetadataWithNotify(x, y, z, l);
         world.scheduleBlockUpdate(x, y, z, blockID, tickRate());
         world.notifyBlocksOfNeighborChange(x, y, z, blockID);
       }
     } else if (flag) {
       updateFlow(world, x, y, z);
     }
   } else {
     updateFlow(world, x, y, z);
   }
   if (liquidCanDisplaceBlock(world, x, y - 1, z)) {
     if (l >= 8) {
       world.setBlockAndMetadataWithNotify(x, y - 1, z, blockID, l);
     } else {
       world.setBlockAndMetadataWithNotify(x, y - 1, z, blockID, l + 8);
     }
     ((LiquidTextureLogic) world.getBlockTileEntity(x, y - 1, z)).setTexturePos(tex);
   } else if (l >= 0 && (l == 0 || blockBlocksFlow(world, x, y - 1, z))) {
     boolean aflag[] = getOptimalFlowDirections(world, x, y, z);
     int k1 = l + byte0;
     if (l >= 8) {
       k1 = 1;
     }
     if (k1 >= 8) return;
     if (aflag[0]) {
       flowIntoBlock(world, x - 1, y, z, k1, tex);
     }
     if (aflag[1]) {
       flowIntoBlock(world, x + 1, y, z, k1, tex);
     }
     if (aflag[2]) {
       flowIntoBlock(world, x, y, z - 1, k1, tex);
     }
     if (aflag[3]) {
       flowIntoBlock(world, x, y, z + 1, k1, tex);
     }
   }
 }
Exemplo n.º 21
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer entityplayer,
      int facing,
      float playerX,
      float playerY,
      float playerZ) {
    if (ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem())) {
      return false;
    }

    if (world.isRemote) {
      return true;
    }

    TileEntityGasTank tileEntity = (TileEntityGasTank) world.getTileEntity(x, y, z);
    int metadata = world.getBlockMetadata(x, y, z);

    if (entityplayer.getCurrentEquippedItem() != null) {
      Item tool = entityplayer.getCurrentEquippedItem().getItem();

      if (ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools")
          && tool instanceof IToolWrench
          && !tool.getUnlocalizedName().contains("omniwrench")) {
        if (((IToolWrench) tool).canWrench(entityplayer, x, y, z)) {
          if (entityplayer.isSneaking()) {
            dismantleBlock(world, x, y, z, false);
            return true;
          }

          ((IToolWrench) tool).wrenchUsed(entityplayer, x, y, z);

          int change = 0;

          switch (tileEntity.facing) {
            case 3:
              change = 5;
              break;
            case 5:
              change = 2;
              break;
            case 2:
              change = 4;
              break;
            case 4:
              change = 3;
              break;
          }

          tileEntity.setFacing((short) change);
          world.notifyBlocksOfNeighborChange(x, y, z, this);
          return true;
        }
      }
    }

    if (tileEntity != null) {
      if (!entityplayer.isSneaking()) {
        entityplayer.openGui(Mekanism.instance, 10, world, x, y, z);
        return true;
      }
    }
    return false;
  }
Exemplo n.º 22
0
  public static void CreateDetailed(
      World world,
      int x,
      int y,
      int z,
      int id,
      int meta,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    TileEntityDetailed te;

    if (id == TFCBlocks.stoneSlabs.blockID) {
      TileEntityPartial tep = (TileEntityPartial) world.getBlockTileEntity(x, y, z);
      int extraX = (int) ((tep.extraData) & 0xf);
      int extraY = (int) ((tep.extraData >> 4) & 0xf);
      int extraZ = (int) ((tep.extraData >> 8) & 0xf);
      int extraX2 = 8 - (int) ((tep.extraData >> 12) & 0xf);
      int extraY2 = 8 - (int) ((tep.extraData >> 16) & 0xf);
      int extraZ2 = 8 - (int) ((tep.extraData >> 20) & 0xf);
      world.setBlock(x, y, z, TFCBlocks.Detailed.blockID);
      te = (TileEntityDetailed) world.getBlockTileEntity(x, y, z);
      te.TypeID = tep.TypeID;
      te.MetaID = tep.MetaID;

      for (int subX = 0; subX < 8; subX++) {
        for (int subZ = 0; subZ < 8; subZ++) {
          for (int subY = 0; subY < 8; subY++) {
            if (subX >= extraX
                && subX < extraX2
                && subY >= extraY
                && subY < extraY2
                && subZ >= extraZ
                && subZ < extraZ2) {
              te.setBlock(subX, subY, subZ);
              te.setQuad(subX, subY, subZ);
            }
          }
        }
      }
      return;
    } else {
      Material m = world.getBlockMaterial(x, y, z);
      world.setBlock(x, y, z, TFCBlocks.Detailed.blockID);

      te = (TileEntityDetailed) world.getBlockTileEntity(x, y, z);
      te.TypeID = (short) id;
      te.MetaID = (byte) meta;

      for (int subX = 0; subX < 8; subX++) {
        for (int subZ = 0; subZ < 8; subZ++) {
          for (int subY = 0; subY < 8; subY++) {
            te.setBlock(subX, subY, subZ);
            te.setQuad(subX, subY, subZ);
          }
        }
      }
    }

    world.notifyBlocksOfNeighborChange(x, y, z, world.getBlockId(x, y, z));
  }
 @Override
 public void postHarvest(World world, int x, int y, int z) {
   world.notifyBlocksOfNeighborChange(x, y, z, getPlantId());
 }
Exemplo n.º 24
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float xOffset,
      float yOffset,
      float zOffset) {
    super.onBlockActivated(world, x, y, z, player, side, xOffset, yOffset, zOffset);

    world.notifyBlocksOfNeighborChange(x, y, z, BuildCraftTransport.genericPipeBlock.blockID);

    Pipe pipe = getPipe(world, x, y, z);

    if (isValid(pipe)) {

      // / Right click while sneaking without wrench to strip equipment
      // from the pipe.
      if (player.isSneaking()
          && (player.getCurrentEquippedItem() == null
              || !(player.getCurrentEquippedItem().getItem() instanceof IToolWrench))) {

        if (pipe.hasGate() || pipe.isWired()) return stripEquipment(pipe);

      } else if (player.getCurrentEquippedItem() == null) {
        // Fall through the end of the test
      } else if (player.getCurrentEquippedItem().itemID == Item.sign.itemID)
        // Sign will be placed anyway, so lets show the sign gui
        return false;
      else if (player.getCurrentEquippedItem().getItem() instanceof ItemPipe) return false;
      else if (player.getCurrentEquippedItem().getItem() instanceof IToolWrench)
        // Only check the instance at this point. Call the IToolWrench
        // interface callbacks for the individual pipe/logic calls
        return pipe.blockActivated(player);
      else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.redPipeWire) {
        if (!pipe.wireSet[IPipe.WireColor.Red.ordinal()]) {
          pipe.wireSet[IPipe.WireColor.Red.ordinal()] = true;
          if (!player.capabilities.isCreativeMode) {
            player.getCurrentEquippedItem().splitStack(1);
          }
          pipe.signalStrength[IPipe.WireColor.Red.ordinal()] = 0;
          pipe.container.scheduleNeighborChange();
          return true;
        }
      } else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.bluePipeWire) {
        if (!pipe.wireSet[IPipe.WireColor.Blue.ordinal()]) {
          pipe.wireSet[IPipe.WireColor.Blue.ordinal()] = true;
          if (!player.capabilities.isCreativeMode) {
            player.getCurrentEquippedItem().splitStack(1);
          }
          pipe.signalStrength[IPipe.WireColor.Blue.ordinal()] = 0;
          pipe.container.scheduleNeighborChange();
          return true;
        }
      } else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.greenPipeWire) {
        if (!pipe.wireSet[IPipe.WireColor.Green.ordinal()]) {
          pipe.wireSet[IPipe.WireColor.Green.ordinal()] = true;
          if (!player.capabilities.isCreativeMode) {
            player.getCurrentEquippedItem().splitStack(1);
          }
          pipe.signalStrength[IPipe.WireColor.Green.ordinal()] = 0;
          pipe.container.scheduleNeighborChange();
          return true;
        }
      } else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.yellowPipeWire) {
        if (!pipe.wireSet[IPipe.WireColor.Yellow.ordinal()]) {
          pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] = true;
          if (!player.capabilities.isCreativeMode) {
            player.getCurrentEquippedItem().splitStack(1);
          }
          pipe.signalStrength[IPipe.WireColor.Yellow.ordinal()] = 0;
          pipe.container.scheduleNeighborChange();
          return true;
        }
      } else if (player.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGate.itemID
          || player.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGateAutarchic.itemID)
        if (!pipe.hasGate()) {

          pipe.gate = Gate.makeGate(pipe, player.getCurrentEquippedItem());
          if (!player.capabilities.isCreativeMode) {
            player.getCurrentEquippedItem().splitStack(1);
          }
          pipe.container.scheduleRenderUpdate();
          return true;
        }

      boolean openGateGui = false;

      if (pipe.hasGate()) {
        RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);

        if (rayTraceResult != null && rayTraceResult.hitPart == Part.Gate) {
          openGateGui = true;
        }
      }

      if (openGateGui) {
        pipe.gate.openGui(player);

        return true;
      } else return pipe.blockActivated(player);
    }

    return false;
  }
Exemplo n.º 25
0
  public static void CreateSlab(
      World world, int x, int y, int z, int id, int meta, int side, int SlabID) {
    TileEntityPartial te;

    if (world.getBlockId(x, y, z) != SlabID) {
      world.setBlock(x, y, z, SlabID, side, 0x2);

      te = (TileEntityPartial) world.getBlockTileEntity(x, y, z);
      te.TypeID = (short) id;
      te.MetaID = (byte) meta;
      te.setMaterial(world.getBlockMaterial(x, y, z));
    } else {
      te = (TileEntityPartial) world.getBlockTileEntity(x, y, z);
      world.notifyBlockChange(x, y, z, SlabID);
    }

    if (TFCOptions.enableDebugMode) {
      System.out.println(side);
    }

    long extraX = (te.extraData) & 0xf;
    long extraY = (te.extraData >> 4) & 0xf;
    long extraZ = (te.extraData >> 8) & 0xf;
    long extraX2 = (te.extraData >> 12) & 0xf;
    long extraY2 = (te.extraData >> 16) & 0xf;
    long extraZ2 = (te.extraData >> 20) & 0xf;

    if (side == 0) {
      long e = extraY + 1;
      long new1 = (extraY << 4);
      long new2 = (e << 4);
      long old2 = new2 | (te.extraData - new1);

      if (e + BlockSlab.getTopChiselLevel(te.extraData) >= 8) {
        world.setBlock(x, y, z, 0);
      } else {
        te.extraData = old2;
      }
    } else if (side == 1) {
      long e = extraY2 + 1;
      long new1 = (extraY2 << 16);
      long new2 = (e << 16);
      long old2 = new2 | (te.extraData - new1);

      if (e + BlockSlab.getBottomChiselLevel(te.extraData) >= 8) {
        world.setBlock(x, y, z, 0);
      } else {
        te.extraData = old2;
      }
    } else if (side == 2) {
      long e = extraZ + 1;
      long new1 = (extraZ << 8);
      long new2 = (e << 8);
      long old2 = new2 | (te.extraData - new1);

      if (e + BlockSlab.getSouthChiselLevel(te.extraData) >= 8) {
        world.setBlock(x, y, z, 0);
      } else {
        te.extraData = old2;
      }
    } else if (side == 3) {
      long e = extraZ2 + 1;
      long new1 = (extraZ2 << 20);
      long new2 = (e << 20);
      long old2 = new2 | (te.extraData - new1);

      if (e + BlockSlab.getNorthChiselLevel(te.extraData) >= 8) {
        world.setBlock(x, y, z, 0);
      } else {
        te.extraData = old2;
      }
    } else if (side == 4) {
      long e = extraX + 1;
      long new1 = (extraX);
      long new2 = (e);
      long old2 = new2 | (te.extraData - new1);

      if (e + BlockSlab.getEastChiselLevel(te.extraData) >= 8) {
        world.setBlock(x, y, z, 0);
      } else {
        te.extraData = old2;
      }
    } else if (side == 5) {
      long e = extraX2 + 1;
      long new1 = (extraX2 << 12);
      long new2 = (e << 12);
      long old2 = new2 | (te.extraData - new1);

      if (e + BlockSlab.getWestChiselLevel(te.extraData) >= 8) {
        world.setBlock(x, y, z, 0);
      } else {
        te.extraData = old2;
      }
    }

    if (TFCOptions.enableDebugMode) {
      System.out.println("Extra =" + te.extraData);
    }

    te = (TileEntityPartial) world.getBlockTileEntity(x, y, z);
    if (te != null) {
      te.broadcastPacketInRange(te.createUpdatePacket());
    }

    world.notifyBlocksOfNeighborChange(x, y, z, world.getBlockId(x, y, z));
  }
Exemplo n.º 26
0
  public boolean placeInBlock(
      World world,
      int x,
      int y,
      int z,
      EnumPosition pos,
      ItemStack itemstack,
      boolean doBlockUpdate,
      int sideClicked) {
    if (DEBUG) {
      System.out.println(
          (world.isRemote ? "client" : "server")
              + " placeInBlock "
              + x
              + ","
              + y
              + ","
              + z
              + " "
              + pos);
      System.out.println("ID of microblock is " + getPartTypeID(itemstack));
    }
    if (world.isRemote) {
      MicroblockPlacementPacket packet = PacketHandler.getPacket(MicroblockPlacementPacket.class);
      packet.position = pos.ordinal();
      packet.side = sideClicked;
      packet.posX = x;
      packet.posY = y;
      packet.posZ = z;
      BasicUtils.sendPacketToServer(packet.getPacket());
      return true;
    }

    int d = getPartTypeID(itemstack);
    if (!MicroblockSystem.parts.containsKey(d)) {
      if (DEBUG) System.out.println("wrong part ID, got " + d);
      return false;
    }

    TileEntity newTE = world.getBlockTileEntity(x, y, z);
    boolean addedTE = false;
    if (newTE == null || !(newTE instanceof IMicroblockSupporterTile)) {
      Block replacing = Block.blocksList[world.getBlockId(x, y, z)];
      if (replacing != null && !replacing.isBlockReplaceable(world, x, y, z)) {
        if (DEBUG) System.out.println("not replaceable");
        return false;
      }
      if (!block.canPlaceBlockOnSide(world, x, y, z, 0)) {
        if (DEBUG) System.out.println("can't place on side");
        return false;
      }

      world.setBlock(x, y, z, block.blockID, 0, 0);
      newTE = new TileMicroblockContainer();
      world.setBlockTileEntity(x, y, z, newTE);
      addedTE = true;
    }

    PartType<?> type = MicroblockSystem.parts.get(d);
    assert type != null : "No part type with ID " + d;

    IMicroblockCoverSystem cover = ((IMicroblockSupporterTile) newTE).getCoverSystem();
    assert cover != null : "New tile entity has no cover system";

    if (!cover.addPart(type.createPart(pos))) {
      if (addedTE) world.setBlock(x, y, z, 0, 0, 0);

      if (DEBUG) System.out.println("addPart failed");
      return false;
    }
    if (DEBUG) System.out.println("addPart ok");

    if (doBlockUpdate) {
      if (newTE instanceof IMicroblockSupporterTile2)
        ((IMicroblockSupporterTile2) newTE).onMicroblocksChanged();
      else {
        world.notifyBlocksOfNeighborChange(x, y, z, block.blockID);
        world.markBlockForUpdate(x, y, z);
      }
    }
    return true;
  }
  /** Ticks the block if it's been scheduled */
  public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    int l = this.getFlowDecay(par1World, par2, par3, par4);
    byte b0 = 1;

    boolean flag = true;
    int i1;

    if (l > 0) {
      byte b1 = -100;
      this.numAdjacentSources = 0;
      int j1 = this.getSmallestFlowDecay(par1World, par2 - 1, par3, par4, b1);
      j1 = this.getSmallestFlowDecay(par1World, par2 + 1, par3, par4, j1);
      j1 = this.getSmallestFlowDecay(par1World, par2, par3, par4 - 1, j1);
      j1 = this.getSmallestFlowDecay(par1World, par2, par3, par4 + 1, j1);
      i1 = j1 + b0;

      if (i1 >= 8 || j1 < 0) {
        i1 = -1;
      }

      if (this.getFlowDecay(par1World, par2, par3 + 1, par4) >= 0) {
        int k1 = this.getFlowDecay(par1World, par2, par3 + 1, par4);

        if (k1 >= 8) {
          i1 = k1;
        } else {
          i1 = k1 + 8;
        }
      }

      if (this.numAdjacentSources >= 2) {
        if (par1World.getBlockMaterial(par2, par3 - 1, par4).isSolid()) {
          i1 = 0;
        } else if (par1World.getBlockMaterial(par2, par3 - 1, par4) == this.blockMaterial
            && par1World.getBlockMetadata(par2, par3 - 1, par4) == 0) {
          i1 = 0;
        }
      }

      if (i1 == l) {
        if (flag) {
          this.updateFlow(par1World, par2, par3, par4);
        }
      } else {
        l = i1;

        if (i1 < 0) {
          par1World.setBlockToAir(par2, par3, par4);
        } else {
          par1World.setBlockMetadataWithNotify(par2, par3, par4, i1, 2);
          par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
          par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
        }
      }
    } else {
      this.updateFlow(par1World, par2, par3, par4);
    }

    if (this.liquidCanDisplaceBlock(par1World, par2, par3 - 1, par4)) {

      if (l >= 8) {
        this.flowIntoBlock(par1World, par2, par3 - 1, par4, l);
      } else {
        this.flowIntoBlock(par1World, par2, par3 - 1, par4, l + 8);
      }
    } else if (l >= 0 && (l == 0 || this.blockBlocksFlow(par1World, par2, par3 - 1, par4))) {
      boolean[] aboolean = this.getOptimalFlowDirections(par1World, par2, par3, par4);
      i1 = l + b0;

      if (l >= 8) {
        i1 = 1;
      }

      if (i1 >= 8) {
        return;
      }

      if (aboolean[0]) {
        this.flowIntoBlock(par1World, par2 - 1, par3, par4, i1);
      }

      if (aboolean[1]) {
        this.flowIntoBlock(par1World, par2 + 1, par3, par4, i1);
      }

      if (aboolean[2]) {
        this.flowIntoBlock(par1World, par2, par3, par4 - 1, i1);
      }

      if (aboolean[3]) {
        this.flowIntoBlock(par1World, par2, par3, par4 + 1, i1);
      }
    }
  }