Esempio n. 1
0
  private void setDispenserDefaultDirection(World par1World, int par2, int par3, int par4) {
    if (!par1World.isRemote) {
      Block l = par1World.getBlock(par2, par3, par4 - 1);
      Block i1 = par1World.getBlock(par2, par3, par4 + 1);
      Block j1 = par1World.getBlock(par2 - 1, par3, par4);
      Block k1 = par1World.getBlock(par2 + 1, par3, par4);
      byte b0 = 3;
      if (l.isOpaqueCube() && !i1.isOpaqueCube()) {
        b0 = 3;
      }

      if (i1.isOpaqueCube() && !l.isOpaqueCube()) {
        b0 = 2;
      }

      if (j1.isOpaqueCube() && !k1.isOpaqueCube()) {
        b0 = 5;
      }

      if (k1.isOpaqueCube() && !j1.isOpaqueCube()) {
        b0 = 4;
      }

      par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2);
    }
  }
Esempio n. 2
0
 @Override
 public boolean shouldRenderInPass(int arg0) {
   if (facadeId != null
       && facadeId.isOpaqueCube()
       && !ConduitUtil.isFacadeHidden(this, EnderIO.proxy.getClientPlayer())) {
     return false;
   }
   return super.shouldRenderInPass(arg0);
 }
 @Override
 @SideOnly(Side.CLIENT)
 public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int s) {
   if (Minecraft.getMinecraft().gameSettings.fancyGraphics) return true;
   ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[s];
   int dx = x; // +dir.offsetX;
   int dy = y; // +dir.offsetY;
   int dz = z; // +dir.offsetZ;
   Block id = world.getBlock(dx, dy, dz);
   if (id == Blocks.air) return true;
   if (id == this) return false;
   return !id.isOpaqueCube();
 }
Esempio n. 4
0
 @Override
 public boolean isValidPaintSource(ItemStack paintSource) {
   if (paintSource == null) {
     return false;
   }
   Block block = Util.getBlockFromItemId(paintSource);
   if (block == null || block instanceof IPaintedBlock) {
     return false;
   }
   if (PaintSourceValidator.instance.isBlacklisted(paintSource)) {
     return false;
   }
   if (PaintSourceValidator.instance.isWhitelisted(paintSource)) {
     return true;
   }
   if (!Config.allowTileEntitiesAsPaintSource && block instanceof ITileEntityProvider) {
     return false;
   }
   if (block == EnderIO.blockFusedQuartz && paintSource.getItemDamage() < 2) {
     return true;
   }
   return block.getRenderType() == 0 || block.isOpaqueCube() || block.isNormalCube();
 }
  @SuppressWarnings("rawtypes")
  public void doExplosionB(boolean par1) {
    if (this.explosionSize >= 2.0F && this.isSmoking)
      this.worldObj.spawnParticle(
          "hugeexplosion", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D);
    else
      this.worldObj.spawnParticle(
          "largeexplode", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D);

    Iterator iterator;
    ChunkPosition chunkposition;
    int i;
    int j;
    int k;
    Block l;

    if (this.isSmoking) {
      iterator = this.affectedBlockPositions.iterator();

      while (iterator.hasNext()) {
        chunkposition = (ChunkPosition) iterator.next();
        i = chunkposition.chunkPosX;
        j = chunkposition.chunkPosY;
        k = chunkposition.chunkPosZ;
        l = this.worldObj.getBlock(i, j, k);

        if (par1) {
          double d0 = i + this.worldObj.rand.nextFloat();
          double d1 = j + this.worldObj.rand.nextFloat();
          double d2 = k + this.worldObj.rand.nextFloat();
          double d3 = d0 - this.explosionX;
          double d4 = d1 - this.explosionY;
          double d5 = d2 - this.explosionZ;
          double d6 = MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5);
          d3 /= d6;
          d4 /= d6;
          d5 /= d6;
          double d7 = 0.5D / (d6 / this.explosionSize + 0.1D);
          d7 *= this.worldObj.rand.nextFloat() * this.worldObj.rand.nextFloat() + 0.3F;
          d3 *= d7;
          d4 *= d7;
          d5 *= d7;
          this.worldObj.spawnParticle(
              "explode",
              (d0 + this.explosionX * 1.0D) / 2.0D,
              (d1 + this.explosionY * 1.0D) / 2.0D,
              (d2 + this.explosionZ * 1.0D) / 2.0D,
              d3,
              d4,
              d5);
          this.worldObj.spawnParticle("smoke", d0, d1, d2, d3, d4, d5);
        }
      }
    }

    if (this.isFlaming) {
      iterator = this.affectedBlockPositions.iterator();

      while (iterator.hasNext()) {
        chunkposition = (ChunkPosition) iterator.next();
        i = chunkposition.chunkPosX;
        j = chunkposition.chunkPosY;
        k = chunkposition.chunkPosZ;
        l = this.worldObj.getBlock(i, j, k);
        Block i1 = this.worldObj.getBlock(i, j - 1, k);

        if (l == null && i1.isOpaqueCube() && this.explosionRNG.nextInt(3) == 0)
          this.worldObj.setBlock(i, j, k, Blocks.fire);
      }
    }
  }
