示例#1
0
  @SuppressWarnings("rawtypes")
  @Override
  public void addCollisionBoxesToList(
      World worldIn,
      BlockPos pos,
      IBlockState state,
      AxisAlignedBB mask,
      List list,
      Entity collidingEntity) {
    int meta = getMetaFromState(state);

    if (meta == 2 || meta == 6) {
      this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.2F, 1.0F);
      super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
    } else if (meta == 0 || meta == 4) {
      this.setBlockBounds(
          0.3F,
          0.0F,
          0.3F,
          0.7F,
          worldIn.getBlockState(pos.up()).getBlock() == this ? 1.0F : 0.6F,
          0.7F);
      super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
    }
    /*else if (meta == 7)
    {
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.38F, 1.0F);
        super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity);
    }*/
    else {
      super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
    }
  }
 public void addCollisionBoxesToList(
     World par1World,
     int par2,
     int par3,
     int par4,
     AxisAlignedBB par5AxisAlignedBB,
     List par6List,
     Entity par7Entity) {
   this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.3125F, 1.0F);
   super.addCollisionBoxesToList(
       par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
   float f = 0.03F;
   this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
   super.addCollisionBoxesToList(
       par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
   this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
   super.addCollisionBoxesToList(
       par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
   this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
   super.addCollisionBoxesToList(
       par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
   this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
   super.addCollisionBoxesToList(
       par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
   this.setBlockBoundsForItemRender();
 }
  @Override
  public void onNeighborBlockChange(World world, int x, int y, int z, Block blockId) {
    super.onNeighborBlockChange(world, x, y, z, blockId);
    if (updateEveryone) {
      TileEntityLittleChunk tile = (TileEntityLittleChunk) world.getTileEntity(x, y, z);
      if (tile != null) {
        int maX = tile.size, maY = tile.size, maZ = tile.size;
        int startX = 0, startY = 0, startZ = 0;
        for (int side = 0; side < 6; side++) {
          switch (side) {
            case 0:
              maY = 1;
              break;

            case 1:
              startY = maY - 1;
              break;

            case 2:
              maZ = 1;
              break;

            case 3:
              startZ = maZ - 1;
              break;

            case 4:
              maX = 1;
              break;

            case 5:
              startX = maX - 1;
              break;
          }

          for (int xx = startX; xx < maX; xx++) {
            for (int yy = startY; yy < maY; yy++) {
              for (int zz = startZ; zz < maZ; zz++) {
                if (tile.getBlock(xx, yy, zz) != Blocks.air) {
                  Block littleBlock = tile.getBlock(xx, yy, zz);
                  if (littleBlock != null) {
                    littleBlock.onNeighborBlockChange(
                        (World) tile.getLittleWorld(),
                        (x << 3) + xx,
                        (y << 3) + yy,
                        (z << 3) + zz,
                        blockId);
                  }
                }
              }
            }
          }
        }
      } else {
        super.onNeighborBlockChange(world, x, y, z, blockId);
      }
    }
  }
  public void onBlockPlacedBy(
      World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
    byte b0 = 0;
    int l = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

    if (l == 0) {
      b0 = 2;
    }

    if (l == 1) {
      b0 = 5;
    }

    if (l == 2) {
      b0 = 3;
    }

    if (l == 3) {
      b0 = 4;
    }

    world.setBlockMetadataWithNotify(x, y, z, b0, 2);

    world.markBlockForUpdate(x, y, z);

    super.onBlockPlacedBy(world, x, y, z, entity, stack);
  }
  @Override
  public void onBlockAdded(World par1World, int par2, int par3, int par4) {
    super.onBlockAdded(par1World, par2, par3, par4);
    this.unifyAdjacentChests(par1World, par2, par3, par4);
    Block var5 = par1World.getBlock(par2, par3, par4 - 1);
    Block var6 = par1World.getBlock(par2, par3, par4 + 1);
    Block var7 = par1World.getBlock(par2 - 1, par3, par4);
    Block var8 = par1World.getBlock(par2 + 1, par3, par4);

    if (var5 == this) {
      this.unifyAdjacentChests(par1World, par2, par3, par4 - 1);
    }

    if (var6 == this) {
      this.unifyAdjacentChests(par1World, par2, par3, par4 + 1);
    }

    if (var7 == this) {
      this.unifyAdjacentChests(par1World, par2 - 1, par3, par4);
    }

    if (var8 == this) {
      this.unifyAdjacentChests(par1World, par2 + 1, par3, par4);
    }
  }
  /**
   * Called on server worlds only when the block has been replaced by a different block ID, or the
   * same block with a different metadata value, but before the new metadata value is set. Args:
   * World, x, y, z, old block ID, old metadata
   */
  public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
    TileEntityBoundChest tileentitychest =
        (TileEntityBoundChest) par1World.getTileEntity(par2, par3, par4);

    if (tileentitychest != null) {
      this.dropItem(
          new ItemStack(
              ThaumicExploration.blankSeal,
              1,
              15
                  - ((TileEntityBoundChest) par1World.getTileEntity(par2, par3, par4))
                      .getSealColor()),
          par1World,
          par2,
          par3,
          par4);
      for (int j1 = 0; j1 < tileentitychest.getSizeInventory(); ++j1) {
        ItemStack itemstack = tileentitychest.getStackInSlot(j1);
        this.dropItem(itemstack, par1World, par2, par3, par4);
      }

      par1World.func_147453_f(par2, par3, par4, par5);
    }

    super.breakBlock(par1World, par2, par3, par4, par5, par6);
  }
 public void onBlockPlacedBy(
     World world, int x, int y, int z, EntityLiving entity, ItemStack stack) {
   super.onBlockPlacedBy(world, x, y, z, entity, stack);
   IRotatable rotate = (IRotatable) world.getBlockTileEntity(x, y, z);
   rotate.setRotation(
       ForgeDirection.getOrientation(PlayerUtil.determineOrientation(world, x, y, z, entity)));
 }
  /** A randomly called display update to be able to add particles or other items for display */
  public void randomDisplayTick(World var1, int var2, int var3, int var4, Random var5) {
    super.randomDisplayTick(var1, var2, var3, var4, var5);

    for (int var6 = var2 - 2; var6 <= var2 + 2; ++var6) {
      for (int var7 = var4 - 2; var7 <= var4 + 2; ++var7) {
        if (var6 > var2 - 2 && var6 < var2 + 2 && var7 == var4 - 1) {
          var7 = var4 + 2;
        }

        if (var5.nextInt(16) == 0) {
          for (int var8 = var3; var8 <= var3 + 1; ++var8) {
            if (var1.getBlockId(var6, var8, var7) == Block.bookShelf.blockID) {
              if (!var1.isAirBlock((var6 - var2) / 2 + var2, var8, (var7 - var4) / 2 + var4)) {
                break;
              }

              var1.spawnParticle(
                  "enchantmenttable",
                  (double) var2 + 0.5D,
                  (double) var3 + 2.0D,
                  (double) var4 + 0.5D,
                  (double) ((float) (var6 - var2) + var5.nextFloat()) - 0.5D,
                  (double) ((float) (var8 - var3) - var5.nextFloat() - 1.0F),
                  (double) ((float) (var7 - var4) + var5.nextFloat()) - 0.5D);
            }
          }
        }
      }
    }
  }
示例#9
0
  public void onNeighborBlockChange(World world, int x, int y, int z, int neighbor) {
    if (!canBeHere(world, x, y, z)) {
      world.setBlock(x, y, z, 0);
    }

    super.onNeighborBlockChange(world, x, y, z, neighbor);
  }
 @Override
 public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
   String ownerName = ((TileVendorBlock) world.getTileEntity(x, y, z)).blockOwner;
   if (player.capabilities.isCreativeMode) {
     super.removedByPlayer(world, player, x, y, z);
     return true;
   }
   if (player.getDisplayName().matches(ownerName) && !world.isRemote) {
     ItemStack stack = getItemStackWithData(world, x, y, z);
     EntityItem entityItem = new EntityItem(world, x, y, z, stack);
     world.spawnEntityInWorld(entityItem);
     super.removedByPlayer(world, player, x, y, z);
     return true;
   }
   return false;
 }
  @Override
  public void breakBlock(World world, int x, int y, int z, Block blockID, int blockMeta) {
    super.breakBlock(world, x, y, z, blockID, blockMeta);
    boolean var5 = true;
    for (Iterator<ItemStack> iter =
            getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0).iterator();
        iter.hasNext();
        var5 = false) {
      ItemStack var7 = (ItemStack) iter.next();
      if (!var5) {
        if (var7 == null) {
          return;
        }

        double var8 = 0.7D;
        double var10 = (double) world.rand.nextFloat() * var8 + (1.0D - var8) * 0.5D;
        double var12 = (double) world.rand.nextFloat() * var8 + (1.0D - var8) * 0.5D;
        double var14 = (double) world.rand.nextFloat() * var8 + (1.0D - var8) * 0.5D;
        EntityItem var16 =
            new EntityItem(world, (double) x + var10, (double) y + var12, (double) z + var14, var7);
        var16.delayBeforeCanPickup = 10;
        world.spawnEntityInWorld(var16);
        return;
      }
    }
  }
  @Override
  public void breakBlock(
      World p_149749_1_,
      int p_149749_2_,
      int p_149749_3_,
      int p_149749_4_,
      Block p_149749_5_,
      int p_149749_6_) {
    if (!keepInventory) {
      TileEntityLaunchPad tileentityfurnace =
          (TileEntityLaunchPad) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);

      if (tileentityfurnace != null) {
        for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) {
          ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);

          if (itemstack != null) {
            float f = LaunchPad.field_149933_a.nextFloat() * 0.8F + 0.1F;
            float f1 = LaunchPad.field_149933_a.nextFloat() * 0.8F + 0.1F;
            float f2 = LaunchPad.field_149933_a.nextFloat() * 0.8F + 0.1F;

            while (itemstack.stackSize > 0) {
              int j1 = LaunchPad.field_149933_a.nextInt(21) + 10;

              if (j1 > itemstack.stackSize) {
                j1 = itemstack.stackSize;
              }

              itemstack.stackSize -= j1;
              EntityItem entityitem =
                  new EntityItem(
                      p_149749_1_,
                      p_149749_2_ + f,
                      p_149749_3_ + f1,
                      p_149749_4_ + f2,
                      new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));

              if (itemstack.hasTagCompound()) {
                entityitem
                    .getEntityItem()
                    .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
              }

              float f3 = 0.05F;
              entityitem.motionX = (float) LaunchPad.field_149933_a.nextGaussian() * f3;
              entityitem.motionY = (float) LaunchPad.field_149933_a.nextGaussian() * f3 + 0.2F;
              entityitem.motionZ = (float) LaunchPad.field_149933_a.nextGaussian() * f3;
              p_149749_1_.spawnEntityInWorld(entityitem);
            }
          }
        }

        p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
      }
    }

    super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
  }
  /**
   * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
   * (coordinates passed are their own) Args: x, y, z, neighbor blockID
   */
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) {
    super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
    TileEntityBoundChest tileentitychest =
        (TileEntityBoundChest) par1World.getTileEntity(par2, par3, par4);

    if (tileentitychest != null) {
      tileentitychest.updateContainingBlockInfo();
    }
  }
