@Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    ItemStack stack = player.getCurrentEquippedItem();
    if (stack != null) {
      IFloatingFlower flower = (IFloatingFlower) world.getTileEntity(x, y, z);
      IslandType type = null;
      if (stack.getItem() == Items.snowball) type = IslandType.SNOW;
      else if (stack.getItem() == ModItems.grassSeeds) type = ItemGrassSeeds.getIslandType(stack);

      if (type != null && type != flower.getIslandType()) {
        if (!world.isRemote) {
          flower.setIslandType(type);
          VanillaPacketDispatcher.dispatchTEToNearbyPlayers(world, x, y, z);
        }

        if (!player.capabilities.isCreativeMode) stack.stackSize--;
        return true;
      }
    }
    return false;
  }
Beispiel #2
0
 @Override
 public void recieveMana(int mana) {
   int tiles = validPools.size();
   if (tiles != 0) {
     int manaForEach = mana / tiles;
     for (IManaReceiver pool : validPools) {
       pool.recieveMana(manaForEach);
       TileEntity tile = (TileEntity) pool;
       VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, tile.getPos());
     }
   }
 }