Esempio n. 6
0
  @Override
  public void rebuildChunk(
      final float x, final float y, final float z, final ChunkCompileTaskGenerator generator) {
    final CompiledOverlay compiledOverlay = new CompiledOverlay();
    final BlockPos from = getPosition();
    final BlockPos to = from.add(15, 15, 15);
    generator.getLock().lock();
    RegionRenderCache regionRenderCache;
    final SchematicWorld schematic = (SchematicWorld) this.world;

    try {
      if (generator.getStatus() != ChunkCompileTaskGenerator.Status.COMPILING) {
        return;
      }

      if (from.getX() < 0
          || from.getZ() < 0
          || from.getX() >= schematic.getWidth()
          || from.getZ() >= schematic.getLength()) {
        generator.setCompiledChunk(CompiledChunk.DUMMY);
        return;
      }

      regionRenderCache =
          new RegionRenderCache(this.world, from.add(-1, -1, -1), to.add(1, 1, 1), 1);
      generator.setCompiledChunk(compiledOverlay);
    } finally {
      generator.getLock().unlock();
    }

    final VisGraph visgraph = new VisGraph();

    if (!regionRenderCache.extendedLevelsInChunkCache()) {
      ++renderChunksUpdated;

      final World mcWorld = Minecraft.getMinecraft().theWorld;

      final EnumWorldBlockLayer layer = EnumWorldBlockLayer.TRANSLUCENT;
      final WorldRenderer worldRenderer =
          generator.getRegionRenderCacheBuilder().getWorldRendererByLayer(layer);

      GeometryTessellator.setStaticDelta(ConfigurationHandler.blockDelta);

      for (final BlockPos pos : BlockPos.getAllInBox(from, to)) {
        if (schematic.isRenderingLayer && schematic.renderingLayer != pos.getY()
            || !schematic.isInside(pos)) {
          continue;
        }

        boolean render = false;
        int sides = 0;
        int color = 0;

        final IBlockState schBlockState = schematic.getBlockState(pos);
        final Block schBlock = schBlockState.getBlock();

        if (schBlock.isOpaqueCube()) {
          visgraph.func_178606_a(pos);
        }

        final BlockPos mcPos = pos.add(schematic.position);
        final IBlockState mcBlockState = mcWorld.getBlockState(mcPos);
        final Block mcBlock = mcBlockState.getBlock();

        final boolean isSchAirBlock = schematic.isAirBlock(pos);
        final boolean isMcAirBlock =
            mcWorld.isAirBlock(mcPos) || ConfigurationHandler.isExtraAirBlock(mcBlock);

        if (!isMcAirBlock) {
          if (isSchAirBlock && ConfigurationHandler.highlightAir) {
            render = true;
            sides = GeometryMasks.Quad.ALL;
            color = 0xBF00BF;
          }
        }

        if (!render) {
          if (ConfigurationHandler.highlight) {
            if (!isMcAirBlock) {
              if (schBlock != mcBlock) {
                render = true;
                color = 0xFF0000;
              } else if (schBlock.getMetaFromState(schBlockState)
                  != mcBlock.getMetaFromState(mcBlockState)) {
                render = true;
                color = 0xBF5F00;
              }
            } else if (!isSchAirBlock) {
              render = true;
              color = 0x00BFFF;
            }
          }

          if (render) {
            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.DOWN), EnumFacing.DOWN)) {
              sides |= GeometryMasks.Quad.DOWN;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.UP), EnumFacing.UP)) {
              sides |= GeometryMasks.Quad.UP;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.NORTH), EnumFacing.NORTH)) {
              sides |= GeometryMasks.Quad.NORTH;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.SOUTH), EnumFacing.SOUTH)) {
              sides |= GeometryMasks.Quad.SOUTH;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.WEST), EnumFacing.WEST)) {
              sides |= GeometryMasks.Quad.WEST;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.EAST), EnumFacing.EAST)) {
              sides |= GeometryMasks.Quad.EAST;
            }
          }
        }

        if (render && sides != 0) {
          if (!compiledOverlay.isLayerStarted(layer)) {
            compiledOverlay.setLayerStarted(layer);
            preRenderBlocks(worldRenderer, from);
          }

          GeometryTessellator.drawCuboid(worldRenderer, pos, sides, 0x3F000000 | color);
          compiledOverlay.setLayerUsed(layer);
        }
      }

      if (compiledOverlay.isLayerStarted(layer)) {
        postRenderBlocks(layer, x, y, z, worldRenderer, compiledOverlay);
      }
    }

    compiledOverlay.setVisibility(visgraph.computeVisibility());
  }
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float clickX,
      float clickY,
      float clickZ) {
    TileEntityDoorController tileEntity = (TileEntityDoorController) world.getTileEntity(x, y, z);
    if (tileEntity == null || player.isSneaking()) {
      return false;
    }

    // If the user is not the owner, or the user is not in creative drop out.
    if (tileEntity.getOwner() != null) {
      if (!tileEntity.getOwner().equals(player.getUniqueID().toString())
          && !player.capabilities.isCreativeMode) {
        if (!tileEntity.getOwner().isEmpty()) {
          return false;
        }
      }
    }
    // Change the block texture
    if (player.getCurrentEquippedItem() != null
        && player.getCurrentEquippedItem().getItem() instanceof ItemBlock) {
      Block block = Block.getBlockFromItem(player.getCurrentEquippedItem().getItem());
      Item oldBlock = tileEntity.DoorControllerCamo[0].getItem();
      if (block.isOpaqueCube()
          || block instanceof BlockGlass
          || block instanceof BlockStainedGlass) {
        if (!tileEntity
            .DoorControllerCamo[0]
            .getItem()
            .equals(player.getCurrentEquippedItem().getItem())) {
          if (player.capabilities.isCreativeMode) {
            tileEntity.overrideTexture(
                block,
                player.getCurrentEquippedItem().splitStack(0),
                ForgeDirection.getOrientation(side));
          } else {
            tileEntity.overrideTexture(
                block,
                player.getCurrentEquippedItem().splitStack(1),
                ForgeDirection.getOrientation(side));
          }
          world.scheduleBlockUpdate(x, y, z, tileEntity.block, 5);
          if (!world.isRemote) {
            ItemStack testAgainst = new ItemStack(oldBlock);
            if (!testAgainst
                .getItem()
                .equals(Item.getItemFromBlock(ContentRegistry.DoorController))) {
              EntityItem myItemEntity = new EntityItem(world, x, y, z, testAgainst);
              world.spawnEntityInWorld(myItemEntity);
            }
          }
        }
      }
      // Remove the block texture with the scrench
    } else if (player.getCurrentEquippedItem() != null
        && player.getCurrentEquippedItem().getItem() instanceof Wrench) {
      if (!world.isRemote) {
        if (!tileEntity
            .DoorControllerCamo[0]
            .getItem()
            .equals(Item.getItemFromBlock(ContentRegistry.DoorController))) {
          EntityItem myItemEntity =
              new EntityItem(world, x, y, z, tileEntity.DoorControllerCamo[0]);
          world.spawnEntityInWorld(myItemEntity);
        }
      }
      tileEntity.overrideTexture(
          ContentRegistry.DoorController,
          new ItemStack(Item.getItemFromBlock(ContentRegistry.DoorController)),
          ForgeDirection.getOrientation(side));
      world.scheduleBlockUpdate(x, y, z, tileEntity.block, 5);
    }
    return true;
  }
 @Override
 public void fire(World world, double[] xyz) {
   if (world.isRemote) return;
   for (float i = 0; i <= this.getMaxRange(); i += 0.5F) {
     double dx = i * Math.cos(Math.toRadians(theta)) * Math.cos(Math.toRadians(-phi + 90));
     double dy = i * Math.sin(Math.toRadians(theta));
     double dz = i * Math.cos(Math.toRadians(theta)) * Math.sin(Math.toRadians(-phi + 90));
     int r = 1;
     AxisAlignedBB light =
         AxisAlignedBB.getBoundingBox(
                 xCoord + dx, yCoord + dy, zCoord + dz, xCoord + dx, yCoord + dy, zCoord + dz)
             .expand(r, r, r);
     List<Entity> in = world.getEntitiesWithinAABB(Entity.class, light);
     for (Entity e : in) {
       if (e instanceof TargetEntity) {
         ((TargetEntity) e).onLaserBeam(this);
       }
       if (e instanceof EntityLivingBase) {
         e.attackEntityFrom(DamageSource.lava, 4);
         e.setFire(7);
       }
     }
     int x = xCoord + (int) dx;
     int y = yCoord + (int) dy;
     int z = zCoord + (int) dz;
     Block id = world.getBlock(x, y, z);
     int meta = world.getBlockMetadata(x, y, z);
     Block id2 = this.getAffectedID(id, meta);
     int meta2 = this.getAffectedMetadata(id2, meta);
     // ReikaJavaLibrary.pConsole(id+"  to  "+id2+"  @  "+x+", "+y+", "+z);
     // ReikaJavaLibrary.pConsole(theta);
     if (ConfigRegistry.ATTACKBLOCKS.getState()) {
       if (id2 != id || meta2 != meta) {
         world.setBlock(x, y, z, id2, meta2, 3);
         world.markBlockForUpdate(x, y, z);
         this.setRange((int) i + 1);
         return;
       }
       if (id == Blocks.netherrack) {
         world.newExplosion(null, x + 0.5, y + 0.5, z + 0.5, 3F, true, true);
         world.markBlockForUpdate(x, y, z);
         this.setRange((int) i + 1);
         return;
       }
       if (id == Blocks.tnt) {
         world.setBlockToAir(x, y, z);
         EntityTNTPrimed var6 = new EntityTNTPrimed(world, x + 0.5D, y + 0.5D, z + 0.5D, null);
         world.spawnEntityInWorld(var6);
         world.playSoundAtEntity(var6, "random.fuse", 1.0F, 1.0F);
         world.spawnParticle(
             "lava", x + rand.nextFloat(), y + rand.nextFloat(), z + rand.nextFloat(), 0, 0, 0);
         this.setRange((int) i + 1);
         return;
       }
     }
     if (id != Blocks.air && id.isOpaqueCube()) {
       this.setRange((int) i + 1);
       return;
     }
     if (i == this.getMaxRange()) {
       this.setRange(this.getMaxRange());
     }
   }
 }
 public final boolean canThisPaneConnectToThisBlock(Block b) {
   return b.isOpaqueCube() || b == (Block) this || b == Blocks.glass;
 }