示例#14
0
 @Override
 public void onPostBlockPlaced(World world, int x, int y, int z, int meta) {
   super.onPostBlockPlaced(world, x, y, z, meta);
   if (RailcraftConfig.printSignalDebug()) {
     Game.logTrace(Level.INFO, 10, "Signal Block onPostBlockPlaced. [{0}, {1}, {2}]", x, y, y);
   }
   TileEntity tile = world.getTileEntity(x, y, z);
   if (tile instanceof TileSignalFoundation) ((TileSignalFoundation) tile).onBlockPlaced();
 }
 @Override
 public void onBlockPlacedBy(
     World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
   TileEntity tile = world.getBlockTileEntity(x, y, z);
   if (tile != null && tile instanceof TileEntityBasicProximitySensor) {
     ((TileEntityBasicProximitySensor) tile).setOwner(player.getEntityName());
   }
   super.onBlockPlacedBy(world, x, y, z, player, itemStack);
 }
  @Override
  public void onNeighborBlockChange(World world, int x, int y, int z, int neighborBlockID) {
    super.onNeighborBlockChange(world, x, y, z, neighborBlockID);

    TileEntity te = world.getBlockTileEntity(x, y, z);
    if (te instanceof TileEntityReactorRedstonePort) {
      ((TileEntityReactorRedstonePort) te).onNeighborBlockChange(x, y, z, neighborBlockID);
    }
  }
