private void trySpawnSticks(World world, BlockPos pos, Random random) {
   int x = pos.getX();
   int y = pos.getY();
   int z = pos.getZ();
   y++;
   if (!world.isAirBlock(new BlockPos(x, y, z))) {
     return;
   }
   y++;
   if (!BlockTools.isTopValidAndSolid(world, pos)) {
     return;
   }
   for (int i = 0; i < 15; i++) {
     if (!world.isAirBlock(new BlockPos(x, y, z))) {
       if (isLeafBlock(world.getBlockState(new BlockPos(x, y, z)).getBlock())) {
         world.setBlockState(
             pos.up(),
             ModBlocks.sticksBlock
                 .getDefaultState()
                 .withProperty(
                     GenericBlock.FACING_HORIZ, EnumFacing.getHorizontal(random.nextInt(4))),
             3);
         SticksTE sticksTE = (SticksTE) world.getTileEntity(pos.up());
         sticksTE.setSticks(random.nextInt(6) + 1);
       }
       return;
     }
     y++;
   }
 }
  private void setDefaultDirection(World world, int x, int y, int z) {

    if (!world.isRemote) {
      Block block1 = world.getBlock(x, y, z - 1);
      Block block2 = world.getBlock(x, y, z + 1);
      Block block3 = world.getBlock(x - 1, y, z);
      Block block4 = world.getBlock(x + 1, y, z);

      byte b = 3;

      if (block1.func_149730_j() && !block2.func_149730_j()) {
        b = 3;
      }
      if (block2.func_149730_j() && !block1.func_149730_j()) {
        b = 2;
      }
      if (block3.func_149730_j() && !block4.func_149730_j()) {
        b = 5;
      }
      if (block4.func_149730_j() && !block3.func_149730_j()) {
        b = 4;
      }

      world.setBlockMetadataWithNotify(x, y, z, b, 2);
    }
  }
Exemple #3
0
  private void direction(World world, int x, int y, int z) {
    if (!world.isRemote) {
      Block direction = world.getBlock(x, y, z - 1);
      Block direction1 = world.getBlock(x, y, z + 1);
      Block direction2 = world.getBlock(x - 1, y, z);
      Block direction3 = world.getBlock(x + 1, y, z);
      byte byte0 = 3;

      if (direction.func_149730_j() && direction.func_149730_j()) {
        byte0 = 3;
      }

      if (direction1.func_149730_j() && direction1.func_149730_j()) {
        byte0 = 2;
      }

      if (direction2.func_149730_j() && direction2.func_149730_j()) {
        byte0 = 5;
      }

      if (direction3.func_149730_j() && direction3.func_149730_j()) {
        byte0 = 4;
      }

      world.setBlockMetadataWithNotify(x, y, z, byte0, 2);
    }
  }
  @Override
  public ActionResult<ItemStack> onItemRightClick(
      ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {

    if (!playerIn.capabilities.isCreativeMode) {
      itemStackIn.damageItem(1, playerIn);
      if (itemStackIn.getItemDamage() == 0) {
        itemStackIn = new ItemStack(ModItems.staff);
      }
    }

    worldIn.playSound(
        (EntityPlayer) null,
        playerIn.posX,
        playerIn.posY,
        playerIn.posZ,
        SoundEvents.ENTITY_SNOWBALL_THROW,
        SoundCategory.NEUTRAL,
        0.5F,
        0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote) {
      EntityLargeSnowBall snowball = new EntityLargeSnowBall(worldIn, playerIn);
      snowball.setHeadingFromThrower(
          playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
      worldIn.spawnEntityInWorld(snowball);
    }

    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
  }
 public void generateStructures(World world, Random rand, BlockPos position, int radius) {
   for (int i = 0; radius >= 0 && i < 3; ++i) {
     int j = radius + rand.nextInt(2);
     int k = (radius + rand.nextInt(2));
     int l = radius + rand.nextInt(2);
     float f = (float) (j + k + l) * 0.333F + 0.5F;
     for (BlockPos blockpos :
         BlockPos.getAllInBox(position.add(-j, -k, -l), position.add(j, k, l))) {
       if (blockpos.distanceSq(position) <= (double) (f * f)
           && world.isAirBlock(blockpos)
           && world
               .getBlockState(blockpos.down())
               .getBlock()
               .getUnlocalizedName()
               .contains("frozen")) {
         int chance = rand.nextInt(100);
         if (chance < 4) {
           int chance2 = rand.nextInt(20);
           System.out.println(chance2);
           switch (chance2) {
             default:
               generateGoldPile(world, rand, blockpos);
               break;
             case 1:
               generateArchNS(world, rand, blockpos);
               break;
             case 2:
               generateArchEW(world, rand, blockpos);
               break;
           }
         }
       }
     }
   }
 }
 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));
     }
   }
 }
  private void controlLoop(World w, int x, int y, int z) {
    ArenaCellEntity ace;

    if (!(w.getBlock(x, y, z) instanceof ArenaCellBlock) || w.getTileEntity(x, y, z) == null)
      return;
    ace = (ArenaCellEntity) w.getTileEntity(x, y, z);

    if (ace.passed) return;

    ace.passed = true;
    aaCounter += 1;

    if (ace.gameUsable) {
      aCounter += 1;

      if (ace.XOwnership == 1) t1T += 1;
      else if (ace.XOwnership == 2) t2T += 1;
      else nT += 1;
    }

    /*if (!ace.gameUsable)
    aInit = false;*/

    controlLoop(w, x, y, z + 1);
    controlLoop(w, x, y, z - 1);

    controlLoop(w, x + 1, y, z);
    controlLoop(w, x - 1, y, z);
  }
 @Override
 public boolean onBlockActivated(
     World world,
     int x,
     int y,
     int z,
     EntityPlayer player,
     int par6,
     float par7,
     float par8,
     float par9) {
   TileEntity tileEntity = world.getTileEntity(x, y, z);
   if (tileEntity != null && tileEntity instanceof TileVendor) {
     TileVendor tileVendor = (TileVendor) world.getTileEntity(x, y, z);
     EntityPlayer playerTest = world.getPlayerEntityByName(tileVendor.playerName);
     if (playerTest == null || !tileVendor.isUseableByPlayer(playerTest)) {
       tileVendor.inUse = false;
     }
     ;
     if (tileVendor.inUse && !player.getDisplayName().contentEquals(tileVendor.playerName)) {
       if (!world.isRemote) {
         player.addChatMessage(
             new ChatComponentText(StatCollector.translateToLocal("chat.warning.inuse")));
       }
       return true;
     } else {
       player.openGui(UniversalCoins.instance, 0, world, x, y, z);
       tileVendor.playerName = player.getDisplayName();
       tileVendor.inUse = true;
       tileVendor.updateCoinsForPurchase();
       return true;
     }
   }
   return false;
 }
 public ItemStack getItemStackWithData(World world, int x, int y, int z) {
   ItemStack stack = new ItemStack(world.getBlock(x, y, z), 1, 0);
   TileEntity tentity = world.getTileEntity(x, y, z);
   if (tentity instanceof TileVendorBlock) {
     TileVendorBlock te = (TileVendorBlock) tentity;
     NBTTagList itemList = new NBTTagList();
     NBTTagCompound tagCompound = new NBTTagCompound();
     for (int i = 0; i < te.getSizeInventory(); i++) {
       ItemStack invStack = te.getStackInSlot(i);
       if (invStack != null) {
         NBTTagCompound tag = new NBTTagCompound();
         tag.setByte("Slot", (byte) i);
         invStack.writeToNBT(tag);
         itemList.appendTag(tag);
       }
     }
     tagCompound.setTag("Inventory", itemList);
     tagCompound.setInteger("CoinSum", te.coinSum);
     tagCompound.setInteger("UserCoinSum", te.userCoinSum);
     tagCompound.setInteger("ItemPrice", te.itemPrice);
     tagCompound.setString("BlockOwner", te.blockOwner);
     tagCompound.setBoolean("Infinite", te.infiniteMode);
     stack.setTagCompound(tagCompound);
     return stack;
   } else return stack;
 }
  /**
   * 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
   */
  @Override
  public void onNeighborBlockChange(World par1World, int x, int y, int z, int neighborBlockID) {
    super.onNeighborBlockChange(par1World, x, y, z, neighborBlockID);

    if (par1World.getBlockId(x, y, z) == this.blockID) {
      this.setNotStationary(par1World, x, y, z);
    } else if (neighborBlockID == Block.fire.blockID
        || neighborBlockID == Block.lavaMoving.blockID
        || neighborBlockID == Block.lavaStill.blockID) {
      par1World.setBlockWithNotify(x, y, z, Block.fire.blockID);
      par1World.playSoundEffect(
          (double) ((float) x + 0.5F),
          (double) ((float) y + 0.5F),
          (double) ((float) z + 0.5F),
          "random.fizz",
          0.5F,
          2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F);
      par1World.spawnParticle(
          "largesmoke",
          (double) x + Math.random(),
          (double) y + 1.2D,
          (double) z + Math.random(),
          0.0D,
          0.0D,
          0.0D);
    }
  }
  @Override
  public void onBlockPlacedBy(
      World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
    if (world.isRemote) return;
    if (stack.hasTagCompound()) {
      TileEntity te = world.getTileEntity(x, y, z);
      if (te instanceof TileVendorBlock) {
        TileVendorBlock tentity = (TileVendorBlock) te;
        NBTTagCompound tagCompound = stack.getTagCompound();
        if (tagCompound == null) {
          return;
        }
        NBTTagList tagList = tagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND);
        for (int i = 0; i < tagList.tagCount(); i++) {
          NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
          byte slot = tag.getByte("Slot");
          if (slot >= 0 && slot < tentity.getSizeInventory()) {
            tentity.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(tag));
          }
        }
        tentity.coinSum = tagCompound.getInteger("CoinSum");
        tentity.userCoinSum = tagCompound.getInteger("UserCoinSum");
        tentity.itemPrice = tagCompound.getInteger("ItemPrice");
        tentity.blockOwner = tagCompound.getString("BlockOwner");
        tentity.infiniteMode = tagCompound.getBoolean("Infinite");
      }
      world.markBlockForUpdate(x, y, z);

    } else {
      // item has no owner so we'll set one and get out of here
      ((TileVendorBlock) world.getTileEntity(x, y, z)).blockOwner = entity.getCommandSenderName();
    }
    int meta = stack.getItemDamage();
    world.setBlockMetadataWithNotify(x, y, z, meta, 2);
  }
  @Override
  public void onBlockAdded(World par1World, int x, int y, int z) {
    super.onBlockAdded(par1World, x, y, z);

    for (byte i = 0; i < 6; i++) {
      Vector3 neighborPosition = new Vector3(x, y, z);
      neighborPosition.modifyPositionFromSide(ForgeDirection.getOrientation(i));

      int neighborBlockID =
          par1World.getBlockId(
              neighborPosition.intX(), neighborPosition.intY(), neighborPosition.intZ());

      if (neighborBlockID == Block.fire.blockID
          || neighborBlockID == Block.lavaMoving.blockID
          || neighborBlockID == Block.lavaStill.blockID) {
        par1World.setBlockWithNotify(x, y, z, Block.fire.blockID);
        par1World.playSoundEffect(
            (double) ((float) x + 0.5F),
            (double) ((float) y + 0.5F),
            (double) ((float) z + 0.5F),
            "random.fizz",
            0.5F,
            2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F);
        par1World.spawnParticle(
            "largesmoke",
            (double) x + Math.random(),
            (double) y + 1.2D,
            (double) z + Math.random(),
            0.0D,
            0.0D,
            0.0D);
        return;
      }
    }
  }
  /** Returns a list of all Tile Entities matching the class given within the bounding box */
  public static <T extends TileEntity> List<T> getTileEntitiesWithinAABB(
      World world, Class<T> clazz, AxisAlignedBB aabb) {
    List<T> list = new ArrayList<T>();
    int minX = MathHelper.floor_double(aabb.minX - World.MAX_ENTITY_RADIUS);
    int maxX = MathHelper.floor_double(aabb.maxX + World.MAX_ENTITY_RADIUS);
    int minY = MathHelper.floor_double(aabb.minY - World.MAX_ENTITY_RADIUS);
    int maxY = MathHelper.floor_double(aabb.maxY + World.MAX_ENTITY_RADIUS);
    int minZ = MathHelper.floor_double(aabb.minZ - World.MAX_ENTITY_RADIUS);
    int maxZ = MathHelper.floor_double(aabb.maxZ + World.MAX_ENTITY_RADIUS);
    if (!world.checkChunksExist(minX, minY, minZ, maxX, maxY, maxZ)) {
      return list;
    }
    for (int i = minX; i <= maxX; ++i) {
      for (int j = minY; j <= maxY; ++j) {
        for (int k = minZ; k <= maxZ; ++k) {
          TileEntity te = world.getTileEntity(i, j, k);
          if (te != null && clazz.isAssignableFrom(te.getClass())) {
            list.add((T) te);
          }
        }
      }
    }

    return list;
  }
  public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
    if (playerIn.isSneaking()) {
      if (!playerIn.capabilities.isCreativeMode) {
        --itemStackIn.stackSize;
      }

      worldIn.playSoundAtEntity(
          playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

      if (!worldIn.isRemote) {
        // EntityEnchantedEbonheart

        worldIn.spawnEntityInWorld(new EntityEnchantedEbonheart(worldIn, playerIn));

        // EntityEnchantedEbonheart entityenchantedebonheart = new EntityEnchantedEbonheart(worldIn,
        // playerIn);
        // entityenchantedebonheart.setHeadingFromThrower(playerIn, playerIn.rotationPitch,
        // playerIn.rotationYaw, -20.0F, 0.7F, 1.0F);
        // worldIn.spawnEntityInWorld(entityenchantedebonheart);

        // EntityExpBottle entityexpbottle = new EntityExpBottle(worldIn, playerIn);
        // entityexpbottle.func_184538_a(playerIn, playerIn.rotationPitch, playerIn.rotationYaw,
        // -20.0F, 0.7F, 1.0F);
        // worldIn.spawnEntityInWorld(entityexpbottle);
      }

      playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
      return itemStackIn;
    }
    return itemStackIn;
  }
  @Override
  public int onBlockPlaced(
      World par1World,
      int par2,
      int par3,
      int par4,
      int par5,
      float par6,
      float par7,
      float par8,
      int par9) {
    int j1 = par9;

    if ((j1 == 0 || par5 == 0)
        && par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH)) {
      j1 = 0;
    }

    if ((j1 == 0 || par5 == 1)
        && par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH)) {
      j1 = 1;
    }

    if ((j1 == 0 || par5 == 2)
        && par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST)) {
      j1 = 2;
    }

    if ((j1 == 0 || par5 == 3)
        && par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST)) {
      j1 = 3;
    }

    return j1;
  }
  public void onTickInGame() {
    world = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(0);
    if (world != null) {
      if (!dataRead) {
        WorldSaveToKHandler.readData();
        this.dataRead = true;
      }

      if (td.tdd == 0 && !ConfigFileToK.GuildSpawning && dataRead) {
        if (x.xLocation == 0 && x.yLocation == 0 && x.zLocation == 0) {
          WorldGenGuild wgg =
              new WorldGenGuild(
                  world,
                  world.getWorldInfo().getSpawnX(),
                  world.getWorldInfo().getSpawnZ(),
                  world.getWorldInfo().getSpawnY());
          wgg.CreateGuild();
          spawnGuildMembers(
              world.getWorldInfo().getSpawnX(),
              world.getWorldInfo().getSpawnY(),
              world.getWorldInfo().getSpawnZ());
        } else {
          WorldGenGuild wgg = new WorldGenGuild(world, x.xLocation, x.zLocation, x.yLocation);
          wgg.CreateGuild();
          spawnGuildMembers(x.xLocation, x.yLocation, x.zLocation);
        }
        td.tdd = 1;
        WorldSaveToKHandler.writeData();
      }
    }
  }
 @Override
 public void handle(NetHandler handler, Packet131MapData mapData) {
   ByteArrayDataInput in = ByteStreams.newDataInput(mapData.itemData);
   EntityPlayer player = handler.getPlayer();
   World world = player.worldObj;
   int x;
   int y;
   int z;
   switch (mapData.uniqueID) { // this is your PACKET_ID from above
     case EXPORTER_GUI:
       x = in.readInt();
       y = in.readInt();
       z = in.readInt();
       if (QBEBlockType.NonSolids.EXPORTER.matches(world, x, y, z)) {
         TileEntityExporter eb = (TileEntityExporter) world.getBlockTileEntity(x, y, z);
         eb.xSize = in.readInt();
         eb.ySize = in.readInt();
         eb.zSize = in.readInt();
       }
       break;
     case INTERFACE_GUI_SAVE:
       x = in.readInt();
       y = in.readInt();
       z = in.readInt();
       int dimX = in.readInt();
       int dimY = in.readInt();
       int dimZ = in.readInt();
   }
 }
  @Override
  public void addCollisionBoxesToList(World world, int x, int y, int z, List list) {
    int meta = world.getBlockMetadata(x, y, z);
    int dir = meta & 3;
    TEBloomery te = (TEBloomery) world.getTileEntity(x, y, z);
    if (te.isFlipped) dir = flipDir(dir);
    float f = 0.125F;

    if (!BlockEarlyBloomery.isOpen(meta)) {
      if (dir == 0)
        list.add(new Object[] {AxisAlignedBB.getBoundingBox(0.0F, 0.0F, 0.0f, 1.0f, 1.0F, f)});
      else if (dir == 1)
        list.add(
            new Object[] {AxisAlignedBB.getBoundingBox(1.0f - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0f)});
      else if (dir == 2)
        list.add(
            new Object[] {AxisAlignedBB.getBoundingBox(0.0f, 0.0F, 1.0f - f, 1.0F, 1.0F, 1.0F)});
      else if (dir == 3)
        list.add(new Object[] {AxisAlignedBB.getBoundingBox(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F)});
    } else {
      if (dir == 0) {
        list.add(new Object[] {AxisAlignedBB.getBoundingBox(0.0F, 0.0F, 0.0f, f, 1.0F, 0.5F)});
        list.add(new Object[] {AxisAlignedBB.getBoundingBox(1 - f, 0.0F, 0.0f, 1, 1.0F, 0.5F)});
      } else if (dir == 1) {
        list.add(new Object[] {AxisAlignedBB.getBoundingBox(0.5F, 0.0F, 0, 1.0F, 1.0F, f)});
        list.add(new Object[] {AxisAlignedBB.getBoundingBox(0.5F, 0.0F, 1 - f, 1.0F, 1.0F, 1)});
      } else if (dir == 2) {
        list.add(new Object[] {AxisAlignedBB.getBoundingBox(0.0F, 0.0F, 0.5f, f, 1.0F, 1.0F)});
        list.add(new Object[] {AxisAlignedBB.getBoundingBox(1 - f, 0.0F, 0.5f, 1, 1.0F, 1.0F)});
      } else if (dir == 3) {
        list.add(new Object[] {AxisAlignedBB.getBoundingBox(0.0F, 0.0F, 0.0F, 0.5F, 1.0F, f)});
        list.add(new Object[] {AxisAlignedBB.getBoundingBox(0.0F, 0.0F, 1 - f, 0.5F, 1.0F, 1.0)});
      }
    }
  }
  @Override
  public boolean onBlockActivated(
      World worldIn,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float subX,
      float subY,
      float subZ) {
    // Play the block break sound and spawn the block break particle effects
    worldIn.playAuxSFXAtEntity(
        player,
        2001,
        x,
        y,
        z,
        Block.getIdFromBlock(this) + (worldIn.getBlockMetadata(x, y, z) << 12));

    if (!worldIn.isRemote) {
      ItemStack itemStack =
          LootSpawns.RubbleMilitaryLoot.getOneItem(
              worldIn.rand); // Get a random item from the loot list
      dropBlockAsItem(worldIn, x, y, z, itemStack); // Drop it in the world

      worldIn.setBlockToAir(x, y, z); // Set this block to air
    }

    return true;
  }
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer entityplayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (!canBlockStay(world, x, y, z)) {
      world.setBlockToAir(x, y, z);
      world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(this, 1)));
    } else if ((TEBloomery) world.getTileEntity(x, y, z) != null) {
      TEBloomery te = (TEBloomery) world.getTileEntity(x, y, z);
      ItemStack is = entityplayer.getCurrentEquippedItem();

      if (is != null
          && (is.getItem() == TFCItems.FireStarter || is.getItem() == TFCItems.FlintSteel)) {
        if (te.canLight()) entityplayer.getCurrentEquippedItem().damageItem(1, entityplayer);
      } else {
        world.playAuxSFXAtEntity(entityplayer, 1003, x, y, z, 0);
        if (isOpen(world.getBlockMetadata(x, y, z)))
          world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 8, 3);
        else world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) + 8, 3);
      }
    }
    return true;
  }
  private void cleanTeamLoop(World w, int x, int y, int z, int team) {
    ArenaCellEntity ace;

    if (!(w.getBlock(x, y, z) instanceof ArenaCellBlock) || w.getTileEntity(x, y, z) == null)
      return;
    ace = (ArenaCellEntity) w.getTileEntity(x, y, z);

    if (ace.passed) return;

    if (ace.ownership == team) {
      w.spawnEntityInWorld(new EntityItem(w, x, y, z, ace.getStack()));
      ace.stackIn = null;
      ace.ownership = 0;
      ace.XOwnership = 0;
    }

    ace.gameUsable = false;
    ace.passed = true;

    w.markBlockForUpdate(x, y, z);

    cleanTeamLoop(w, x, y, z + 1, team);
    cleanTeamLoop(w, x, y, z - 1, team);

    cleanTeamLoop(w, x + 1, y, z, team);
    cleanTeamLoop(w, x - 1, y, z, team);
  }
  @Override
  public boolean canBlockStay(World world, int x, int y, int z) {
    if (world.isAirBlock(x, y, z)) return true;

    if (world.getTileEntity(x, y, z) instanceof TEBloomery) // Prevent ClassCastException
    {
      boolean flipped = false;
      int dir = world.getBlockMetadata(x, y, z) & 3;
      TEBloomery te = (TEBloomery) world.getTileEntity(x, y, z);

      if (te != null) flipped = te.isFlipped;

      if (checkStack(world, x, y, z, dir)) {
        if (checkVertical(world, x, y, z, flipped)) {
          if (checkHorizontal(world, x, y, z, flipped)) return true;
        } else if (te != null && !flipped) {
          this.tryFlip(world, x, y, z);
          flipped = te.isFlipped;
          if (checkVertical(world, x, y, z, flipped)) {
            if (checkHorizontal(world, x, y, z, flipped)) return true;
          }
        }
      }
    }
    return false;
  }
 public void generateGoldPile(World world, Random rand, BlockPos position) {
   int height = 1 + new Random().nextInt(7);
   int chance = rand.nextInt(100);
   if (chance < 20) {
     world.setBlockState(
         position,
         Blocks.CHEST
             .getDefaultState()
             .withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[new Random().nextInt(3)]),
         3);
     if (world.getBlockState(position).getBlock() instanceof BlockChest) {
       TileEntity tileentity1 = world.getTileEntity(position);
       if (tileentity1 instanceof TileEntityChest
           && !((TileEntityChest) tileentity1).isInvalid()) {
         ((TileEntityChest) tileentity1)
             .setLootTable(WorldGenIceDragonCave.ICEDRAGON_CHEST, new Random().nextLong());
       }
     }
   } else {
     world.setBlockState(
         position,
         ModBlocks.silverPile.getDefaultState().withProperty(BlockGoldPile.LAYERS, height),
         3);
   }
 }
  @Override
  public IMessage onMessage(PacketKurosawaAttack message, MessageContext ctx) {
    EntityPlayer player = ctx.getServerHandler().playerEntity;
    Kurosawa item = (Kurosawa) player.getHeldItem().getItem();

    if (!item.getCooldown()) {
      World world = player.worldObj;
      EntityLivingBase target = (EntityLivingBase) world.getEntityByID(message.targetID);
      Vec3 targetPos = target.getPositionVector();
      Vec3 attackerPos = player.getPositionVector();

      Vec3 distance = targetPos.subtractReverse(attackerPos).normalize();
      distance = new Vec3(distance.xCoord * 3, distance.yCoord * 3, distance.zCoord * 3);

      player.setPositionAndRotation(
          target.posX - distance.xCoord,
          target.posY - distance.yCoord,
          target.posZ - distance.zCoord,
          player.rotationYaw + 180,
          player.rotationPitch);
      player.setRotationYawHead(player.rotationYawHead + 180);
      player.cameraPitch += 180;
      player.setPositionAndUpdate(
          target.posX - distance.xCoord,
          target.posY - distance.yCoord,
          target.posZ - distance.zCoord);
      target.attackEntityFrom(DamageSource.causePlayerDamage(player), 44);
      item.setCooldown();
    }
    return null;
  }
  @Override
  public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
    NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
    World world = player.worldObj;
    int bID = player.worldObj.getBlockId(x, y, z);
    int meta = world.getBlockMetadata(x, y, z);
    Block block = Block.blocksList[bID];
    if (block == null || bID < 1) return false;
    int hlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getHarvestType());
    int shlvl = MinecraftForge.getBlockHarvestLevel(block, meta, getSecondHarvestType());

    if (hlvl <= tags.getInteger("HarvestLevel") && shlvl <= tags.getInteger("HarvestLevel2")) {
      boolean cancelHarvest = false;
      for (ActiveToolMod mod : TConstructRegistry.activeModifiers) {
        if (mod.beforeBlockBreak(this, stack, x, y, z, player)) cancelHarvest = true;
      }

      return cancelHarvest;
    } else {
      if (!player.capabilities.isCreativeMode) onBlockDestroyed(stack, world, bID, x, y, z, player);
      world.setBlockToAir(x, y, z);
      if (!world.isRemote) world.playAuxSFX(2001, x, y, z, bID + (meta << 12));
      return true;
    }
  }
  public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int meta) {
    System.out.println("Breaking with " + x + ":" + y + ":" + z);
    if (meta == 0) x--;
    if (meta == 1) {
      x--;
      z--;
    }
    if (meta == 2) z--;
    if (meta == 3) {
      x++;
      z--;
    }
    if (meta == 4) x++;
    if (meta == 5) {
      x++;
      z++;
    }
    if (meta == 6) z++;
    if (meta == 7) {
      x--;
      z++;
    }

    System.out.println("Breaking " + x + ":" + y + ":" + z + ":" + world.getBlock(x, y, z));
    world.getBlock(x, y, z).breakBlock(world, x, y, z, world.getBlock(x, y, z), 0);
  }