示例#17
0
 @Override
 public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
   if (RailcraftConfig.printSignalDebug()) {
     Game.logTrace(Level.INFO, 10, "Signal Block breakBlock. [{0}, {1}, {2}]", x, y, z);
   }
   TileEntity tile = world.getTileEntity(x, y, z);
   if (tile instanceof TileSignalFoundation) ((TileSignalFoundation) tile).onBlockRemoval();
   super.breakBlock(world, x, y, z, block, meta);
 }
 public void onBlockAdded(World world, int x, int y, int z) {
   super.onBlockAdded(world, x, y, z);
   coords[0] = x;
   coords[1] = y;
   coords[2] = z;
   TileEntityMysticRedGenerator tile =
       (TileEntityMysticRedGenerator) world.getBlockTileEntity(x, y, z);
   tile.setCoords();
 }
示例#19
0
 @Override
 public void breakBlock(World world, int x, int y, int z, Block block, int metadata) {
   TileEntityBase tileentity =
       (TileEntityBase) BlockHelper.getTileEntity(world, x, y, z, this.getTileMapData(metadata));
   if (tileentity != null) {
     tileentity.breakBlock(block, metadata);
   }
   super.breakBlock(world, x, y, z, block, metadata);
 }
示例#20
0
  /**
   * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
   * (coordinates passed are their own) Args: x, y, z, neighbor Block
   */
  public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
    super.onNeighborBlockChange(world, x, y, z, block);
    TileEntityBlueMateriaChest TileEntityBlueMateriaChest =
        (TileEntityBlueMateriaChest) world.getTileEntity(x, y, z);

    if (TileEntityBlueMateriaChest != null) {
      TileEntityBlueMateriaChest.updateContainingBlockInfo();
    }
  }
示例#21
0
  @Override
  public void onBlockClicked(
      World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) {
    super.onBlockClicked(par1World, par2, par3, par4, par5EntityPlayer);

    if (this.explodeOnBroken) {
      checkExplosion(par1World, par2, par3, par4, true);
    }
  }
示例#22
0
 @Override
 public void breakBlock(World par1World, int x, int y, int z, int blockID, int meta) {
   TileEntity te = par1World.getBlockTileEntity(x, y, z);
   if (te != null && te instanceof BucketTE) {
     BucketTE inv = (BucketTE) te;
     inv.removeBlock(par1World);
   }
   super.breakBlock(par1World, x, y, z, blockID, meta);
 }
  // ブロックのドロップ時に中身を落とす
  @Override
  public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
    TileIncenseBase tile = (TileIncenseBase) world.getTileEntity(x, y, z);
    if (tile != null) {
      ItemStack drop = tile.getItemstack();
      ItemStack ash = tile.getAsh();
      if (drop != null) {
        float f = world.rand.nextFloat() * 0.8F + 0.1F;
        float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
        float f2 = world.rand.nextFloat() * 0.8F + 0.1F;

        EntityItem entityitem =
            new EntityItem(
                world,
                (double) ((float) x + f),
                (double) ((float) y + f1),
                (double) ((float) z + f2),
                drop.copy());

        if (drop.hasTagCompound()) {
          entityitem.getEntityItem().setTagCompound((NBTTagCompound) drop.getTagCompound().copy());
        }

        float f3 = 0.05F;
        entityitem.motionX = (double) ((float) world.rand.nextGaussian() * f3);
        entityitem.motionY = (double) ((float) world.rand.nextGaussian() * f3 + 0.2F);
        entityitem.motionZ = (double) ((float) world.rand.nextGaussian() * f3);
        world.spawnEntityInWorld(entityitem);
      }
      if (ash != null) {
        float f = world.rand.nextFloat() * 0.8F + 0.1F;
        float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
        float f2 = world.rand.nextFloat() * 0.8F + 0.1F;

        EntityItem entityitem2 =
            new EntityItem(
                world,
                (double) ((float) x + f),
                (double) ((float) y + f1),
                (double) ((float) z + f2),
                ash.copy());

        if (ash.hasTagCompound()) {
          entityitem2.getEntityItem().setTagCompound((NBTTagCompound) ash.getTagCompound().copy());
        }

        float f3 = 0.05F;
        entityitem2.motionX = (double) ((float) world.rand.nextGaussian() * f3);
        entityitem2.motionY = (double) ((float) world.rand.nextGaussian() * f3 + 0.2F);
        entityitem2.motionZ = (double) ((float) world.rand.nextGaussian() * f3);
        world.spawnEntityInWorld(entityitem2);
      }
    }

    super.breakBlock(world, x, y, z, block, meta);
  }