Exemple #27
0
  public void onBlockPlacedBy(
      World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack) {
    int direction =
        MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

    if (direction == 0) {
      world.setBlockMetadataWithNotify(x, y, z, 2, 2);
    }

    if (direction == 1) {
      world.setBlockMetadataWithNotify(x, y, z, 5, 2);
    }

    if (direction == 2) {
      world.setBlockMetadataWithNotify(x, y, z, 3, 2);
    }

    if (direction == 3) {
      world.setBlockMetadataWithNotify(x, y, z, 4, 2);
    }

    /*if (itemstack.hasDisplayName()) {
    	((Crusher_TileEntity) world.getTileEntity(x, y, z)).crusherName(itemstack.getDisplayName());
    }*/
  }
 @Override
 public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
   return par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST)
       || par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST)
       || par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH)
       || par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH);
 }
 @Override
 public boolean generate(World world, Random rand, int var3, int var4, int var5) {
   for (int i = var3; i < var3 + 16; i++) {
     for (int k = var5; k < var5 + 16; k++) {
       for (int j = 255; j >= var4; --j) {
         Block block = world.getBlock(i, j, k);
         int meta = 0;
         if (block == Blocks.sand) {
           meta = 1;
         } else if (block == Blocks.grass) {
           meta = 2;
         } else if (block == Blocks.clay) {
           meta = 3;
         } else if (block == Blocks.dirt) {
           meta = 2;
         } else {
           continue;
         }
         world.setBlock(i, j, k, Ids.blockFrass, meta, 3);
         break;
       }
     }
   }
   return true;
 }
 private int findCaveSpot(World world, BlockPos pos) {
   boolean air = false;
   int x = pos.getX();
   int y = pos.getY();
   int z = pos.getZ();
   while (y > 1 && !air) {
     if (world.isAirBlock(new BlockPos(x, y, z))) {
       air = true;
     }
     y--;
   }
   if (air) {
     while (y > 1 && air) {
       if (!world.isAirBlock(new BlockPos(x, y, z))) {
         air = false;
       } else {
         y--;
       }
     }
     if (!air) {
       return y;
     }
   }
   return -1;
 }