示例#24
0
  @Override
  public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    TileEntity tileEntity = worldIn.getTileEntity(pos);

    if (tileEntity instanceof TileEntityMulti) {
      ((TileEntityMulti) tileEntity).onBlockRemoval();
    }

    super.breakBlock(worldIn, pos, state);
  }
示例#25
0
  /* Wrappers ************************************************************ */
  @Override
  public void onNeighborBlockChange(World world, int x, int y, int z, int id) {
    super.onNeighborBlockChange(world, x, y, z, id);

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

    if (isValid(pipe)) {
      pipe.container.scheduleNeighborChange();
    }
  }
示例#26
0
  @Override
  public void onBlockPlacedBy(
      World world, int x, int y, int z, EntityLivingBase placer, ItemStack stack) {
    super.onBlockPlacedBy(world, x, y, z, placer, stack);
    Pipe pipe = getPipe(world, x, y, z);

    if (isValid(pipe)) {
      pipe.onBlockPlacedBy(placer);
    }
  }
示例#27
0
  @Override
  public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) {
    super.onEntityCollidedWithBlock(world, i, j, k, entity);

    Pipe pipe = getPipe(world, i, j, k);

    if (isValid(pipe)) {
      pipe.onEntityCollidedWithBlock(entity);
    }
  }
  @Override
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block par5) {
    super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
    final TileEntityT10TreasureChest var6 =
        (TileEntityT10TreasureChest) par1World.getTileEntity(par2, par3, par4);

    if (var6 != null) {
      var6.updateContainingBlockInfo();
    }
  }
示例#29
0
 public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
   TileEntityGunBox te = (TileEntityGunBox) world.getBlockTileEntity(x, y, z);
   if (te != null && te.getType() != null)
     world.spawnEntityInWorld(
         new EntityItem(
             world,
             x + 0.5F,
             y + 0.5F,
             z + 0.5F,
             new ItemStack(blockID, 1, te.getType().gunBoxID)));
   super.breakBlock(world, x, y, z, par5, par6);
 }
示例#30
0
  @Override
  public int onBlockPlaced(
      World world, int x, int y, int z, int side, float par6, float par7, float par8, int meta) {
    super.onBlockPlaced(world, x, y, z, side, par6, par7, par8, meta);
    Pipe pipe = getPipe(world, x, y, z);

    if (isValid(pipe)) {
      pipe.onBlockPlaced();
    }

    return meta;
  }